samuri25404 Grandmaster Cheater
Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Mon Feb 04, 2008 12:36 pm Post subject: |
|
|
I couldn't explain it to you, but here's the source code from wii128unctions.pas (dbk32) of Buffy Engine:
| Code: |
function {ReadProcessMemory}RPM(hProcess:THANDLE;lpBaseAddress:pointer;lpBuffer:pointer;nSize:DWORD;var NumberOfBytesRead:DWORD):BOOL; stdcall;
type TInputstruct=record
processid: dword;
startaddress: dword;
bytestoread: word;
end;
var ao: array [0..600] of byte; //give it some space
input: TInputstruct absolute ao[0];
cc:dword;
i: integer;
ok: boolean;
br: dword;
mempointer: dword;
bufpointer: dword;
bufpointer2: pointer;
toread: dword;
begin
result:=false;
numberofbytesread:=0;
//find the hprocess in the handlelist, if it isn't use the normal method (I could of course use NtQueryProcessInformation but it's undocumented and I'm too lazy to dig it up
for i:=0 to length(handlelist)-1 do
if handlelist[i].processhandle=hProcess then
begin
if hdevice<>INVALID_HANDLE_VALUE then
begin
cc:=IOCTL_CE_READMEMORY;
mempointer:=dword(lpBaseAddress);
bufpointer:=dword(lpbuffer);
ok:=true;
while ok do
begin
input.processid:=handlelist[i].processid;
if nSize-numberofbytesread>=512 then
toread:=512
else
toread:=nSize-numberofbytesread;
input.bytestoread:=toread;
input.startaddress:=mempointer;
if deviceiocontrol(hdevice,cc,@ao[0],128,@ao[0],514,br,nil) then
begin
bufpointer2:=pointer(bufpointer);
copymemory(bufpointer2,@ao[0],toread);
//no check if it works or try except, it's up to the (retarded) user to do it right
end
else
begin
exit;
end;
inc(mempointer,toread);
inc(bufpointer,toread);
inc(numberofbytesread,toread);
if numberofbytesread=nSize then
begin
result:=true;
exit;
end;
end;
exit;
end else if not handlelist[i].validhandle then exit; //else use the normal method...
end;
//not found so ....
result:=windows.ReadProcessMemory(hProcess,lpBaseAddress,lpBuffer,nSize,NumberOfBytesRead);
end;
function {WriteProcessMemory}WPM(hProcess:THANDLE;lpBaseAddress:pointer;lpBuffer:pointer;nSize:DWORD;var NumberOfBytesWritten:DWORD):BOOL; stdcall;
type TInputstruct=record
processid: dword;
startaddress: dword;
bytestowrite: word;
end;
var ao: array [0..511] of byte;
input: TInputstruct absolute ao[0];
cc:dword;
i: integer;
ok: boolean;
br: dword;
mempointer: dword;
bufpointer: dword;
bufpointer2: pointer;
towrite: dword;
begin
result:=false;
NumberOfByteswritten:=0;
//find the hprocess in the handlelist, if it isn't use the normal method (I could of course use NtQueryProcessInformation but it's undocumented and I'm too lazy to dig it up
for i:=0 to length(handlelist)-1 do
if handlelist[i].processhandle=hProcess then
begin
if hdevice<>INVALID_HANDLE_VALUE then
begin
cc:=IOCTL_CE_WRITEMEMORY;
mempointer:=dword(lpBaseAddress);
bufpointer:=dword(lpbuffer);
ok:=true;
while ok do
begin
zeromemory(@ao[0],512);
input.processid:=handlelist[i].processid;
if nSize-NumberOfByteswritten>=(512-sizeof(TInputstruct)) then
towrite:=(512-sizeof(TInputstruct))
else
towrite:=nSize-NumberOfByteswritten;
input.bytestowrite:=towrite;
input.startaddress:=mempointer;
bufpointer2:=pointer(bufpointer);
copymemory(@ao[sizeof(tinputstruct)],bufpointer2,towrite);
if not deviceiocontrol(hdevice,cc,@ao[0],514,@ao[0],514,br,nil) then exit;
inc(mempointer,towrite);
inc(bufpointer,towrite);
inc(NumberOfByteswritten,towrite);
if NumberOfByteswritten=nSize then
begin
result:=true;
exit;
end;
end;
exit;
end else if not handlelist[i].validhandle then exit;
end;
//not found so ....
result:=windows.writeProcessMemory(hProcess,lpBaseAddress,lpBuffer,nSize,NumberOfByteswritten);
end;
|
_________________
|
|