Archive: call __stdcall function in WIn32 dll from NSIS


call __stdcall function in WIn32 dll from NSIS
Hi All,

I have created a Win32 DLL with a function exported as -

#define MY_API extern"C" __declspec(dllexport)
MY_API int __stdcall myFunc(char *path);

When i call this function from NSIS it is failing. Though its entering the DllMain the function does not get called.

If i remove remove __stdcall and compile the DLL with __cdecl calling convention it works.

What is the work around for calling functions with __stdcall calling convention

Rgds
Venu


How exactly do you call it? The System plug-in uses the stdcall calling convention by default.


Hi Kichik,

Function Declaretion in Dll:
#define MY_API extern"C" __declspec(dllexport)
MY_API int __stdcall myFunc(char *path);

Calling the function from NSIS:
StrCpy $0 "NSIS"
System::Call '$EXEDIR\MyDll::myFunc(t)i(r0).r1'

Iam using VC++6 and NSIS 2.06


Order of args for one parameter may be not so important..
BTW what name shows Dependency Walker for yor dll?


Hi Takhir,

The dependency walker shows the name:
int myFunc(char *)
( Decorated Name: ?myFunc@@YGHPAD@Z )


That's not good. NSIS uses the name shown by Dependency Walker (?myFunc@@YGHPAD@Z). Add extern "C" before the function definition if you're compiling a C++ file. For example:

extern "C" void myFunc(char *);