sorry... i'm pretty sure someone has asked this before, but i couldn't find it. i've got this array:

ArrayBlah STRUCT
Foo1 BYTE 256 dup (?)
Foo2 BYTE 256 dup (?)
ArrayBlah ENDS

i want to get the address of Foo2 while using invoke. i tried this:

mov ecx,PtrToArray
invoke FunctionBlah,addr .ArrayBlah.Foo2

but it doesn't work. i also tried changing my struct to:
ArrayBlah STRUCT
pFoo2 DWORD $+512
Foo1 BYTE 256 dup (?)
Foo2 BYTE 256 dup (?)
ArrayBlah ENDS

and using:
mov ecx,PtrToArray
invoke FunctionBlah,.ArrayBlah.pFoo2

much thanks! :)
Posted on 2002-04-14 23:14:38 by jademtech
Why not just ?

mov ecx, pArray
add ecx,256 ; location of Foo2
invoke FuncBlah, Somthg, ecx

or even

lea ecx,
invoke FuncBlah, Somthg, ecx
Posted on 2002-04-14 23:26:08 by JimmyClif
you're right... that's what i'm using right now:
mov ecx, pArray
add ecx,256
invoke FuncBlah, ecx

but i'm sure there is something that doesn't tie up that extra register and doesn't require my array to be fixed. i.e. i can resize the elements at a future time. thanks, anyway :)
Posted on 2002-04-14 23:34:39 by jademtech
Not sure if this is exacly what you want but try this
invoke SomeFunction, offset ArrayBlah.Foo2
Posted on 2002-04-15 00:16:04 by Kudos
mov ecx,PtrToArray 

invoke FunctionBlah,addr [ecx].ArrayBlah.Foo2


This *will* work, i've done it before. So i have to wonder how ECX is getting the pointer to the struct...

I like to do this:


.data?
MyData ArrayBlah <>

.code

...
lea ecx, MyData
invoke FunctionBlah, addr [ecx].ArrayBlah.Foo2


When disassembled, the code becomes:


lea ecx, [00402024] ; my lea ecx, MyData
lea eax, [ecx + 100] ; EAX == addr [ecx].ArrayBlah.Foo2
push eax
call FunctionBlah


Hope it helps...
:alright:
NaN
Posted on 2002-04-15 00:34:14 by NaN
hm... NaN, you're right - i went back and tried the code that i had tried earlier... it assembled, but the data got all messed up when i used MessageBox (which is what happened before) - i was careless and used a register that MessageBox modified, and so screwed up execution. thanks :)
Posted on 2002-04-15 17:13:23 by jademtech
:grin: It happens to the best of us....
Posted on 2002-04-15 17:26:51 by NaN