Why does MSVC 2010 32bit project link to 64bit kernel32.dll?

前端 未结 3 787
慢半拍i
慢半拍i 2021-01-17 17:57

I have a Win32 (32bit) DLL project which builds and links without error. The DLL fails to load into a 32bit process. Using DependencyWalker, I see that the DLL is 32bit but

相关标签:
3条回答
  • 2021-01-17 18:05

    Dependency Walker isn't using the same search path as the OS. It has its own search paths to try and find DLLs. You can view this by going to "Options -> Configure Module Search Order..."

    Unfortunantly its search paths don't include "C:\Windows\SysWow64" (the location of the 32 bit version for Kernel32.dll)

    This is why Dependency Walker incorrectly thinks your application is mixing x64 DLLs with your x86 application.

    If you fix up the search order to include SysWow64 and remove all references to the System32 directory. This error should go away.

    A better way to check which the output window of Visual Studio debugger or WinDbg when your application is run. It will list out the DLL's full path as they're loaded.

    0 讨论(0)
  • 2021-01-17 18:14

    Check out the dependency website FAQ. http://www.dependencywalker.com/faq.html

    Q.Will Dependency Walker work with 64-bit modules?
    

    you need use the x86 version for the 32bit modules, x64 for the 64bit modules. It means you need have 2 copy in the 64bit OS and use them accordingly.

    you can use the windows registry to create the context menu in order to save your trouble like this.

    Windows Registry Editor Version 5.00
    
    [HKEY_CLASSES_ROOT\dllfile\shell]
    
    [HKEY_CLASSES_ROOT\dllfile\shell\View Dependencies]
    
    [HKEY_CLASSES_ROOT\dllfile\shell\View Dependencies\command]
    @="\\\\psf\\Public\\Library\\DEPE~K17\\depends.exe /dde"
    
    [HKEY_CLASSES_ROOT\dllfile\shell\View Dependencies\ddeexec]
    @="[open(\"%1\")]"
    
    [HKEY_CLASSES_ROOT\dllfile\shell\View Dependencies(32bit)]
    
    [HKEY_CLASSES_ROOT\dllfile\shell\View Dependencies(32bit)\command]
    @="\\\\psf\\Public\\Library\\DEPE~K17\\x86\\depends.exe /dde"
    
    [HKEY_CLASSES_ROOT\dllfile\shell\View Dependencies(32bit)\ddeexec]
    @="[open(\"%1\")]"
    
    [HKEY_CLASSES_ROOT\exefile\shell]
    
    [HKEY_CLASSES_ROOT\exefile\shell\View Dependencies]
    
    [HKEY_CLASSES_ROOT\exefile\shell\View Dependencies\command]
    @="\\\\psf\\Public\\Library\\DEPE~K17\\depends.exe /dde"
    
    [HKEY_CLASSES_ROOT\exefile\shell\View Dependencies\ddeexec]
    @="[open(\"%1\")]"
    
    [HKEY_CLASSES_ROOT\exefile\shell\View Dependencies(32bit)]
    
    [HKEY_CLASSES_ROOT\exefile\shell\View Dependencies(32bit)\command]
    @="\\\\psf\\Public\\Library\\DEPE~K17\\x86\\depends.exe /dde"
    
    [HKEY_CLASSES_ROOT\exefile\shell\View Dependencies(32bit)\ddeexec]
    @="[open(\"%1\")]"
    
    0 讨论(0)
  • 2021-01-17 18:15

    Short Answer: Use Dependency Walker for x86 for x86 stuff.

    Long Answer: Initially I used Dependency Walker for x64 on the MS Windows 7 OS and ran into the hurdles you did. I then followed MerickOWA's advice about changing the search paths (thanks MerickOWA). Though I still had a handful of dependencies causing "Error: Modules with different CPU types were found".

    Instead of figuring out how to configure Dependency Walker to search for the x86 DLLs in bizarre looking paths like "c:\windows\winsxs\amd64_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.7601.17514_none_2b24536c71ed437a\GDIPLUS.DLL" correctly, I used the Dependency Walker for x86. Worked like a charm for me!

    0 讨论(0)
提交回复
热议问题