ExAllocatePoolWithQuota throws an exception

As such I’m wrapping in a try{}/except{}, but my catch condition is EXCEPTION_EXECUTE_HANDLER. PreFAST doesn’t much care for me doing this saying it could mask exceptions that weren’t meant to be handled.

So, what exceptions should I be catching from ExAllocatePoolWithQuota?

To be clear, I haven’t actually gotten the allocation to throw the exception.

Why are you using ExAllocatePoolWithQuota in the first place?

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@hotmail.com
Sent: Friday, June 21, 2013 2:46 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] ExAllocatePoolWithQuota throws an exception

As such I’m wrapping in a try{}/except{}, but my catch condition is EXCEPTION_EXECUTE_HANDLER. PreFAST doesn’t much care for me doing this saying it could mask exceptions that weren’t meant to be handled.

So, what exceptions should I be catching from ExAllocatePoolWithQuota?

To be clear, I haven’t actually gotten the allocation to throw the exception.


NTDEV is sponsored by OSR

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

xxxxx@hotmail.com wrote:

As such I’m wrapping in a try{}/except{}, but my catch condition is EXCEPTION_EXECUTE_HANDLER. PreFAST doesn’t much care for me doing this saying it could mask exceptions that weren’t meant to be handled.

So, what exceptions should I be catching from ExAllocatePoolWithQuota?

Exception handling is expensive, and ExAllocatePoolWithQuota is
deprecated. Why don’t you use ExAllocatePoolWithQuotaTag, which lets
you ask for a failure instead of an exception?


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

I’m building an old wdk sample and interrogating the PreFAST findings. I haven’t found too many system calls that throw exceptions, but this one got me curious. I was considering using a snippet of this sample in my driver.

It looks like an allocation is being made while still in the context of the caller. I’ll definitely use ExAllocatePoolWithQuotaTag specifying POOL_QUOTA_FAIL_INSTEAD_OF_RAISE when I do it. My curiosity was piqued with the exception thrown by the older variety of this particular allocation though.

> As such I’m wrapping in a try{}/except{}, but my catch condition is

EXCEPTION_EXECUTE_HANDLER. PreFAST doesn’t much care for me doing this
saying it could mask exceptions that weren’t meant to be handled.

So, what exceptions should I be catching from ExAllocatePoolWithQuota?

To be clear, I haven’t actually gotten the allocation to throw the
exception.

That said, it is a common failure in the Microsoft documentation to use
the meaningless phrase “raise AN exception”, which is nonsensical
documentation. The exceptions have numbers, and why would it
inconvenience the documentation team to insist that the developers tell
them the exact symbolic name associated with the exception value.
joe

You should not be catching exceptions at all. PreFAST is correct. RTFM.
What part of “is obsolete” did you miss?


NTDEV is sponsored by OSR

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

I once worked on a system where the ONLY way the OS could signal an API
failure was to throw an exception. I am of very mixed mind on this. For
one thing, it meant that you almost always needed one exception frame per
API, which was really painful. On the other, it was completely uniform;
there were no APIs that returned FALSE, 0, -1, etc. And the exception was
one of a limited number of exceptions reserved by the operating system. I
think we had 16 reserved exceptions, but only used one of them.
Therefore, it was possible to change the exception code raised by throwing
a user-defined exception code. which was a powerful mechanism.

The fact that the value of the exception thrown is considered Top Secret
in Windows is a real annoyance. We don’t know what the range of OS
exception codes are, or if an internal call can raise more than one
particular value. This makes the idea of throwing exceptions next to
useless.
joe

I’m building an old wdk sample and interrogating the PreFAST findings. I
haven’t found too many system calls that throw exceptions, but this one
got me curious. I was considering using a snippet of this sample in my
driver.

It looks like an allocation is being made while still in the context of
the caller. I’ll definitely use ExAllocatePoolWithQuotaTag specifying
POOL_QUOTA_FAIL_INSTEAD_OF_RAISE when I do it. My curiosity was piqued
with the exception thrown by the older variety of this particular
allocation though.


NTDEV is sponsored by OSR

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer