|
-
April 4th, 1999, 06:35 PM
#1
What is the ESP, I need help
Her my little Code, but I don't know why it isn't work ;-(
// DLL:
extern "C" void __declspec (dllexport) Get_Func(int* i)
{
*i=99;
}
//Main-PRG:
CMyProg::OpenDLL()
{
HINSTANCE hDll;
typedef void (__stdcall *LPFNDLLFUNC1)(i*);
LPFNDLLFUNC1 lpGet_Func;
hDLL=LoadLibrary ("Test.DLL");
lpGet_Func= (LPFNDLLFUNC1)::GetProcAddress(hDLL,_T("Get_Func"));
if (lpGet_Func!=NULL)
{
int i;
lpGet_Func(&i);
// Now i must be 99 but I've got the ERROR
}
FreeLibrary (hDLL);
}
ERROR:
Debug Error!
The value of ESP was not properly saved across a function call. This is....
-
April 5th, 1999, 11:34 AM
#2
Re: What is the ESP, I need help
Get rid of "__stdcall" from your typedef and it should fix the problem.
The reason this is happening is because you're exporting the DLL function using the default calling convention (which is __cdecl). But you're calling it as if it used the __stdcall convention.
Cheers!
Alvaro
-
April 5th, 1999, 02:41 PM
#3
Re: What is the ESP, I need help
Alvaro is correct.
FYI - ESP is the Extended Stack Pointer.
Since you specified _stdcall, the callee (your DLL function) is expected
to clean up the stack prior to returning which means restoring it to the
value it had just before the function was called.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|