Dynamic Memory Allocation

I need help..(first, my english is not good, if you don understand pls guest it. Its like a puzzle of the day. You a programmer ;)

The question:
How do we allocate dynamic memory in asm?
What I know is we can't (No easy way). So maybe we has to use window dll. What is the dll function for alocate dynamic memory? If it's has a lot, may be consider the easiest one. I need something like this..

MOV EAX,1234 ;1234 is size of memory to allocate
PUSH EAX
CALL DLLFunction ;Now EAX contain pointer to the new dynamic address.

Thank a lot for help..
nothing nothing

Comments

  • to alloc some memory under win32 you could use the win32-api.thats exactly the same what c/c++ does when calling 'new' or something like that.a look to the api-help shows the following code-snipet to allocate memory:

    HeapAlloc(GetProcessHeap(), 0, dwBytes);

    you could read the win32-sdk to see,what each of the both api-calls do.to reach some parameters to a win-api-function,just push them to the stack and call the api.it will pops the parameters itself and returning the result in eax:

    call GetProcessHeap ;returns handle to the currents process heap
    push dwBytes ;here you must put in your bytes to allocate
    push 0 ;look to the sdk for the flags
    push eax ;handle to process-heap
    call HeapAlloc ; now eax holds a pointer to your memory



Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion