Monthly Archive for 4월, 2008

[NT Inside Study] System CALL , MSR, SYSENTER

펜티엄 2 이상 부터의 IA-32  Instruction을 보면 Sysenter와 Sysexit라는 녀석이 추가 되어 있습니다.  바로 기존의 Trap Handler를 통한 System Call을 대체하기 위한 Instruction이지요. 많은 책들이 이부분에 대해서 설명을 하고는 있지만 사실 자세히 설명하고 있지는 않습니다. Intel Manual 을 뒤져 보기 전에는 이해가 힘든 부분이 있지요.  우리가 Windows API를 호출하면 System Stub이 호출되어 Kernel로 넘어 가는건 누구나 알고 있는 사실입니다. 바로 System Stub에 해당하는 녀석이 sysenter Instruction 입니다.

uf ntdll!NtCreateFile
ntdll!NtCreateFile:
7c93d682 b825000000 mov eax,25h
7c93d687 ba0003fe7f mov edx,offset SharedUserData!SystemCallStub (7ffe0300)
7c93d68c ff12 call dword ptr [edx]

7c93d68e c22c00 ret 2Ch
lkd> dd 7ffe0300 L4
7ffe0300 7c93eb8b 7c93eb94 00000000 00000000

lkd> uf 7c93eb8b
ntdll!KiFastSystemCall:
7c93eb8b 8bd4 mov edx,esp
7c93eb8d 0f34 sysenter
7c93eb8f 90 nop
7c93eb90 90 nop
7c93eb91 90 nop
7c93eb92 90 nop
7c93eb93 90 nop
7c93eb94 c3 ret

NtCreateFile의 경우 결과적보면 eax에 ServiceTable의 Index를 넣고 현재 스택을 edx에 넣고 sysenter를 호출하는 군요. 그럼 sysenter가 호출되는 시점에는 어떤 동작을 하게 될까요 ??  sysenter를 호출하게 되면 CPU는 MSR을 참고하여 커널 모드로 넘어가기 위한 동작을 합니다.

  1. Kernel Mode에서 동작하기 위한 CS 와 EIP를 설정
  2. Kernel Mode에서 동작하기 위한 SS 와 ESP를 설정
  3. Switches to Privilege Level 0
  4. Clear VM Flag
  5. System Procedure 실행

SS 를 설정할 때는 MSR[ IA32_SYSENTER_CS] + 8 의 값을 설정해 줍니다. 일종에 규약입니다.  그러한 이유에서 GDT를 구성할 때  SS의 위치를 CS 다음에 설정해 줘야합니다. 

IA32_SYSENTER_CS ==> 174H
IA32_SYSENTER_ESP ==> 175H
IA32_SYSENTER_EIP ==> 176H
CS <- MSR[ IA32_SYSENTER_CS ]
SS <- MSR[ IA32_SYSENTER_CS ] +8
EIP <- MSR[IA32_SYSENTER_EIP ]
ESP <- MSR[IA32_SYSENTER_ESP ]

결과적으로 위와 같은 형태가 되겠죠 .   이러한 과정을 모두 마치게 되면 EIP에 설정된 Instruction을 실행하게 됩니다.

lkd> rdmsr 0x176
msr[176] = 00000000`804df89f
lkd> u 00000000`804df89f
nt!KiFastCallEntry:
804df89f b923000000 mov ecx,23h
804df8a4 6a30 push 30h
804df8a6 0fa1 pop fs
804df8a8 8ed9 mov ds,cx
804df8aa 8ec1 mov es,cx
804df8ac 648b0d40000000 mov ecx,dword ptr fs:[40h]
804df8b3 8b6104 mov esp,dword ptr [ecx+4]
804df8b6 6a23 push 23h

결과적으로 nt!KiFastCallEntry 를 호출하는 것을 알수 있습니다. 그럼 KiSystemService 는 어떨까 ?? KiSystemService 역시 결과 적으로 KiFastCallEntry의 Instruction 영역으로 jump 하는 것을 알 수 있습니다.

nt!KiSystemService:
804df7d1 6a00 push 0
804df7d3 55 push ebp
804df7d4 53 push ebx
804df7d5 56 push esi
804df7d6 57 push edi
804df7d7 0fa0 push fs
804df7d9 bb30000000 mov ebx,30h
804df7de 8ee3 mov fs,bx
804df7e0 64ff3500000000 push dword ptr fs:[0]
804df7e7 64c70500000000ffffffff mov dword ptr fs:[0],0FFFFFFFFh
804df7f2 648b3524010000 mov esi,dword ptr fs:[124h]
804df7f9 ffb640010000 push dword ptr [esi+140h]
804df7ff 83ec48 sub esp,48h
804df802 8b5c246c mov ebx,dword ptr [esp+6Ch]
804df806 83e301 and ebx,1
804df809 889e40010000 mov byte ptr [esi+140h],bl
804df80f 8bec mov ebp,esp
804df811 8b9e34010000 mov ebx,dword ptr [esi+134h]
804df817 895d3c mov dword ptr [ebp+3Ch],ebx
804df81a 89ae34010000 mov dword ptr [esi+134h],ebp
804df820 fc cld
804df821 8b5d60 mov ebx,dword ptr [ebp+60h]
804df824 8b7d68 mov edi,dword ptr [ebp+68h]
804df827 89550c mov dword ptr [ebp+0Ch],edx
804df82a c74508000ddbba mov dword ptr [ebp+8],0BADB0D00h
804df831 895d00 mov dword ptr [ebp],ebx
804df834 897d04 mov dword ptr [ebp+4],edi
804df837 f6462cff test byte ptr [esi+2Ch],0FFh
804df83b 0f858bfeffff jne nt!Dr_kss_a (804df6cc)
nt!KiSystemService+0x71:
804df841 fb sti
804df842 e9eb000000 jmp nt!KiFastCallEntry+0×8f (804df932)

좀더 자세한 내용은 Intel Software Developer’s Manual을 참고 하시기 바랍니다.

[windbg] Raw Stack Trace - dds , ebp

많은 분들이 Raw Stack Trace에 대해서 궁금해 하시더군요. Stack 만 보고 어찌 Trace를 하냐고 .. Stack이 깨지 않는 이상 Raw Stack Trace를 하는 경우는 거의 없습니다. 물론 간혹 중간 중간의 Data가 깨져서 안보일 경우는 Raw Stack Trace를 해줘야하지만요 .

0:000> ~0kvn 50
# ChildEBP RetAddr Args to Child
00 0013ef14 77cf9418 77d0dba8 00000000 00000000 ntdll!KiFastSystemCallRet (FPO: [0,0,0])
01 0013ef4c 77d0593f 00060156 00000000 00000001 USER32!NtUserWaitMessage+0xc
02 0013ef74 77d1a91e 77cf0000 00194538 00000000 USER32!InternalDialogBox+0xd0 (FPO: [Non-Fpo])
03 0013f234 77d1a284 0013f390 0013f508 0013f430 USER32!SoftModalMessageBox+0×938 (FPO: [Non-Fpo])
04 0013f384 77d461d3 0013f390 00000028 00000000 USER32!MessageBoxWorker+0×2ba (FPO: [Non-Fpo])
05 0013f3dc 77d305f3 00000000 0069a6e0 0069a6ec USER32!MessageBoxTimeoutW+0×7a (FPO: [Non-Fpo])
06 0013f3fc 77d4634f 00000000 0069a6e0 0069a6ec USER32!MessageBoxExW+0×1b (FPO: [Non-Fpo])
07 0013f418 004edc49 00000000 0069a6e0 0069a6ec USER32!MessageBoxW+0×45 (FPO: [Non-Fpo])
08 0013f508 004f9fb0 00000000 00000176 00000004 PackerTest!CPackerTestDlg::OnBnClickedOk+0×39 (FPO: [Non-Fpo]) (CONV: thiscall) [e:\per\packertest\packertest\packertestdlg.cpp @ 156]
09 0013f54c 004fa6ef 0013fe18 00000001 00000000 PackerTest!_AfxDispatchCmdMsg+0xb0 (FPO: [Non-Fpo]) (CONV: stdcall) [f:\sp\vctools\vc7libs\ship\atlmfc\src\mfc\cmdtarg.cpp @ 82]
0a 0013f5b0 004fff21 00000001 00000000 00000000 PackerTest!CCmdTarget::OnCmdMsg+0×2df (FPO: [Non-Fpo]) (CONV: thiscall) [f:\sp\vctools\vc7libs\ship\atlmfc\src\mfc\cmdtarg.cpp @ 381]
0b 0013f5ec 0050b20d 00000001 00000000 00000000 PackerTest!CDialog::OnCmdMsg+0×21 (FPO: [Non-Fpo]) (CONV: thiscall) [f:\sp\vctools\vc7libs\ship\atlmfc\src\mfc\dlgcore.cpp @ 85]
0c 0013f650 0050a197 00000001 000a0220 a3ca6afd PackerTest!CWnd::OnCommand+0×16d (FPO: [Non-Fpo]) (CONV: thiscall) [f:\sp\vctools\vc7libs\ship\atlmfc\src\mfc\wincore.cpp @ 2300]
0d 0013f788 0050a0f0 00000111 00000001 000a0220 PackerTest!CWnd::OnWndMsg+0×77 (FPO: [Non-Fpo]) (CONV: thiscall) [f:\sp\vctools\vc7libs\ship\atlmfc\src\mfc\wincore.cpp @ 1755]
0e 0013f7a8 005075ee 00000111 00000001 000a0220 PackerTest!CWnd::WindowProc+0×30 (FPO: [Non-Fpo]) (CONV: thiscall) [f:\sp\vctools\vc7libs\ship\atlmfc\src\mfc\wincore.cpp @ 1741]
0f 0013f824 00507af4 0013fe18 00080148 00000111 PackerTest!AfxCallWndProc+0xee (FPO: [Non-Fpo]) (CONV: stdcall) [f:\sp\vctools\vc7libs\ship\atlmfc\src\mfc\wincore.cpp @ 240]
10 0013f844 77cf8734 00080148 00000111 00000001 PackerTest!AfxWndProc+0xa4 (FPO: [Non-Fpo]) (CONV: stdcall) [f:\sp\vctools\vc7libs\ship\atlmfc\src\mfc\wincore.cpp @ 389]
11 0013f870 77cf8816 004dbe1a 00080148 00000111 USER32!InternalCallWinProc+0×28
12 0013f8d8 77cfb4c0 00000000 004dbe1a 00080148 USER32!UserCallWinProcCheckWow+0×150 (FPO: [Non-Fpo])
13 0013f92c 77cfb50c 0098f2a0 00000111 00000001 USER32!DispatchClientMessage+0xa3 (FPO: [Non-Fpo])
14 0013f954 7c93eae3 0013f964 00000018 0098f2a0 USER32!__fnDWORD+0×24 (FPO: [Non-Fpo])
15 0013f978 77cf94be 77cfd4e4 00080148 00000111 ntdll!KiUserCallbackDispatcher+0×13 (FPO: [0,0,0])
16 0013f9b4 77cfb903 0098f2a0 00000111 00000001 USER32!NtUserMessageCall+0xc
17 0013f9d4 77187344 00080148 00000111 00000001 USER32!SendMessageW+0×7f (FPO: [Non-Fpo])
18 0013f9f4 77187426 0018b7c0 00000000 000c002a COMCTL32!Button_NotifyParent+0×3d (FPO: [Non-Fpo])
19 0013fa10 7718972b 0018b7c0 00000001 0013fb08 COMCTL32!Button_ReleaseCapture+0xd7 (FPO: [Non-Fpo])
1a 0013faa0 77cf8734 000a0220 00000202 00000000 COMCTL32!Button_WndProc+0×887 (FPO: [Non-Fpo])
1b 0013facc 77cf8816 77188ea4 000a0220 00000202 USER32!InternalCallWinProc+0×28
1c 0013fb34 77cf89cd 00000000 77188ea4 000a0220 USER32!UserCallWinProcCheckWow+0×150 (FPO: [Non-Fpo])
1d 0013fb94 77cf8a10 00188cb8 00000000 0013fbc8 USER32!DispatchMessageWorker+0×306 (FPO: [Non-Fpo])
1e 0013fba4 77d0d99d 00188cb8 7ffdb000 0013fd2c USER32!DispatchMessageW+0xf (FPO: [Non-Fpo])
1f 0013fbc8 0051f4e1 00080148 00a2fb28 77cfb970 USER32!IsDialogMessageW+0×572 (FPO: [Non-Fpo])
20 0013fbe0 0050f8ec 00188cb8 0013fe18 0013fc08 PackerTest!CWnd::IsDialogMessageW+0×71 (FPO: [Non-Fpo]) (CONV: thiscall) [f:\sp\vctools\vc7libs\ship\atlmfc\src\mfc\winocc.cpp @ 198]
21 0013fbf0 004ffeed 00188cb8 0013fe18 0013fe18 PackerTest!CWnd::PreTranslateInput+0×6c (FPO: [Non-Fpo]) (CONV: thiscall) [f:\sp\vctools\vc7libs\ship\atlmfc\src\mfc\wincore.cpp @ 4268]
22 0013fc08 0050c36b 00188cb8 0013fe18 00080148 PackerTest!CDialog::PreTranslateMessage+0xed (FPO: [Non-Fpo]) (CONV: thiscall) [f:\sp\vctools\vc7libs\ship\atlmfc\src\mfc\dlgcore.cpp @ 80]
23 0013fc1c 004fbddd 00080148 00188cb8 0013fc3c PackerTest!CWnd::WalkPreTranslateTree+0×8b (FPO: [Non-Fpo]) (CONV: stdcall) [f:\sp\vctools\vc7libs\ship\atlmfc\src\mfc\wincore.cpp @ 2882]
24 0013fc38 004fcdc3 00188cb8 00783e40 0013fc58 PackerTest!AfxInternalPreTranslateMessage+0×4d (FPO: [Non-Fpo]) (CONV: cdecl) [f:\sp\vctools\vc7libs\ship\atlmfc\src\mfc\thrdcore.cpp @ 233]
25 0013fc48 004fbe53 00188cb8 00783e40 0013fc78 PackerTest!CWinThread::PreTranslateMessage+0×23 (FPO: [Non-Fpo]) (CONV: thiscall) [f:\sp\vctools\vc7libs\ship\atlmfc\src\mfc\thrdcore.cpp @ 773]
26 0013fc58 004fbcaf 00188cb8 0013fc74 005356b5 PackerTest!AfxPreTranslateMessage+0×23 (FPO: [Non-Fpo]) (CONV: cdecl) [f:\sp\vctools\vc7libs\ship\atlmfc\src\mfc\thrdcore.cpp @ 252]
27 0013fc78 004fd11c 00783e40 0013fc90 004fbcff PackerTest!AfxInternalPumpMessage+0xdf (FPO: [Non-Fpo]) (CONV: stdcall) [f:\sp\vctools\vc7libs\ship\atlmfc\src\mfc\thrdcore.cpp @ 178]
28 0013fc84 004fbcff 00783e40 0013fcb8 0050fad5 PackerTest!CWinThread::PumpMessage+0xc (FPO: [Non-Fpo]) (CONV: thiscall) [f:\sp\vctools\vc7libs\ship\atlmfc\src\mfc\thrdcore.cpp @ 896]
29 0013fc90 0050fad5 00000000 00000000 0013fe18 PackerTest!AfxPumpMessage+0×1f (FPO: [Non-Fpo]) (CONV: stdcall) [f:\sp\vctools\vc7libs\ship\atlmfc\src\mfc\thrdcore.cpp @ 190]
2a 0013fcb8 00500f41 00000004 a3ca6051 0013feb0 PackerTest!CWnd::RunModalLoop+0×1d5 (FPO: [Non-Fpo]) (CONV: thiscall) [f:\sp\vctools\vc7libs\ship\atlmfc\src\mfc\wincore.cpp @ 4322]
2b 0013fd24 004ed19d a3ca63c9 00011970 7c9418f1 PackerTest!CDialog::DoModal+0×1e1 (FPO: [Non-Fpo]) (CONV: thiscall) [f:\sp\vctools\vc7libs\ship\atlmfc\src\mfc\dlgcore.cpp @ 587]
2c 0013febc 00685c52 00000000 00188e40 0013fedc PackerTest!CPackerTestApp::InitInstance+0xad (FPO: [Non-Fpo]) (CONV: thiscall) [e:\per\packertest\packertest\packertest.cpp @ 63]
2d 0013fee0 00685b48 00400000 00000000 00020914 PackerTest!AfxWinMain+0×82 (FPO: [Non-Fpo]) (CONV: stdcall) [f:\sp\vctools\vc7libs\ship\atlmfc\src\mfc\winmain.cpp @ 37]
2e 0013fef8 006126ef 00400000 00000000 00020914 PackerTest!wWinMain+0×18 (FPO: [Non-Fpo]) (CONV: stdcall) [f:\sp\vctools\vc7libs\ship\atlmfc\src\mfc\appmodul.cpp @ 33]
2f 0013ffb8 0061242d 0013fff0 7c816fd7 00011970 PackerTest!__tmainCRTStartup+0×2af (FPO: [Non-Fpo]) (CONV: cdecl) [f:\sp\vctools\crt_bld\self_x86\crt\src\crt0.c @ 324]
30 0013ffc0 7c816fd7 00011970 7c9418f1 7ffdb000 PackerTest!wWinMainCRTStartup+0xd (FPO: [Non-Fpo]) (CONV: cdecl) [f:\sp\vctools\crt_bld\self_x86\crt\src\crt0.c @ 196]
31 0013fff0 00000000 004da8d5 00000000 78746341 kernel32!BaseProcessStart+0×23 (FPO: [Non-Fpo])

일단 꽤 큰 Call Stack을 만들어 봤습니다.  ( 사실 이 정도는 큰게 아닙니다. ..  MFC를 사용하면 쉽게 만들어지는 … )  맨아랫줄만 보면 kernel32!BaseProcessStart 의 EBP는 0013fff0 이고 PackerTest!wWinMainCRTStartup의 EBP는 0013ffc0 return Address는 7c816fd7  입니다. 그럼 Raw Stack 상에는 어떻게 나타날까 ?? 

0013ff9c 00000005
0013ffa0 0013ff10
0013ffa4 000009e9
0013ffa8 0013ffe0
0013ffac 004de5a7 PackerTest!ILT+34210(__except_handler4)
0013ffb0 a3ae243d
0013ffb4 00000001
0013ffb8 0013ffc0
0013ffbc 0061242d PackerTest!wWinMainCRTStartup+0xd [f:\sp\vctools\crt_bld\self_x86\crt\src\crt0.c @ 196]
0013ffc0 0013fff0
0013ffc4 7c816fd7 kernel32!BaseProcessStart+0×23
0013ffc8 00011970
0013ffcc 7c9418f1 ntdll!RtlDeleteCriticalSection+0×72
0013ffd0 7ffdb000
0013ffd4 805522fa
0013ffd8 0013ffc8
0013ffdc 85e23790
0013ffe0 ffffffff
0013ffe4 7c839aa8 kernel32!_except_handler3
0013ffe8 7c816fe0 kernel32!`string’+0×98
0013ffec 00000000
0013fff0 00000000
0013fff4 00000000
0013fff8 004da8d5 PackerTest!ILT+18640(_wWinMainCRTStartup)
0013fffc 00000000
00140000 78746341

EBP에는 Child EBP가 EBP+4에는 Return Address가 있다는걸 명심하시기 바랍니다.  Application의 경우 Raw Stack Trace는 BaseProcessStart를 찾는것 부터 시작합니다.  0013ffc4  7c816fd7 kernel32!BaseProcessStart+0×23 이 부분을 보면 Return Address를 표시한 부분이죠. EBP-4위치가 바로 kernel32!BaseProcessStart+0×23  부근에서 Call 되어진 Function의 EBP 가 됩니다. 0013ffc0  0013fff0 부분이 그것이죠 0013ffc0은 kernel32!BaseProcessStart+0×23 부근에서 Call 되어진 Function의 EBP이고  0013fff0는 kernel32!BaseProcessStart의 EBP가 되겠죠. 그럼 다음 Function의 Stack을 찾기 위해서는 0013ffc0를 값으로 가지고 있는 부분을 검색해 내면 ( 검색된 부분 + 4 ) Address에 다시 Return Address가 존재 하게 됩니다.

0013ffb8 0013ffc0
0013ffbc 0061242d PackerTest!wWinMainCRTStartup+0xd [f:\sp\vctools\crt_bld\self_x86\crt\src\crt0.c @ 196]

바로 이 부분이 그 부분이 됩니다.  0013ffc0 값이 0013ffb8 Address에 저장되어 있군요. 다시 말해 PackerTest!wWinMainCRTStartup+0xd 부근에서 Call 되어진 Function의 EBP는  0013ffb8 가 되는거죠. 다시 같은 방법으로 0013ffb8를 검색하면 다음 EBP를 구해 낼수 있게 됩니다.  이런식으로 Stack Trace를 하게되면 아래와 같은 부분 들을 찾을 수 있습니다.

0013ef4c 0013ef74
0013ef50 77d0593f USER32!InternalDialogBox+0xd0
0013ef54 00060156
0013ef58 00000000
0013ef5c 00000001
0013ef60 00000000
... 너무 많아서 생략
0013fc78 0013fc84
0013fc7c 004fd11c PackerTest!CWinThread::PumpMessage+0xc [f:\sp\vctools\vc7libs\ship\atlmfc\src\mfc\thrdcore.cpp @ 896]

0013fc84 0013fc90
0013fc88 004fbcff PackerTest!AfxPumpMessage+0×1f [f:\sp\vctools\vc7libs\ship\atlmfc\src\mfc\thrdcore.cpp @ 190]

0013fc90 0013fcb8
0013fc94 0050fad5 PackerTest!CWnd::RunModalLoop+0×1d5 [f:\sp\vctools\vc7libs\ship\atlmfc\src\mfc\wincore.cpp @ 4322]

0013fcb8 0013fd24
0013fcbc 00500f41 PackerTest!CDialog::DoModal+0×1e1 [f:\sp\vctools\vc7libs\ship\atlmfc\src\mfc\dlgcore.cpp @ 587]

0013fd24 0013febc
0013fd28 004ed19d PackerTest!CPackerTestApp::InitInstance+0xad [e:\per\packertest\packertest\packertest.cpp @ 63]

0013febc 0013fee0
0013fec0 00685c52 PackerTest!AfxWinMain+0×82 [f:\sp\vctools\vc7libs\ship\atlmfc\src\mfc\winmain.cpp @ 37]

0013fee0 0013fef8
0013fee4 00685b48 PackerTest!wWinMain+0×18 [f:\sp\vctools\vc7libs\ship\atlmfc\src\mfc\appmodul.cpp @ 33]
0013fee8 00400000 PackerTest!_enc$textbss$begin <PERF> (PackerTest+0×0)
0013feec 00000000
0013fef0 00020914
0013fef4 0000000a
0013fef8 0013ffb8
0013fefc 006126ef PackerTest!__tmainCRTStartup+0×2af [f:\sp\vctools\crt_bld\self_x86\crt\src\crt0.c @ 324]

0013ffb8 0013ffc0
0013ffbc 0061242d PackerTest!wWinMainCRTStartup+0xd [f:\sp\vctools\crt_bld\self_x86\crt\src\crt0.c @ 196]
0013ffc0 0013fff0
0013ffc4 7c816fd7 kernel32!BaseProcessStart+0×23

이렇게 검색된 Raw Stack의 최상위 EBP를 이용하여 Stack을 재구성해 보면

0:000> K L=0013ef4c 50
ChildEBP RetAddr
0013ef14 77cf9418 ntdll!KiFastSystemCallRet
0013ef4c 77d0593f USER32!NtUserWaitMessage+0xc
0013ef74 77d1a91e USER32!InternalDialogBox+0xd0
0013f234 77d1a284 USER32!SoftModalMessageBox+0×938
0013f384 77d461d3 USER32!MessageBoxWorker+0×2ba
0013f3dc 77d305f3 USER32!MessageBoxTimeoutW+0×7a
0013f3fc 77d4634f USER32!MessageBoxExW+0×1b
0013f418 004edc49 USER32!MessageBoxW+0×45
0013f508 004f9fb0 PackerTest!CPackerTestDlg::OnBnClickedOk+0×39
0013f54c 004fa6ef PackerTest!_AfxDispatchCmdMsg+0xb0
0013f5b0 004fff21 PackerTest!CCmdTarget::OnCmdMsg+0×2df
0013f5ec 0050b20d PackerTest!CDialog::OnCmdMsg+0×21
0013f650 0050a197 PackerTest!CWnd::OnCommand+0×16d
0013f788 0050a0f0 PackerTest!CWnd::OnWndMsg+0×77
0013f7a8 005075ee PackerTest!CWnd::WindowProc+0×30
0013f824 00507af4 PackerTest!AfxCallWndProc+0xee
0013f844 77cf8734 PackerTest!AfxWndProc+0xa4
0013f870 77cf8816 USER32!InternalCallWinProc+0×28
0013f8d8 77cfb4c0 USER32!UserCallWinProcCheckWow+0×150
0013f92c 77cfb50c USER32!DispatchClientMessage+0xa3
0013f954 7c93eae3 USER32!__fnDWORD+0×24
0013f978 77cf94be ntdll!KiUserCallbackDispatcher+0×13
0013f9b4 77cfb903 USER32!NtUserMessageCall+0xc
0013f9d4 77187344 USER32!SendMessageW+0×7f
0013f9f4 77187426 COMCTL32!Button_NotifyParent+0×3d
0013fa10 7718972b COMCTL32!Button_ReleaseCapture+0xd7
0013faa0 77cf8734 COMCTL32!Button_WndProc+0×887
0013facc 77cf8816 USER32!InternalCallWinProc+0×28
0013fb34 77cf89cd USER32!UserCallWinProcCheckWow+0×150
0013fb94 77cf8a10 USER32!DispatchMessageWorker+0×306
0013fba4 77d0d99d USER32!DispatchMessageW+0xf
0013fbc8 0051f4e1 USER32!IsDialogMessageW+0×572
0013fbe0 0050f8ec PackerTest!CWnd::IsDialogMessageW+0×71
0013fbf0 004ffeed PackerTest!CWnd::PreTranslateInput+0×6c
0013fc08 0050c36b PackerTest!CDialog::PreTranslateMessage+0xed
0013fc1c 004fbddd PackerTest!CWnd::WalkPreTranslateTree+0×8b
0013fc38 004fcdc3 PackerTest!AfxInternalPreTranslateMessage+0×4d
0013fc48 004fbe53 PackerTest!CWinThread::PreTranslateMessage+0×23
0013fc58 004fbcaf PackerTest!AfxPreTranslateMessage+0×23
0013fc78 004fd11c PackerTest!AfxInternalPumpMessage+0xdf
0013fc84 004fbcff PackerTest!CWinThread::PumpMessage+0xc
0013fc90 0050fad5 PackerTest!AfxPumpMessage+0×1f
0013fcb8 00500f41 PackerTest!CWnd::RunModalLoop+0×1d5
0013fd24 004ed19d PackerTest!CDialog::DoModal+0×1e1
0013febc 00685c52 PackerTest!CPackerTestApp::InitInstance+0xad
0013fee0 00685b48 PackerTest!AfxWinMain+0×82
0013fef8 006126ef PackerTest!wWinMain+0×18
0013ffb8 0061242d PackerTest!__tmainCRTStartup+0×2af
0013ffc0 7c816fd7 PackerTest!wWinMainCRTStartup+0xd
0013fff0 00000000 kernel32!BaseProcessStart+0×23

멋지게 Stack을 볼수 있게 되죠 .. 그 외에 간단한 Tip이라면 EBP+8위치에는 첫번째 Parameter가 오고 EBP-4위치에는 첫번째 Local Value가 들어갑니다. 

누군가 내 블로그를 Google 번역기로 ….

report

누군가 내 블로그를 구글 번역기로 읽어 보았군요 … 왠지 기분 좋은 .. ㅋ

[blogging] Reference Life Time

+// Example 1

string f() { return "abc"; }

void g() {
const string& s = f();
cout << s << endl; // can we still use the “temporary” object?
}

string f() { return “abc”; }

void g() {
string& s = f(); // still legal?
cout << s << endl;
}

두 코드의 차이 ?? const라는 녀석이 있군요. const reference의 Life Time에 대해서 잘 알고 계신가요 ??

간만에 들어간 Herb Sutter의 Blog에 반가운 GOTW가 올라와 있더군요

http://herbsutter.wordpress.com/2008/01/01/gotw-88-a-candidate-for-the-most-important-const/

[blogging] NULL Pointer CALL - 당황하기 쉽지요 …

0:002> kv
ChildEBP RetAddr Args to Child
WARNING: Frame IP not in any known module. Following frames may be wrong.
0222ffb8 7d4dfe21 00000000 00000000 00000000 0×0
0222ffec 00000000 00000000 00000000 00000000 kernel32!BaseThreadStart+0×34

이런 스택 보신적있나요 ?? 0×0 을 CALL 하고 있군요. 꽤 당황하기 쉬운 스택이지만 가장 쉬운 Dump 중하나이지요 .

http://www.dumpanalysis.org/blog/index.php/2008/04/28/crash-dump-analysis-patterns-part-6a/

참고하시길….