Hello!
This is my simple problem: I've tried to declare a structure like this
MyObject STRUCT
Function1 PROC :DWORD
Function2 PROC :DWORD
Function3 PROC :DWORD
MyObject ENDS
and, then, to call a function like this
push 10h
call dword ptr [eax+MyObject.Function1]
Now this doesn't work. It only works if I rreplace PROTO definitions with DWORD's.
I would like to know why, and where can you use that kind of structure?
Thanks,
Nick
Nick,
Structures and unions are data structures where a prototype is a type checking mechanism for invoke calls, they are not the same animal.
Hi, hutch
:bg
Ok, but where can be used this structure? I've tried to use it like this, but this is not the way...
ProcedureStr STRUCT
Function1 PROTO :DWORD
ProcedureStr ENDS
ProcedureStr.Function1 PROC A_Argument:DWORD
mov eax, A_Argument
ret
ProcedureStr.Function1 ENDP
.
.
.
INVOKE ProcedureStr.Function1, 100h
Nick
I've came to this when I was thinking about a macro for calls to COM objects. I thought that I could do something like this:
OBJStructure STRUCT
Function1 PROTO :DWORD, DWORD
Function2 PROTO :DWORD
OBJStructure ENDS
.DATA
PointerToObj OBJStructure ptr 0
.CODE
MyMacro PointerToObj.Function1, Arg1, Arg2
and, within MyMacro to do a typecheck like INVOKE does, using PROTO in that structure, and, if everything is OK, to do something like this in the end:
call dword ptr [eax+OBJStructure.Function1]
But I'm stuck with this problem.
I found a way arround that seem to work till now:
OBJStructure STRUCT
union
Function1 PROTO :DWORD, DWORD
Function1_ DWORD ?
ends
union
Function2 PROTO :DWORD, DWORD
Function2_ DWORD ?
ends
OBJStructure ENDS
but this is ugly... :)
I was hoping that there is a way to know - within macro - at wich offset form the start of a structure is the proto the caller needs.
here are my iFunc/iFuncVar macros. In the .inc file there are examples of their usage.
[attachment deleted by admin]
Hello, Ultrano! Thanks for that!
But I was thinking that all this can be done in a standard way, using PROTO. As I said earlier, I've found a way to use that structure, but I can't get the PROTO within it, so I can't compare arguments against the proto.... I better attach an example:
Nick
[attachment deleted by admin]
Hello,
Why don't use :
Quote
pcomethod1 TYPEDEF PROTO :DWORD
comethod1 TYPEDEF PTR pcomethod1
STIPersistFile STRUCT DWORD
; Iunknown commune a toutes les interfaces
Fonction comethod1 ?
//
STIPersistFile ENDS
ToutEnMasm
Hi!
Thanks for reply! But will I be able to follow back a symbol till his PROTO (suposing that I have lots of structures and objects, so I have to rely on that symbol name, as in zip file)?
No doubt, neither my method can follow back, and this looks better.
Ok, I will post thisquestion, even if it sound silly:
Why you can put PROTO in a STRUCT, if you can't retive a offset from the begining of that structure?
Nick
Hello,
For the addres of the structure , there is two cases.
***** For interfaces , the adress is given by an API
***** FOR prototypes in the source code,create a data in .data (must be initialised data,not .data?)
sample
MYPROGS STRUCT
first method3 ?
MYPROGS ENDS
.data
myprogs MYPROGS <>
.code
lea ebx,myprogs ;and you have the pointer on the structure usable with invoke
I see thet, ToutEnMasm , merci for reply!
In fact, I was interested in that because of COM objects, and this won't help there, science there is no point in creating a structure in .DATA, .DATA? or .CONST section.
Best regards,
Nick