Search code examples
c++memorymemory-managementx86opcodes

Is there an allocate winapi call in x86 EXEs?


How is allocation handled within a C++ compiled EXE? Is the allocation manager baked into the app making it impossible to track allocations / unallocations if you don't have the code? Or is there a WinAPI call or something similar for memory allocation?


Solution

  • The basis for the memory allocation is indeed some WinAPI call (typically the Heap functionality). These are "hidden" behind the operator new and malloc and other related functionality. You should be able to identify the calls to the Heap Functions, but there are probably several layers of functions between the raw heap and the actual memory allocation call.

    Edit: Clearly, if the program is compiled to use the C runtime as a .DLL, the code to actually perform the allocation is not in the executable at all - it would be in the DLL.

    And of course, it's interely possible that the programmer who wrote the code: 1. didn't use C/C++, in which case all bets are off. 2. wrote their own version of memory management in some way, using for example VirtualAlloc