build problems with AbnormalTermination

>----------------------------------------------------------------------

Subject: AbnormalTermination() cause Errror!!
From: xxxxx@esecurity.co.kr
Date: Thu, 5 Jul 2001 1:51:28
X-Message-Number: 1

Hi~~

I read over FASTFAT source in the IFS KIT.

And I copy some function to my own File System Filter Driver

( that is based on tfilter) But AbnormalTermination() causes some error.

Error code is C2707 :
_exception_code() was called outside an exception filter or __except block
_exception_info() was called outside an exception filter
_abnormal_termination() was called outside a __finally block

But I use this within __finally block.

Do you know what causes error?

These errors are “self explanatory if you understand them”.
#define GetExceptionCode() _exception_code()
#define GetExceptionInformation or Pointers or Info, I forget,
_exception_info()
#define AbnormalTermination() _abnormal_termination
look in except.h or excpt.h or ex*.h or x*.h or similar.

The following examples are all legal:

void F()
{
__try
{
}
__finally
{
if (AbnormalTermination())
{
}
}

void F()
{
__try
{
}
__except(GetExceptionCode() == 1234 ? 567 : 8912) /* BUT DON’t USE THESE
BOGUS VALUES */
{
}
}

int F1(LPEXCEPTION_POINTERS or INFO or RECORD or somesuch)
{
}

int F2(DWORD ExceptionCode)
{
}

void F2()
{
__try
{
} __except (F1(GetExceptionInfo())
{
}
__try
{
} __except (F2(GetExceptionCode())
{
}
}

The following examples are NOT legal
void NotLegal() { AbnormalTermination(); }
void NotLegal() { GetExceptionCode(); }
void NotLegal() { GetExceptionInformation or GetExceptionPointers or
somesuch(); }
void NotLegal() { __try { } __finally { GetExceptionCode(); } }
void NotLegal() { __try { } __finally { GetExceptionInformation or
GetExceptionPointers or somesuch(); } }
void IdontThinkThisIsLegal { __try {} __except(…)
{ AbnormalTermination(); } }

To summarize what is legal and what is not:

AbnormalTermination is legal in a __finally block
AbnormalTermination might be legal in an __except block, but I think not

GetExcpetionCode and GetExceptionInformation are only legal in the __except
expression (aka “filter”, not the block)

These three functions are not legal anywhere else, including in a __try
block, or an “normal” places.

And all the “not legal” cases are flagged by the compiler at compile time.

The results of these three functions can be passed outside the
block/expression/whatever to other functions, but they must be called from
inside the special places.

I believe this is all clearly documented besides…

  • Jay

You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com