Made this little function because WriteProcessMemory was getting detected in a game hack I was making
// Write Bytes to Address Method
Function WriteIt(pAddress: Pointer; Bytes: Array of Byte): Boolean;
var
OldProtect, DummyProtect: DWord;
begin
if VirtualProtect(pAddress, SizeOf(Bytes), PAGE_EXECUTE_READWRITE, @OldProtect) then
begin
Move(Bytes, pAddress^, Length(Bytes));
VirtualProtect(pAddress, SizeOf(Bytes), OldProtect, @DummyProtect);
Result := True
end
else
Result := False;
end;
Great for when you Dll is injected into a process, you can use it like this... Example]Const
//NoReLoad
AddressReload = $374B1826;
PatchReload : Array[0..7] of byte = ($90,$90,$90,$90,$90,$90,$90,$90);
OriginalReload : Array[0..7] of byte = ($81,$44,$24,$04,$1C,$00,$00,$00);
.......
//Apply new bytes
WriteIt(ptr(AddressReload),PatchReload);
//Restore Old bytes
//WriteIt(ptr(AddressReload),OriginalReload);[/delphi]
by Departure