please help....i always seems to have a problem here. i have two functions
that i have in my DLL, my app loads the DLL and uses GetProcAddress to have
the functions. but in the debuger it tells me: The vale of ESP was not
properly saved across a fucntion call. This is usally a result of calling a
function declared with one calling convetion with a function declared with a
different calling conventions

and i cant figure out how i am making them different.....please help! below
is the code

thanks ahead, as always.

sergio

in my DLL

#define XDLL __declspec(dllexport)
XDLL int BringItDown (void)
XDLL int HookItUp (HWND wMainExe)

and this is what i do in my APP

typedef int (WINAPI *pfnHookItUp)(IN HWND hWnd);
pfnHookItUp MyHookItUp;
typedef int (WINAPI *pfnBringItDown)(void);
pfnBringItDown MyBringItDown;

Re: proper casting from DLL by Jeff

Jeff
Sun Feb 08 17:26:40 CST 2004

"Sergio D. Caplan" <NOJUNK@EMAILPLEASE.COM> wrote in message
news:e7tv$fp7DHA.2676@TK2MSFTNGP10.phx.gbl...
> please help....i always seems to have a problem here. i have two
functions
> that i have in my DLL, my app loads the DLL and uses GetProcAddress to
have
> the functions. but in the debuger it tells me: The vale of ESP was not
> properly saved across a fucntion call. This is usally a result of calling
a
> function declared with one calling convetion with a function declared with
a
> different calling conventions
>
> and i cant figure out how i am making them different.....please help!
below
> is the code
>
> thanks ahead, as always.
>
> sergio
>
> in my DLL
>
> #define XDLL __declspec(dllexport)
> XDLL int BringItDown (void)
> XDLL int HookItUp (HWND wMainExe)
>
> and this is what i do in my APP
>
> typedef int (WINAPI *pfnHookItUp)(IN HWND hWnd);
> pfnHookItUp MyHookItUp;
> typedef int (WINAPI *pfnBringItDown)(void);
> pfnBringItDown MyBringItDown;

Specify the calling convention in the function prototype as well as the
function pointer prototype. And make sure they are the same. You do the
latter, but omit the former. WINAPI resolves to _stdcall, and I think an
unspecified calling convention defaults to _cdecl (no doubt there's a
command line switch for it). If that's the case, then there you go:
mismatched calling conventions. :)
--
Jeff Partch [VC++ MVP]



Re: proper casting from DLL by Sergio

Sergio
Sun Feb 08 18:11:55 CST 2004

i must ask a followup, so i understand better....

when i ADDED WINAPI to the functions, it didnt work at all....

but when i removed ALL references to WINAPI, everything worked fine...why
one way, and not the other...

thanks



Re: proper casting from DLL by Jeff

Jeff
Sun Feb 08 18:23:30 CST 2004

"Sergio D. Caplan" <NOJUNK@EMAILPLEASE.COM> wrote in message
news:eR24AGq7DHA.2044@TK2MSFTNGP10.phx.gbl...
> i must ask a followup, so i understand better....
>
> when i ADDED WINAPI to the functions, it didnt work at all....
>
> but when i removed ALL references to WINAPI, everything worked fine...why
> one way, and not the other...

Doesn't make sense to me, Sergio. Could you maybe post examples of the
WINAPI function and pointer prototypes that didn't work at all?
--
Jeff Partch [VC++ MVP]



Re: proper casting from DLL by Pavel

Pavel
Sun Feb 08 19:56:09 CST 2004

Nice. So both your DLL and app use cdecl calls.


"Sergio D. Caplan" <NOJUNK@EMAILPLEASE.COM> wrote in message news:eR24AGq7DHA.2044@TK2MSFTNGP10.phx.gbl...
> i must ask a followup, so i understand better....
>
> when i ADDED WINAPI to the functions, it didnt work at all....
>
> but when i removed ALL references to WINAPI, everything worked fine...why
> one way, and not the other...
>
> thanks
>
>