Why isn't my SEH2 try-except statement preventing Page Faults?

All development related issues welcome

Moderator: Moderator Team

Post Reply
berylliumquestion
Posts: 10
Joined: Sun Sep 01, 2019 12:59 am

Why isn't my SEH2 try-except statement preventing Page Faults?

Post by berylliumquestion »

So for a while, I wasn't entirely sure how to construct the try-except statement so that it would compile. Yesterday I figured it out, but I haven't constructed it correctly, because it's still crashing.

I tried this:

Code: Select all

_SEH2_TRY {
	DPRINT1("Irp->IoStatus.Status: %p\n", Irp->IoStatus.Status);
} _SEH2_FINALLY {
        NOTHING;
} _SEH2_END;
I also tried this:

Code: Select all

SEH2_TRY {
        DPRINT1("Irp->IoStatus.Status: %p\n", Irp->IoStatus.Status);
} _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) {
        NOTHING;
} _SEH2_END;
They both resulted in this error:

Code: Select all

Entered debugger on first-chance exception (Exception Code: 0xc0000005) (Page Fault)
Memory at 0x00000018 could not be read: Page not present.
What am I doing wrong here?

User avatar
binarymaster
Posts: 368
Joined: Sun Nov 16, 2014 7:05 pm
Location: Russia, Moscow
Contact:

Re: Why isn't my SEH2 try-except statement preventing Page Faults?

Post by binarymaster »

You have first-chance exception handling enabled in kernel debugger. If you disable it, your exceptions will be handled by SEH.

Also you can simply do "cont" in debugger to pass exception to SEH.

ThFabba
Developer
Posts: 291
Joined: Sun Jul 11, 2010 11:39 am

Re: Why isn't my SEH2 try-except statement preventing Page Faults?

Post by ThFabba »

Also note that the try-finally won't actually catch the exception, only the try-except will.

berylliumquestion
Posts: 10
Joined: Sun Sep 01, 2019 12:59 am

Re: Why isn't my SEH2 try-except statement preventing Page Faults?

Post by berylliumquestion »

Thank you for the information, both of you.

I think I may have made an error in reading the logs. I think it may have actually worked, but I realized that the problem was in another DPRINT1 statement I added further down the code. Sorry about that.

There is one piece of information I'm not entirely clear on.
binarymaster wrote:
Sat Feb 01, 2020 12:44 am
You have first-chance exception handling enabled in kernel debugger. If you disable it, your exceptions will be handled by SEH.

Also you can simply do "cont" in debugger to pass exception to SEH.
How do I disable it? Is it disabled before compiling or within an already installed running ReactOS?

User avatar
binarymaster
Posts: 368
Joined: Sun Nov 16, 2014 7:05 pm
Location: Russia, Moscow
Contact:

Re: Why isn't my SEH2 try-except statement preventing Page Faults?

Post by binarymaster »

berylliumquestion wrote:
Sat Feb 01, 2020 1:37 am
How do I disable it? Is it disabled before compiling or within an already installed running ReactOS?
Check out your freeldr.ini, specifically "Options" parameters. Find "/FIRSTCHANCE" and remove it.

Usually it's disabled by default, so it seems you enabled it at some point.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests