1.循環,用得比較多,也是加密/驗證常用的
MOV EAX,DWORD PTR SS:[EBP-4] CALL XXXXXXXX //這一般是取長度 TEST EAX,EAX @@Loop: JBE XXXXXXXX //長度爲0,不做循環 MOV EDX,1 //從第一個開始:Delphi程序 MOV ECX,DWORD PTR SS:[EBP-4] MOVZX ECX,BYTE PTR DS:[ECX+EDX-1] //取一個字符 ... ... //其它操作,各人有異 ... INC EDX //取下一個 DEC EAX JNZ @@Loop //下一輪
2.取無效地址?
在處理中,經常看到有類似LEA ECX,DWORD PTR DS:[ECX+ECX*2]的句子. 心想,怎麼可能,這樣訪問不會出錯嗎? 不會,原來LEA不會訪問地址後才取地址,而是直接取,呵呵,其實這個只是用 來做運算:ECX = ECX * 3;
3.對Delphi 程序Timer設置斷點
方法:在模塊中查找cmp esi, 113 設置斷點
Delphi 在處理Timer時,SetTimer傳的TimeProc 是0,因爲Delphi不通過回調函數的方式,而是通過消息實現。 constructor TTimer.Create(AOwner: TComponent); begin inherited Create(AOwner); FEnabled := True; FInterval := 1000; FWindowHandle := AllocateHWnd(WndProc); end; 其中AllocateHWnd(WndProc)就會產生一個大小爲0的窗口,並將WndProc作爲其窗口過程,來處理消息。 再看其窗口過程: procedure TTimer.WndProc(var Msg: TMessage); begin with Msg do if Msg = WM_TIMER then try Timer; except Application.HandleException(Self); end else Result := DefWindowProc(FWindowHandle, Msg, wParam, lParam); end; 裏邊只做了對WM_TIMER的比較,所以就有希望了。 這個過程反彙編後就是: 這是編譯時,選擇“Build with runtime package”的方式: 4007A6A8 V> 55 push ebp 4007A6A9 8BEC mov ebp,esp 4007A6AB 51 push ecx 4007A6AC 53 push ebx 4007A6AD 56 push esi 4007A6AE 57 push edi 4007A6AF 8BDA mov ebx,edx 4007A6B1 8945 FC mov dword ptr ss:[ebp-4],eax 4007A6B4 8B33 mov esi,dword ptr ds:[ebx] 4007A6B6 81FE 13010000 cmp esi,113 //if Msg = WM_TIMER then 4007A6BC 75 3F jnz short Vcl50.4007A6FD 4007A6BE 33C0 xor eax,eax 4007A6C0 55 push ebp 4007A6C1 68 E2A60740 push Vcl50.4007A6E2 4007A6C6 64:FF30 push dword ptr fs:[eax] 4007A6C9 64:8920 mov dword ptr fs:[eax],esp 4007A6CC 8B45 FC mov eax,dword ptr ss:[ebp-4] 4007A6CF 66:BB F0FF mov bx,0FFF0 4007A6D3 E8 D495F8FF call Vcl50.System::CallDynaInst 4007A6D8 33C0 xor eax,eax 4007A6DA 5A pop edx 4007A6DB 59 pop ecx 4007A6DC 59 pop ecx 4007A6DD 64:8910 mov dword ptr fs:[eax],edx 4007A6E0 EB 33 jmp short Vcl50.4007A715 4007A6E2 ^ E9 BD98F8FF jmp Vcl50.System::HandleAnyException 4007A6E7 A1 E0EB1540 mov eax,dword ptr ds:[4015EBE0] 4007A6EC 8B00 mov eax,dword ptr ds:[eax] 4007A6EE 8B55 FC mov edx,dword ptr ss:[ebp-4] 4007A6F1 E8 1A06FEFF call Vcl50.Forms::TApplication::HandleException 4007A6F6 E8 C59CF8FF call Vcl50.System::DoneExcept 4007A6FB EB 18 jmp short Vcl50.4007A715 4007A6FD 8B43 08 mov eax,dword ptr ds:[ebx+8] 4007A700 50 push eax 4007A701 8B43 04 mov eax,dword ptr ds:[ebx+4] 4007A704 50 push eax 4007A705 56 push esi 4007A706 8B45 FC mov eax,dword ptr ss:[ebp-4] 4007A709 8B40 28 mov eax,dword ptr ds:[eax+28] 4007A70C 50 push eax 4007A70D E8 7A07F9FF call 4007A712 8943 0C mov dword ptr ds:[ebx+C],eax 4007A715 5F pop edi 4007A716 5E pop esi 4007A717 5B pop ebx 4007A718 59 pop ecx 4007A719 5D pop ebp 4007A71A C3 retn 如果不選擇則是: 0043EECA . 57 push edi 0043EECB . 8BDA mov ebx,edx 0043EECD . 8945 FC mov dword ptr ss:[ebp-4],eax 0043EED0 . 8B33 mov esi,dword ptr ds:[ebx] 0043EED2 . 81FE 13010000 cmp esi,113 //if Msg = WM_TIMER then 0043EED8 . 75 3F jnz short tm1.0043EF19 0043EEDA . 33C0 xor eax,eax 呵呵,看出什麼沒? 再告訴你:WM_TIMER 定義爲:$0113 所以只要在代碼中查找命令: cmp esi,113 就可以找到onTimer入口了。 需要注意的是:如果Build with runtime package時,要到VCLXX.bpl的模塊中找。