OK, i am attempting to write a custom control. Well this is my problem. I have a struct with member inside and 1 of them is an pointer to a returned value from Heapalloc. This is suppose to be my dynamically allocated array that will contain a maximum of 40 items. This array's first element is the counter to work out the length of the array and also the number of assigned buttons in the control. Now i wander into the darker areas of my assembler capabilities. I can only seem to load into the first DWORD part of the array. I have used HEAP_ZERO_MEMORY to make it clear that i am not overwriting some data. So well here is a snippit of code.
And the last instruction is the one that seems to be overwriting some data.
If there is a better way to achieve this can you please tell me how - or why cant i write to the second DWORD in the array?
PS: i have zero'ed the struct so that debugging is easier.
took away the message box call - was for me to see if the function got called
assume ebx:PTR WhistlerMenu
.IF lParam!=NULL
invoke GetProcessHeap
.IF [ebx].arrayButton==NULL
push eax
invoke HeapAlloc,eax,HEAP_ZERO_MEMORY,8
mov [ebx].arrayButton,eax
pop eax
invoke HeapAlloc,eax,HEAP_ZERO_MEMORY,sizeof WhistlerMenuItem
[b]mov ecx,[ebx].arrayButton ;attemptin to save value into second DWORD in array
mov [ecx+4],eax[/b]
.ELSE
mov ecx,4
mov eax,[[ebx].arrayButton]
inc eax
mul eax
pop ecx
invoke HeapReAlloc,ecx,NULL,[ebx].arrayButton,eax
.IF eax==NULL
ret
.ENDIF
mov [ebx].arrayButton,eax
.ENDIF
;find pointer in array,
;copy struct members into struct pointed by array pointer
[b]inc DWORD PTR [[ebx].arrayButton][/b] ;increase the first element to reflect the # of buttons
.ENDIF
And the last instruction is the one that seems to be overwriting some data.
If there is a better way to achieve this can you please tell me how - or why cant i write to the second DWORD in the array?
PS: i have zero'ed the struct so that debugging is easier.
took away the message box call - was for me to see if the function got called
Haven't gone into any depth of your logic but there is one obvious problem with your code: there is no push for your pop ecx
Antonis
Antonis
Thank you, akyprian.
This would have been a future problem. I forgot to mention that the first if statement is taken. The else is for later - haven't got that far yet.
This would have been a future problem. I forgot to mention that the first if statement is taken. The else is for later - haven't got that far yet.
If you could post your project, then I could be of more help
Antonis
Antonis
Well *imbaressed* - i am in the VERY beginnig stages, but have a look.
Thank you, akyprian.
PS: WinAsm Studio is great.:alright:
remove attachment - as i said it is in the very beginning stages, no use of waisting space:grin:
Thank you, akyprian.
PS: WinAsm Studio is great.:alright:
remove attachment - as i said it is in the very beginning stages, no use of waisting space:grin:
akyprian, thank you for looking @ it. i have gotten it working.
Looks like you can't use [.y], you cant referer to a value in that santax - it will compile and take .y and not to what it reffers to. Thanks anyway.
Idoit @ work - sorry:grin:
assume ebx:PTR WhistlerMenu
.IF lParam!=NULL
invoke GetProcessHeap
.IF [ebx].arrayButton==NULL
push eax
invoke HeapAlloc,eax,HEAP_ZERO_MEMORY,8
mov [ebx].arrayButton,eax
pop eax
invoke HeapAlloc,eax,HEAP_ZERO_MEMORY,sizeof WhistlerMenuItem
mov ecx,[ebx].arrayButton
mov [ecx+4],eax
.ELSE
mov ecx,4
mov eax,[[ebx].arrayButton]
inc eax
mul eax
invoke HeapReAlloc,ecx,NULL,[ebx].arrayButton,eax
.IF eax==NULL
ret
.ENDIF
mov [ebx].arrayButton,eax
.ENDIF
mov ecx,[ebx].arrayButton
inc DWORD PTR [ecx]
Looks like you can't use [.y], you cant referer to a value in that santax - it will compile and take .y and not to what it reffers to. Thanks anyway.
Idoit @ work - sorry:grin:
Here is an alternative.
Antonis
PS. Needs a lot of clearing/testing. Look at XPM_INSERTITEM, test your WM_DESTROY if you are going to take this approach
Antonis
Antonis
PS. Needs a lot of clearing/testing. Look at XPM_INSERTITEM, test your WM_DESTROY if you are going to take this approach
Antonis
Thank you akyprian.
I see what you have done. Seems simple enough.
Black iCE
I see what you have done. Seems simple enough.
Black iCE