簡體   English   中英

Masm32在seh處理程序處理異常后跳轉到其他模塊中的label

[英]Masm32 jump to label in other module after seh handler handled exception

我正在嘗試一種反調試方法。

首先,我做了所有的事情,並通過一行未更正的代碼引發了異常

    assume fs:nothing
    push offset antiDebug    ;function to deal with exception
    push fs:[0]
    mov fs:[0],esp
    mov eax,offset MENU   ;Menu is the label I want to jump to after the exception handled
    push eax
    call dumpRegs
    mov edx,0
    mov dword ptr[edx],0    ;wrong code

    MENU:                   ;I want to jump here after exception handled

antiDebug function ↓,在上面代碼的另一個模塊中

antiDebug proc _lpExceptionRecord:ptr EXCEPTION_RECORD,_lpSEH:ptr SEH,_lpContext:ptr CONTEXT,_lpDispatcherContext:ptr DISPATCHER_CONTEXT 
    mov esi,_lpExceptionRecord
    mov edi,_lpContext
    assume esi:ptr EXCEPTION_RECORD,edi:ptr CONTEXT
    invoke MessageBox,NULL,addr infoUser,NULL,MB_OK
    mov eax,[ebp+638H]       ;I debug many times to find the relative 
                             ;distance,eax gets the location oflable MENU
    mov [edi].regEip,eax
    assume esi:nothing,edi:nothing
    mov eax,ExceptionContinueExecution
    ret
antiDebug endp

問題是 MENU 的位置不在 antiDebug function 的同一個模塊中。所以我不能通過mov [edi].regEip,eax跳轉 MENU 我該怎么辦?

添加細節:在我的主模塊中,在觸發異常之前,我將 MENU 的位置推送到堆棧中,您可以在調試 window 中看到,eax 得到正確的值在此處輸入圖像描述

我繼續調試,在antiDebug function,這里,eax成功獲取到lable的位置,傳給[edi].regEip 在此處輸入圖像描述

但是問題來了。我確定我得到了正確的 MENU 位置,但是當這個 function 返回時,我得到了錯誤。 在此處輸入圖像描述

然后處理程序 function 出錯,處理程序 function 出錯,我只是重復執行處理程序函數(antiDebug)

PS:如果我在antiDebug的同一個模塊中通過[edi].regEip一個label,我可以跳到那里。

提前致謝!

幾天后,我似乎弄明白了。我沒有得到正確的MENU(標簽)位置。解決問題的關鍵是如何獲得標簽的正確位置(如何將label導出到另一個模塊.所以我的解決方案是在主模塊中定義一個全局變量,並在主模塊中定義一個 function 來移動mov eax,variable that store location

通過調用這個 function,我在 antiDebug 模塊中得到了 label 的位置。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM