okay i have this C type definition
and then i have a struct here in asm
along with its declaration and whatnot(omitted code to save space)
when the app i have loads the Dll it doesn't work because it isn't properly defined i've tried many ways of defing fpEntry in the PLUGIN_INTERFACE struct but none work. I think i have to convert the typedef struct to asm and use it as so. but the thing is i dunno how so i was wondering if anyone could help.
i post this in the heap and out of all the people that looked in there only a few clicked on it. so hopefully this'll get some attention:rolleyes:
typedef DWORD ( __stdcall * PluginEntryFunc)(DWORD dwReason, LPVOID lpData);
and then i have a struct here in asm
PLUGIN_INTERFACE struct
dwMagicword dd ?
dwVersion dd ?
szDescription dd ?
fpEntry
PLUGIN_INTERFACE ends
along with its declaration and whatnot(omitted code to save space)
.data
..... blah blah
Interface PLUGIN_INTERFACE <>
.code
..... blah blah
mov Interface.fpEntry,offset PluginEntry
when the app i have loads the Dll it doesn't work because it isn't properly defined i've tried many ways of defing fpEntry in the PLUGIN_INTERFACE struct but none work. I think i have to convert the typedef struct to asm and use it as so. but the thing is i dunno how so i was wondering if anyone could help.
i post this in the heap and out of all the people that looked in there only a few clicked on it. so hopefully this'll get some attention:rolleyes:
you should define fpEntry as a DWORD, since you're putting a dword value in it.
but what is the problem exactly? Is three anything happening with that value after you place something in it? Do you use it anywhere?
but what is the problem exactly? Is three anything happening with that value after you place something in it? Do you use it anywhere?
you should define fpEntry as a DWORD, since you're putting a dword value in it.
but what is the problem exactly? Is three anything happening with that value after you place something in it? Do you use it anywhere?
yeah from the original C code
typedef DWORD ( __stdcall * PluginEntryFunc)(DWORD dwReason, LPVOID lpData);
typedef struct
{
DWORD dwMagicword; /* should be "x0\x02D" */
DWORD dwVersion; /* plugin version */
LPCSTR szDescription;
PluginEntryFunc fpEntry;
} PLUGIN_INTERFACE, * LPPLUGIN_INTERFACE;
it is initialized as that and i was basically(god i dunno why i didn't just say this from the start) seeing if it was possible to do something similar if not the same thing in Asm. i've recently ordered some more books pertaining to Asm and C but their not coming in anytime soon so i was hoping i could handle this problem before hand.:)
PluginEntryFunc is a pointer (to a function) so it's 32-bits i.e. a DWORD
PLUGIN_INTERFACE struct
dwMagicword dd ?
dwVersion dd ?
szDescription dd ?
fpEntry [color=red]dd ?[/color]
PLUGIN_INTERFACE ends
yes i've established that.:grin: , but i wanna know how to convert that C typedef to its Asm equvilant..:alright:
there is no reason to convert a typedef to an asm equivilent... c++ has 329823983298 different types of variables and the only reason there are so many is to try and catch errors. This typedef....
typedef DWORD ( __stdcall * PluginEntryFunc)(DWORD dwReason, LPVOID lpData);
is saying "Create a new type of variable that holds a pointer to a function which returns a dword and accepts a dword and lpvoid argument." Now that youve stated this, if you say...
PluginEntryFunc pfnPEF;
pfnPEF = 1;
c++ will now yell at you because '1' is not a pointer to a function that returns a dword, blah, blah, blah
In asm we dont have all this nasty type conflicts because asm assums you know what your doing (unlike c++)... so if i have a 32 bit variable and I want it to contain the number 1, the compiler will blindly say "ok"... if later I decide to put a pointer to a function in that variable, its still gonna say "ok". So if you wanna know the eqivilent to that typedef here it is...
PluginEntryFunc DWORD ?
typedef DWORD ( __stdcall * PluginEntryFunc)(DWORD dwReason, LPVOID lpData);
is saying "Create a new type of variable that holds a pointer to a function which returns a dword and accepts a dword and lpvoid argument." Now that youve stated this, if you say...
PluginEntryFunc pfnPEF;
pfnPEF = 1;
c++ will now yell at you because '1' is not a pointer to a function that returns a dword, blah, blah, blah
In asm we dont have all this nasty type conflicts because asm assums you know what your doing (unlike c++)... so if i have a 32 bit variable and I want it to contain the number 1, the compiler will blindly say "ok"... if later I decide to put a pointer to a function in that variable, its still gonna say "ok". So if you wanna know the eqivilent to that typedef here it is...
PluginEntryFunc DWORD ?
I should think before I write more often... what I should of said is that...
is equivilent to...
typedef DWORD ( __stdcall * PluginEntryFunc)(DWORD dwReason, LPVOID lpData);
is equivilent to...
PluginEntryFunc typedef DWORD
I should think before I write more often... what I should of said is that...
never. if i had more people out there explaining stuff to me like this... i'd be one knowledgeable guy:grin:
thanks for the indepth answer:cool:
This works more conveniently:
Since you can now call the function with invoke:
Thomas
PluginEntryFunc TYPEDEF PROTO :DWORD, :DWORD
PluginEntryFuncPtr TYPEDEF PTR PluginEntryFunc
PLUGIN_INTERFACE struct
dwMagicword dd ?
dwVersion dd ?
szDescription dd ?
fpEntry PluginEntryFuncPtr ?
PLUGIN_INTERFACE ends
Since you can now call the function with invoke:
invoke Interface.fpEntry, 1, addr someData
Thomas