okay i have this C type definition
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:
Posted on 2003-01-09 19:28:34 by Guy on ASM
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?
Posted on 2003-01-09 20:03:49 by Hiroshimator

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.:)
Posted on 2003-01-09 21:48:41 by Guy on ASM
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
Posted on 2003-01-10 08:58:54 by stormix
yes i've established that.:grin: , but i wanna know how to convert that C typedef to its Asm equvilant..:alright:
Posted on 2003-01-10 14:06:06 by Guy on ASM
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 ?
Posted on 2003-01-10 18:00:30 by BubbaFate
I should think before I write more often... what I should of said is that...

typedef DWORD ( __stdcall * PluginEntryFunc)(DWORD dwReason, LPVOID lpData);

is equivilent to...
PluginEntryFunc typedef DWORD
Posted on 2003-01-10 18:53:53 by BubbaFate

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:
Posted on 2003-01-10 19:45:43 by Guy on ASM
This works more conveniently:



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
Posted on 2003-01-11 04:26:52 by Thomas