Microsoft MVP성태의 닷넷 이야기
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 

windbg - 64비트 운영체제에서 작업 관리자로 뜬 32비트 프로세스의 덤프를 sos로 디버깅하는 방법

예전 글에서,

windbg - SOS does not support the current target architecture.
; https://www.sysnet.pe.kr/2/0/11262

64비트 운영체제 환경에서 "작업 관리자(Task Manager)"를 이용해 32비트 프로세스의 덤프를 뜨는 경우, sos.dll 로딩이 안 된다는 설명을 했었습니다. 그러다, 최근에 쓴 글에서 "wow64exts.sw" 명령어를 실습하는 중에 문득 그것이 가능하지 않을까... 하는 생각이 들었는데요, 실제로 wow64exts.sw 명령어 후에는 해당 덤프에 대해 sos 확장이 잘 로드가 됩니다.

0:000> !wow64exts.sw
Switched to Guest (WoW) mode

0:000:x86> .loadby sos clr

0:000:x86> .chain
Extension DLL search Path:
    C:\Program Files...[생략]...\AppData\Local\Microsoft\WindowsApps
Extension DLL chain:
    C:\Windows\Microsoft.NET\Framework\v4.0.30319\sos.dll: image 4.8.9105.0, API 1.0.0, built Thu Sep 15 09:28:04 2022
        [path: C:\Windows\Microsoft.NET\Framework\v4.0.30319\sos.dll]
    ...[생략]...
    ntsdexts: image 10.0.22000.194, API 1.0.0, 
        [path: C:\Program Files (x86)\Windows Kits\10\Debuggers\x86\WINXP\ntsdexts.dll]

하지만, sos 명령어는 동작하지 않습니다.

0:000:x86> !clrstack
SOS does not support the current target architecture (8664).

0:000:x86> !name2ee
SOS does not support the current target architecture (8664).

그런데, 이런 간극을 메워주는 확장을 작성해 공개한 것이 있습니다. ^^

SOS does not support the current target architecture
; https://stackoverflow.com/questions/16422577/sos-does-not-support-the-current-target-architecture

poizan42/soswow64
; https://github.com/poizan42/soswow64

soswow64.zip
; https://github.com/poizan42/soswow64/releases/download/v1.0.4/soswow64.zip

그래서 이 확장을 추가로 로드하면,

0:000:x86> .load c:\temp\soswow64.dll
Successfully hooked IDebugControl::GetExecutingProcessorType.
Failed patching DbgEng!X86MachineInfo::ConvertCanonContextToTarget, stack related commands may not work correctly.

Windows 11의 제 환경에서는 "Failed ..." 오류가 발생하긴 하지만 그런대로 대부분의 명령어는 정상적으로 동작을 합니다.

0:000:x86> !clrstack
OS Thread Id: 0xea88 (0)
Child SP       IP Call Site
006fedec 0000002b [InlinedCallFrame: 006fedec] 
006fede8 71be7821 DomainNeutralILStubClass.IL_STUB_PInvoke(Microsoft.Win32.SafeHandles.SafeFileHandle, Byte*, Int32, Int32 ByRef, IntPtr)
006fedec 7231b19a [InlinedCallFrame: 006fedec] Microsoft.Win32.Win32Native.ReadFile(Microsoft.Win32.SafeHandles.SafeFileHandle, Byte*, Int32, Int32 ByRef, IntPtr)
006fee50 7231b19a System.IO.__ConsoleStream.ReadFileNative(Microsoft.Win32.SafeHandles.SafeFileHandle, Byte[], Int32, Int32, Boolean, Boolean, Int32 ByRef)
006fee80 7231b0a7 System.IO.__ConsoleStream.Read(Byte[], Int32, Int32)
006feea0 71b7a669 System.IO.StreamReader.ReadBuffer()
006feeb0 71b7aa52 System.IO.StreamReader.ReadLine()
006feecc 724502e6 System.IO.TextReader+SyncTextReader.ReadLine()
006feedc 722b5a85 System.Console.ReadLine()
006feee4 02660896 *** WARNING: Unable to verify checksum for ConsoleApp1.exe
Program.Main(System.String[]) [C:\temp\ConsoleApp1\ConsoleApp1\Program.cs @ 9]
006ff09c 735b2526 [GCFrame: 006ff09c] 

0:000:x86> !name2ee ConsoleApp1!Program.Main
Module:      00d24044
Assembly:    ConsoleApp1.exe
Token:       06000001
MethodDesc:  00d24d54
Name:        Program.Main(System.String[])
JITTED Code Address: 02660848

0:000:x86> !savemodule 0x00d24044 c:\temp\test.dll 
3 sections in file
section 0 - VA=2000, VASize=7bc, FileAddr=200, FileSize=800
section 1 - VA=4000, VASize=5bc, FileAddr=a00, FileSize=600
section 2 - VA=6000, VASize=c, FileAddr=1000, FileSize=200

위의 실습은, x86 버전의 windbg로 해야 하고, 만약 Preview AppStore 버전을 사용한다면 덤프 파일 로딩 시 "Target architecture"를 "Autodetect"가 아닌 명시적으로 "X86"을 지정해야 합니다.




참고로 이전 글(https://www.sysnet.pe.kr/2/0/11262)에서 작업 관리자 대신 Process Explorer를 사용하라고 했는데요, "SOS does not support the current target architecture" Q&A에 더 나은 방법을 제시하는 덧글이 있습니다.

바로, ^^ 32비트 Task Manager를 띄워서 덤프를 뜨면 된다는 것입니다. 따라서, 다음의 경로에 있는 작업 관리자 모듈을,

C:\Windows\SysWOW64\taskmgr.exe 

직접 실행해 덤프를 떠도 됩니다. 이로써 고객사 덤프 뜰 때 Process Explorer를 다운로드해야 한다는 부탁을 할 필요가 없어진 것입니다. ^^ 그렇긴 한데, 이제는 x86 버전의 .NET Framework 응용 프로그램을 거의 볼 일이 없으니... 너무 늦게 알아버렸군요. ^^




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]







[최초 등록일: ]
[최종 수정일: 1/13/2023]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




1  2  3  4  5  6  7  8  9  10  11  12  [13]  14  15  ...
NoWriterDateCnt.TitleFile(s)
13296정성태3/25/20233692Windows: 234. IsDialogMessage와 협업하는 WM_GETDLGCODE Win32 메시지 [1]파일 다운로드1
13295정성태3/24/20233955Windows: 233. Win32 - modeless 대화창을 modal처럼 동작하게 만드는 방법파일 다운로드1
13294정성태3/22/20234125.NET Framework: 2105. LargeAddressAware 옵션이 적용된 닷넷 32비트 프로세스의 가용 메모리 - 두 번째
13293정성태3/22/20234192오류 유형: 853. dumpbin - warning LNK4048: Invalid format file; ignored
13292정성태3/21/20234313Windows: 232. C/C++ - 일반 창에도 사용 가능한 IsDialogMessage파일 다운로드1
13291정성태3/20/20234716.NET Framework: 2104. C# Windows Forms - WndProc 재정의와 IMessageFilter 사용 시의 차이점
13290정성태3/19/20234222.NET Framework: 2103. C# - 윈도우에서 기본 제공하는 FindText 대화창 사용법파일 다운로드1
13289정성태3/18/20233418Windows: 231. Win32 - 대화창 템플릿의 2진 리소스를 읽어들여 자식 윈도우를 생성하는 방법파일 다운로드1
13288정성태3/17/20233516Windows: 230. Win32 - 대화창의 DLU 단위를 pixel로 변경하는 방법파일 다운로드1
13287정성태3/16/20233686Windows: 229. Win32 - 대화창 템플릿의 2진 리소스를 읽어들여 윈도우를 직접 띄우는 방법파일 다운로드1
13286정성태3/15/20234147Windows: 228. Win32 - 리소스에 포함된 대화창 Template의 2진 코드 해석 방법
13285정성태3/14/20233738Windows: 227. Win32 C/C++ - Dialog Procedure를 재정의하는 방법파일 다운로드1
13284정성태3/13/20233939Windows: 226. Win32 C/C++ - Dialog에서 값을 반환하는 방법파일 다운로드1
13283정성태3/12/20233480오류 유형: 852. 파이썬 - TypeError: coercing to Unicode: need string or buffer, NoneType found
13282정성태3/12/20233818Linux: 58. WSL - nohup 옵션이 필요한 경우
13281정성태3/12/20233720Windows: 225. 윈도우 바탕화면의 아이콘들이 넓게 퍼지는 경우 [2]
13280정성태3/9/20234466개발 환경 구성: 670. WSL 2에서 호스팅 중인 TCP 서버를 외부에서 접근하는 방법
13279정성태3/9/20234011오류 유형: 851. 파이썬 ModuleNotFoundError: No module named '_cffi_backend'
13278정성태3/8/20233968개발 환경 구성: 669. WSL 2의 (init이 아닌) systemd 지원 [1]
13277정성태3/6/20234587개발 환경 구성: 668. 코드 사인용 인증서 신청 및 적용 방법(예: Digicert)
13276정성태3/5/20234313.NET Framework: 2102. C# 11 - ref struct/ref field를 위해 새롭게 도입된 scoped 예약어
13275정성태3/3/20234666.NET Framework: 2101. C# 11의 ref 필드 설명
13274정성태3/2/20234255.NET Framework: 2100. C# - ref 필드로 ref struct 타입을 허용하지 않는 이유
13273정성태2/28/20233955.NET Framework: 2099. C# - 관리 포인터로서의 ref 예약어 의미
13272정성태2/27/20234215오류 유형: 850. SSMS - mdf 파일을 Attach 시킬 때 Operating system error 5: "5(Access is denied.)" 에러
13271정성태2/25/20234148오류 유형: 849. Sql Server Configuration Manager가 시작 메뉴에 없는 경우
1  2  3  4  5  6  7  8  9  10  11  12  [13]  14  15  ...