Search in sources :

Example 1 with LUID_AND_ATTRIBUTES

use of com.sun.jna.platform.win32.WinNT.LUID_AND_ATTRIBUTES in project jna by java-native-access.

the class W32Service method addShutdownPrivilegeToProcess.

private void addShutdownPrivilegeToProcess() {
    HANDLEByReference hToken = new HANDLEByReference();
    LUID luid = new LUID();
    Advapi32.INSTANCE.OpenProcessToken(Kernel32.INSTANCE.GetCurrentProcess(), WinNT.TOKEN_ADJUST_PRIVILEGES, hToken);
    Advapi32.INSTANCE.LookupPrivilegeValue("", WinNT.SE_SHUTDOWN_NAME, luid);
    TOKEN_PRIVILEGES tp = new TOKEN_PRIVILEGES(1);
    tp.Privileges[0] = new LUID_AND_ATTRIBUTES(luid, new DWORD(WinNT.SE_PRIVILEGE_ENABLED));
    Advapi32.INSTANCE.AdjustTokenPrivileges(hToken.getValue(), false, tp, tp.size(), null, new IntByReference());
}
Also used : TOKEN_PRIVILEGES(com.sun.jna.platform.win32.WinNT.TOKEN_PRIVILEGES) IntByReference(com.sun.jna.ptr.IntByReference) LUID(com.sun.jna.platform.win32.WinNT.LUID) LUID_AND_ATTRIBUTES(com.sun.jna.platform.win32.WinNT.LUID_AND_ATTRIBUTES) DWORD(com.sun.jna.platform.win32.WinDef.DWORD) HANDLEByReference(com.sun.jna.platform.win32.WinNT.HANDLEByReference)

Aggregations

DWORD (com.sun.jna.platform.win32.WinDef.DWORD)1 HANDLEByReference (com.sun.jna.platform.win32.WinNT.HANDLEByReference)1 LUID (com.sun.jna.platform.win32.WinNT.LUID)1 LUID_AND_ATTRIBUTES (com.sun.jna.platform.win32.WinNT.LUID_AND_ATTRIBUTES)1 TOKEN_PRIVILEGES (com.sun.jna.platform.win32.WinNT.TOKEN_PRIVILEGES)1 IntByReference (com.sun.jna.ptr.IntByReference)1