Am I wrong or the code below should show an empty Message Box?

.386
.model flat,stdcall
option casemap:none

include windows.inc
include user32.inc
include kernel32.inc
include gdi32.inc

includelib user32.lib
includelib kernel32.lib
includelib gdi32.lib

.data
hInstance dd 0
MainHandle dd 0
TimerHandle dd 0
Hour dd 0

.code
Main:
invoke GetProcessHeap
invoke HeapAlloc,eax,HEAP_ZERO_MEMORY,512
mov Hour,eax
invoke MessageBox,0,addr Hour,addr Hour,0
invoke GetProcessHeap
invoke HeapFree,Hour
ret
End Main
Posted on 2004-02-12 05:44:15 by Eternal Idol Birmingham
I'm not sure of what you are trying to do here, but to show the address of the allocated memory you first would have to convert the dword (Hour) to a null terminated string.
Posted on 2004-02-12 06:07:15 by Delight
The HeapAlloc returns a pointer already, you do not have to convert it to a pointer using ADDR :

invoke HeapAlloc,eax,HEAP_ZERO_MEMORY,512

mov Hour,eax
invoke MessageBox,0,addr Hour,addr Hour,0

Should be

invoke HeapAlloc,eax,HEAP_ZERO_MEMORY,512
mov Hour,eax
invoke lstrcpy, Hour, OFFSET SomeString
invoke MessageBox,0,Hour,Hour,0
Posted on 2004-02-12 06:08:19 by donkey
Thanks both of you. Delight I don't need to do that because the whole memory is filled with zeros.
Donkey you are right, I was using the addr and I didn't need to.

Thanks again.
Posted on 2004-02-12 06:13:55 by Eternal Idol Birmingham