flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
baldr 23 Nov 2008, 11:07
Everhest,
Code: … stdcall MemoryInit, hglb1, eax … proc MemoryInit HGLOBAL, size invoke GlobalAlloc, GMEM_ZEROINIT, [size] mov [HGLOBAL], eax; <- look here! … proc MemoryReSize HGLOBAL, size ; - not work invoke GlobalReAlloc, [HGLOBAL], [size], GMEM_ZEROINIT; <- and here … |
|||
![]() |
|
Everhest 23 Nov 2008, 12:53
But as it is correct this do that not to break syntax of the language?
|
|||
![]() |
|
baldr 23 Nov 2008, 14:22
Everhest,
It's not about language syntax. IA-32 doesn't allow double indirection. You passed address of hglb1 structure to MemoryInit as HGLOBAL parameter on stack, then successfully overwrite that parameter (address on stack, not contents of the memory it points to) with pointer to memory allocated in global heap (GMEM_FIXED==0, so GlobalAlloc() returns pointer, not handle; you should use GMEM_MOVEABLE additionally (or GHND — it's defined as GMEM_MOVEABLE | GMEM_ZEROINIT) to get handle). Something like Code: invoke GlobalAlloc, GMEM_ZEROINIT, [size] mov ecx, [HGLOBAL]; retrieve pointer parameter (ecx==hglb1) mov [ecx], eax; save heap pointer |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.