!!!!高分求教ReadProcessMemory读取内存.有关内存偏移量的问题!
2009-02-11 16:47
555 查看
!!!!高分求教ReadProcessMemory读取内存.有关内存偏移量的问题! Delphi / Windows SDK/API
http://www.delphi2007.net/DelphiBase/html/delphi_20061207125413246.html
已知一基地址$010EA0CC,偏移量为$2A4,先在用ReadProcessMemory函数连读取内存数据,为什么我用其他工具(例如:CE)可以读取到正常的数据,但
ReadProcessMemory(h,Pointer(addr+$2A4),@buf,nSize,lpNumberOfBytes);
却为0?是不是$010EA0CC是一个指针地址.请大家赐教
procedure TForm1.Button1Click(Sender: TObject);
var gameHwnd:Hwnd;
pid: dword;
h: THandle;
lpNumberOfBytes: DWord;
buf:DWord;
buf2:Pointer;
Buffer : Array[0..3] Of DWord;
addr:DWORD;
nSize: DWORD;
s:WideString;
i:Integer;
begin
gameHwnd:=FindWindow(nil,'Element Client');
if gameHwnd<>0 then
begin
GetWindowThreadProcessId(gameHwnd, @pid);
h:=OpenProcess(PROCESS_ALL_ACCESS, false, pid);
if h<>0 then
begin
addr:=$010EA0CC;
edit2.Text:=Inttostr(gameHwnd);
edit3.Text:=Inttostr(h);
nSize:=4;
ReadProcessMemory(h,Pointer(addr+$2A4),@buf,nSize,lpNumberOfBytes);
s:=inttoStr(buf);
edit1.Text:=s;
showmessage(s);
end;
closeHandle(h);
end else begin
showmessage('游戏未运行!');
end;
end;
Return Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
The function fails if the requested read operation crosses into an area of the process that is inaccessible.
看帮助 第一句话 函数成功的时候 这个值是非0
楼上的。不是这个意思.或许是我描述能力太差了。
不过已经解决了。多谢啊.
放分。
噢 呵呵 是参数的问题还是?
不是。具体我也不太懂.我是在网上找到的一个函数搞定的,你看看能看懂不?讲一讲.我对内存这些东西是刚接触.很菜.
===========================================
addr:=GetAddyfrmpointer($010EA0CC,$2A4,h);
===========================================
function GetAddyfrmpointer(baseaddress, offset: dword;
hID: THandle): Dword;
var a: dword;
x: dword;
i: integer;
offsetcount: integer;
offsets:array of dword;
b:integer;
maxid:integer;
begin
offsetcount:=1;
b:=0;
setlength(offsets,1);
offsets[b]:=offset;
a:=baseaddress;
i:=0;
while (i<offsetcount) do
begin
if not readprocessmemory(hID,pointer(a),@a,4,x) then exit;
inc(a,offsets[i]);
inc(i);
result:=a
end;
end;
看来基地址+偏移量直接取的办法是不对.
http://www.delphi2007.net/DelphiBase/html/delphi_20061207125413246.html
已知一基地址$010EA0CC,偏移量为$2A4,先在用ReadProcessMemory函数连读取内存数据,为什么我用其他工具(例如:CE)可以读取到正常的数据,但
ReadProcessMemory(h,Pointer(addr+$2A4),@buf,nSize,lpNumberOfBytes);
却为0?是不是$010EA0CC是一个指针地址.请大家赐教
procedure TForm1.Button1Click(Sender: TObject);
var gameHwnd:Hwnd;
pid: dword;
h: THandle;
lpNumberOfBytes: DWord;
buf:DWord;
buf2:Pointer;
Buffer : Array[0..3] Of DWord;
addr:DWORD;
nSize: DWORD;
s:WideString;
i:Integer;
begin
gameHwnd:=FindWindow(nil,'Element Client');
if gameHwnd<>0 then
begin
GetWindowThreadProcessId(gameHwnd, @pid);
h:=OpenProcess(PROCESS_ALL_ACCESS, false, pid);
if h<>0 then
begin
addr:=$010EA0CC;
edit2.Text:=Inttostr(gameHwnd);
edit3.Text:=Inttostr(h);
nSize:=4;
ReadProcessMemory(h,Pointer(addr+$2A4),@buf,nSize,lpNumberOfBytes);
s:=inttoStr(buf);
edit1.Text:=s;
showmessage(s);
end;
closeHandle(h);
end else begin
showmessage('游戏未运行!');
end;
end;
Return Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
The function fails if the requested read operation crosses into an area of the process that is inaccessible.
看帮助 第一句话 函数成功的时候 这个值是非0
楼上的。不是这个意思.或许是我描述能力太差了。
不过已经解决了。多谢啊.
放分。
噢 呵呵 是参数的问题还是?
不是。具体我也不太懂.我是在网上找到的一个函数搞定的,你看看能看懂不?讲一讲.我对内存这些东西是刚接触.很菜.
===========================================
addr:=GetAddyfrmpointer($010EA0CC,$2A4,h);
===========================================
function GetAddyfrmpointer(baseaddress, offset: dword;
hID: THandle): Dword;
var a: dword;
x: dword;
i: integer;
offsetcount: integer;
offsets:array of dword;
b:integer;
maxid:integer;
begin
offsetcount:=1;
b:=0;
setlength(offsets,1);
offsets[b]:=offset;
a:=baseaddress;
i:=0;
while (i<offsetcount) do
begin
if not readprocessmemory(hID,pointer(a),@a,4,x) then exit;
inc(a,offsets[i]);
inc(i);
result:=a
end;
end;
看来基地址+偏移量直接取的办法是不对.
相关文章推荐
- 通过ReadProcessMemory读取进程内存
- WinAPI: ReadProcessMemory 读取指定进程内存数据
- Read tiff from memory(从内存流读取TIFF)
- 读取与修改其他程序的数据Read/WriteProcessMemory
- windows 编程ReadProcessMemory 使用中遇到的问题解决
- ReadProcessMemory 输入进程ID 输入读取地址
- 【并行计算-CUDA开发】有关CUDA当中global memory如何实现合并访问跟内存对齐相关的问题
- 有关fstream::read()读取错误问题
- 彻底解决Android因加载多个大图引起的OutOfMemoryError,内存溢出的有关问题
- 有关内存DC和双缓冲位图的问题汇总
- 对有关对Stream读取的问题
- ReadProcessMemory
- Oracle调整内存超出限制出现ORA-27100: shared memory realm already exists问题解决办法
- Readprocessmemory使用方法
- 解决使用maven的java web项目导入后出现的有关问题 -cannot be read or is not a valid ZIP file
- 彻底解决Android因加载多个大图引起的OutOfMemoryError,内存溢出的问题
- 出现0x0000002c内存不能为"read"的问题
- 简单内存泄漏检测方法 解决 Detected memory leaks! 问题
- 【转】简单内存泄漏检测方法 解决 Detected memory leaks! 问题
- MFC 简单内存泄漏检测方法,解决Detected memory leaks!问题