Hey all,

Still busy coding away on my next self-taught tutorial, and I keep thinking in C++ terms, where memory can be accessed from the heap. I imagine this is possible in assembler... or is it? Or is it possible-but-not-typically-done?

Just curious.


Posted on 2002-04-20 00:28:49 by Chalain

Just have a pot through the API memory functions, GlobalAlloc(), VirtualAlloc(), OLE string memory and there are a few others, memory mapped files can be used at times so you have a "HEAP":) of ways to allocate memory.


Posted on 2002-04-20 02:12:30 by hutch--
Chalain, HeapAlloc for "various allocations", VirtualAlloc if you need
big chunks of memory (4k multiples) that don't need to be resized.
LocalAlloc=GlobalAlloc (under win2k they are exactly the same, ie
same address in kernel32, probably the same with 9x). And they
end up calling HeapAlloc... so you might as well use HeapAlloc directly.
Posted on 2002-04-20 07:05:57 by f0dder
Allocating memory

invoke GetProcessHeap
invoke HeapAlloc, eax, 0, size_in_bytes

The second parameter (0) may be one or more flags. One is HEAP_ZERO_MEMORY which will zero the memory after it's allocated.

Freeing memory

invoke GetProcessHeap
invoke HeapFree, eax, 0, ptrAllocatedMem

The heap functions can be used on other heaps, created with HeapCreate, but for most applications, the default process heap will do. A handle to this default heap can be retrieved using GetProcessHeap, as shown above.

Posted on 2002-04-20 17:00:46 by Thomas