Masm32在seh处理程序处理异常后跳转到其他模块中的标签

问题描述 投票:0回答:1

我正在尝试一种反调试方法。

首先,我做了所有的工作,并通过未更正的代码行引发了异常

    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函数↓,在上述代码的另一个模块中

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功能的同一模块中。所以我不能按mov [edi].regEip,eax跳转MENU该怎么办?

详细信息:在我的主模块中,在触发异常之前,将MENU的位置压入堆栈,然后您可以在调试窗口中看到eax获得正确的值enter image description here

我继续调试。在antiDebug函数中,eax在此成功获取了lable的位置,并将其传递给[edi] .regEipenter image description here

但是问题来了。我确定我得到了正确的MENU位置,但是当该函数返回时,我得到了错误。enter image description here

然后处理程序函数中的错误和处理程序函数中的错误,我重复执行该处理程序函数(antiDebug)

PS:如果我传递[edi] .reg在antiDebug的同一模块中标签,我可以跳到那里。

提前感谢!

winapi assembly x86 masm32 seh
1个回答
0
投票

[几天后,我似乎想通了。我没有得到MENU(标签)的正确位置。解决问题的关键是如何获得标签的正确位置(如何将标签导出到因此,我的解决方案是在主模块中定义一个全局变量,然后在主模块中定义一个函数至mov eax,variable that store location

通过调用此函数,我获得了antiDebug模块中标签的位置。

© www.soinside.com 2019 - 2024. All rights reserved.