My WRITEPROCESSMEMORY call is consistently not writing anything, and the Bytes Written returned is consistently ZERO..
Here's the code I am using to prepare for the calls :
Get the Process ID as :
Main_Process_ID : Cardinal;
Main_Process_ID := Get_ProcessID( Trim( UpperCase( lbProcesses.GetSelectedText )));
Set up the read/write area as :
VAR Heap_Byte_Address : Pointer;
tmpByte_Array : ARRAY [ 00 .. 128 ] OF BYTE;
Heap byte address was fetched from corresponding ModuleInfo.lpBaseOfDll...
So the READS work great.
This works ok. (even when I read the entire heap... but only trying two bytes here )
PROCEDURE intReadBuffer_From_Memory;
VAR HowManyBytesRead : QWord;
Process_Handle : HANDLE;
BEGIN
Process_Handle := OpenProcess( PROCESS_ALL_ACCESS, False, Main_Process_ID );
ReadProcessMemory( Process_Handle,
Pointer( Heap_Byte_Address ),
@tmpByte_Array,
2,
HowManyBytesRead );
CloseHandle( Process_Handle );
END;
Here is how I prepare the assigning for Write (two bytes only)...
tmpByte_Array[ 0 ] := 65;
tmpByte_Array[ 1 ] := 65;
WB_Size := 2;
Then I call with WriteBufferToMemory( Heap_Byte_Address ); (below)...
Here's the call that fails :
PROCEDURE WriteBufferToMemory( inAddress : Pointer );
VAR HowManyBytesWritten : QWord;
Process_Handle : HANDLE;
BEGIN
HowManyBytesWritten := 0;
Process_Handle := OpenProcess( PROCESS_ALL_ACCESS, False, Main_Process_ID );
WriteProcessMemory( Process_Handle,
Pointer( Heap_Byte_Address ),
@tmpByte_Array,
2,
HowManyBytesWritten );
CloseHandle( Process_Handle );
END;
It's the WriteProcessMemory that fails. Keeps showing 0 bytes written, and returns the original bytes again when I call the read again.
Any ideas?