这是从以前写的修改指定程序内存数据的代码里摘的,你看是不是你要的
[Delphi] 纯文本查看 复制代码
var
Base:Pointer;
GameH:HWND;
GamePid:DWORD;
mNum: LONG64;
val:integer;
wds:NativeUInt;
begin
GameH := FindWindow('xxx','xxx');
if GameH <=0 then Exit;
GetWindowThreadProcessId(GameH ,@GamePid);
pHandle:= OpenProcess(PROCESS_ALL_ACCESS,false,GamePid);
Base:=GetModuleBaseAddress(GamePid,'xxx.exe'); //取基址
if ReadProcessMemory(pHandle, Pointer(long64(Base) +$xxx), @mNum, 8,lBuf) then begin //偏移
nAddr:=Pointer(long64(mNum) + $xxx); //偏移
val:=xxx;
WriteProcessMemory(pHandle, nAddr, Pointer(@val), 8, wds); //写
end;
end |