谁能帮我注释...详细超详细的.奉上(100)急~~~~~~~~~~~~~~~~~ (100分)

  • 主题发起人 主题发起人 学习DELPHI
  • 开始时间 开始时间

学习DELPHI

Unregistered / Unconfirmed
GUEST, unregistred user!
var<br>WindowName : integer;<br>ProcessId : integer;<br>ThreadId : integer;<br>buf : PChar;<br>HandleWindow : Integer;<br>write : cardinal;<br>const<br>WindowTitle = 'aaa';<br>Address = $3212321;<br>PokeValue = $2121;<br>NumberOfBytes = 2;<br>begin<br>WindowName := FindWindow(nil,WindowTitle);<br>If WindowName = 0 then<br>begin<br>MessageDlg('Game not running! Please run it and try again!', mtwarning,[mbOK],0);<br>end;<br><br>ThreadId := GetWindowThreadProcessId(WindowName,@ProcessId);<br>HandleWindow := OpenProcess(PROCESS_ALL_ACCESS,False,ProcessId);<br>GetMem(buf,1);<br>buf^ := Chr(PokeValue);<br>WriteProcessMemory(HandleWindow,ptr(Address),buf,NumberOfBytes,write);<br>FreeMem(buf);<br>closehandle(HandleWindow);<br><br>end;<br><br><br><br>-=-=-=-=-=-=-=-=-=-=-这四句重点-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-<br>GetMem(buf,1);<br>buf^ := Chr(PokeValue);<br>WriteProcessMemory(HandleWindow,ptr(Address),buf,NumberOfBytes,write);<br>FreeMem(buf);<br>-=-=-=-=-=-=-==-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=<br><br><br><br>
 
这个过程主要是修改某一进程的内存信息:<br>Address = $3212321;要修改的内存地址<br>WindowName := FindWindow(nil,WindowTitle);找出handel<br>ThreadId := GetWindowThreadProcessId(WindowName,@ProcessId);获取进程ID<br>HandleWindow := OpenProcess(PROCESS_ALL_ACCESS,False,ProcessId);最高级别打开进程<br>GetMem(buf,1);为pchar型的buf分配内存<br>buf^ := Chr(PokeValue);为指针赋值<br>WriteProcessMemory(HandleWindow,ptr(Address),buf,NumberOfBytes,write);<br>改写这个进程,把地址为address改成buf<br>end;<br><br>
 
谢谢谢谢。。<br><br>GetMem(buf,1);为pchar型的buf分配内存 &nbsp; &nbsp;<br>&nbsp; &nbsp; &nbsp;BUF是一个pchar型,1代表什么?1字节(=8bit)?<br>buf^ := Chr(PokeValue);为指针赋值<br>&nbsp; &nbsp; &nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ptr()函数作用. &nbsp; NumberOfBytes,write//这个再说一下好么?<br>WriteProcessMemory(HandleWindow,ptr(Address),buf,NumberOfBytes,write);<br>改写这个进程,把地址为address改成buf<br><br><br><br>-=-=-=-=-=-=-=-=-=-=-这四句重点-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-<br>GetMem(buf,1);<br>buf^ := Chr(PokeValue);<br>WriteProcessMemory(HandleWindow,ptr(Address),buf,NumberOfBytes,write);<br>FreeMem(buf);<br>-=-=-=-=-=-=-==-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=<br>
 
GetMen 原型:procedure GetMem(var P:Pointer;Size:Integer);<br>P代表一个任何可变的指针类型,分配Size字节大小的动态内存,关在P中存储一个指向内存的指针。<br><br>ptr()函数作用.<br>原型:Function Ptr(Seg,Ofs:Word):Pointer; &nbsp; <br>以Seg:Ofs的形式构造一个指针返回。<br>NumberOfBytes,write//是这个API函数的参数,可查一下delphi SDK的帮助。<br>WriteProcessMemory(HandleWindow,ptr(Address),buf,NumberOfBytes,write);
 
chr是用来将传入的参数表示的ASCII值转化成字符。
 
你是做外挂的 把!!有时间交流一下!!
 
接受答案了.
 
后退
顶部