自己写了个仿记事本程序,MFC的,就是没有拖放功能,在LZ的启发下,准备弄弄,添加函数简单,郁闷的是找窗口
句柄,MFC功能全是封装的,找到相关函数后就老在MFC42D.dll,以及系统dll里转,怎么才能在程序空间里找到窗口句
柄参数呢,我不可能去改动MFC42D.dll啊,后来发现用VC调试时,能够清楚的显示函数名称,如
00401E15 push 5
00401E17 mov eax,dword ptr [ebp-10h]
00401E1A mov ecx,dword ptr [eax+20h]
00401E1D call CWnd::ShowWindow (004033bc)
而在OD里却显示为
00401E15 |> \6A 05 PUSH 5
00401E17 |. 8B45 F0 MOV EAX,DWORD PTR SS:[EBP-10]
00401E1A |. 8B48 20 MOV ECX,DWORD PTR DS:[EAX+20]
00401E1D |. E8 9A150000 CALL <JMP.&MFC42D.#4951>
怎么才能显示出函数名称呢,搞了半天,后来发现是OD里没有添加导入库,汗,添加了MFCD42.lib后,重载程序,
结果如下
00401E15 |> \6A 05 PUSH 5
00401E17 |. 8B45 F0 MOV EAX,DWORD PTR SS:[EBP-10]
00401E1A |. 8B48 20 MOV ECX,DWORD PTR DS:[EAX+20]
00401E1D |. E8 9A150000 CALL <JMP.&MFC42D.#?ShowWindow@CWnd@@QAEHH@Z_4951>
现在好办了,跟进call,来到如下代码
5F436C5F > 55 PUSH EBP
5F436C60 8BEC MOV EBP,ESP
5F436C62 51 PUSH ECX
5F436C63 53 PUSH EBX
5F436C64 56 PUSH ESI
5F436C65 57 PUSH EDI
5F436C66 894D FC MOV DWORD PTR SS:[EBP-4],ECX
5F436C69 8B45 FC MOV EAX,DWORD PTR SS:[EBP-4]
5F436C6C 8B48 20 MOV ECX,DWORD PTR DS:[EAX+20]
5F436C6F 51 PUSH ECX
5F436C70 FF15 6CB64A5F CALL DWORD PTR DS:[<&USER32.IsWindow>] ;
user32.IsWindow
5F436C76 85C0 TEST EAX,EAX
5F436C78 75 14 JNZ SHORT MFC42D.5F436C8E
5F436C7A 68 2D010000 PUSH 12D
5F436C7F 68 DCD64C5F PUSH OFFSET MFC42D.THIS_FILE ; ASCII "winocc.cpp"
5F436C84 E8 27FF0300 CALL MFC42D.#?AfxAssertFailedLine@@YGHPBDH@Z_1041
5F436C89 85C0 TEST EAX,EAX
5F436C8B 74 01 JE SHORT MFC42D.5F436C8E
5F436C8D CC INT3
5F436C8E 33D2 XOR EDX,EDX
5F436C90 85D2 TEST EDX,EDX
5F436C92 ^ 75 D5 JNZ SHORT MFC42D.5F436C69
5F436C94 8B45 FC MOV EAX,DWORD PTR SS:[EBP-4]
5F436C97 8378 3C 00 CMP DWORD PTR DS:[EAX+3C],0
5F436C9B 75 13 JNZ SHORT MFC42D.5F436CB0
5F436C9D 8B4D 08 MOV ECX,DWORD PTR SS:[EBP+8]
5F436CA0 51 PUSH ECX
5F436CA1 8B55 FC MOV EDX,DWORD PTR SS:[EBP-4]
5F436CA4 8B42 20 MOV EAX,DWORD PTR DS:[EDX+20]
5F436CA7 50 PUSH EAX
5F436CA8 FF15 70B94A5F CALL DWORD PTR DS:[<&USER32.ShowWindow>] ;
user32.ShowWindow
仔细看call showwindow的参数hwnd是[[ebp-4]+20],而[EBP-4]是由5F436C66处的ECX赋值,这样我们就知道在
00401E1D前如何得到窗口句柄了,也就是 [ecx+20],最后更改如下
00401E15 > \6A 05 PUSH 5
00401E17 . 8B45 F0 MOV EAX,DWORD PTR SS:[EBP-10]
00401E1A . 8B48 20 MOV ECX,DWORD PTR DS:[EAX+20]
00401E1D . EB 45 JMP SHORT pad1.00401E64
00401E1F 90 NOP
00401E20 90 NOP
00401E21 90 NOP
00401E22 > 8B4D F0 MOV ECX,DWORD PTR SS:[EBP-10]
..........
00401E64 > \51 PUSH ECX
00401E65 . 50 PUSH EAX
00401E66 . 8B51 20 MOV EDX,DWORD PTR DS:[ECX+20]
00401E69 . 6A 01 PUSH 1 ; /Accept = TRUE
00401E6B . 52 PUSH EDX ; |hWnd
00401E6C FF15 96D04100 CALL DWORD PTR DS:[<&SHELL32.DragAcceptFiles>] ;
shell32.DragAcceptFiles
00401E72 . 58 POP EAX
00401E73 . 59 POP ECX
00401E74 . E8 43150000 CALL <JMP.&MFC42D.#?ShowWindow@CWnd@@QAEHH@Z_4951>
00401E79 .^ EB A7 JMP SHORT pad1.00401E22
后来发现VB的程序也不好分析,在网上也没找到msvbvm60.lib文件,用其他工具转出来的lib文件,分析程序时还是有好多函数分析不出名称,以序号方式显示,郁闷