这是我写的一个内存修改程序的某段(是个cracker内存补丁),相信对你会有帮助<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> FSnapshotHandle:THandle;<br> FProcessEntry32:TProcessEntry32;<br> Ret : BOOL;<br> ProcessID : integer;<br> ProcessHndle : THandle;<br> lpBuffer
byte;<br> nSize: DWORD;<br> lpNumberOfBytesWrite: DWORD;<br> i:integer;<br> s:string;<br>begin<br> FSnapshotHandle:=CreateToolhelp32Snapshot(<br>TH32CS_SNAPPROCESS,0);<br> //创建系统快照<br> FProcessEntry32.dwSize:=Sizeof(FProcessEntry32);<br> //先初始化 FProcessEntry32 的大小<br> Ret:=Process32First(FSnapshotHandle,FProcessEntry32);<br> while Ret do<br> begin<br> s:=ExtractFileName(FProcessEntry32.szExeFile);<br> if s='xxxx.EXE' then //你要修改的exe文件名<br> begin<br> ProcessID:=FProcessEntry32.th32ProcessID;<br> s:='';<br> break;<br> end;<br> Ret:=Process32Next(FSnapshotHandle,FProcessEntry32);<br> end;<br> //循环枚举出系统开启的所有进程,找出“G:/xxx/xxx.exe”<br> CloseHandle(FSnapshotHandle);<br> //Memo1.Lines.Clear ;<br> //memo1.lines.add('Process ID '+IntToHex(FProcessEntry32.th32ProcessID));<br> //memo1.lines.Add('File name '+FProcessEntry32.szExeFile);<br> ////输出进程的一些信息<br> nSize:=2;<br> lpBuffer:=AllocMem(nSize);<br> ProcessHndle:=OpenProcess(PROCESS_VM_WRITE,false,ProcessID);<br>//现在可以开始修改了。i是内存偏移地址,lpbuffer是要修改的数值<br> i:=$00451ebd;<br> lpbuffer^:=$84;<br> WriteProcessMemory(<br> ProcessHndle,<br> Pointer(i),<br> lpBuffer,<br> nSize,<br> lpNumberOfBytesWRite<br>  
;<br>//下面是读内存的方法<br> ReadProcessMemory(<br> ProcessHndle,<br> Pointer(i),<br> lpBuffer,<br> nSize,<br> lpNumberOfBytesWRite<br>  
;<br> edit1.text:=inttohex(i)+' value Is:'+intTohex(lpBuffer^);<br> FreeMem(lpBuffer,nSize);<br> CloseHandle(ProcessHndle);<br> application.Terminate;<br> //关闭句柄,释放内存<br>end;<br><br>记得把 TLHelp32加入到use,单这个单元只能在win9x下,nt下不能用的。<br><br><br>