I am trying to cut down on variables in the data/data? and LOCAL areas so I am starting to learn and use registers.

Now, for a LVITEM structure not allocated anywhere, I found I can use:


mov [edi].LVITEM.imask, LVIF_PARAM
mov [edi].LVITEM.iSubItem, 0
mov [edi].LVITEM.iItem, ebx
lea eax, [edi]
push eax ; pointer to a LVITEM structure yes?
push 0 ;
push LVM_GETITEM ;
push hListView2 ;
call SendMessage ;

Which works fine, but am having problems when I have to pass the size of a structure to an API



mov [edi].INITCOMMONCONTROLSEX.dwSize, sizeof INITCOMMONCONTROLSEX
mov [edi].INITCOMMONCONTROLSEX.dwICC, ICC_LISTVIEW_CLASSES or ICC_TREEVIEW_CLASSES
lea esi, [edi]
push esi
call InitCommonControlsEx

InitCommonControlsEx returns 1 for success but the controls don't show on the main window, but do show if I open another window, and the app doesn't close correctly (seems to hang, Win98 shows as app not responding)

but if I do the following: where iccex is defined as:
LOCAL iccex :INITCOMMONCONTROLSEX


mov iccex.dwSize, sizeof INITCOMMONCONTROLSEX
mov iccex.dwICC, ICC_LISTVIEW_CLASSES or ICC_TREEVIEW_CLASSES
invoke InitCommonControlsEx, ; Initialize Common Controls
addr iccex

all works well! how do I not use addr <structure with size of> and use pushes?
Posted on 2003-01-07 19:57:27 by Gunner
[i]Originally posted by Gunner [/i]

mov [edi].INITCOMMONCONTROLSEX.dwSize, sizeof INITCOMMONCONTROLSEX
mov [edi].INITCOMMONCONTROLSEX.dwICC, ICC_LISTVIEW_CLASSES or ICC_TREEVIEW_CLASSES
;; [b][size=18]lea esi, [edi][/SIZE][/b]
push [b]edi[/b]
call InitCommonControlsEx


This is wrong, you already have the pointer in EDI, well i assume anyways, since you dont show 'LEA EDI, iccex' or some other areas of memory meant for this structure..

your error is the above bolded line, it should not be there. And instead push the pointer EDI!

:alright:
NaN
Posted on 2003-01-07 20:31:08 by NaN
Don't assume, you know what that makes us right? :grin:

actually, I was hoping to use a register to hold my needed info and pass the register instead of an allocated structure for iccex anywhere, same with the LVITEM, not allocated anywhere, just using the register to hold the info. Figured I would use .somestructure.somefield instead of or whatnot, or do I have to use ? Me don't know... Hard to find info for MASM and everything is for using a register as already defined structure somewhere...
Posted on 2003-01-07 20:42:08 by Gunner
what does edi/esi point to in your program anyway? ;)
Posted on 2003-01-07 20:51:57 by Tola
You cannot put a structure "inside" a register, a register is only 4 bytes..... (Well i guess if you had a structure that was less than or equal to 4 bytes you could, but thats rare) secondly when you call an api function you always have to pass structures by reference (aka u pass the starting memory address to the structure) tell me what exactly is the address for a register?? (hint there is none, therefore its impossible to pass a register's address as an argument to a function). Also .somestructure.somefield is just another way to add an offset to whatever memory address is contained within esi, therefore its the same thing as saying .
Posted on 2003-01-07 23:14:44 by BubbaFate
Perhaps its would be some help to read This Thread...

As well, there is only 4 registers able to have "structure":

EAX STRUC
ax word ?
ah byte ?
al byte ?
EAX ENDS

EBX STRUC
bx word ?
bh byte ?
bl byte ?
EBX ENDS

ECX STRUC
cx word ?
ch byte ?
cl byte ?
ECX ENDS

EDX STRUC
dx word ?
dh byte ?
dl byte ?
EDX ENDS

Dont bother cut'n and pasting these structs, Intel gave you a head start ;) :grin: :eek:

:nAn:
Posted on 2003-01-08 00:06:22 by NaN
Gunner,

The proble is that the structures that ask for the size depend on it being correct so you have little choice but to use SIZEOF or hard code the number which is no better as SIZEOF is hard coded at assembly time.

mov mem_operand, immediate

is no big deal in terms of size so I don't see why you are worrying about it.

To share an idle moment with you, for practice recently I went through the entire code for TheGun recently and did every tacky little register trick to try and get the size down and it did not drop one section in size.

Size is nearly always a matter of getting the architecture right and rarely ever has to do with nitpicking mnemonics so unless you need the amusement, put your effort into stuff that is of advantage to you.

Regards,

hutch@movsd.com
Posted on 2003-01-08 04:27:09 by hutch--
Ah, thanks all, that cleared a lot up for me. I will keep defining structures locally to a proc and use them for api calls.
Posted on 2003-01-08 08:41:44 by Gunner