1.使用!analyze -v分析出如下一条信息:
STACK_COMMAND: .cxr 02D3EF58 ; kb ; dds 2d3f23c ; kb
2.这个.cxr 02D3EF58 地址是如何得到的呢?
~*kbn 查看所有进程的调用栈情况发现如下信息:
# ChildEBP RetAddr Args to Child
0b 02d3ee50 77a071b9 fffffffe 02d3fd9c 02d3ef58 ntdll!_except_handler4+0x8e
0c 02d3ee74 77a0718b 02d3ef3c 02d3fd9c 02d3ef58 ntdll!ExecuteHandler2+0x26
0d 02d3ee98 779df96f 02d3ef3c 02d3fd9c 02d3ef58 ntdll!ExecuteHandler+0x24
0e 02d3ef24 77a07017 00d3ef3c 02d3ef58 02d3ef3c ntdll!RtlDispatchException+0x127
0f 02d3ef24 694ba6f0 00d3ef3c 02d3ef58 02d3ef3c ntdll!KiUserExceptionDispatcher+0xf
这个就是发生异常时寄存器上下文信息地址。
总结:
(1)KiUserExceptionDispatcher 函数的第二个参数就可以用来作.cxr指令的地址
0:000> .cxr 02d3ef58
eax=00000003 ebx=00000000 ecx=00000000 edx=02d3f304 esi=7ffda6cc edi=00000000
eip=694ba6f0 esp=02d3f23c ebp=02d3f254 iopl=0 nv up ei pl nz na pe nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00010206
XXX!DllCanUnloadNow+0x4110:
694ba6f0 0000 add byte ptr [eax],al ds:0023:00000003=??
(2)KiUserExceptionDispatcher 函数的第三个参数就可以用来作.exr指令的地址
0:000> .exr 02d3ef3c 分析异常类型
ExceptionAddress: 694ba6f0 (XXX!DllCanUnloadNow+0x00004110)
ExceptionCode: c0000005 (Access violation)
ExceptionFlags: 00000000
NumberParameters: 2
Parameter[0]: 00000001
Parameter[1]: 00000003
Attempt to write to address 00000003
(3)KiUserExceptionDispatcher( PEXCEPTION_RECORD pExcptRec, CONTEXT * pContext )函数
0:000> dt _EXCEPTION_RECORD
wbprotect!_EXCEPTION_RECORD
+0x000 ExceptionCode : Uint4B
+0x004 ExceptionFlags : Uint4B
+0x008 ExceptionRecord : Ptr32 _EXCEPTION_RECORD
+0x00c ExceptionAddress : Ptr32 Void
+0x010 NumberParameters : Uint4B
+0x014 ExceptionInformation : [15] Uint4B
0:000> dt _CONTEXT
wbprotect!_CONTEXT
+0x000 ContextFlags : Uint4B
+0x004 Dr0 : Uint4B
+0x008 Dr1 : Uint4B
+0x00c Dr2 : Uint4B
+0x010 Dr3 : Uint4B
+0x014 Dr6 : Uint4B
+0x018 Dr7 : Uint4B
+0x01c FloatSave : _FLOATING_SAVE_AREA
+0x08c SegGs : Uint4B
+0x090 SegFs : Uint4B
+0x094 SegEs : Uint4B
+0x098 SegDs : Uint4B
+0x09c Edi : Uint4B
+0x0a0 Esi : Uint4B
+0x0a4 Ebx : Uint4B
+0x0a8 Edx : Uint4B
+0x0ac Ecx : Uint4B
+0x0b0 Eax : Uint4B
+0x0b4 Ebp : Uint4B
+0x0b8 Eip : Uint4B
+0x0bc SegCs : Uint4B
+0x0c0 EFlags : Uint4B
+0x0c4 Esp : Uint4B
+0x0c8 SegSs : Uint4B
+0x0cc ExtendedRegisters : [512] UChar
(4) 使用结构查看一下
0:000> dt -r _EXCEPTION_RECORD 02d3ef3c
wbprotect!_EXCEPTION_RECORD
+0x000 ExceptionCode : 0xc0000005
+0x004 ExceptionFlags : 0
+0x008 ExceptionRecord : (null)
+0x00c ExceptionAddress : 0x694ba6f0 Void
+0x010 NumberParameters : 2
+0x014 ExceptionInformation : [15] 1
0:000> dt _CONTEXT 02d3ef58
wbprotect!_CONTEXT
+0x000 ContextFlags : 0x1003f
+0x004 Dr0 : 0
+0x008 Dr1 : 0
+0x00c Dr2 : 0
+0x010 Dr3 : 0
+0x014 Dr6 : 0
+0x018 Dr7 : 0
+0x01c FloatSave : _FLOATING_SAVE_AREA
+0x08c SegGs : 0
+0x090 SegFs : 0x3b
+0x094 SegEs : 0x23
+0x098 SegDs : 0x23
+0x09c Edi : 0
+0x0a0 Esi : 0x7ffda6cc
+0x0a4 Ebx : 0
+0x0a8 Edx : 0x2d3f304
+0x0ac Ecx : 0
+0x0b0 Eax : 3
+0x0b4 Ebp : 0x2d3f254
+0x0b8 Eip : 0x694ba6f0
+0x0bc SegCs : 0x1b
+0x0c0 EFlags : 0x10206
+0x0c4 Esp : 0x2d3f23c
+0x0c8 SegSs : 0x23
+0x0cc ExtendedRegisters : [512] "???"