Ben
Ben

Reputation: 3440

Check if VirtualFreeEx has been completed/executed

I use VirtualAllocEx on a remote process to reserve some space like this:

VirtualAllocEX (RemoteProcessHandle, nil, SizeInBytes, MEM_COMMIT or MEM_RESERVE, PAGE_EXECUTE_READWRITE);

Then I "fill"/write the allocated addressspace with WriteProcessMemory

Then I properly use

VirtualFreeEx (RemoteProcessHandle, Address, 0, MEM_RELEASE);

to release the allocated space.

Is it possible to check on the Address of VirtualAllocEx after VirtualFreeEx has been called to check if VirtualFreeEx was successful?

Upvotes: 1

Views: 563

Answers (1)

David Heffernan
David Heffernan

Reputation: 612993

As soon as you return the address to the system, any future reference of that address is invalid. Once you have made the successful call to VirtualFreeEx, you must not refer to Address again. Once you have returned the address to the system, the system owns it. The only way for that address to become valid in the future, is through another call to VirtualAllocEx.

Upvotes: 4

Related Questions