Reputation: 1082
I was trying out this code.
I am hitting on error "Types of actual and formal var parameters must be identical" . Any help in this regard is highly appreciated.
......
ReadProcessMemory(ProcInfo.hProcess, pointer(Context.Ebx + 8), @BaseAddress, 4, Bytes); <-- error is here
.......
and
.....
WriteProcessMemory(ProcInfo.hProcess, pointer(ImageNtHeaders.OptionalHeader.ImageBase), InjectMemory, InjectSize, Bytes); <---- error here
......
I am using Delphi XE2 and windows 7 64 bit. Some of my friends are able to compile it under D7 environment. Any help is appreciated.
Upvotes: 4
Views: 2808
Reputation: 612814
The error tells you that one of the variables you are passing as parameter does not have the required type. The error is in a var
parameter. The final parameter for both these functions is the only var parameter so clearly Bytes
is not the required type.
The solution is to make Bytes
match the type specified in the declaration of ReadProcessMemory
and WriteProcessMemory
. In XE2 that type is SIZE_T
. So you just need to change your definition of Bytes
to be of type SIZE_T
.
Here are the XE2 declarations:
function ReadProcessMemory(hProcess: THandle; const lpBaseAddress: Pointer;
lpBuffer: Pointer; nSize: SIZE_T; var lpNumberOfBytesRead: SIZE_T): BOOL; stdcall;
function WriteProcessMemory(hProcess: THandle; const lpBaseAddress: Pointer;
lpBuffer: Pointer; nSize: SIZE_T; var lpNumberOfBytesWritten: SIZE_T): BOOL; stdcall;
Upvotes: 5