Examples of TOKEN_PRIVILEGES


Examples of com.sun.jna.platform.win32.WinNT.TOKEN_PRIVILEGES

      HANDLEByReference hToken = new HANDLEByReference();
      assertTrue(Advapi32.INSTANCE.OpenProcessToken(Kernel32.INSTANCE.GetCurrentProcess(),
          WinNT.TOKEN_ADJUST_PRIVILEGES | WinNT.TOKEN_QUERY, hToken));
     
      // Find an already enabled privilege
      TOKEN_PRIVILEGES tp = new TOKEN_PRIVILEGES(1024);
      IntByReference returnLength = new IntByReference();
      assertTrue(Advapi32.INSTANCE.GetTokenInformation(hToken.getValue(),  WinNT.TOKEN_INFORMATION_CLASS.TokenPrivileges,
          tp, tp.size(), returnLength));
      assertTrue(tp.PrivilegeCount.intValue() > 0);
     
      WinNT.LUID luid = null;
      for (int i=0; i<tp.PrivilegeCount.intValue(); i++) {
        if ((tp.Privileges[i].Attributes.intValue() & WinNT.SE_PRIVILEGE_ENABLED) > 0) {
View Full Code Here

Examples of com.sun.jna.platform.win32.WinNT.TOKEN_PRIVILEGES

      HANDLEByReference hToken = new HANDLEByReference();
      assertTrue(Advapi32.INSTANCE.OpenProcessToken(Kernel32.INSTANCE.GetCurrentProcess(),
          WinNT.TOKEN_ADJUST_PRIVILEGES | WinNT.TOKEN_QUERY, hToken));
     
      // Find an already enabled privilege
      TOKEN_PRIVILEGES tp = new TOKEN_PRIVILEGES(1024);
      IntByReference returnLength = new IntByReference();
      assertTrue(Advapi32.INSTANCE.GetTokenInformation(hToken.getValue(),  WinNT.TOKEN_INFORMATION_CLASS.TokenPrivileges,
          tp, tp.size(), returnLength));
      assertTrue(tp.PrivilegeCount.intValue() > 0);
     
      WinNT.LUID luid = null;
      for (int i=0; i<tp.PrivilegeCount.intValue(); i++) {
        if ((tp.Privileges[i].Attributes.intValue() & WinNT.SE_PRIVILEGE_ENABLED) > 0) {
View Full Code Here

Examples of org.rzo.yajsw.os.ms.win.w32.WindowsXPProcess.MyAdvapi.TOKEN_PRIVILEGES

    return result;
  }

  private boolean setPrivilege(Pointer hToken, String lpszPrivilege, boolean bEnablePrivilege)
  {
    TOKEN_PRIVILEGES tp = new TOKEN_PRIVILEGES();
    MyAdvapi.LUID luid = new MyAdvapi.LUID();
    luid.size();

    if (!MyAdvapi.INSTANCE.LookupPrivilegeValueA(null, lpszPrivilege, luid))
      return false;

    tp.Privileges[0].Luid = luid;
    tp.write();

    if (bEnablePrivilege)
      tp.Privileges[0].Attributes = MyAdvapi.SE_PRIVILEGE_ENABLED;
    else
      tp.Privileges[0].Attributes = 0;

    int size = tp.size();
    boolean result = MyAdvapi.INSTANCE.AdjustTokenPrivileges(hToken, false, tp, 0, null, null);
    // return GetLastError() == ERROR_SUCCESS;
    if (!result)
    {
      int errNr = MyKernel32.INSTANCE.GetLastError();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.