【问题标题】:Kernel32.INSTANCE.ReadProcessMemory cannot be found in JNA在 JNA 中找不到 Kernel32.INSTANCE.ReadProcessMemory
【发布时间】:2012-11-14 02:50:58
【问题描述】:
       import com.sun.jna.Native;
       import com.sun.jna.Memory;
       import com.sun.jna.Pointer;
       import com.sun.jna.ptr.*;
       import com.sun.jna.platform.win32.Kernel32;
       import com.sun.jna.platform.win32.User32;
       import com.sun.jna.platform.win32.WinDef;
       import com.sun.jna.platform.win32.WinDef.HWND;
       import com.sun.jna.platform.win32.*;


public class apples {


       public static void main(String[] args) {

           IntByReference pid = new IntByReference();
           int offset = 0x7AF5DBDC;
           int buffer = 32;
           Memory output = new Memory(buffer);

HWND hwnd = User32.INSTANCE.FindWindow("notepad", null);   
    if (hwnd != null)
    {
    System.out.println("i got the handle");
    User32.INSTANCE.GetWindowThreadProcessId(hwnd, pid);
    System.out.println("PID is " + pid.getValue());
    WinNT.HANDLE hProc =  Kernel32.INSTANCE.OpenProcess(0, false, pid.getValue());

    Output: 
    i got the handle
    PID is 752

接下来,我想使用 Kernel32.INSTANCE.ReadProcessMemory();

但是,我无法在 Kernel32 中找到该函数。这个功能被删除了吗?如果是这样,还有其他方法可以做 ReadProcessMemory 吗?

我正在使用 Java 并使用 JNA Lib。

谢谢。

【问题讨论】:

  • 如果缺少,您可以随时扩展接口并定义自己的。

标签: java jna kernel32


【解决方案1】:

您可能需要在调用它的函数之前定义 Kernel32 实例。

Kernel32 kernel32 = (Kernel32) Native.loadLibrary(Kernel32.class, W32APIOptions.UNICODE_OPTIONS);
int memValue = kernel32.ReadProcessMemory(WinNT.HANDLE, pointer, pointer, int, IntByReference);

【讨论】:

    【解决方案2】:

    这个问题最初是在2012年提出的。jna.platform.win32.Kernel32接口on Jun 29 2014中添加了ReadProcessMemory函数,这意味着该函数在提问时还没有映射。

    JNA 4.2.0 及以上版本附带该功能。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-01-03
      • 2018-07-22
      • 1970-01-01
      • 1970-01-01
      • 2016-11-09
      • 1970-01-01
      • 1970-01-01
      • 2015-10-12
      相关资源
      最近更新 更多