file File<> ;my struct


invoke rgb_bgr, Logical, addr ;my invoke


rgb_bgr proc Logical:DWORD, data:DWORD ;proc and code

mov edi, Logical;
mov eax, data
mov esi, ;.startf
mov ecx, ;.sizef


I tried and tried and tried. I want to pass the value of the first element of the file STRUCT, but everything I tried only gave me the address of file.

Now that I look at this, it maight not be what I want to do, but I'd still like to know.
Posted on 2001-09-10 20:29:30 by ThoughtCriminal

I want to pass the value of the first element of the file STRUCT
invoke rgb_bgr, Logical, file.first_element

...or...

invoke rgb_bgr, Logical, DWORD PTR
Posted on 2001-09-10 21:23:56 by bitRAKE
Doh! It's #2 I was looking for.
Posted on 2001-09-11 00:14:57 by ThoughtCriminal
This will only work for the FIRST stuct location, however!! This is because the first location IS the address of the struct, and every other is some # of bytes beyond the first.

If you wanted to do, say, any other stuct location you would have to do something like this:




SomeStruct STRUC
PARAM1 dd ?
PARAM2 dd ?
PARAM3 dd ?
SomeStruct ENDS

.data?

hData SomeStruct <>

.code

...
lea edx, hData
invoke SomeFunction, hWnd, (SomeStruct PTR [edx]).PARAM2
...


This passes the data found at the PARAM2 of hData, as organized by SomeStruct...

I have an artical on these issues on my Web-site, since this is often a hard to understand issue.... Here...

Its the last article. As well, it may do you some good to read the first one as well, as it discusses basically when and why to use the PTR symbol (seeing this is why you went 'doh!' :)

Hope this helped..

NaN
Posted on 2001-09-11 00:36:08 by NaN
If I followed yoos correctly, yoos wanna push the address of any element of a struct.

Cake and pie:



.data

SomeStruct STRUC
PARAM1 dd ?
PARAM2 dd ?
PARAM3 dd ?
SomeStruct ENDS

hData SomeStruct <>

.code

; to use the data itself:
invoke SomeFunct, hData.PARAM1, hData.PARAM2, hData.PARAM3

; to use pointers to the data
invoke OtherFunct, ADDR hData.PARAM1, ADDR hData.PARAM2, ADDR hData.PARAM3



When generating it's internal symbols, MASM remembers the PARAM's as simple numbers, in this case 0, 4 and 8. So it's generating the following code:



push [hData+0] ; PARAM1
push [hData+4] ; PARAM2
push [hData+8] ; PARAM3
call SomeFunct

lea eax, [hData+0] ; address of PARAM1
push eax
lea eax, [hData+4] ; address of PARAM2
push eax
lea eax, [hData+8] ; address of PARAM3
push eax
call OtherFunct, hData.PARAM1, hData.PARAM2,
Posted on 2001-09-11 06:47:55 by Ernie
Correct NaN, that why I wrote this:


Now that I look at this, it maight not be what I want to do, but I'd still like to know.


I realized that too as I was writing the post.

Thanks.
Posted on 2001-09-11 13:22:51 by ThoughtCriminal
Dooooooh! ( that was a juicy brain fart now wasnt it )


Well i tried, LoL... :)


NaN
Posted on 2001-09-11 22:44:31 by NaN