Hello...
I have a strange problem with calling conventions. I am building a MFC dll in VS 2005. I exported following function with the help of .def file.
I havent changed the calling convention for the project so the default is now __cdecl. Thus functions in the DLL file must be decorated. But when I use dependency walker to check, this function is not decorated. This is the first problem.Code:bool GenerateSerialNumber(string strActivationCode, string strVID, string strPID, string& strSerialNumber);
I build a test client to use this library as follow..
This clients loads the library and calls the function properly. But at the end of the function i get following error..Code:typedef bool (*GenerateSerialNumber)(string strActivationCode, string strVID, string strPID, string& strSerialNumber); .... ... void CTestActivatorShimDlg::OnBnClickedOk() { HMODULE hModule = LoadLibrary("c:\\ActivatorShimDll.dll"); GenerateSerialNumber ptrGenerate; ptrGenerate = (GenerateSerialNumber)GetProcAddress(hModule,"GenerateSerialNumber"); bool bRet = false; string str1("122345"); string str2(""); bRet = ((*ptrGenerate)(str2,str2,str2,str1)); FreeLibrary(hModule); }
which tells that there is something wrong about calling convention or function pointer . Is there something I am missing...Code:Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
plz help...




Reply With Quote