No, that’s inaccurate, or at least it is an incomplete and useless response.
Structured exception handling can be used in kernel-mode code, subject to
certain constraints. The most important is that you can only use SEH at
PASSIVE_LEVEL. So, you must never use __try/__except at elevated IRQL
(DISPATCH_LEVEL, device level, etc.).
The second constraint is that you must be aware of the greater impact on
your stack consumption. Using SEH causes the compiler to emit more code,
which uses more stack space, in your driver. Kernel stacks are fixed in
size, and cannot grow dynamically. If you exceed the maximum stack size,
you will crash the system.
By the way, ExAcquireFastMutex raises your current thread to APC_LEVEL. I
don’t know whethe SEH is safe at PASSIVE_LEVEL or not. So you might want to
verify whether or not using __try/__except is safe or not.
DDK 2600 contains an article titled “Handling Exceptions”, that describes
how to deal with SEH in drivers.
– arlie
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of MM
Sent: Monday, December 19, 2005 9:44 AM
To: Windows File Systems Devs Interest List
Subject: Re: [ntfsd] __try, __finally question
If an exception occors in the kernel, don’t count on your handlers doing a
damn thing. Count on a bsod…
Jon Anglin wrote:
I write a lot of code like the following:
__try {
ExAcquireFastMutex(&lock);
if (something) {
…
__leave;
} else {
…
}
}
__finally {
ExReleaseFastMutex(&lock);
}
I like this because the lock will be freed even if an exception occurs.
Is this bad for performance and/or stack usage in a filter?
Thanks,
Jon
Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
You are currently subscribed to ntfsd as: xxxxx@comcast.net To
unsubscribe send a blank email to xxxxx@lists.osr.com
Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
You are currently subscribed to ntfsd as: xxxxx@stonestreetone.com To
unsubscribe send a blank email to xxxxx@lists.osr.com