Problems passing data to 64 bit DLLs

Hi

I am attempting to create a simple 64 bit win32 test application that loads a simple 64 bit MFC DLL. I created a test function within the DLL that takes in a pointer to an integer. This function is an exported DLL function. I load the DLL in the executable. I get access to the exported function. I call the DLL function, sending it a pointer to an integer where the value is = to 100. I then step into the DLL function using the debugger. Within the DLL function the address of the integer pointer is undefined or NULL. So the pointer was not passed properly. Now, if I rebuild the application and DLL using the 32 bit compilers then all problems go away. The integer pointer is passed without any issues into the DLL function and I can see the value (100).

Any ideas would be greatly appreciated.
thanks


Here is my code for the win32 application:



typedef void (CALLBACK* D_TestDllTest)(int* Val);

.
.
.

int APIENTRY _tWinMain(HINSTANCE hInstance,...)
{

.
.
.

// load "TestDLL.dll"
CString Path = "c:\\TestDll.dll";
HINSTANCE TestDllHInst = AfxLoadLibrary((LPCTSTR)Path);

// get pointer to exported DLL function
D_TestDllTest TestDllTest = (D_TestDllTest)GetProcAddress(TestDllHInst, "TestDllTest");

// call the DLL function
int Val = 100;
TestDllTest(&Val);

.
.
.

}



Here is the DLL code:


void CTestDllApp::TestDllTest(int* Val)
{

*Val = 2;

return;
}




Lesson 2. Support of 32-bit applications in the 64-bit Windows environment. (Why cannot 32-bit DLL's be used in a 64-bit program? Is there a way to evade this limitation?)

Link: http://www.viva64.com/en/l/0002/
This blog post, by Raymond Chen, and the following discussion might also be of interest:

"Why can't you thunk between 32-bit and 64-bit Windows?"
http://blogs.msdn.com/b/oldnewthing/archive/2008/10/20/9006720.aspx

Last edited on
Topic archived. No new replies allowed.