0

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

blackshadow
  • 77
  • 1
  • 4
  • FWIW, it seems relatively unlikely that 0x405000 is free - 0x400000 is the default load address for executables. – 500 - Internal Server Error Feb 26 '21 at 11:39
  • I know that! My program is dynamic base so 0x400000 is MEM_FREE. See my screenshot. –  blackshadow Feb 26 '21 at 12:36
  • @blackshadow: I don't think you can _guarantee_ it's free. With Address Space Layout Randomization (I assume that's what you mean by "dynamic base"), the address space layout is literally random. That means you can't assume hardcoded addresses. This technique wasn't exactly designed to beat cheats, but cheats and viruses are both a sort of hack attempt. – MSalters Feb 26 '21 at 12:43

0 Answers0