Package com.sun.jna.platform.win32.WinDef

Examples of com.sun.jna.platform.win32.WinDef.HWND


    String result = "?";
    PROCESS_BASIC_INFORMATION pbi = null;

    pbi = new PROCESS_BASIC_INFORMATION();
    IntByReference returnLength = new IntByReference();
    HANDLE hProcess = _processInformation.hProcess;
    int size = pbi.size();
    int ret = Ntdll.INSTANCE.ZwQueryInformationProcess(hProcess, (byte) 0, pbi.getPointer(), size, returnLength);
    if (ret == 0)
    {
      pbi.read();
View Full Code Here


      assertTrue(W32Errors.ERROR_SUCCESS != Kernel32.INSTANCE.GetLastError());
    }
   
    public void testOpenThreadTokenNoToken() {
      HANDLEByReference phToken = new HANDLEByReference();
      HANDLE threadHandle = Kernel32.INSTANCE.GetCurrentThread();
      assertNotNull(threadHandle);
      assertFalse(Advapi32.INSTANCE.OpenThreadToken(threadHandle,
          WinNT.TOKEN_READ, false, phToken));
      assertEquals(W32Errors.ERROR_NO_TOKEN, Kernel32.INSTANCE.GetLastError());
    }
View Full Code Here

      assertEquals(W32Errors.ERROR_NO_TOKEN, Kernel32.INSTANCE.GetLastError());
    }
   
    public void testOpenProcessToken() {
      HANDLEByReference phToken = new HANDLEByReference();
      HANDLE processHandle = Kernel32.INSTANCE.GetCurrentProcess();
      assertTrue(Advapi32.INSTANCE.OpenProcessToken(processHandle,
          WinNT.TOKEN_DUPLICATE | WinNT.TOKEN_QUERY, phToken));
      assertTrue(Kernel32.INSTANCE.CloseHandle(phToken.getValue()));     
    }
View Full Code Here

      assertTrue(Kernel32.INSTANCE.CloseHandle(phToken.getValue()));     
    }
   
    public void testOpenThreadOrProcessToken() {
      HANDLEByReference phToken = new HANDLEByReference();
      HANDLE threadHandle = Kernel32.INSTANCE.GetCurrentThread();
      if (! Advapi32.INSTANCE.OpenThreadToken(threadHandle,
          WinNT.TOKEN_DUPLICATE | WinNT.TOKEN_QUERY, true, phToken)) {
          assertEquals(W32Errors.ERROR_NO_TOKEN, Kernel32.INSTANCE.GetLastError());
          HANDLE processHandle = Kernel32.INSTANCE.GetCurrentProcess();
          assertTrue(Advapi32.INSTANCE.OpenProcessToken(processHandle,
              WinNT.TOKEN_DUPLICATE | WinNT.TOKEN_QUERY, phToken));
      }
      assertTrue(Kernel32.INSTANCE.CloseHandle(phToken.getValue()));
    }
View Full Code Here

    }
   
    public void testDuplicateToken() {
      HANDLEByReference phToken = new HANDLEByReference();
      HANDLEByReference phTokenDup = new HANDLEByReference();
      HANDLE processHandle = Kernel32.INSTANCE.GetCurrentProcess();
        assertTrue(Advapi32.INSTANCE.OpenProcessToken(processHandle,
            WinNT.TOKEN_DUPLICATE | WinNT.TOKEN_QUERY, phToken));
        assertTrue(Advapi32.INSTANCE.DuplicateToken(phToken.getValue(),
            WinNT.SECURITY_IMPERSONATION_LEVEL.SecurityImpersonation, phTokenDup));
      assertTrue(Kernel32.INSTANCE.CloseHandle(phTokenDup.getValue()));
View Full Code Here

    }
   
    public void testDuplicateTokenEx() {
      HANDLEByReference hExistingToken = new HANDLEByReference();
      HANDLEByReference phNewToken = new HANDLEByReference();
      HANDLE processHandle = Kernel32.INSTANCE.GetCurrentProcess();
      assertTrue(Advapi32.INSTANCE.OpenProcessToken(processHandle,
          WinNT.TOKEN_DUPLICATE | WinNT.TOKEN_QUERY, hExistingToken));
      assertTrue(Advapi32.INSTANCE.DuplicateTokenEx(hExistingToken.getValue(),
          WinNT.GENERIC_READ, null, SECURITY_IMPERSONATION_LEVEL.SecurityAnonymous,
          TOKEN_TYPE.TokenPrimary, phNewToken));
View Full Code Here

      assertTrue(Kernel32.INSTANCE.CloseHandle(hExistingToken.getValue()));
    }
   
    public void testGetTokenOwnerInformation() {
      HANDLEByReference phToken = new HANDLEByReference();
      HANDLE processHandle = Kernel32.INSTANCE.GetCurrentProcess();
        assertTrue(Advapi32.INSTANCE.OpenProcessToken(processHandle,
            WinNT.TOKEN_DUPLICATE | WinNT.TOKEN_QUERY, phToken));
        IntByReference tokenInformationLength = new IntByReference();
        assertFalse(Advapi32.INSTANCE.GetTokenInformation(phToken.getValue(),
            WinNT.TOKEN_INFORMATION_CLASS.TokenOwner, null, 0, tokenInformationLength));
View Full Code Here

        assertTrue(Kernel32.INSTANCE.CloseHandle(phToken.getValue()));
    }
   
    public void testGetTokenUserInformation() {
      HANDLEByReference phToken = new HANDLEByReference();
      HANDLE processHandle = Kernel32.INSTANCE.GetCurrentProcess();
        assertTrue(Advapi32.INSTANCE.OpenProcessToken(processHandle,
            WinNT.TOKEN_DUPLICATE | WinNT.TOKEN_QUERY, phToken));
        IntByReference tokenInformationLength = new IntByReference();
        assertFalse(Advapi32.INSTANCE.GetTokenInformation(phToken.getValue(),
            WinNT.TOKEN_INFORMATION_CLASS.TokenUser, null, 0, tokenInformationLength));
View Full Code Here

        assertTrue(Kernel32.INSTANCE.CloseHandle(phToken.getValue()));
    }  
   
    public void testGetTokenGroupsInformation() {
      HANDLEByReference phToken = new HANDLEByReference();
      HANDLE processHandle = Kernel32.INSTANCE.GetCurrentProcess();
        assertTrue(Advapi32.INSTANCE.OpenProcessToken(processHandle,
            WinNT.TOKEN_DUPLICATE | WinNT.TOKEN_QUERY, phToken));
        IntByReference tokenInformationLength = new IntByReference();
        assertFalse(Advapi32.INSTANCE.GetTokenInformation(phToken.getValue(),
            WinNT.TOKEN_INFORMATION_CLASS.TokenGroups, null, 0, tokenInformationLength));
View Full Code Here

      String convertedSidString = convertedSidStringPtr.getValue().getWideString(0);
      assertEquals(EVERYONE, convertedSidString);
    }
   
    public void testOpenEventLog() {
      HANDLE h = Advapi32.INSTANCE.OpenEventLog(null, "Application");
      assertNotNull(h);
      assertFalse(h.equals(WinBase.INVALID_HANDLE_VALUE));
      assertTrue(Advapi32.INSTANCE.CloseEventLog(h));
    }
View Full Code Here

TOP

Related Classes of com.sun.jna.platform.win32.WinDef.HWND

Copyright © 2018 www.massapicom. 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.