I'm stuck as to why I can't load my dll "interfac" using LoadLibrary. It seems to be failing when loading a dependency but I'm not sure why.
Here's the code:
AfxMessageBox(L"before load library");
HMODULE interfacDll = LoadLibrary(TEXT("C:\QA\Pcdlrn\Win32\Release\INTERFAC.DLL"));
if (!interfacDll)
DWORD dw = GetLastError(); // returns 0xc1 (193)
AfxMessageBox(L"after load library");
And here's the output from gflags (x86)'s loader snaps:
18a0:2a40 @ 06858973 - LdrGetDllHandleEx - ENTER: DLL name: ntdll.dll DLL path: NULL
18a0:2a40 @ 06858973 - LdrGetDllHandleEx - INFO: Locating DLL ntdll.dll in path C:QAPcdlrnCNCSERVERWin32Release;C:Windowssystem32;C:Windowssystem;C:Windows;C:Program Files (x86)Microsoft Visual Studio 14.0Common7IDECommonExtensionsMicrosoftTeamFoundationTeam ExplorerNativeBinariesx86;C:windowssystem32;C:windows;C:Program Files (x86)NVIDIA CorporationPhysXCommon;C:Program Files (x86)InteliCLS Client;C:Program FilesInteliCLS Client;C:Windowssystem32;C:Windows;C:Windows
18a0:2a40 @ 06858989 - LdrpFindLoadedDll - ENTER: DLL name: ntdll.dll DLL path: C:QAPcdlrnCNCSERVERWin32Release;C:Windowssystem32;C:Windowssystem;C:Windows;C:Program Files (x86)Microsoft Visual Studio 14.0Common7IDECommonExtensionsMicrosoftTeamFoundationTeam ExplorerNativeBinariesx86;C:windowssystem32;C:windows;C:Program Files (x86)NVIDIA CorporationPhysXCommon;C:Program Files (x86)InteliCLS Client;C:Program FilesInteliCLS Client;C:Windowssystem32;C:Windows;C:Windows
18a0:2a40 @ 06858989 - LdrpFindLoadedDll - RETURN: Status: 0x00000000
18a0:2a40 @ 06858989 - LdrGetDllHandleEx - RETURN: Status: 0x00000000
18a0:2a40 @ 06858989 - LdrGetProcedureAddressEx - INFO: Locating procedure "KiUserExceptionDispatcher" by name
18a0:2a40 @ 06858989 - LdrLoadDll - ENTER: DLL name: C:QAPcdlrnWin32ReleaseINTERFAC.DLL DLL path: C:QAPcdlrnCNCSERVERWin32Release;C:Windowssystem32;C:Windowssystem;C:Windows;.;C:Program Files (x86)Microsoft Visual Studio 14.0Common7IDECommonExtensionsMicrosoftTeamFoundationTeam ExplorerNativeBinariesx86;C:windowssystem32;C:windows;C:Program Files (x86)NVIDIA CorporationPhysXCommon;C:Program Files (x86)InteliCLS Client;C:Program FilesInteliCLS Client;C:Windowssyste
18a0:2a40 @ 06858989 - LdrpLoadDll - ENTER: DLL name: C:QAPcdlrnWin32ReleaseINTERFAC.DLL DLL path: C:QAPcdlrnCNCSERVERWin32Release;C:Windowssystem32;C:Windowssystem;C:Windows;.;C:Program Files (x86)Microsoft Visual Studio 14.0Common7IDECommonExtensionsMicrosoftTeamFoundationTeam ExplorerNativeBinariesx86;C:windowssystem32;C:windows;C:Program Files (x86)NVIDIA CorporationPhysXCommon;C:Program Files (x86)InteliCLS Client;C:Program FilesInteliCLS Client;C:Windowssyst
18a0:2a40 @ 06858989 - LdrpLoadDll - INFO: Loading DLL C:QAPcdlrnWin32ReleaseINTERFAC.DLL from path C:QAPcdlrnCNCSERVERWin32Release;C:Windowssystem32;C:Windowssystem;C:Windows;.;C:Program Files (x86)Microsoft Visual Studio 14.0Common7IDECommonExtensionsMicrosoftTeamFoundationTeam ExplorerNativeBinariesx86;C:windowssystem32;C:windows;C:Program Files (x86)NVIDIA CorporationPhysXCommon;C:Program Files (x86)InteliCLS Client;C:Program FilesInteliCLS Client;C:Windowssys
18a0:2a40 @ 06858989 - LdrpFindOrMapDll - ENTER: DLL name: C:QAPcdlrnWin32ReleaseINTERFAC.DLL DLL path: C:QAPcdlrnCNCSERVERWin32Release;C:Windowssystem32;C:Windowssystem;C:Windows;.;C:Program Files (x86)Microsoft Visual Studio 14.0Common7IDECommonExtensionsMicrosoftTeamFoundationTeam ExplorerNativeBinariesx86;C:windowssystem32;C:windows;C:Program Files (x86)NVIDIA CorporationPhysXCommon;C:Program Files (x86)InteliCLS Client;C:Program FilesInteliCLS Client;C:Windows
18a0:2a40 @ 06858989 - LdrpSearchPath - ENTER: DLL name: C:QAPcdlrnWin32ReleaseINTERFAC.DLL DLL path: C:QAPcdlrnCNCSERVERWin32Release;C:Windowssystem32;C:Windowssystem;C:Windows;.;C:Program Files (x86)Microsoft Visual Studio 14.0Common7IDECommonExtensionsMicrosoftTeamFoundationTeam ExplorerNativeBinariesx86;C:windowssystem32;C:windows;C:Program Files (x86)NVIDIA CorporationPhysXCommon;C:Program Files (x86)InteliCLS Client;C:Program FilesInteliCLS Client;C:Windowss
18a0:2a40 @ 06858989 - LdrpResolveFileName - ENTER: DLL name: C:QAPcdlrnWin32ReleaseINTERFAC.DLL
18a0:2a40 @ 06858989 - LdrpResolveFileName - RETURN: Status: 0x00000000
18a0:2a40 @ 06858989 - LdrpResolveDllName - ENTER: DLL name: C:QAPcdlrnWin32ReleaseINTERFAC.DLL
18a0:2a40 @ 06858989 - LdrpResolveDllName - RETURN: Status: 0x00000000
18a0:2a40 @ 06858989 - LdrpSearchPath - RETURN: Status: 0x00000000
18a0:2a40 @ 06859036 - LdrpMapViewOfSection - ENTER: DLL name: C:QAPcdlrnWin32ReleaseINTERFAC.DLL
'CNCServer.exe': Loaded 'C:QAPcdlrnWin32ReleaseINTERFAC.dll', Symbols loaded.
18a0:2a40 @ 06859098 - LdrpMapViewOfSection - RETURN: Status: 0x40000003
18a0:2a40 @ 06859098 - LdrpRelocateImage - ENTER: DLL name: C:QAPcdlrnWin32ReleaseINTERFAC.DLL
18a0:2a40 @ 06859098 - LdrpProtectAndRelocateImage - RETURN: Status: 0x00000000
18a0:2a40 @ 06859098 - LdrpRelocateImage - RETURN: Status: 0x00000000
18a0:2a40 @ 06859098 - LdrpFindOrMapDll - RETURN: Status: 0x00000000
18a0:2a40 @ 06859098 - LdrpHandleOneOldFormatImportDescriptor - INFO: DLL "C:QAPcdlrnWin32ReleaseINTERFAC.DLL" imports "PCDLRN.exe"
18a0:2a40 @ 06859098 - LdrpLoadImportModule - ENTER: DLL name: PCDLRN.exe DLL path: C:QAPcdlrnCNCSERVERWin32Release;C:Windowssystem32;C:Windowssystem;C:Windows;.;C:Program Files (x86)Microsoft Visual Studio 14.0Common7IDECommonExtensionsMicrosoftTeamFoundationTeam ExplorerNativeBinariesx86;C:windowssystem32;C:windows;C:Program Files (x86)NVIDIA CorporationPhysXCommon;C:Program Files (x86)InteliCLS Client;C:Program FilesInteliCLS Client;C:Windowssystem32;C:Windows;C:W
18a0:2a40 @ 06859098 - LdrpFindOrMapDll - ENTER: DLL name: PCDLRN.exe DLL path: C:QAPcdlrnCNCSERVERWin32Release;C:Windowssystem32;C:Windowssystem;C:Windows;.;C:Program Files (x86)Microsoft Visual Studio 14.0Common7IDECommonExtensionsMicrosoftTeamFoundationTeam ExplorerNativeBinariesx86;C:windowssystem32;C:windows;C:Program Files (x86)NVIDIA CorporationPhysXCommon;C:Program Files (x86)InteliCLS Client;C:Program FilesInteliCLS Client;C:Windowssystem32;C:Windows;C:Windo
18a0:2a40 @ 06859098 - LdrpFindKnownDll - ENTER: DLL name: PCDLRN.exe
18a0:2a40 @ 06859098 - LdrpFindKnownDll - RETURN: Status: 0xc0000135
18a0:2a40 @ 06859098 - LdrpSearchPath - ENTER: DLL name: PCDLRN.exe DLL path: C:QAPcdlrnCNCSERVERWin32Release;C:Windowssystem32;C:Windowssystem;C:Windows;.;C:Program Files (x86)Microsoft Visual Studio 14.0Common7IDECommonExtensionsMicrosoftTeamFoundationTeam ExplorerNativeBinariesx86;C:windowssystem32;C:windows;C:Program Files (x86)NVIDIA CorporationPhysXCommon;C:Program Files (x86)InteliCLS Client;C:Program FilesInteliCLS Client;C:Windowssystem32;C:Windows;C:Windows
18a0:2a40 @ 06859098 - LdrpResolveFileName - ENTER: DLL name: C:QAPcdlrnCNCSERVERWin32ReleasePCDLRN.exe
18a0:2a40 @ 06859098 - LdrpResolveFileName - RETURN: Status: 0xc0000135
18a0:2a40 @ 06859098 - LdrpResolveFileName - ENTER: DLL name: C:Windowssystem32PCDLRN.exe
18a0:2a40 @ 06859098 - LdrpResolveFileName - RETURN: Status: 0xc0000135
18a0:2a40 @ 06859098 - LdrpResolveFileName - ENTER: DLL name: C:WindowssystemPCDLRN.exe
18a0:2a40 @ 06859098 - LdrpResolveFileName - RETURN: Status: 0xc0000135
18a0:2a40 @ 06859098 - LdrpResolveFileName - ENTER: DLL name: C:WindowsPCDLRN.exe
18a0:2a40 @ 06859098 - LdrpResolveFileName - RETURN: Status: 0xc0000135
18a0:2a40 @ 06859098 - LdrpResolveFileName - ENTER: DLL name: .PCDLRN.exe
18a0:2a40 @ 06859098 - LdrpResolveFileName - RETURN: Status: 0x00000000
18a0:2a40 @ 06859098 - LdrpResolveDllName - ENTER: DLL name: .PCDLRN.exe
18a0:2a40 @ 06859098 - LdrpResolveDllName - RETURN: Status: 0x00000000
18a0:2a40 @ 06859098 - LdrpSearchPath - RETURN: Status: 0x00000000
18a0:2a40 @ 06859098 - LdrpMapViewOfSection - ENTER: DLL name: C:QAPcdlrnWin32ReleasePCDLRN.exe
'CNCServer.exe': Loaded 'C:QAPcdlrnWin32ReleasePCDLRN.exe', Symbols loaded.
18a0:2a40 @ 06859597 - LdrpMapViewOfSection - RETURN: Status: 0x40000003
'CNCServer.exe': Unloaded 'C:QAPcdlrnWin32ReleasePCDLRN.exe'
18a0:2a40 @ 06859597 - LdrpFindOrMapDll - RETURN: Status: 0xc000007b
18a0:2a40 @ 06859597 - LdrpLoadImportModule - ERROR: Loading DLL PCDLRN.exe from path C:QAPcdlrnCNCSERVERWin32Release;C:Windowssystem32;C:Windowssystem;C:Windows;.;C:Program Files (x86)Microsoft Visual Studio 14.0Common7IDECommonExtensionsMicrosoftTeamFoundationTeam ExplorerNativeBinariesx86;C:windowssystem32;C:windows;C:Program Files (x86)NVIDIA CorporationPhysXCommon;C:Program Files (x86)InteliCLS Client;C:Program FilesInteliCLS Client;C:Windowssystem32;C:Windows;C:
18a0:2a40 @ 06859597 - LdrpLoadImportModule - RETURN: Status: 0xc000007b
18a0:2a40 @ 06859597 - LdrpHandleOneOldFormatImportDescriptor - ERROR: Loading "?????" from the import table of DLL "C:QAPcdlrnWin32ReleaseINTERFAC.DLL" failed with status 0xc000007b
18a0:2a40 @ 06859613 - LdrpUnloadDll - INFO: Unmapping DLL "C:QAPcdlrnWin32ReleaseINTERFAC.DLL"
'CNCServer.exe': Unloaded 'C:QAPcdlrnWin32ReleaseINTERFAC.dll'
18a0:2a40 @ 06859613 - LdrpLoadDll - RETURN: Status: 0xc000007b
18a0:2a40 @ 06859613 - LdrLoadDll - RETURN: Status: 0xc000007b
I should mention that I am using 64-bit windows but all my executable code is either targeted to x86 (c#) or win32 (c++).
How do I resolve this issue?
Any suggestions would be greatly appreciated.
Thank you very much.
p.s. Here's the dependency walker output:
p.p.s. here's a screenshot showing that my DLLs are x86:
p.p.p.s. here's the linker inputs for interfac.dll:
Edit. Here's the output of dumpbin:
Microsoft (R) COFF/PE Dumper Version 14.00.24210.0
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file pcdlrn.exe
File Type: EXECUTABLE IMAGE
Section contains the following exports for PCDLRN.exe
00000000 characteristics
5796AD2A time date stamp Mon Jul 25 20:22:02 2016
0.00 version
1 ordinal base
5784 number of functions
5784 number of names
ordinal hint RVA name
1 0 0029CDF0 ??0?$CArray@V?$CStringT@_WV?$StrTraitMFC_DLL@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL@@V12@@@QAE@XZ = ??0?$CArray@V?$CStringT@_WV?$StrTraitMFC_DLL@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL@@V12@@@QAE@XZ (public: __thiscall CArray<class ATL::CStringT<wchar_t,class StrTraitMFC_DLL<wchar_t,class ATL::ChTraitsCRT<wchar_t> > >,class ATL::CStringT<wchar_t,class StrTraitMFC_DLL<wchar_t,class ATL::ChTraitsCRT<wchar_t> > > >::CArray<class ATL::CStringT<wchar_t,class StrTraitMFC_DLL<wchar_t,class ATL::ChTraitsCRT<wchar_t> > >,class ATL::CStringT<wchar_t,class StrTraitMFC_DLL<wchar_t,class ATL::ChTraitsCRT<wchar_t> > > >(void))
...
5783 1696 02593550 ?zoomOutFine@VisionTargetControls@UIEvents@@YAXXZ = ?zoomOutFine@VisionTargetControls@UIEvents@@YAXXZ (void __cdecl UIEvents::VisionTargetControls::zoomOutFine(void))
5784 1697 02593640 ?zoomOutMaximum@VisionTargetControls@UIEvents@@YAXXZ = ?zoomOutMaximum@VisionTargetControls@UIEvents@@YAXXZ (void __cdecl UIEvents::VisionTargetControls::zoomOutMaximum(void))
Summary
2C0000 .data
1000 .fnp_dir
1000 .fnp_mar
AFA000 .rdata
1B000 .rsrc
2E7A000 .text
E5000 .textidx
1000 .tls
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…