The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Artoo on February 21, 2005, 09:14:56 AM

Title: Structs, and Procs
Post by: Artoo on February 21, 2005, 09:14:56 AM
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.....
Title: Re: Structs, and Procs
Post by: Jibz on February 21, 2005, 09:27:45 AM
MyObjPTR TYPEDEF PTR MyObj

MyProc proto :ObjPTR


You used ObjPTR instead of MyObjPTR.

Regarding using invoke indirectly, check this thread (http://www.masmforum.com/simple/index.php?topic=694.0).
Title: Re: Structs, and Procs
Post by: Artoo on February 21, 2005, 09:35:04 AM
Oops sorry Jibz, that was just a typo.  I still get the same error message?
Title: Re: Structs, and Procs
Post by: Jibz on February 21, 2005, 09:59:10 AM
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