VirtualAlloc with specified address failed on MEM_FREE memory?

315 Views Asked by At

I want to allocate memory on specified address but failed.
-> GetLastError()=487, Attempt to access invalid address.

 VirtualAlloc((void*)from, len, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);

My program will call this many times, some are ok and some failed.

One failed example: from = 0x405000, len=0x2000

I use CheatEngine to check my program memory region I found that [0x405000-0x407000] are MEM_FREE!!! Why did it failed?

cheatengine screenshot : https://i.stack.imgur.com/1Xow0.png

0

There are 0 best solutions below