Windows allows users to manually generate a kernel/complete memory dump by using the keyboard. Here is the KB article on how to do it.
The following illustrates one case where a complete memory dump is used to solve a user-mode crash.
Several users have reported that FTP/SSH service crashes during machine shutdown. Except the "Runtime Error!" message box, there is no other trace for the crash. I duplicated the crash on one of Win2003 server boxes. However, I could not attach a debugger to the crashed service to generate the process dump during machine shutdown. Then I decided to manually generate a complete memory dump when "Runtime Error!" message box pops up and hoped the dump might contain some useful information regarding to the crash.
The dump was generated by using the keyboard when FTP service crashed during machine shutdown.
0: kd> !process 0 0
**** NT ACTIVE PROCESS DUMP ****
...
PROCESS 89eee6f8 SessionId: 0 Cid: 079c Peb: 7ffdd000 ParentCid: 01bc
DirBase: 7f404380 ObjectTable: e2d03410 HandleCount: 129.
Image: intfysvc.exe
PROCESS 899f2bc8 SessionId: 0 Cid: 07f0 Peb: 7ffd8000 ParentCid: 01bc
DirBase: 7f4043a0 ObjectTable: e2cee100 HandleCount: 267.
Image: SSHServer.exe
PROCESS 8948fa08 SessionId: 0 Cid: 0a04 Peb: 7ffde000 ParentCid: 01bc
DirBase: 7f404520 ObjectTable: e2d831e0 HandleCount: 275.
Image: iftpsvc.exe
...
After locating the FTP service, I set it as the current process context. One of its threads looks suspicious.
0: kd> .process /r /p 8948fa08
Implicit process is now 8948fa08
Loading User Symbols
................................................................
0: kd> !process 8948fa08
PROCESS 8948fa08 SessionId: 0 Cid: 0a04 Peb: 7ffde000 ParentCid: 01bc
DirBase: 7f404520 ObjectTable: e2d831e0 HandleCount: 275.
Image: iftpsvc.exe
VadRoot 8998ed30 Vads 233 Clone 0 Private 1698. Modified 42013. Locked 0.
DeviceMap e10018f0
Token e267fbf0
ElapsedTime 00:01:03.281
UserTime 00:00:00.546
KernelTime 00:00:00.281
QuotaPoolUsage[PagedPool] 154668
QuotaPoolUsage[NonPagedPool] 12236
Working Set Sizes (now,min,max) (5277, 50, 345) (21108KB, 200KB, 1380KB)
PeakWorkingSetSize 5298
VirtualSize 138 Mb
PeakVirtualSize 139 Mb
PageFaultCount 51692
MemoryPriority BACKGROUND
BasePriority 8
CommitCharge 4946
....
THREAD 89e3d418 Cid 0a04.0ae8 Teb: 7ffad000 Win32Thread: e26a6508 WAIT: (Unknown) UserMode Alertable
8948fcb0 NotificationEvent
898f1b88 SynchronizationEvent
89e3d490 NotificationTimer
Not impersonating
DeviceMap e10018f0
Owning Process 8948fa08 Image: iftpsvc.exe
Attached Process N/A Image: N/A
Wait Start TickCount 7198 Ticks: 20 (0:00:00:00.312)
Context Switch Count 24 LargeStack
UserTime 00:00:00.000
KernelTime 00:00:00.000
Win32 Start Address MSVCR80!_endthreadex (0x781329e1)
Start Address KERNEL32!BaseThreadStartThunk (0x77e617ec)
Stack Init b8fdf000 Current b8fde900 Base b8fdf000 Limit b8fdb000 Call 0
Priority 10 BasePriority 8 PriorityDecrement 0
ChildEBP RetAddr
b8fde918 80833485 nt!KiSwapContext+0x26 (FPO: [Uses EBP] [0,0,4])
b8fde944 808294b9 nt!KiSwapThread+0x2e5 (FPO: [0,7,0])
b8fde978 80938f68 nt!KeWaitForMultipleObjects+0x3d7 (FPO: [8,8,4])
b8fdebf4 809390ca nt!ObpWaitForMultipleObjects+0x202 (FPO: [SEH])
b8fded48 808897bc nt!NtWaitForMultipleObjects+0xc8 (FPO: [SEH])
b8fded48 7c8285ec nt!KiFastCallEntry+0xfc (FPO: [0,0] TrapFrame @ b8fded64)
045b9f6c 7c827cfb ntdll!KiFastSystemCallRet (FPO: [0,0,0])
045b9f70 77e6202c ntdll!NtWaitForMultipleObjects+0xc (FPO: [5,0,0])
045ba018 7739bbd1 KERNEL32!WaitForMultipleObjectsEx+0x11a (FPO: [SEH])
045ba074 776c1ffa USER32!RealMsgWaitForMultipleObjectsEx+0x141 (FPO: [5,13,0])
045ba09c 776e2eff ole32!CCliModalLoop::BlockFn+0x7d (FPO: [3,0,4])
045ba10c 79f752f0 ole32!CoWaitForMultipleHandles+0xc9 (FPO: [5,20,4])
045ba12c 79f75232 mscorwks!NT5WaitRoutine+0x51 (FPO: [5,1,0])
045ba198 79f7519a mscorwks!MsgWaitHelper+0xa5 (FPO: [SEH])
045ba1b8 79ed9808 mscorwks!Thread::DoAppropriateAptStateWait+0x28 (FPO: [5,0,4])
045ba23c 79ed96c4 mscorwks!Thread::DoAppropriateWaitWorker+0x13c (FPO: [5,22,4])
045ba28c 79ed9a62 mscorwks!Thread::DoAppropriateWait+0x40 (FPO: [SEH])
045ba2e8 79e78944 mscorwks!CLREvent::WaitEx+0xf7 (FPO: [3,11,4])
045ba2fc 79f7515d mscorwks!CLREvent::Wait+0x17 (FPO: [3,0,0])
045ba37c 79f750b9 mscorwks!CorExitProcess+0x30f (FPO: [0,21,4])
045ba380 79f7509d mscorwks!WaitForEndOfShutdown+0x5 (FPO: [0,0,0])
045ba3ac 79f7478c mscorwks!EEShutDown+0xae (FPO: [1,5,4])
045ba448 79004fab mscorwks!DisableRuntime+0xeb (FPO: [0,0,0])
045ba458 7c348cfa mscoree!CorExitProcess+0x46 (FPO: [1,1,0])
045ba460 7c3476c8 MSVCR71!__crtExitProcess+0x25 (FPO: [1,0,0]) (CONV: cdecl) [f:\vs70builds\3052\vc\crtbld\crt\src\crt0dat.c @ 463]
045ba490 7c348d22 MSVCR71!doexit+0xab (FPO: [Non-Fpo]) (CONV: cdecl) [f:\vs70builds\3052\vc\crtbld\crt\src\crt0dat.c @ 414]
045ba4a0 7c34d2b1 MSVCR71!_exit+0xd (FPO: [1,0,0]) (CONV: cdecl) [f:\vs70builds\3052\vc\crtbld\crt\src\crt0dat.c @ 311]
045ba4e8 7c34cf8a MSVCR71!raise+0xae (FPO: [Non-Fpo]) (CONV: cdecl) [f:\vs70builds\3052\vc\crtbld\crt\src\winsig.c @ 508]
045ba524 77e761b7 MSVCR71!abort+0xe (FPO: [0,0,0]) (CONV: cdecl) [f:\vs70builds\3052\vc\crtbld\crt\src\abort.c @ 48]
045ba77c 77e792a3 KERNEL32!UnhandledExceptionFilter+0x12a (FPO: [SEH])
045ba784 77e61ac1 KERNEL32!BaseThreadStart+0x4a (FPO: [SEH])
045ba7ac 7c828752 KERNEL32!_except_handler3+0x61 (FPO: [Uses EBP] [3,0,7])
045ba7d0 7c828723 ntdll!ExecuteHandler2+0x26
045ba878 7c82863c ntdll!ExecuteHandler+0x24
045bab58 77e4bee7 ntdll!RtlRaiseException+0x3d
045babb8 78158e89 KERNEL32!RaiseException+0x53 (FPO: [4,20,4])
045babf0 03403222 MSVCR80!_CxxThrowException+0x46 (FPO: [2,8,0])
045bac0c 03402f9d ftpsrvdata_pg!_com_raise_error+0x32 (FPO: [2,4,0]) (CONV: stdcall) [f:\sp\vctools\compiler\cxxfe\sl\vccom\comraise.cpp @ 18]
045bac18 033f87b5 ftpsrvdata_pg!_com_issue_error+0xd (FPO: [1,0,0]) (CONV: stdcall) [f:\sp\vctools\compiler\cxxfe\sl\vccom\comsupp.cpp @ 40]
045bcc58 033f9812 ftpsrvdata_pg!PrintProviderError+0x35 (FPO: [1,2058,0]) (CONV: cdecl) [d:\fts\ftpsrvdata_pg\src\idbcommand.cpp @ 860]
...
Then I switched to the register context of the suspicious thread.
0: kd> .thread /r /p 89e3d418
Implicit thread is now 89e3d418
Implicit process is now 8948fa08
Loading User Symbols
................................................................
0: kd> !thread 89e3d418
THREAD 89e3d418 Cid 0a04.0ae8 Teb: 7ffad000 Win32Thread: e26a6508 WAIT: (Unknown) UserMode Alertable
8948fcb0 NotificationEvent
898f1b88 SynchronizationEvent
89e3d490 NotificationTimer
Not impersonating
DeviceMap e10018f0
Owning Process 8948fa08 Image: iftpsvc.exe
Attached Process N/A Image: N/A
Wait Start TickCount 7198 Ticks: 20 (0:00:00:00.312)
Context Switch Count 24 LargeStack
UserTime 00:00:00.000
KernelTime 00:00:00.000
Win32 Start Address MSVCR80!_endthreadex (0x781329e1)
Start Address KERNEL32!BaseThreadStartThunk (0x77e617ec)
Stack Init b8fdf000 Current b8fde900 Base b8fdf000 Limit b8fdb000 Call 0
Priority 10 BasePriority 8 PriorityDecrement 0
ChildEBP RetAddr Args to Child
b8fde918 80833485 89e3d418 f77275c8 00000001 nt!KiSwapContext+0x26 (FPO: [Uses EBP] [0,0,4])
b8fde944 808294b9 89e3d418 00000002 00000000 nt!KiSwapThread+0x2e5 (FPO: [0,7,0])
b8fde978 80938f68 00000002 b8fdeaac 00000001 nt!KeWaitForMultipleObjects+0x3d7 (FPO: [8,8,4])
b8fdebf4 809390ca 00000002 b8fdec1c 00000001 nt!ObpWaitForMultipleObjects+0x202 (FPO: [SEH])
b8fded48 808897bc 00000002 045b9fbc 00000001 nt!NtWaitForMultipleObjects+0xc8 (FPO: [SEH])
b8fded48 7c8285ec 00000002 045b9fbc 00000001 nt!KiFastCallEntry+0xfc (FPO: [0,0] TrapFrame @ b8fded64)
045b9f6c 7c827cfb 77e6202c 00000002 045b9fbc ntdll!KiFastSystemCallRet (FPO: [0,0,0])
045b9f70 77e6202c 00000002 045b9fbc 00000001 ntdll!NtWaitForMultipleObjects+0xc (FPO: [5,0,0])
045ba018 7739bbd1 00000002 045ba040 00000000 KERNEL32!WaitForMultipleObjectsEx+0x11a (FPO: [SEH])
045ba074 776c1ffa 00000001 001514f8 00013880 USER32!RealMsgWaitForMultipleObjectsEx+0x141 (FPO: [5,13,0])
045ba09c 776e2eff 001514f8 00013880 045ba0c4 ole32!CCliModalLoop::BlockFn+0x7d (FPO: [3,0,4])
045ba10c 79f752f0 00000002 00013880 00000001 ole32!CoWaitForMultipleHandles+0xc9 (FPO: [5,20,4])
045ba12c 79f75232 00000000 00013880 00000001 mscorwks!NT5WaitRoutine+0x51 (FPO: [5,1,0])
045ba198 79f7519a 00000001 001514f8 00000000 mscorwks!MsgWaitHelper+0xa5 (FPO: [SEH])
045ba1b8 79ed9808 00000001 001514f8 00000000 mscorwks!Thread::DoAppropriateAptStateWait+0x28 (FPO: [5,0,4])
045ba23c 79ed96c4 00000001 001514f8 00000000 mscorwks!Thread::DoAppropriateWaitWorker+0x13c (FPO: [5,22,4])
045ba28c 79ed9a62 00000001 001514f8 00000000 mscorwks!Thread::DoAppropriateWait+0x40 (FPO: [SEH])
045ba2e8 79e78944 00013880 00000001 00000000 mscorwks!CLREvent::WaitEx+0xf7 (FPO: [3,11,4])
045ba2fc 79f7515d 00013880 00000001 00000000 mscorwks!CLREvent::Wait+0x17 (FPO: [3,0,0])
045ba37c 79f750b9 79f7509d 1e232538 00000000 mscorwks!CorExitProcess+0x30f (FPO: [0,21,4])
045ba380 79f7509d 1e232538 00000000 00000000 mscorwks!WaitForEndOfShutdown+0x5 (FPO: [0,0,0])
045ba3ac 79f7478c 00000e10 045ba3f0 79f7394a mscorwks!EEShutDown+0xae (FPO: [1,5,4])
045ba448 79004fab 00000003 79e70000 045ba490 mscorwks!DisableRuntime+0xeb (FPO: [0,0,0])
045ba458 7c348cfa 00000003 7c3476c9 00000003 mscoree!CorExitProcess+0x46 (FPO: [1,1,0])
045ba460 7c3476c8 00000003 00000000 7c391300 MSVCR71!__crtExitProcess+0x25 (FPO: [1,0,0]) (CONV: cdecl) [f:\vs70builds\3052\vc\crtbld\crt\src\crt0dat.c @ 463]
045ba490 7c348d22 00000003 00000001 00000000 MSVCR71!doexit+0xab (FPO: [Non-Fpo]) (CONV: cdecl) [f:\vs70builds\3052\vc\crtbld\crt\src\crt0dat.c @ 414]
045ba4a0 7c34d2b1 00000003 00000000 045ba7a4 MSVCR71!_exit+0xd (FPO: [1,0,0]) (CONV: cdecl) [f:\vs70builds\3052\vc\crtbld\crt\src\crt0dat.c @ 311]
045ba4e8 7c34cf8a 00000016 0000000a 00000000 MSVCR71!raise+0xae (FPO: [Non-Fpo]) (CONV: cdecl) [f:\vs70builds\3052\vc\crtbld\crt\src\winsig.c @ 508]
045ba524 77e761b7 045ba7a4 00000000 00000000 MSVCR71!abort+0xe (FPO: [0,0,0]) (CONV: cdecl) [f:\vs70builds\3052\vc\crtbld\crt\src\abort.c @ 48]
045ba77c 77e792a3 045ba7a4 77e61ac1 045ba7ac KERNEL32!UnhandledExceptionFilter+0x12a (FPO: [SEH])
045ba784 77e61ac1 045ba7ac 00000000 045ba7ac KERNEL32!BaseThreadStart+0x4a (FPO: [SEH])
045ba7ac 7c828752 045bab68 045bffdc 045ba888 KERNEL32!_except_handler3+0x61 (FPO: [Uses EBP] [3,0,7])
045ba7d0 7c828723 045bab68 045bffdc 045ba888 ntdll!ExecuteHandler2+0x26
045ba878 7c82863c 045b0000 045ba888 00010007 ntdll!ExecuteHandler+0x24
045bab58 77e4bee7 045bab68 00000000 e06d7363 ntdll!RtlRaiseException+0x3d
045babb8 78158e89 e06d7363 00000001 00000003 KERNEL32!RaiseException+0x53 (FPO: [4,20,4])
045babf0 03403222 045bac00 03440a54 0342dc6c MSVCR80!_CxxThrowException+0x46 (FPO: [2,8,0])
045bac0c 03402f9d 80004003 00000000 033f87b5 ftpsrvdata_pg!_com_raise_error+0x32 (FPO: [2,4,0]) (CONV: stdcall) [f:\sp\vctools\compiler\cxxfe\sl\vccom\comraise.cpp @ 18]
045bac18 033f87b5 80004003 045bf9b0 045bd1cc ftpsrvdata_pg!_com_issue_error+0xd (FPO: [1,0,0]) (CONV: stdcall) [f:\sp\vctools\compiler\cxxfe\sl\vccom\comsupp.cpp @ 40]
045bcc58 033f9812 00000000 78158ed7 045bf9b0 ftpsrvdata_pg!PrintProviderError+0x35 (FPO: [1,2058,0]) (CONV: cdecl) [d:\fts\ftpsrvdata_pg\src\idbcommand.cpp @ 860]
It seems that the thread had thrown an unhandled exception, which caused the service to crash.
Since KERNEL32!UnhandledExceptionFilter is on the stack, I could dereference its first parameter to retrieve the exception record and context record and thereby find the exception stack. Here is the KB article on how to do it.
0: kd> dd 045ba7a4 l2
045ba7a4 045bab68 045ba888
0: kd> .cxr 045ba888
eax=045bab68 ebx=033f97fe ecx=00000000 edx=045bac00 esi=045babf0 edi=00000000
eip=77e4bee7 esp=045bab64 ebp=045babb8 iopl=0 nv up ei pl nz na pe nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000206
KERNEL32!RaiseException+0x53:
001b:77e4bee7 5e pop esi
0: kd> kb
*** Stack trace for last set context - .thread/.cxr resets it
ChildEBP RetAddr Args to Child
045babb8 78158e89 e06d7363 00000001 00000003 KERNEL32!RaiseException+0x53
045babf0 03403222 045bac00 03440a54 0342dc6c MSVCR80!_CxxThrowException+0x46
045bac0c 03402f9d 80004003 00000000 033f87b5 ftpsrvdata_pg!_com_raise_error+0x32 [f:\sp\vctools\compiler\cxxfe\sl\vccom\comraise.cpp @ 18]
045bac18 033f87b5 80004003 045bf9b0 045bd1cc ftpsrvdata_pg!_com_issue_error+0xd [f:\sp\vctools\compiler\cxxfe\sl\vccom\comsupp.cpp @ 40]
045bcc58 033f9812 00000000 78158ed7 045bf9b0 ftpsrvdata_pg!PrintProviderError+0x35 [d:\fts\ftpsrvdata_pg\src\idbcommand.cpp @ 860]
045bf9bc 033dbf4a 045bf9f0 045bcc60 71f5cadb ftpsrvdata_pg!IDBCommand::ExecuteResults+0x2a2 [d:\fts\ftpsrvdata_pg\src\idbcommand.cpp @ 610]
045bfe08 00d66a6a 00000001 045bfe74 00000015 ftpsrvdata_pg!IFTPSystemStats_Impl::UpdateSystemStats+0xaa [d:\fts\ftpsrvdata_pg\src\ftpsystemstats_impl.cpp @ 288]
045bff78 781329bb 006ab558 1e2328f2 00000000 FTPParsers!SessionManagerThreadProc+0x19a [d:\fts\ftpparsers\ftpstats.cpp @ 413]
045bffb0 78132a47 00000000 77e64829 03266678 MSVCR80!_endthreadex+0x3b
045bffb8 77e64829 03266678 00000000 00000000 MSVCR80!_endthreadex+0xc7
045bffec 00000000 781329e1 03266678 00000000 KERNEL32!BaseThreadStart+0x34
ftpsrvdata_pg!PrintProviderError has the following signature,
void PrintProviderError(ADODB::_ConnectionPtr pConnection).
ftpsrvdata_pg!_com_raise_error has the following signature,
void __stdcall _com_raise_error(HRESULT hr, IErrorInfo* perrinfo = 0).
When I ran !error 80004003 (the first parameter of _com_raise_error), it returned "Invalid Pointer" error message. The only parameter of ftpsrvdata_pg!PrintProviderError is NULL, it seems that the crash was due to the NULL pointer. Since there is the line number for the source code, it would be pretty straightforward to verify the result -- the code does not check the NULL pointer.
