.if eax==WM_INITDIALOG
INITGROWABLEHEAP hMemory,pMemory
Invoke SetDlgItemInt,hWin,IDC_EDT1,pMemory,NULL

.elseif eax==WM_COMMAND
mov eax,wParam
and eax,0FFFFh

.if eax==IDC_BTN1

inc pMemory
Invoke SetDlgItemInt,hWin,IDC_EDT1,pMemory,NULL


.elseif eax==IDC_BTN2
DEINITGROWABLEHEAP hMemory,pMemory
add pMemory,3
INITGROWABLEHEAP hMemory,pMemory
mov pMemory,1
Invoke SetDlgItemInt,hWin,IDC_EDT1,1,NULL



problem is when i debug pMemory is STILL the same address... i want pMemory to be in ANOTHER address...
Posted on 2003-07-07 11:49:46 by Ni?o
This macros i made are not an official :tongue: macros so nobody will help u with this till u post macros.

But since i know what this is a will tell u this :grin:

.elseif eax==IDC_BTN2
DEINITGROWABLEHEAP hMemory,pMemory <----- after deinit (heapFree and so on pMemory is useless for u)

INITGROWABLEHEAP hMemory,pMemory <------ pMemory is a pointer to new adress (man dont use macros like proc , analize it before using)
mov pMemory,1
Invoke SetDlgItemInt,hWin,IDC_EDT1,1,NULL
Posted on 2003-07-08 17:39:01 by AceEmbler
here are the macros

INITGROWABLEHEAP MACRO hHEAP,pHEAPMEM
invoke HeapCreate,HEAP_NO_SERIALIZE,0,0
mov hHEAP,eax
invoke HeapAlloc,hHEAP,HEAP_NO_SERIALIZE or HEAP_ZERO_MEMORY,0
mov pHEAPMEM,eax
ENDM



DEINITGROWABLEHEAP MACRO hHEAP,pHEAPMEM
invoke HeapFree,hHEAP,HEAP_NO_SERIALIZE,pHEAPMEM
invoke HeapDestroy,hHEAP
ENDM


anyway, that was what i was telling. after heapfree pMemory is still in same address.
Posted on 2003-07-08 23:18:48 by Ni?o
I do not know whats youre roblem, after heapFree who cares what pMemory points, becouse this space it's not readable-writable for you.
Posted on 2003-07-09 03:58:53 by AceEmbler
pMemory doesn't change because pMemory is your variable, not windows (well isn't everything windows really). Basically HeapFree isn't going to touch the variable pMemory, you simply pass the value in it to HeapFree.

When you init again the old address is free (cause you freed it) so windows reuses it.

I don't understand why this is a problem though :confused: .
Posted on 2003-07-09 07:56:55 by Eóin
is there a way wherein i can allocate another address/variable for this??
Posted on 2003-07-09 10:39:42 by Ni?o
Use GetProcessHeap instead of HeapCreate or use VirtualAlloc.
Posted on 2003-07-09 10:47:30 by roticv
Still dont know whats your problem. U can use the same macro once again but then u have to use another variables. Or the same variables when u already freed and destroy that previous block of memory.
Posted on 2003-07-09 14:04:51 by AceEmbler
If you want your second allocation to have a different address, allocate the new data before freeing the old data.

invoke HeapAlloc,hMemory,HEAP_NO_SERIALIZE or HEAP_ZERO_MEMORY,0
push eax ; save address of new data
invoke HeapFree,hMemory,HEAP_NO_SERIALIZE,pMemory ; free old data
pop pMemory ; retrieve address of new data

If there are no other allocations, HeapAlloc will probably flipflop between two locations.
Posted on 2003-07-09 19:02:35 by tenkey
hi tenkey. thanks a lot that worked, it has different values everytime i restart. when i debug, here are the values i get:

7663628
7663644

can i write to this values? i mean use those values as addresses?
Posted on 2003-07-09 21:07:46 by Ni?o
Well the best way to find out is to try. But yes you should be able to.

If you really want to have some control over what address memory is allocated you really should use VirtualAlloc. The method you're using leaves you with no real control.
Posted on 2003-07-10 07:17:15 by Eóin
thanks for all the replies guys, please bear with me. anyway, i tried the ff codes:

mov pMemory,1 --> this overwrites the actual values in pMemory (the pointer to the dynamic address)

mov ,1 --> still overwrites the values in pMemory

any routine on how to do it?
Posted on 2003-07-10 10:59:38 by Ni?o
Do what? Access the pmemory? Use a register



mov esi, pmemory
mov [esi+4], eax
mov edx, [esi]
mov al, [esi+6]


Just some examples.
Posted on 2003-07-10 11:15:10 by roticv
thanks a lot everyone! ive got it working at last :)
Posted on 2003-07-10 12:02:53 by Ni?o