본문 바로가기

프로그래밍/디버깅

Image File Execution options

출처: byung.egloos.com/3572751


Debugging은 분석도 중요하지만, Crash Dump를 수집하거나 적절한 시점에 Debugger를 attach 하는 것도 중요합니다. 특히 이미 실행중인 Process에 WinDBG 를 attach 하거나 cdb.exe(w/ ADPLUS.vbs) 를 통해 Memory Dump를 수집하는 방법은 널리 사용되는 방법입니다만 Program이 Start 시에 Crash 를 발생하고 Terminated 되는 경우도 Debugging을 해야 할 때가 있습니다. 이 경우에는 Image File Execution options을 이용하면 유용합니다. 설정은 아래와 같이 합니다. 

 1. Regedit.exe 를 Open 합니다. 
 2. 다음의 Registry Key로 위치 합니다. 
     [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\]
 3. Subkey 로 Debugging 하고자 하는 Program의 이름을 추가합니다. (ex. MyApp.exe)
 4. 해당 subkey에 "Debugger" 라는 String(REG_SZ) 를 추가합니다. 그리고, Debugger의 Full path를 추가합니다. 
     "Debugger" = "c:\debuggers\windbg.exe"
 5. Regedit.exe 를 Close 합니다.

그러면, MyApp.exe가 실행될 때 windbg.exe 가 MyApp.exe에 attach 되어 실행됩니다.  

참조: Debugging a Windows NT Service
        Specifying the Debugger for Unhandled User Mode Exceptions