I need help with my MASM dll. I'm counting elements in array then I want to allocate memory for another array, in C I'm using vector. I tried to use:
invoe GetProcessHeap
invoke HeapAlloc, eax, HEAP_NO_SERIALIZE + HEAP_ZERO_MEMORY, <size>
or
invoke GlobalAlloc, GMEM_ZEROINIT, <size>
mov tab, eax
but I'm getting errors undefined symbol : GetProcessHeap
undefined symbol : HeapAlloc
I'm using this library in C# application. Can you show me example how can I dynamically allocate memory?
You need to link against the appropriate library. If you look at the MSDN page for
HeapAlloc
you'll see that it's located inkernel32.dll
.Assuming that you're using MASM32 there should be a
kernel32.inc
(for the procedure prototype) andkernel32.lib
(for linking) included with your MASM32 installation. So you need to add the following lines to your assembly file:If you don't have a
kernel32.lib
file it gets a bit more complicated, but it's still doable by usingLoadLibrary
to loadkernel32.dll
and then getting the address of theHeapAlloc
function withGetProcAddress
.