hi all, I was trying to compile a simple windows application using winelib. it crashs and returns: err:seh:setup_exception stack overflow 12 bytes in thread 0009 eip 60169224 esp 00230ff4 stack 0x231000-0x340000
I first convert a .dll, which contains a simple add function (int add(int a, int b)) to be .dll.so. And then I compile a simple program which calls this function. I am able to compile it properly. but when i run it, it shows above error message. -----------------.h is ------------------------------ int __stdcall add(int a, int b);
----------------.c is---------------------------- HMODULE hDLL=0; /* DLL to call */
#ifdef __i386__ #define GET_THIS(t,p) t p;\ __asm__ __volatile__ ("movl %%ecx, %0" : "=m" (p)) #endif
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { TRACE("(0x%p, %ld, %p)\n",hinstDLL,fdwReason,lpvReserved);
if (fdwReason == DLL_WINE_PREATTACH) return FALSE; /* prefer native version */
if (fdwReason == DLL_PROCESS_ATTACH) { hDLL = LoadLibraryA( "libjason.dll" ); printf("load dll\n"); TRACE(":Forwarding DLL (libJason.dll) loaded (%ld)\n",(LONG)hDLL); } else if (fdwReason == DLL_PROCESS_DETACH) { FreeLibrary( hDLL ); TRACE(":Forwarding DLL (libJason.dll) freed\n"); }
return TRUE; }
int add(int a, int b) { int (*pFunc)(int, int); int retVal; pFunc=(void*)GetProcAddress(hDLL,"vgMath"); TRACE("((int)%ld,(int)%ld): forward\n",(LONG)a,(LONG)b); retVal = pFunc(a,b); TRACE("Returned (%ld)\n",(LONG)retVal); return retVal; } ------------------------.spec is -------------------- 1 stdcall add( long long ) vgMath
can any one help me?
thanks
Send instant messages to your online friends http://au.messenger.yahoo.com
xie jason wrote:
can any one help me?
Yes, it looks like you're using the wrong calling convention.
int add(int a, int b) { int (*pFunc)(int, int);
This should probably be "int (* __stdcall pFunc)(int, int);"
int retVal; pFunc=(void*)GetProcAddress(hDLL,"vgMath"); TRACE("((int)%ld,(int)%ld): forward\n",(LONG)a,(LONG)b); retVal = pFunc(a,b); TRACE("Returned (%ld)\n",(LONG)retVal); return retVal; } ------------------------.spec is -------------------- 1 stdcall add( long long ) vgMath