📚 OpenRCE is preserved as a read-only archive. Launched at RECon Montreal in 2005. Registration and posting are disabled.








Flag: Tornado! Hurricane!

 Forums >>  Debuggers  >>  Passing Access Violations to the Debuggee

Topic created on: January 29, 2007 00:34 CST by kroudo .

I have written a small debugger in C++ using CreateProcessA with CREATE_SUSPENDED | DEBUG_PROCESS flag set and WaitForDebugEvent APIs. I am able to handle all types of events occuring like dll load/unload , exceptions etc. But there seems to be a problem with EXCEPTION_ACCESS_VIOLATION when the debugged process has an exception handler attached.. at this point i keep getting the EXCEPTION_ACCESS_VIOLATION continually whereas i want the debugged process to continue with its excetion handler.

here is the code for debugged process:

int main()
{
DWORD handler = (DWORD)_except_handler;

__asm
{ // Build EXCEPTION_REGISTRATION record:
push handler // Address of handler function
push FS:[0] // Address of previous handler
mov FS:[0],ESP // Install new EXECEPTION_REGISTRATION
}
__asm
{
mov eax,0      // Zero out EAX
mov [eax], 1 // Write to EAX to deliberately cause a fault
}
printf( "After writing!\n" );
__asm
{ // Remove our EXECEPTION_REGISTRATION record
mov eax,[ESP] // Get pointer to previous record
mov FS:[0], EAX // Install previous record
add esp, 8 // Clean our EXECEPTION_REGISTRATION off stack
}
return 0;
}

This exception handler sets right address for eax and the process executes fine when run alone.

what i want to know is that is there any manual way/procedure to tell the debugged process to search its own handler and run it?

Also, when run in olly with ignoring exceptions, the process runs perfectly fine.

Help needed.

  fileoffset     January 29, 2007 01:26.41 CST
If you wish for the calling process to handle the exception, you could try querying the debugee's SEH record, and manually setting EIP to the address of the exception, and then resume the process (making sure the context is correct). This is essentially what happens when a debugger isn't attached anyway.

  kroudo   January 30, 2007 05:22.30 CST
Thanks fileoffset.

I have resolved this issue, i had to change the value of DbgContinue Parameter from DBG_CONTINUE to DBG_EXCEPTION_NOT_HANDLED for this particular condition. Now it works just as i expect it to.

Note: Registration is required to post to the forums.

There are 31,328 total registered users.


Recently Created Topics
[help] Unpacking VMP...
Mar/12
Reverse Engineering ...
Jul/06
let 'IDAPython' impo...
Sep/24
set 'IDAPython' as t...
Sep/24
GuessType return une...
Sep/20
About retrieving the...
Sep/07
How to find specific...
Aug/15
How to get data depe...
Jul/07
Identify RVA data in...
May/06
Question about memor...
Dec/12


Recent Forum Posts
Finding the procedur...
rolEYder
Question about debbu...
rolEYder
Identify RVA data in...
sohlow
let 'IDAPython' impo...
sohlow
How to find specific...
hackgreti
Problem with ollydbg
sh3dow
How can I write olly...
sh3dow
New LoadMAP plugin v...
mefisto...
Intel pin in loaded ...
djnemo
OOP_RE tool available?
Bl4ckm4n


Recent Blog Entries
halsten
Mar/14
Breaking IonCUBE VM

oleavr
Oct/24
Anatomy of a code tracer

hasherezade
Sep/24
IAT Patcher - new tool for ...

oleavr
Aug/27
CryptoShark: code tracer ba...

oleavr
Jun/25
Build a debugger in 5 minutes

More ...


Recent Blog Comments
nieo on:
Mar/22
IAT Patcher - new tool for ...

djnemo on:
Nov/17
Kernel debugger vs user mod...

acel on:
Nov/14
Kernel debugger vs user mod...

pedram on:
Dec/21
frida.github.io: scriptable...

capadleman on:
Jun/19
Using NtCreateThreadEx for ...

More ...


Imagery
SoySauce Blueprint
Jun 6, 2008

[+] expand

View Gallery (11) / Submit