flat assembler
Message board for the users of flat assembler.
Index
> Windows > How to use memory allocated with HeapAlloc? |
Author |
|
typedef 08 Jan 2012, 22:42
Here's a code snippet from my project that I;m working on right now.
It is highly recommended to check if the returned pointer is not NULL otherwise your app will crash with possibly an Access violation Code: call [GetProcessHeap] push 2028 ; Unicode buffer size in my project push HEAP_ZERO_MEMORY ; zero out the buffer push eax call [HeapAlloc] or eax, eax jnz __no_err invoke MessageBox,0,'Error allocating memory','Windows Wins. Fatality !', MB_OK + MB_ICONSTOP push -$1 call [ExitProcess] __no_err: mov [temp_buffer], eax ; move the pointer After use, then you call HeapFree |
|||
08 Jan 2012, 22:42 |
|
LocoDelAssembly 08 Jan 2012, 23:07
Quote:
Code: virtual at ebx someLabel: .a rb 16 .b dd ? moreData rb 512 SIZE = $ - $$ end virtual invoke HeapAlloc, [hHeap], 0, SIZE mov [allocated_mem], eax mov ebx, eax ; access .b mov eax, [someLabel.b] ; fasm assembles "mov eax, [ebx+16]" Additionally, if you have a STRUCT defined, then you can just do the pointer arithmetic yourself too (e.g. "mov eax, [ebx+BITMAPINFOHEADER.biSize]") |
|||
08 Jan 2012, 23:07 |
|
rohagymeg 08 Jan 2012, 23:44
I better start reading the whole FASM documentation. If I still don't get it, I'll tell. Thanks LocoDelAssembly for help.
|
|||
08 Jan 2012, 23:44 |
|
typedef 09 Jan 2012, 00:30
Put it on your iPhone / iPad / iPod.
That is what I did, |
|||
09 Jan 2012, 00:30 |
|
rohagymeg 09 Jan 2012, 05:39
*Runs into the closest istore and buys an ipad*
|
|||
09 Jan 2012, 05:39 |
|
typedef 09 Jan 2012, 06:05
^^Really ?
|
|||
09 Jan 2012, 06:05 |
|
rohagymeg 09 Jan 2012, 14:27
typedef wrote: ^^Really ? True story bro:). If I had the money... |
|||
09 Jan 2012, 14:27 |
|
typedef 09 Jan 2012, 17:23
Haha. Nice sense of humor
|
|||
09 Jan 2012, 17:23 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.