I am accessing a c++ dll library (I don't have the source code) from c++ code. I use this library to mount a usb device so I can access the files on the device. This code worked well in VS2010 but since we updated to VS2013 it no longer works. Here is my question. What differences between VS2010 and VS2013 might cause this to fail or what settings might cause this to fail?
Here is what I observe when running the code:
- The LoadLibary call returns a module handle
- The GetProcAddress seems to return a valid procedure address
- Invoking the dyn_Open_Device always returns false with VS2013 it almost always returned true in VS2010.
- After calling dyn_Open_Device, GetLastError returns 2 (ERROR_FILE_NOT_FOUND)
Here is the code:
typedef bool(*PFUNC_Open_Device)();
DWORD dwError = GetLastError();
BOOL bSuccess = SetDllDirectory(_T("C:\\Users\\steve epp\\Desktop\\EH16\\sdk1.1\\lib\\"));
// Step 2: Dynamically load the dll
HMODULE m_hModule = LoadLibrary("eeyelog_protocol_v1.0.dll");
dwError = GetLastError();
// Handle the case that the dll is not found
if (m_hModule == NULL)
{
dwError = GetLastError();
if (dwError == ERROR_MOD_NOT_FOUND)
{
CString msg = "Unable to load eeyelog_protocol_v1.0.dll.";
AfxMessageBox(msg, MB_OK | MB_ICONEXCLAMATION);
}
}
PFUNC_Open_Device dyn_Open_Device = (PFUNC_Open_Device)GetProcAddress(m_hModule, "Open_Device");
dwError = GetLastError();
bool ret = dyn_Open_Device();
dwError = GetLastError();
Here is the DUMPBIN results:
DUMPBIN /EXPORTS "C:\Users\steve epp\Desktop\EH16\sdk1.1\lib\eeyelog_protocol_v1.0.dll"
Microsoft (R) COFF/PE Dumper Version 10.00.40219.01
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file C:\Users\steve epp\Desktop\EH16\sdk1.1\lib\eeyelog_protocol_v1.0.dll
File Type: DLL
Section contains the following exports for eeyelog_protocol_v1.0.dll
00000000 characteristics
59CC4F90 time date stamp Wed Sep 27 18:25:36 2017
0.00 version
1 ordinal base
33 number of functions
33 number of names
ordinal hint RVA name
1 0 000010A0 Check_Device_state
2 1 000011D0 Close_Device
3 2 000012E0 Login
4 3 000011A0 Open_Device