关于指针读取人物信息的简便方法
看到几篇文章,作者是在Delphi中嵌入汇编来读取一些资料,今天闲来无事,就拿来研究了一阵,发现虽然 可用,但却多余,根本算不上指针方式读取!
这是嵌入汇编的代码:
procedure MyProc; //刷新本人信息
var
hp,mp,Lv,tmpName:DWORD;
Name:PWideChar;
begin
asm
mov eax,[base];
mov eax,[eax +$1c]
mov eax,[eax +$28]
mov ebx,[eax +$248]
mov hp,ebx
mov ebx,[eax +$24c]
mov mp,ebx
mov ebx,[eax+$240]
mov Lv,ebx
mov ebx,[eax+$450]
mov name,ebx
end;
Form1.Label5.Caption:=Name;
Form1.Label6.Caption:=IntToStr(Lv);
Form1.Label7.Caption:=IntToStr(hp);
Form1.Label8.Caption:=IntToStr(mp);
end;
咋一看,似乎不错!
但指针怎么着也不是这么个用法吧!
下面我改写一下:
=========================================
定义一个函数,ReadP(),用来读整数,
function ReadP(addr:pointer):integer;
var
tmp:integer;
PInteger:integer;
begin
PInteger := addr ;
tmp := PInteger ^;
result := tmp ;
end;
同样可以定义读取浮点、双精度、字符串等类型的函数。。
这样在DLL注入目标程序后,既不需要用ReadMemoryProcess,也不需要一个汇编语句,就可以把所有信息都读出了!