LoadLibrary失败,错误代码为193

markf78

我对为什么不能使用LoadLibrary加载dll“ interfac”感到困惑。加载依赖项时似乎失败了,但我不确定为什么。

这是代码:

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");

这是gflags(x86)的加载程序快照的输出:

18a0:2a40 @ 06858973 - LdrGetDllHandleEx - ENTER: DLL name: ntdll.dll DLL path: NULL
18a0:2a40 @ 06858973 - LdrGetDllHandleEx - INFO: Locating DLL ntdll.dll in path C:\QA\Pcdlrn\CNCSERVER\Win32\Release;C:\Windows\system32;C:\Windows\system;C:\Windows;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\NativeBinaries\x86;C:\windows\system32;C:\windows;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows
18a0:2a40 @ 06858989 - LdrpFindLoadedDll - ENTER: DLL name: ntdll.dll DLL path: C:\QA\Pcdlrn\CNCSERVER\Win32\Release;C:\Windows\system32;C:\Windows\system;C:\Windows;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\NativeBinaries\x86;C:\windows\system32;C:\windows;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;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:\QA\Pcdlrn\Win32\Release\INTERFAC.DLL DLL path: C:\QA\Pcdlrn\CNCSERVER\Win32\Release;C:\Windows\system32;C:\Windows\system;C:\Windows;.;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\NativeBinaries\x86;C:\windows\system32;C:\windows;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\syste
18a0:2a40 @ 06858989 - LdrpLoadDll - ENTER: DLL name: C:\QA\Pcdlrn\Win32\Release\INTERFAC.DLL DLL path: C:\QA\Pcdlrn\CNCSERVER\Win32\Release;C:\Windows\system32;C:\Windows\system;C:\Windows;.;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\NativeBinaries\x86;C:\windows\system32;C:\windows;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\syst
18a0:2a40 @ 06858989 - LdrpLoadDll - INFO: Loading DLL C:\QA\Pcdlrn\Win32\Release\INTERFAC.DLL from path C:\QA\Pcdlrn\CNCSERVER\Win32\Release;C:\Windows\system32;C:\Windows\system;C:\Windows;.;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\NativeBinaries\x86;C:\windows\system32;C:\windows;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\sys
18a0:2a40 @ 06858989 - LdrpFindOrMapDll - ENTER: DLL name: C:\QA\Pcdlrn\Win32\Release\INTERFAC.DLL DLL path: C:\QA\Pcdlrn\CNCSERVER\Win32\Release;C:\Windows\system32;C:\Windows\system;C:\Windows;.;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\NativeBinaries\x86;C:\windows\system32;C:\windows;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows
18a0:2a40 @ 06858989 - LdrpSearchPath - ENTER: DLL name: C:\QA\Pcdlrn\Win32\Release\INTERFAC.DLL DLL path: C:\QA\Pcdlrn\CNCSERVER\Win32\Release;C:\Windows\system32;C:\Windows\system;C:\Windows;.;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\NativeBinaries\x86;C:\windows\system32;C:\windows;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\s
18a0:2a40 @ 06858989 - LdrpResolveFileName - ENTER: DLL name: C:\QA\Pcdlrn\Win32\Release\INTERFAC.DLL
18a0:2a40 @ 06858989 - LdrpResolveFileName - RETURN: Status: 0x00000000
18a0:2a40 @ 06858989 - LdrpResolveDllName - ENTER: DLL name: C:\QA\Pcdlrn\Win32\Release\INTERFAC.DLL
18a0:2a40 @ 06858989 - LdrpResolveDllName - RETURN: Status: 0x00000000
18a0:2a40 @ 06858989 - LdrpSearchPath - RETURN: Status: 0x00000000
18a0:2a40 @ 06859036 - LdrpMapViewOfSection - ENTER: DLL name: C:\QA\Pcdlrn\Win32\Release\INTERFAC.DLL
'CNCServer.exe': Loaded 'C:\QA\Pcdlrn\Win32\Release\INTERFAC.dll', Symbols loaded.
18a0:2a40 @ 06859098 - LdrpMapViewOfSection - RETURN: Status: 0x40000003
18a0:2a40 @ 06859098 - LdrpRelocateImage - ENTER: DLL name: C:\QA\Pcdlrn\Win32\Release\INTERFAC.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:\QA\Pcdlrn\Win32\Release\INTERFAC.DLL" imports "PCDLRN.exe"
18a0:2a40 @ 06859098 - LdrpLoadImportModule - ENTER: DLL name: PCDLRN.exe DLL path: C:\QA\Pcdlrn\CNCSERVER\Win32\Release;C:\Windows\system32;C:\Windows\system;C:\Windows;.;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\NativeBinaries\x86;C:\windows\system32;C:\windows;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\W
18a0:2a40 @ 06859098 - LdrpFindOrMapDll - ENTER: DLL name: PCDLRN.exe DLL path: C:\QA\Pcdlrn\CNCSERVER\Win32\Release;C:\Windows\system32;C:\Windows\system;C:\Windows;.;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\NativeBinaries\x86;C:\windows\system32;C:\windows;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;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:\QA\Pcdlrn\CNCSERVER\Win32\Release;C:\Windows\system32;C:\Windows\system;C:\Windows;.;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\NativeBinaries\x86;C:\windows\system32;C:\windows;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows
18a0:2a40 @ 06859098 - LdrpResolveFileName - ENTER: DLL name: C:\QA\Pcdlrn\CNCSERVER\Win32\Release\PCDLRN.exe
18a0:2a40 @ 06859098 - LdrpResolveFileName - RETURN: Status: 0xc0000135
18a0:2a40 @ 06859098 - LdrpResolveFileName - ENTER: DLL name: C:\Windows\system32\PCDLRN.exe
18a0:2a40 @ 06859098 - LdrpResolveFileName - RETURN: Status: 0xc0000135
18a0:2a40 @ 06859098 - LdrpResolveFileName - ENTER: DLL name: C:\Windows\system\PCDLRN.exe
18a0:2a40 @ 06859098 - LdrpResolveFileName - RETURN: Status: 0xc0000135
18a0:2a40 @ 06859098 - LdrpResolveFileName - ENTER: DLL name: C:\Windows\PCDLRN.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:\QA\Pcdlrn\Win32\Release\PCDLRN.exe
'CNCServer.exe': Loaded 'C:\QA\Pcdlrn\Win32\Release\PCDLRN.exe', Symbols loaded.
18a0:2a40 @ 06859597 - LdrpMapViewOfSection - RETURN: Status: 0x40000003
'CNCServer.exe': Unloaded 'C:\QA\Pcdlrn\Win32\Release\PCDLRN.exe'
18a0:2a40 @ 06859597 - LdrpFindOrMapDll - RETURN: Status: 0xc000007b
18a0:2a40 @ 06859597 - LdrpLoadImportModule - ERROR: Loading DLL PCDLRN.exe from path C:\QA\Pcdlrn\CNCSERVER\Win32\Release;C:\Windows\system32;C:\Windows\system;C:\Windows;.;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\NativeBinaries\x86;C:\windows\system32;C:\windows;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:
18a0:2a40 @ 06859597 - LdrpLoadImportModule - RETURN: Status: 0xc000007b
18a0:2a40 @ 06859597 - LdrpHandleOneOldFormatImportDescriptor - ERROR: Loading "?????" from the import table of DLL "C:\QA\Pcdlrn\Win32\Release\INTERFAC.DLL" failed with status 0xc000007b
18a0:2a40 @ 06859613 - LdrpUnloadDll - INFO: Unmapping DLL "C:\QA\Pcdlrn\Win32\Release\INTERFAC.DLL"
'CNCServer.exe': Unloaded 'C:\QA\Pcdlrn\Win32\Release\INTERFAC.dll'
18a0:2a40 @ 06859613 - LdrpLoadDll - RETURN: Status: 0xc000007b
18a0:2a40 @ 06859613 - LdrLoadDll - RETURN: Status: 0xc000007b

我应该提到我使用的是64位Windows,但是我所有的可执行代码都针对x86(c#)或win32(c ++)。

我该如何解决这个问题?

任何建议将不胜感激。非常感谢你。

ps这是依赖项遍历器的输出: INTERFAC.dll

pps这是一个截图,显示我的DLL是x86:

x86

ppps这是interfac.dll的链接器输入:

链接器输入

编辑。这是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
dxiv

One likely explanation for the ERROR_BAD_EXE_FORMAT error from LoadLibrary is that INTERFAC.DLL was linked with a PCDLRN.LIB import library that declares PCDLRN exports, but the PCDLRN.EXE found at runtime does not have an exports table.

  • The gflags (x86)'s loader snaps shows that the error is triggered while loading PCDLRN.EXE, specifically while resolving the import table of INTERFAC.DLL:

    18a0:2a40 @ 06859098 - LdrpHandleOneOldFormatImportDescriptor - INFO: DLL "C:\QA\Pcdlrn\Win32\Release\INTERFAC.DLL" imports "PCDLRN.exe"
    [...]
    18a0:2a40 @ 06859597 - LdrpHandleOneOldFormatImportDescriptor - ERROR: Loading "?????" from the import table of DLL "C:\QA\Pcdlrn\Win32\Release\INTERFAC.DLL" failed with status 0xc000007b
  • Status 0xc000007b is STATUS_INVALID_IMAGE_FORMAT:

    {Bad Image} %hs is either not designed to run on Windows or it contains an error. Try installing the program again using the original installation media or contact your system administrator or the software vendor for support.

  • NTSTATUS STATUS_INVALID_IMAGE_FORMAT is mapped to Win32 error code ERROR_BAD_EXE_FORMAT per INFO: Mapping NT Status Error Codes to Win32 Error Codes.

I was able to duplicate the same ERROR_BAD_EXE_FORMAT with a mockup of the given scenario: link INTERFAC.DLL to a PCDLRN.LIB that declares an exported foo, then substitute a PCDLRN.EXE without an exports table, and finally attempt to LoadLibrary INTERFAC.DLL.

附带说明一下,将a链接DLL到另一个的导入库EXE并不常见,并且充满陷阱。在这种情况下,即使错误193得到修复,EXE也无法从中直接使用中的功能DLL有关更多详细信息,请参见例如将EXE加载为DLL:可能任务

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

SceneKit CFURLCreateDataAndPropertiesFromResource失败,错误代码为-11

来自分类Dev

订单发送失败,错误代码为130

来自分类Dev

PL / SQL失败,错误代码为ORA-01858

来自分类Dev

读取pendrive时,CreateFile()失败,错误代码为32

来自分类Dev

订单发送失败,错误代码为130

来自分类Dev

gmail发送api流星失败,错误代码为400

来自分类Dev

pip安装paramiko失败,错误代码为1

来自分类Dev

AWS Glue:命令失败,错误代码为 1

来自分类Dev

Android BLE 广告失败,错误代码为 1

来自分类Dev

错误:挂钩失败,错误代码1:

来自分类Dev

Windows 8.1 64位上的“ ionic build android”:错误:挂钩失败,错误代码为ENOENT

来自分类Dev

错误:“python setup.py egg_info”失败,错误代码为 1

来自分类Dev

试剂/启用失败,错误代码为3bc3,Windows Update失败,错误为800F0922

来自分类Dev

npm提取失败。错误代码504

来自分类Dev

缩放会议失败,错误代码1132

来自分类Dev

AudioFileWritePackets 失败(错误代码:1885563711 - 'kcp')

来自分类Dev

Python 3.5 setup.py egg_info失败,错误代码为1 [Linux]

来自分类Dev

virtualenvwrapper:命令“ python setup.py egg_info”失败,错误代码为1

来自分类Dev

节点子进程执行命令失败,错误代码为1

来自分类Dev

Notepad ++,NppExec,CreateProcess()失败,错误代码为2,Windows 8.1

来自分类Dev

命令python setup.py egg_info失败,错误代码为1

来自分类Dev

解码H264:VTDecompressionSessionCreate失败,错误代码为-12910(kVTVideoDecoderUnsupportedDataFormatErr)

来自分类Dev

COM注册失败,错误代码为0xC0000005

来自分类Dev

Android Google登录失败,错误代码为8(无消息)

来自分类Dev

通过AppEngine访问Books API失败,错误代码为400

来自分类Dev

ctypes调用GetProcAddress()失败,错误代码为127,但win32api.GetProcAddress成功

来自分类Dev

Virtualenv OSError-setuptools pip wheel失败,错误代码为1

来自分类Dev

python setup.py egg_info失败,错误代码为1

来自分类Dev

pip3 install pyautogui失败,错误代码为1 Mac OS

Related 相关文章

  1. 1

    SceneKit CFURLCreateDataAndPropertiesFromResource失败,错误代码为-11

  2. 2

    订单发送失败,错误代码为130

  3. 3

    PL / SQL失败,错误代码为ORA-01858

  4. 4

    读取pendrive时,CreateFile()失败,错误代码为32

  5. 5

    订单发送失败,错误代码为130

  6. 6

    gmail发送api流星失败,错误代码为400

  7. 7

    pip安装paramiko失败,错误代码为1

  8. 8

    AWS Glue:命令失败,错误代码为 1

  9. 9

    Android BLE 广告失败,错误代码为 1

  10. 10

    错误:挂钩失败,错误代码1:

  11. 11

    Windows 8.1 64位上的“ ionic build android”:错误:挂钩失败,错误代码为ENOENT

  12. 12

    错误:“python setup.py egg_info”失败,错误代码为 1

  13. 13

    试剂/启用失败,错误代码为3bc3,Windows Update失败,错误为800F0922

  14. 14

    npm提取失败。错误代码504

  15. 15

    缩放会议失败,错误代码1132

  16. 16

    AudioFileWritePackets 失败(错误代码:1885563711 - 'kcp')

  17. 17

    Python 3.5 setup.py egg_info失败,错误代码为1 [Linux]

  18. 18

    virtualenvwrapper:命令“ python setup.py egg_info”失败,错误代码为1

  19. 19

    节点子进程执行命令失败,错误代码为1

  20. 20

    Notepad ++,NppExec,CreateProcess()失败,错误代码为2,Windows 8.1

  21. 21

    命令python setup.py egg_info失败,错误代码为1

  22. 22

    解码H264:VTDecompressionSessionCreate失败,错误代码为-12910(kVTVideoDecoderUnsupportedDataFormatErr)

  23. 23

    COM注册失败,错误代码为0xC0000005

  24. 24

    Android Google登录失败,错误代码为8(无消息)

  25. 25

    通过AppEngine访问Books API失败,错误代码为400

  26. 26

    ctypes调用GetProcAddress()失败,错误代码为127,但win32api.GetProcAddress成功

  27. 27

    Virtualenv OSError-setuptools pip wheel失败,错误代码为1

  28. 28

    python setup.py egg_info失败,错误代码为1

  29. 29

    pip3 install pyautogui失败,错误代码为1 Mac OS

热门标签

归档