I am trying an method of anti-debug.
First I did everything nessissery and raised an exception by a line of not corrected code
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 ↓,in another module from the above code
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
the problem is that the location of MENU is not in the same module of antiDebug function.So I just cant jump MENU by mov [edi].regEip,eax
What am I supposed to do?
ADD DETAILS:
in my main module,before I trigger the exception,I push the location of MENU in stack,and you can see in the debug window,eax gets the right value
I continue to debug.In the antiDebug function,here,eax successfully gets the location of lable and pass it to [edi].regEip
But then problem comes.I am sure I get the right location of MENU,but when this function return,I get error.
then error in handler function and error in handler function,I just repeat to execute the handler function(antiDebug)
PS:if I pass [edi].regEip a label in the same module of antiDebug,I can jump there.
Thanks in advance!