DelphiUK
asked on
WriteProcessMemory with same address.
Hi
I have created a main application which do the following thing:
1. OpenProcess Function (Let's say we open "calc.exe").
2. VirtualAllocEx Function (Allocate some bytes in "calc.exe" memory).
3. WriteProcessMemory Function (Write some bytes in "calc.exe")
4. CloseHandle
Then I try to do the the same thing again with the same instance of "calc.exe".
But this time I know the allocated memory address from the last time so I only need to do the following thing:
1. OpenProcess Function (Same instance).
2. WriteProcessMemory Function (Write some bytes. I know the address from before)
3. CloseHandle
Why is this not posible?
I get an error when I second time tries to write in the same memory address
I have created a main application which do the following thing:
1. OpenProcess Function (Let's say we open "calc.exe").
2. VirtualAllocEx Function (Allocate some bytes in "calc.exe" memory).
3. WriteProcessMemory Function (Write some bytes in "calc.exe")
4. CloseHandle
Then I try to do the the same thing again with the same instance of "calc.exe".
But this time I know the allocated memory address from the last time so I only need to do the following thing:
1. OpenProcess Function (Same instance).
2. WriteProcessMemory Function (Write some bytes. I know the address from before)
3. CloseHandle
Why is this not posible?
I get an error when I second time tries to write in the same memory address
ASKER
Yes but I use "VirtualAllocEx" the first time to allocate some memory as you can see.
So I just can't get why I am not able to use WriteProcessMemory second time.
I use the same address as I was using the first time?
So I just can't get why I am not able to use WriteProcessMemory second time.
I use the same address as I was using the first time?
What is the error code returned?
ASKER
Error code 87 - Wrong parameter (In WriteProcessMemory function)
ASKER
Because it is only in the second time when I am using WriteProcessMemory I get the error.
And I don't get it because I use the same address as I was using in the first time.
And I don't get it because I use the same address as I was using in the first time.
You wouldn't get that error because the address is wrong. Can you post the code of both uses of WriteProcessMemory() and the surrounding code?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
A good! Glad you found it.
http://msdn.microsoft.com/