C++ exception handlers

Hello All !

Does anybody have any experience into writting C++ exception handlers for NT
kernel mode.
If so please help.

Thanx,
Dennis.


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

You have no runtime support for this in the kernel at all, so you will have
to implement the entire runtime library support. It would be better to
remove exception handling.

-----Original Message-----
From: Dennis S. Dyatlov [mailto:xxxxx@acronis.com]
Sent: Monday, September 03, 2001 10:51 AM
To: NT Developers Interest List
Subject: [ntdev] C++ exception handlers

Hello All !

Does anybody have any experience into writting C++ exception handlers for NT
kernel mode. If so please help.

Thanx,
Dennis.


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


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

say he does not want to remove exception handling. the matter is that he
needs to port a huge library, that uses C++ exceptions to kernel. There are
three ways, to redesign the library (too long), leave lib in user mode and
call it when needed from kernel (too awry), or implement several routines
_RTC_Xxx, _CxxFrameHandler etc.

It isn’t supported. This is obvious. But it is not impossible, I’m sure.
Just asking for advice how to do this if someone else have already
implemented it.

Regards,
Max

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Roddy, Mark
Sent: Tuesday, September 04, 2001 4:24 PM
To: NT Developers Interest List
Subject: [ntdev] RE: C++ exception handlers

You have no runtime support for this in the kernel at all, so you will have
to implement the entire runtime library support. It would be better to
remove exception handling.

-----Original Message-----
From: Dennis S. Dyatlov [mailto:xxxxx@acronis.com]
Sent: Monday, September 03, 2001 10:51 AM
To: NT Developers Interest List
Subject: [ntdev] C++ exception handlers

Hello All !

Does anybody have any experience into writting C++ exception handlers for NT
kernel mode. If so please help.

Thanx,
Dennis.


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


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


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

> Does anybody have any experience into writting C++ exception

handlers for NT kernel mode. If so please help.

You can’t use C++ exceptions in kernel mode but you can use SEH (see article
on www.numega.com)

With MBR, Sergey Khorev


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

Well OK then, I believe the runtime source code is available with the MSDN
Universal subscription. My past experience with this is that translating
from the user mode rtl support to kernel mode is not a big deal. However
exception handling gets a bit fuzzy when we are talking about interrupt
driven execution threads. I’m not sure I understand at all what it means to
handle a C++ exception in this case. The other issue is stack bloat, and
here I am sure that exception handling causes a major hit in stack usage.
This alone may make the ‘port it into the kernel’ approach a non-starter.
The original poster ought to analyze the library’s stack usage in user mode
before bothering with moving it into the kernel.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Max Lyadvinsky
Sent: Tuesday, September 04, 2001 9:43 AM
To: NT Developers Interest List
Subject: [ntdev] RE: C++ exception handlers

say he does not want to remove exception handling. the matter is that he
needs to port a huge library, that uses C++ exceptions to kernel. There are
three ways, to redesign the library (too long), leave lib in user mode and
call it when needed from kernel (too awry), or implement several routines
_RTC_Xxx, _CxxFrameHandler etc.

It isn’t supported. This is obvious. But it is not impossible, I’m sure.
Just asking for advice how to do this if someone else have already
implemented it.

Regards,
Max

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Roddy, Mark
Sent: Tuesday, September 04, 2001 4:24 PM
To: NT Developers Interest List
Subject: [ntdev] RE: C++ exception handlers

You have no runtime support for this in the kernel at all, so you will have
to implement the entire runtime library support. It would be better to
remove exception handling.

-----Original Message-----
From: Dennis S. Dyatlov [mailto:xxxxx@acronis.com]
Sent: Monday, September 03, 2001 10:51 AM
To: NT Developers Interest List
Subject: [ntdev] C++ exception handlers

Hello All !

Does anybody have any experience into writting C++ exception handlers for NT
kernel mode. If so please help.

Thanx,
Dennis.


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


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


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


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

Which library do you want to port to kernel ?

A. Roth

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Max Lyadvinsky
Sent: Tuesday, September 04, 2001 3:43 PM
To: NT Developers Interest List
Subject: [ntdev] RE: C++ exception handlers

say he does not want to remove exception handling. the matter is that he
needs to port a huge library, that uses C++ exceptions to kernel. There are
three ways, to redesign the library (too long), leave lib in user mode and
call it when needed from kernel (too awry), or implement several routines
_RTC_Xxx, _CxxFrameHandler etc.

It isn’t supported. This is obvious. But it is not impossible, I’m sure.
Just asking for advice how to do this if someone else have already
implemented it.

Regards,
Max

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Roddy, Mark
Sent: Tuesday, September 04, 2001 4:24 PM
To: NT Developers Interest List
Subject: [ntdev] RE: C++ exception handlers

You have no runtime support for this in the kernel at all, so you will have
to implement the entire runtime library support. It would be better to
remove exception handling.

-----Original Message-----
From: Dennis S. Dyatlov [mailto:xxxxx@acronis.com]
Sent: Monday, September 03, 2001 10:51 AM
To: NT Developers Interest List
Subject: [ntdev] C++ exception handlers

Hello All !

Does anybody have any experience into writting C++ exception handlers for NT
kernel mode. If so please help.

Thanx,
Dennis.


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


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


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


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

Well, no what that says is what we’ve already stated:

“C++ programmers who are new to kernel mode drivers may be unhappy to learn
that C++ exception handling (using try, catch, and throw) is not available
in drivers. While it would be theoretically possible to implement the
necessary run time support to enable this, the NT kernel does not provide
the necessary functions. The benefits of fully implementing C++ exception
handling in the kernel would not be adequate to offset the increased
overhead.”

You could implement the runtime support. There is no explicit technical
obstacle that would prevent such an implementation.

So the original poster, with his large C++ library that makes extensive use
of C++ exception handling, has a problem without an obvious optimal
solution.

-----Original Message-----
From: Khorev Sergey [mailto:xxxxx@SoftLab.RU]
Sent: Tuesday, September 04, 2001 10:49 AM
To: NT Developers Interest List
Subject: [ntdev] RE: C++ exception handlers

Does anybody have any experience into writting C++ exception
handlers for NT kernel mode. If so please help.

You can’t use C++ exceptions in kernel mode but you can use SEH (see article
on www.numega.com)

With MBR, Sergey Khorev


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


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

don’t know why numega guys failed to implement C++ exceptions support in
their vtoolsd, maybe 'cause this code depends on the compiler version, but I
think if one created such a lib for kernel many of developers would change
their opinion “C++ exceptions in kernel? you must be kidding…”

Regards,
Max

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Khorev Sergey
Sent: Tuesday, September 04, 2001 6:49 PM
To: NT Developers Interest List
Subject: [ntdev] RE: C++ exception handlers

Does anybody have any experience into writting C++ exception
handlers for NT kernel mode. If so please help.

You can’t use C++ exceptions in kernel mode but you can use SEH (see article
on www.numega.com)

With MBR, Sergey Khorev


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


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

Hi Dennis,

Monday, September 03, 2001, 6:50:35 PM, you wrote:

DSD> Hello All !

DSD> Does anybody have any experience into writting C++ exception handlers for NT
DSD> kernel mode.
DSD> If so please help.

DSD> Thanx,
DSD> Dennis.

DSD> —
DSD> You are currently subscribed to ntdev as: xxxxx@infpres.com
DSD> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Nothing difficult. Simply use __try/__except() block to catch
exceptions. All functions that are needed for SEH support are in the
NT Kernel runtime library. For details see MSDN or Visual C++ help.

It may be something like this:

__try
{
ProbeForRead(…);

ntStatus=STATUS_SUCCESS; // Or something else
}

__except(EXCEPTION_EXECUTE_HANDLER)
{
ntStatus=GetExceptionCode();
}

return ntStatus;

Best regards,
Konstantin mailto:xxxxx@infpres.com


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

unfortunately SEH and C++ exceptions are two different things…

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Konstantin Manurin
Sent: Tuesday, September 04, 2001 5:04 PM
To: NT Developers Interest List
Subject: [ntdev] Re: C++ exception handlers

Hi Dennis,

Monday, September 03, 2001, 6:50:35 PM, you wrote:

DSD> Hello All !

DSD> Does anybody have any experience into writting C++ exception handlers
for NT
DSD> kernel mode.
DSD> If so please help.

DSD> Thanx,
DSD> Dennis.

DSD> —
DSD> You are currently subscribed to ntdev as: xxxxx@infpres.com
DSD> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Nothing difficult. Simply use __try/__except() block to catch
exceptions. All functions that are needed for SEH support are in the
NT Kernel runtime library. For details see MSDN or Visual C++ help.

It may be something like this:

__try
{
ProbeForRead(…);

ntStatus=STATUS_SUCCESS; // Or something else
}

__except(EXCEPTION_EXECUTE_HANDLER)
{
ntStatus=GetExceptionCode();
}

return ntStatus;

Best regards,
Konstantin mailto:xxxxx@infpres.com


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


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

C exceptions work fine (and widely used in filesystems), as about C++ -
doubts it is possible, you will need to port a bunch of C++ runtime to the
kernel - __CxxFrameHandler and such.

Why bothering yourself with this?

Max

----- Original Message -----
From: “Dennis S. Dyatlov”
To: “NT Developers Interest List”
Sent: Monday, September 03, 2001 6:50 PM
Subject: [ntdev] C++ exception handlers

> Hello All !
>
> Does anybody have any experience into writting C++ exception handlers for
NT
> kernel mode.
> If so please help.
>
> Thanx,
> Dennis.
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>


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

To do this, you’d have to also set the compiler option to have it generate exception handling code, which produces radically
less efficient code.

My recollection is that Microsoft requires only a restricted set of compiler options for drivers. Would setting such a switch
prevent MS from ever blessing a driver?

-DH
----- Original Message -----
From: “Maxim S. Shatskih”
To: “NT Developers Interest List”
Sent: Wednesday, September 05, 2001 4:25 AM
Subject: [ntdev] Re: C++ exception handlers

> C exceptions work fine (and widely used in filesystems), as about C++ -
> doubts it is possible, you will need to port a bunch of C++ runtime to the
> kernel - __CxxFrameHandler and such.
>
> Why bothering yourself with this?
>
> Max
>
> ----- Original Message -----
> From: “Dennis S. Dyatlov”
> To: “NT Developers Interest List”
> Sent: Monday, September 03, 2001 6:50 PM
> Subject: [ntdev] C++ exception handlers
>
>
> > Hello All !
> >
> > Does anybody have any experience into writting C++ exception handlers for
> NT
> > kernel mode.
> > If so please help.
> >
> > Thanx,
> > Dennis.
> >
> >
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> > To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
> >
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@syssoftsol.com
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


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

Perhaps I’m showing my age, but to me “kernel” always meant the “essential, small, core of the OS”.
C++ exceptions don’t seem to fit in this category, nor does STL, and a “huge library” definitely doesn’t belong there.

-DH

----- Original Message -----
From: “Max Lyadvinsky”
To: “NT Developers Interest List”
Sent: Tuesday, September 04, 2001 1:06 PM
Subject: [ntdev] RE: C++ exception handlers

> don’t know why numega guys failed to implement C++ exceptions support in
> their vtoolsd, maybe 'cause this code depends on the compiler version, but I
> think if one created such a lib for kernel many of developers would change
> their opinion “C++ exceptions in kernel? you must be kidding…”
>
> Regards,
> Max
>
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com]On Behalf Of Khorev Sergey
> Sent: Tuesday, September 04, 2001 6:49 PM
> To: NT Developers Interest List
> Subject: [ntdev] RE: C++ exception handlers
>
>
> > Does anybody have any experience into writting C++ exception
> > handlers for NT kernel mode. If so please help.
>
> You can’t use C++ exceptions in kernel mode but you can use SEH (see article
> on www.numega.com)
>
> With MBR, Sergey Khorev
>
> —
> You are currently subscribed to ntdev as: xxxxx@acronis.com
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@syssoftsol.com
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


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