windbg - The call to LoadLibrary(...\sos.dll) failed, Win32 error 0n193
다음의 글에 따라,
windbg의 mscordacwks DLL 로드 문제 - 세 번째 이야기
; https://www.sysnet.pe.kr/2/0/11231
sos.dll을 로드하려는데 다음과 같은 식으로 오류가 발생합니다.
0:000> .load f:\ts\sos.dll
The call to LoadLibrary(f:\ts\sos.dll) failed, Win32 error 0n193
"%1 is not a valid Win32 application."
Please check your debugger configuration and/or network access.
0:000> .cordll -lp f:\ts
CLRDLL: Consider using ".cordll -lp <path>" command to specify .NET runtime directory.
CLR DLL status: ERROR: Unable to load DLL f:\ts\mscordaccore_AMD64_AMD64_4.6.27414.05.dll, Win32 error 0n87
0:000> .cordll -lp f:\ts
CLRDLL: Consider using ".cordll -lp <path>" command to specify .NET runtime directory.
CLR DLL status: ERROR: Unable to load DLL f:\ts\mscordaccore_AMD64_AMD64_4.6.27414.05.dll, Win32 error 0n193
Error Lookup 도구로 보면 각각의 오류 코드는 이렇습니다.
193 == "%1 is not a valid Win32 application."
87 == "The parameter is incorrect."
경험 있으신 분들은 척 보고 ^^ x86/x64 문제인 줄 아셨을 텐데요. 이를 확인하기 위해 dumpbin.exe를 사용할 수 있습니다.
C:\temp> where dumpbin
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.23.28105\bin\Hostx86\x86\dumpbin.exe
간단하게 다음과 같이 실행해 PE32로 나오면 x86 DLL이고,
F:\ts> dumpbin.exe "f:\ts\sos.dll" /HEADERS | findstr PE
Microsoft (R) COFF/PE Dumper Version 14.23.28106.4
PE signature found
10B magic # (PE32)
PE32+로 나오면 x64 DLL입니다.
F:\ts>dumpbin.exe "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.2.5\sos.dll" /HEADERS | findstr PE
Microsoft (R) COFF/PE Dumper Version 14.23.28106.4
PE signature found
20B magic # (PE32+)
또는, depends.exe로 열었을 때 DLL 이름만 나오면 32비트 DLL이고, DLL 이름 옆에 64가 세로로 쓰여 있으면 64비트 DLL입니다.
[x86 DLL인 경우]
[x64 DLL인 경우]
그러니까 이번 문제는 x64 프로세스의 메모리 덤프를 분석하기 위해 x86 sos.dll을 로드하려 했기 때문에 발생한 것이었습니다. (또는 그 반대의 경우에 발생할 수 있습니다.)
[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]