This is my Working Code
DriftMul:=99;
WriteProcessMemory(HandleWindow, ptr($4E709C), @DriftMul, 2, Write);
I want to Convert it without using a variable but it wont work
Below is just an Example of what i want to do.
WriteProcessMemory(HandleWindow, ptr($4E709C), ptr(99), 2, Write);
Does anyone know a way to make this work with using a variable???
I am able to program in a few languages and every language i use their is a
way to to do this. The reason i want to do this is because i am gonna be making a big program that does alot of writing of different values and it will save me around 300+ lines. Below is an Example in c++ i was using.
WriteProcessMemory(hProcess, (void*)0x4E709C, (void*)(PBYTE)"\x20", 1, NULL);
Update:
Solved it
Im using 4 Procedures that i call depending on how many bytes i want to write.
procedure Wpm(Address: Cardinal; ChangeValues: Byte);
Begin
WriteProcessMemory(HandleWindow, Pointer(Address), @ChangeValues, 1, Write);
End;
procedure Wpm2(Address: Cardinal; ChangeValues: Word);
Begin
WriteProcessMemory(HandleWindow, Pointer(Address), @ChangeValues, 2, Write);
End;
procedure Wpm3(Address: Cardinal; ChangeValues: Word);
Begin
WriteProcessMemory(HandleWindow, Pointer(Address), @ChangeValues, 3, Write);
End;
procedure Wpm4(Address: Cardinal; ChangeValues: Cardinal);
Begin
WriteProcessMemory(HandleWindow, Pointer(Address), @ChangeValues, 4, Write);
End;
Example writes
Wpm($477343,$EB);
Wpm2($40A889,$37EB);
Wpm3($416E34,$0086E9);
Pchar is the only method i found to compile without procedures, i dont want to use assci though.
WriteProcessMemory(HandleWindow, Pointer($449A17), PChar('90'), 1, Write);
You have to store the contents of the word that you are writing somewhere.
WriteProcessMemoryexpects a pointer to some memory in your process space. If you don’t want to use a variable, use a constant.Passing
ptr(99)fails becauseptr(99)is not a pointer to a word containing the value99. It is a pointer to address 99. I think you were trying to write@Word(99)but you cannot take the address of a true constant.You can make this more convenient by wrapping up the call to
WriteProcessMemoryin a helper methods. Although your question suggests that you want to writeWordvalues, it became apparent in out lengthy chat that you actually want to write byte sequences. Writing integer data types will lead to machine endianness confusion. So instead I would do it using an open array ofByteto give the flexibility at the call site.You can then call the code