News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Structs, and Procs

Started by Artoo, February 21, 2005, 09:14:56 AM

Previous topic - Next topic

Artoo

Heres another dumb question for you all,  say I have the follow:

MyObj struct
m_fpSetWindowLong  DWORD  NULL
MyObj ends

MyObjPTR TYPEDEF PTR MyObj

MyProc proto :ObjPTR

MyProc proc pData:ObjPTR
    MOV  EAX, pData.m_fpSetWindowLong
MyProc endp


Why does the the assembler give me the following error on the MOV line:
error A2006: undefined symbol : m_fpSetWindowLong


Also, what would I have to do to use invoke to call SetwindowLong?  eg
invoke pData.m_fpSetWindowLong, 0,0,0


Thanks for any help.....

Jibz

MyObjPTR TYPEDEF PTR MyObj

MyProc proto :ObjPTR


You used ObjPTR instead of MyObjPTR.

Regarding using invoke indirectly, check this thread.

Artoo

Oops sorry Jibz, that was just a typo.  I still get the same error message?

Jibz

#3
That's because it's a double indirection. The mov instruction would have to first load the pointer from the stack, and then load the struct member from the struct it points to. You have to first get the pointer, and then use it to access the memory:

    MOV    EDX, pData
    MOV    EAX, [MyObjPTR PTR EDX].m_fpSetWindowLong


or you can use ASSUME if you have multiple accesses throughout the function and keep the struct pointer in the same register:

    MOV    EDX, pData
    ASSUME EDX:MyObjPTR
    MOV    EAX, [EDX].m_fpSetWindowLong
    ...
    ASSUME EDX:NOTHING