4
       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。

谢谢你。

4

2 回答 2

0

该问题最初是在2012年提出的。该功能于2014年6月29日ReadProcessMemory添加到jna.platform.win32.Kernel32界面中,这意味着该功能在询问时还没有映射。

JNA 4.2.0 及更高版本附带该功能。

于 2017-05-15T10:39:31.613 回答
0

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

Kernel32 kernel32 = (Kernel32) Native.loadLibrary(Kernel32.class, W32APIOptions.UNICODE_OPTIONS);
int memValue = kernel32.ReadProcessMemory(WinNT.HANDLE, pointer, pointer, int, IntByReference);
于 2015-12-14T16:00:51.103 回答