Package com.sun.jna.platform.win32

Examples of com.sun.jna.platform.win32.GDI32


      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

      assertTrue(Advapi32.INSTANCE.CloseEventLog(h));
    }
   
    public void testRegisterEventSource() {
      // the Security event log is reserved
      HANDLE h = Advapi32.INSTANCE.RegisterEventSource(null, "Security");
      assertNull(h);
      assertEquals(W32Errors.ERROR_ACCESS_DENIED, Kernel32.INSTANCE.GetLastError());
    }
View Full Code Here

            }
        } catch (Win32Exception e) {
            return;
        }

      HANDLE h = Advapi32.INSTANCE.RegisterEventSource(null, jnaEventSource);     
      IntByReference before = new IntByReference();
      assertTrue(Advapi32.INSTANCE.GetNumberOfEventLogRecords(h, before));
      assertNotNull(h);
      String s[] = { "JNA", "Event" };
      Memory m = new Memory(4);
      m.setByte(0, (byte) 1);
      m.setByte(1, (byte) 2);
      m.setByte(2, (byte) 3);
      m.setByte(3, (byte) 4);
      assertTrue(Advapi32.INSTANCE.ReportEvent(h, WinNT.EVENTLOG_ERROR_TYPE, 0, 0, null, 2, 4, s, m));
      IntByReference after = new IntByReference();
      assertTrue(Advapi32.INSTANCE.GetNumberOfEventLogRecords(h, after));
      assertTrue(before.getValue() < after.getValue());
      assertFalse(h.equals(WinBase.INVALID_HANDLE_VALUE));
      assertTrue(Advapi32.INSTANCE.DeregisterEventSource(h));
      Advapi32Util.registryDeleteKey(WinReg.HKEY_LOCAL_MACHINE, jnaEventSourceRegistryPath);
    }
View Full Code Here

TOP

Related Classes of com.sun.jna.platform.win32.GDI32

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.