Package com.sun.jna.ptr

Examples of com.sun.jna.ptr.IntByReference


                arg.setString(0, args[i], false);
                argsCopy[i + 1] = arg;
            }
            argvMemory.write(0, argsCopy, 0, argsCopy.length);
            argvRef = new PointerByReference(argvMemory);
            argcRef = new IntByReference(args.length + 1);
        }
View Full Code Here


    PointerByReference hToken = new PointerByReference();
    HANDLE hp = new HANDLE();
    hp.setPointer(hProcess.getPointer());
    if (MyAdvapi.INSTANCE.OpenProcessToken(hp, MyAdvapi.TOKEN_READ, hToken))
    {
      IntByReference dwSize = new IntByReference();
      MyAdvapi.INSTANCE.GetTokenInformation(hToken.getValue(), MyAdvapi.TokenUser, null, 0, dwSize);
      {
        Memory pTokenUser = new Memory(dwSize.getValue());
        if (MyAdvapi.INSTANCE.GetTokenInformation(hToken.getValue(), MyAdvapi.TokenUser, pTokenUser, dwSize.getValue(), dwSize))
        {
          MyAdvapi.TOKEN_USER tokenUser = new MyAdvapi.TOKEN_USER(pTokenUser);
          Pointer lpSid = tokenUser.User.Sid;
          Memory lpName = new Memory(256);
          IntByReference cchName = new IntByReference();
          cchName.setValue(256);
          Memory lpReferencedDomainName = new Memory(256);
          IntByReference cchReferencedDomainName = new IntByReference();
          cchReferencedDomainName.setValue(256);
          IntByReference peUse = new IntByReference();
          if (MyAdvapi.INSTANCE.LookupAccountSidW(null, lpSid, lpName, cchName, lpReferencedDomainName, cchReferencedDomainName, peUse))

            result._user = lpReferencedDomainName.getString(0, true) + "\\" + lpName.getString(0, true);
          ;
          // System.out.println(result._user);
View Full Code Here

   */
  private int getProcessAffinity()
  {
    if (_cpuAffinity <= 0)
      return 0;
    IntByReference lpProcessAffinityMask = new IntByReference();
    IntByReference lpSystemAffinityMask = new IntByReference();
    if (MyKernel32.INSTANCE.GetProcessAffinityMask(_processInformation.hProcess, lpProcessAffinityMask, lpSystemAffinityMask))
      return lpSystemAffinityMask.getValue() & _cpuAffinity;
    else
    {
      log("could not get process affinity mask -> not setting");
      return 0;
    }
View Full Code Here

   *
   * @return the exit code internal
   */
  private int getExitCodeInternal()
  {
    IntByReference code = new IntByReference();
    if (_processInformation == null)
      return -1;
    boolean result = MyKernel32.INSTANCE.GetExitCodeProcess(_processInformation.hProcess, code);
    try
    {
      // if server overloaded windows may need some time to set the exit
      // code.
      Thread.sleep(100);
    }
    catch (InterruptedException e)
    {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    // System.out.println("get exit code internal " + result + " " +
    // code.getValue());
    if (result)
    {
      if (_debug)
        log("GetExitCodeProcess returned " + code.getValue());
      return code.getValue();
    }
    else
    {
      log("Error in GetExitCodeProcess OS Error #" + MyKernel32.INSTANCE.GetLastError());
      return -3;
View Full Code Here

    {
      // lParam is the pid of our process
      public boolean callback(Pointer wnd, int lParam)
      {
        // get the pid of the window
        IntByReference dwID = new IntByReference();
        MyUser32.INSTANCE.GetWindowThreadProcessId(wnd, dwID);
        // if this windows belongs to our process
        if (dwID.getValue() == lParam)
        {
          // System.out.println("post message a: " + wnd);
          MyUser32.INSTANCE.PostMessageA(wnd, MyUser32.WM_CLOSE, null, null);
          // MyUser32.INSTANCE.PostMessageA(wnd, MyUser32.WM_QUIT,
          // null, null) ;
View Full Code Here

    // System.out.println("get command internal "+getPid());
    String result = "?";
    PROCESS_BASIC_INFORMATION pbi = null;

    pbi = new PROCESS_BASIC_INFORMATION();
    IntByReference returnLength = new IntByReference();
    HANDLE hProcess = _processInformation.hProcess;
    int pbiSize = pbi.size(); // x64 = 48 bytes, x32 = 24
    int ret = Ntdll.INSTANCE.ZwQueryInformationProcess(hProcess, (byte) 0, pbi.getPointer(), pbiSize, returnLength);
    if (ret == 0)
    {
View Full Code Here

    log("get command internal 64 " + getPid());
    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)
    {
View Full Code Here

   * @return the int
   */
  public static int processIdOfActiveWindow()
  {
    Pointer w = MyUser32.INSTANCE.GetForegroundWindow();
    IntByReference result = new IntByReference();
    MyUser32.INSTANCE.GetWindowThreadProcessId(w, result);
    return result.getValue();
  }
View Full Code Here

  boolean doesUserHavePrivilege(String lpPrivilegeName)

  {
    PointerByReference hToken = new PointerByReference();
    IntByReference dwSize = new IntByReference();
    Memory lpPrivileges;
    MyAdvapi.LUID PrivilegeLuid = new MyAdvapi.LUID();
    int i;
    boolean bResult = false;

    if (!MyAdvapi.INSTANCE.OpenProcessToken(MyKernel32.INSTANCE.GetCurrentProcess(), MyAdvapi.INSTANCE.TOKEN_QUERY, hToken))
      return false;

    MyAdvapi.INSTANCE.GetTokenInformation(hToken.getValue(), MyAdvapi.TokenPrivileges, null, 0, dwSize);

    lpPrivileges = new Memory(dwSize.getValue());

    if (!MyAdvapi.INSTANCE.GetTokenInformation(hToken.getValue(), MyAdvapi.TokenPrivileges, lpPrivileges, dwSize.getValue(), dwSize))
    {
      return false;
    }

    MyKernel32.INSTANCE.CloseHandle(hToken.getValue());
View Full Code Here

    if (english)
      objectName = translate(objectName);
    Bag bag = new HashBag();
    int pdhStatus = Pdhdll.ERROR_SUCCESS;
    Memory szCounterListBuffer = null;
    IntByReference dwCounterListSize = new IntByReference();
    Memory szInstanceListBuffer = null;
    IntByReference dwInstanceListSize = new IntByReference();
    String szThisInstance = null;

    // Determine the required buffer size for the data.
    pdhStatus = Pdhdll.INSTANCE.PdhEnumObjectItemsA(null, // real time
        // source
        null, // local machine
        objectName, // object to enumerate
        szCounterListBuffer, // pass NULL and 0
        dwCounterListSize, // to get length required
        szInstanceListBuffer, // buffer size
        dwInstanceListSize, //
        Pdhdll.PERF_DETAIL_WIZARD, // counter detail level
        0);

    if (pdhStatus == Pdhdll.PDH_MORE_DATA)
    {
      // Allocate the buffers and try the call again.
      szCounterListBuffer = new Memory(dwCounterListSize.getValue() * 4);
      szInstanceListBuffer = new Memory((dwInstanceListSize.getValue() * 4));

      if ((szCounterListBuffer != null) && (szInstanceListBuffer != null))
      {
        pdhStatus = Pdhdll.INSTANCE.PdhEnumObjectItemsA(null, // real
            // time
View Full Code Here

TOP

Related Classes of com.sun.jna.ptr.IntByReference

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.