C++ support lib for kernel?

Wow, so with c++ randomly misused code can cause bugs? OMFG!**&&%^!*

I am going back to assembler.

Mark Roddy

On Thu, May 19, 2011 at 9:12 PM, wrote:
> All it takes is when someone uses the code with a different version of new that doesn’t do that. It could be as innocent as someone cutting and pasting a snippet of code from a sample or a forum particularly since the Microsoft header file is stupidly zeroing everything that people will look at and say gee, i don’t need to do that anymore in my code since it has become redundant. Then someone else gets this snippet and their standard new doesn’t zero and so garbage is being passed around in their code rather than zeroed values. It might even work–sometimes.
>
>
> —
> NTDEV is sponsored by OSR
>
> 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
>

Shocking, isn’t?

mm

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Mark Roddy
Sent: Friday, May 20, 2011 10:00 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] C++ support lib for kernel?

Wow, so with c++ randomly misused code can cause bugs? OMFG!**&&%^!*

I am going back to assembler.

Mark Roddy

On Thu, May 19, 2011 at 9:12 PM, wrote:
> All it takes is when someone uses the code with a different version of new
that doesn’t do that. It could be as innocent as someone cutting and pasting
a snippet of code from a sample or a forum particularly since the Microsoft
header file is stupidly zeroing everything that people will look at and say
gee, i don’t need to do that anymore in my code since it has become
redundant. Then someone else gets this snippet and their standard new
doesn’t zero and so garbage is being passed around in their code rather than
zeroed values. It might even work–sometimes.
>
>
> —
> NTDEV is sponsored by OSR
>
> 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
>


NTDEV is sponsored by OSR

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

>On the contrary, operator overloading is fantastic in the kernel and
Microsoft has even gone to the trouble of defining some operators for us.
Here is an example. I am eager to to hear how this is evil >and the C way is
superior:

So you’re saying that MSFT encourages use of operator overloading the kernel
in the GENERAL case, because you found this one (somewhere), which I would
agree is indeed very natural?

That’s pretty absurd argument, imo.

// in C we are forced to scour the docs looking for this ridiculous
function
if (IsEqualGUID(&a, &b))

That really is on outrage. I hope that they find that IsEqualGUID bastard
and string him up by the balls.

Save for the C++ hecklers, I am pretty sure everyone else is capable of
picking out DATA() init syntax very naturally. That’s grade school type
stuff you could play “which one of these things is not >like the other” on
sesame street with. It’s just not that hard.

Yeah, I wasn’t really arguing that anyone would be incapable of appending
‘()’ to their new calls. Rather, that if you weren’t especially familiar
with C++, you wouldn’t know to do so, and errors caused by failing to do so
would be hard to find.

X y = new X;

v.

X y = new X();

They look kind of similar, no? And they both compile, without warning.

That’s grade school type stuff you could play “which one of these things is
not like the other” on sesame street with.

How very coy.

?Geesh, I guarantee you if DATA x={}; syntax was a C++ construct to zero
data rather than C then a number of people would be complaining about how
bad and evil it

For the record, I use C++ in a pretty full sense extensively in the kernel.
I just don’t necessarily advocate it as ‘better’ for any given situation,
and I definitely am not on some forced march of Evangelism.

It is quite clear to me that DATA() initialization is one of those cases
where C++ is more suitable than C for writing kernel code.

Yes, I get that. And as I said before, that’s great for you. But maybe not
for everybody else. Or maybe it is. I guess I’m just content to let them
choose for themselves. I’m not sure how you can argue that C++ is more
suitable for writing WINDOWS KERNEL MODE DRIVERS WITH THE WDK. I mean, it’s
unsupported. And you have to provide your own implementation. That’s just
how it is. There’s also this issue of all the kernels out there that people
have SOMEHOW managed to write in ‘C.’ Or Assembler. Or PL/I. In my
opinion, if you look at the history of truly massive software failures, one
of things that they all have in common is that they used a new language/tool
(commonly that was written for that specific project) that few of the
developers had experience with, because ‘it couldn’t be done in else>,’ where was frequently ‘C,’ and the new language was
frequently some 4GL that sucked. Always a bullshit argument. In
particular, several of the first large scale C++ projects outside of Bell
Labs were spectacular failures (see Mentor Graphics), simply because the
authors weren’t familiar with C++ yet bought into the idea that somehow
things would be ‘better’ just by using it. Almost anything produced using
tools with which you are less familiar is going to suffer the learning
curve. Arguing that using C++ for a WINDOWS KERNEL DRIVER is inherently
‘better’ or more ‘suitable’ makes no sense to me, that I use it frequently
and that it can be used just as well, notwithstanding.

mm

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@gmail.com
Sent: Friday, May 20, 2011 4:09 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] C++ support lib for kernel?

> the Kernel is not the place to leverage the more subtle features of c++ -
like, say, operator overloading

On the contrary, operator overloading is fantastic in the kernel and
Microsoft has even gone to the trouble of defining some operators for us.
Here is an example. I am eager to to hear how this is evil and the C way is
superior:

GUID a, b;

// in C we are forced to scour the docs looking for this ridiculous function

if (IsEqualGUID(&a, &b))

// in C++ it just happens naturally; a round of applause for operator ==

if (a == b)

> write your own. No ambiguity. No surprises. Does just what you want

No ambiguity? No surprises? Could not be further from the truth and it is
pretty astonishing to see someone advocate new or delete should do what you
want. So why aren’t we all overriding ExAllocatePool with our own version
that zeros every single allocation out too? And then when Microsoft decides
to include a basic new & delete in the next ntddk.h what are we to do with
our special version, comment out Microsoft’s I guess? Also keep in mind
there is more of a need now to base off or even share source code between
apps, drivers, and other operating systems. Really there are countless
reasons that writing your code to try to elevate undefined behavior to
defined behavior and rely on it could be a time bomb that will cause a
substantial architectural failure on something down the line.

Save for the C++ hecklers, I am pretty sure everyone else is capable of
picking out DATA() init syntax very naturally. That’s grade school type
stuff you could play “which one of these things is not like the other” on
sesame street with. It’s just not that hard. And it absolutely cannot
accidentally zero out the wrong area nor the wrong length which
RtlZeroMemory can, has, and will continue to do from time to time because it
on the other hand absolutely does lend itself to being used incorrectly.
Geesh, I guarantee you if DATA x={}; syntax was a C++ construct to zero data
rather than C then a number of people would be complaining about how bad and
evil it. It is quite clear to me that DATA() initialization is one of those
cases where C++ is more suitable than C for writing kernel code.


NTDEV is sponsored by OSR

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

To get back on the subject - is there anything specific about templates that I should know about? The library
uses them, the driver links and it runs (templates are used in run-time). None of the objects are initialized before
driver entry is run.


Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
http://www.alfasp.com
File system audit, security and encryption kits.

The simplest answer is that as long as you don’t page any code, you’ll have
no problems.

Otherwise, it is possible that the compiler could locate some code it
generates (not just for templates) in a pagable section, which would
obviously be an IRQL issue.

In my experience, I have never seen this happen in the wild, and I had to
try pretty hard to get it to occur intentionally.

That being said, unless you have a really compelling reason not to do so, I
would take the simple answer - don’t page anything.

mm
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Dejan Maksimovic
Sent: Friday, May 20, 2011 11:54 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] C++ support lib for kernel?

To get back on the subject - is there anything specific about templates
that I should know about? The library
uses them, the driver links and it runs (templates are used in run-time).
None of the objects are initialized before
driver entry is run.


Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
http://www.alfasp.com
File system audit, security and encryption kits.


NTDEV is sponsored by OSR

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

Thanks. Somehow, I feel I need to test this a lot more than just DV fault injection though :frowning:

Martin O’Brien wrote:

The simplest answer is that as long as you don’t page any code, you’ll have
no problems.

Otherwise, it is possible that the compiler could locate some code it
generates (not just for templates) in a pagable section, which would
obviously be an IRQL issue.

In my experience, I have never seen this happen in the wild, and I had to
try pretty hard to get it to occur intentionally.

That being said, unless you have a really compelling reason not to do so, I
would take the simple answer - don’t page anything.


Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
http://www.alfasp.com
File system audit, security and encryption kits.

I suspect that you mean test in general - good idea, of course - but if
you’re talking about the compiler generate stuff, you’re going to find
testing it to quite difficult, IMO. Or at least that was my experience
maybe five years ago when I was trying to figure out how realistic the
concerns of placement of compiler generated code were. Conceptually, the
concern made sense to me, but in practice, I didn’t see it occurring, so I
wrote a tool that mapped from symbols to sections, ran it on everything I
generated, and still produced exactly no instances of anything ending up
anywhere unexpected. So I then spent a while trying explicitly to get it to
occur and was able to do so in a few specific cases, but they all required
explicit, somewhat wonky usage of segment #pragma’s. The other thing I
studied at the same time was how much space I was really consuming in the
way of code that could be paged. The answer was very little and nothing
that even charts compared to other nonpaged usage that you can do nothing
about (like by a whole bunch of services that I don’t even know what they do
but all sound the same), so in the end, I just went with not paging
anything.

Never have regretted it, though your mileage may of course vary.

mm

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Dejan Maksimovic
Sent: Friday, May 20, 2011 12:21 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] C++ support lib for kernel?

Thanks. Somehow, I feel I need to test this a lot more than just DV
fault injection though :frowning:

Martin O’Brien wrote:

The simplest answer is that as long as you don’t page any code, you’ll
have
no problems.

Otherwise, it is possible that the compiler could locate some code it
generates (not just for templates) in a pagable section, which would
obviously be an IRQL issue.

In my experience, I have never seen this happen in the wild, and I had to
try pretty hard to get it to occur intentionally.

That being said, unless you have a really compelling reason not to do so,
I
would take the simple answer - don’t page anything.


Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
http://www.alfasp.com
File system audit, security and encryption kits.


NTDEV is sponsored by OSR

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

Use dumpbin to examine the location of stuff.

Mark Roddy

On Fri, May 20, 2011 at 12:21 PM, Dejan Maksimovic wrote:
>
> ? ?Thanks. Somehow, I feel I need to test this a lot more than just DV fault injection though :frowning:
>
> Martin O’Brien wrote:
>
>> The simplest answer is that as long as you don’t page any code, you’ll have
>> no problems.
>>
>> Otherwise, it is possible that the compiler could locate some code it
>> generates (not just for templates) in a pagable section, which would
>> obviously be an IRQL issue.
>>
>> In my experience, I have never seen this happen in the wild, and I had to
>> try pretty hard to get it to occur intentionally.
>>
>> That being said, unless you have a really compelling reason not to do so, I
>> would take the simple answer - don’t page anything.
>>
>
> –
> Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
> http://www.alfasp.com
> File system audit, security and encryption kits.
>
>
>
> —
> NTDEV is sponsored by OSR
>
> 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
>

No, I mean whether something under the hood doesn’t work. The sections are good.

Mark Roddy wrote:

Use dumpbin to examine the location of stuff.

Mark Roddy

On Fri, May 20, 2011 at 12:21 PM, Dejan Maksimovic wrote:
> >
> > Thanks. Somehow, I feel I need to test this a lot more than just DV fault injection though :frowning:
> >
> > Martin O’Brien wrote:
> >
> >> The simplest answer is that as long as you don’t page any code, you’ll have
> >> no problems.
> >>
> >> Otherwise, it is possible that the compiler could locate some code it
> >> generates (not just for templates) in a pagable section, which would
> >> obviously be an IRQL issue.
> >>
> >> In my experience, I have never seen this happen in the wild, and I had to
> >> try pretty hard to get it to occur intentionally.
> >>
> >> That being said, unless you have a really compelling reason not to do so, I
> >> would take the simple answer - don’t page anything.
> >>
> >
> > –
> > Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
> > http://www.alfasp.com
> > File system audit, security and encryption kits.
> >
> >
> >
> > —
> > NTDEV is sponsored by OSR
> >
> > 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
> >
>
> —
> NTDEV is sponsored by OSR
>
> 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


Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
http://www.alfasp.com
File system audit, security and encryption kits.

I am not using paged code for anything. Exactly for the reason you gave - the driver code is so small, saving a
few KBs at most, and then having to test more (or having to change code) is not worth it. It’s not like it’s the
kernel stack consumption size.

The other thing I studied at the same time was how much space I was really consuming in the
way of code that could be paged. The answer was very little and nothing
that even charts compared to other nonpaged usage that you can do nothing
about (like by a whole bunch of services that I don’t even know what they do
but all sound the same), so in the end, I just went with not paging
anything.

Never have regretted it, though your mileage may of course vary.


Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
http://www.alfasp.com
File system audit, security and encryption kits.

How about your initialization code: Do you have a separate INIT
section? If compiler generated code lands there it can be most
unpleasant. However, you will know about it the first time you try to
run your driver. :slight_smile:

Since your driver is small you can afford to disassemble it to see if
the generated object code is what you expected.

The only things, other than programmer error, that don’t work “under
the hood” are c++ exceptions and misplaced code and data. You avoid
c++ exceptions by not using them and you can test for misplacement
either manually using dumpbin or you can automate that effort as
martin suggested. There is nothing else “under the hood” that is some
mystery waiting to happen that needs special effort.

Mark Roddy

On Fri, May 20, 2011 at 1:04 PM, Dejan Maksimovic wrote:
>
> ? ?No, I mean whether something under the hood doesn’t work. The sections are good.
>
> Mark Roddy wrote:
>
>> Use dumpbin to examine the location of stuff.
>>
>> Mark Roddy
>>
>> On Fri, May 20, 2011 at 12:21 PM, Dejan Maksimovic wrote:
>> >
>> > ? ?Thanks. Somehow, I feel I need to test this a lot more than just DV fault injection though :frowning:
>> >
>> > Martin O’Brien wrote:
>> >
>> >> The simplest answer is that as long as you don’t page any code, you’ll have
>> >> no problems.
>> >>
>> >> Otherwise, it is possible that the compiler could locate some code it
>> >> generates (not just for templates) in a pagable section, which would
>> >> obviously be an IRQL issue.
>> >>
>> >> In my experience, I have never seen this happen in the wild, and I had to
>> >> try pretty hard to get it to occur intentionally.
>> >>
>> >> That being said, unless you have a really compelling reason not to do so, I
>> >> would take the simple answer - don’t page anything.
>> >>
>> >
>> > –
>> > Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
>> > http://www.alfasp.com
>> > File system audit, security and encryption kits.
>> >
>> >
>> >
>> > —
>> > NTDEV is sponsored by OSR
>> >
>> > 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
>> >
>>
>> —
>> NTDEV is sponsored by OSR
>>
>> 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
>
> –
> Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
> http://www.alfasp.com
> File system audit, security and encryption kits.
>
>
>
> —
> NTDEV is sponsored by OSR
>
> 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
>

Small addition to the under the hood list - RTTI, but if you’re using that
and haven’t added support for it, you’ll get build errors.

mm
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Mark Roddy
Sent: Friday, May 20, 2011 1:48 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] C++ support lib for kernel?

The only things, other than programmer error, that don’t work “under
the hood” are c++ exceptions and misplaced code and data. You avoid
c++ exceptions by not using them and you can test for misplacement
either manually using dumpbin or you can automate that effort as
martin suggested. There is nothing else “under the hood” that is some
mystery waiting to happen that needs special effort.

Mark Roddy

On Fri, May 20, 2011 at 1:04 PM, Dejan Maksimovic wrote:
>
> ? ?No, I mean whether something under the hood doesn’t work. The sections
are good.
>
> Mark Roddy wrote:
>
>> Use dumpbin to examine the location of stuff.
>>
>> Mark Roddy
>>
>> On Fri, May 20, 2011 at 12:21 PM, Dejan Maksimovic
wrote:
>> >
>> > ? ?Thanks. Somehow, I feel I need to test this a lot more than just DV
fault injection though :frowning:
>> >
>> > Martin O’Brien wrote:
>> >
>> >> The simplest answer is that as long as you don’t page any code, you’ll
have
>> >> no problems.
>> >>
>> >> Otherwise, it is possible that the compiler could locate some code it
>> >> generates (not just for templates) in a pagable section, which would
>> >> obviously be an IRQL issue.
>> >>
>> >> In my experience, I have never seen this happen in the wild, and I had
to
>> >> try pretty hard to get it to occur intentionally.
>> >>
>> >> That being said, unless you have a really compelling reason not to do
so, I
>> >> would take the simple answer - don’t page anything.
>> >>
>> >
>> > –
>> > Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
>> > http://www.alfasp.com
>> > File system audit, security and encryption kits.
>> >
>> >
>> >
>> > —
>> > NTDEV is sponsored by OSR
>> >
>> > 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
>> >
>>
>> —
>> NTDEV is sponsored by OSR
>>
>> 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
>
> –
> Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
> http://www.alfasp.com
> File system audit, security and encryption kits.
>
>
>
> —
> NTDEV is sponsored by OSR
>
> 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
>


NTDEV is sponsored by OSR

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

Rossetoecioccolato wrote:

How about your initialization code: Do you have a separate INIT
section? If compiler generated code lands there it can be most
unpleasant. However, you will know about it the first time you try to
run your driver. :slight_smile:

Since your driver is small you can afford to disassemble it to see if
the generated object code is what you expected.

Yes. Empirically, the compiler’s rule seems to be that whatever code
section pragma is in effect at the end of a source file is used to hold
compiler-generated code, like expanded templates. So, as long as you
set the pragma back to the non-paged section as the last in the source
file, I believe you will be safe.

However, that rule is not written down anywhere in any official
documentation.


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

Cool. C++ exceptions cannot be used anyway (EHsc is always overridden). I’ll run dumpbin next.

D.

Mark Roddy wrote:

The only things, other than programmer error, that don’t work “under
the hood” are c++ exceptions and misplaced code and data. You avoid
c++ exceptions by not using them and you can test for misplacement
either manually using dumpbin or you can automate that effort as
martin suggested. There is nothing else “under the hood” that is some
mystery waiting to happen that needs special effort.

Mark Roddy

On Fri, May 20, 2011 at 1:04 PM, Dejan Maksimovic wrote:
> >
> > No, I mean whether something under the hood doesn’t work. The sections are good.
> >
> > Mark Roddy wrote:
> >
> >> Use dumpbin to examine the location of stuff.
> >>
> >> Mark Roddy
> >>
> >> On Fri, May 20, 2011 at 12:21 PM, Dejan Maksimovic wrote:
> >> >
> >> > Thanks. Somehow, I feel I need to test this a lot more than just DV fault injection though :frowning:
> >> >
> >> > Martin O’Brien wrote:
> >> >
> >> >> The simplest answer is that as long as you don’t page any code, you’ll have
> >> >> no problems.
> >> >>
> >> >> Otherwise, it is possible that the compiler could locate some code it
> >> >> generates (not just for templates) in a pagable section, which would
> >> >> obviously be an IRQL issue.
> >> >>
> >> >> In my experience, I have never seen this happen in the wild, and I had to
> >> >> try pretty hard to get it to occur intentionally.
> >> >>
> >> >> That being said, unless you have a really compelling reason not to do so, I
> >> >> would take the simple answer - don’t page anything.
> >> >>
> >> >
> >> > –
> >> > Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
> >> > http://www.alfasp.com
> >> > File system audit, security and encryption kits.
> >> >
> >> >
> >> >
> >> > —
> >> > NTDEV is sponsored by OSR
> >> >
> >> > 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
> >> >
> >>
> >> —
> >> NTDEV is sponsored by OSR
> >>
> >> 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
> >
> > –
> > Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
> > http://www.alfasp.com
> > File system audit, security and encryption kits.
> >
> >
> >
> > —
> > NTDEV is sponsored by OSR
> >
> > 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
> >
>
> —
> NTDEV is sponsored by OSR
>
> 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


Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
http://www.alfasp.com
File system audit, security and encryption kits.

You might want to check -GR as well.

mm
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Dejan Maksimovic
Sent: Friday, May 20, 2011 2:12 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] C++ support lib for kernel?

Cool. C++ exceptions cannot be used anyway (EHsc is always overridden).
I’ll run dumpbin next.

D.

Mark Roddy wrote:

The only things, other than programmer error, that don’t work “under
the hood” are c++ exceptions and misplaced code and data. You avoid
c++ exceptions by not using them and you can test for misplacement
either manually using dumpbin or you can automate that effort as
martin suggested. There is nothing else “under the hood” that is some
mystery waiting to happen that needs special effort.

Mark Roddy

On Fri, May 20, 2011 at 1:04 PM, Dejan Maksimovic
wrote:
> >
> > No, I mean whether something under the hood doesn’t work. The
sections are good.
> >
> > Mark Roddy wrote:
> >
> >> Use dumpbin to examine the location of stuff.
> >>
> >> Mark Roddy
> >>
> >> On Fri, May 20, 2011 at 12:21 PM, Dejan Maksimovic
wrote:
> >> >
> >> > Thanks. Somehow, I feel I need to test this a lot more than just
DV fault injection though :frowning:
> >> >
> >> > Martin O’Brien wrote:
> >> >
> >> >> The simplest answer is that as long as you don’t page any code,
you’ll have
> >> >> no problems.
> >> >>
> >> >> Otherwise, it is possible that the compiler could locate some code
it
> >> >> generates (not just for templates) in a pagable section, which would
> >> >> obviously be an IRQL issue.
> >> >>
> >> >> In my experience, I have never seen this happen in the wild, and I
had to
> >> >> try pretty hard to get it to occur intentionally.
> >> >>
> >> >> That being said, unless you have a really compelling reason not to
do so, I
> >> >> would take the simple answer - don’t page anything.
> >> >>
> >> >
> >> > –
> >> > Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
> >> > http://www.alfasp.com
> >> > File system audit, security and encryption kits.
> >> >
> >> >
> >> >
> >> > —
> >> > NTDEV is sponsored by OSR
> >> >
> >> > 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
> >> >
> >>
> >> —
> >> NTDEV is sponsored by OSR
> >>
> >> 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
> >
> > –
> > Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
> > http://www.alfasp.com
> > File system audit, security and encryption kits.
> >
> >
> >
> > —
> > NTDEV is sponsored by OSR
> >
> > 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
> >
>
> —
> NTDEV is sponsored by OSR
>
> 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


Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
http://www.alfasp.com
File system audit, security and encryption kits.


NTDEV is sponsored by OSR

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

Not possible, it’s overridden also.

Martin O’Brien wrote:

You might want to check -GR as well.

mm
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Dejan Maksimovic
Sent: Friday, May 20, 2011 2:12 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] C++ support lib for kernel?

Cool. C++ exceptions cannot be used anyway (EHsc is always overridden).
I’ll run dumpbin next.

D.

Mark Roddy wrote:

> The only things, other than programmer error, that don’t work “under
> the hood” are c++ exceptions and misplaced code and data. You avoid
> c++ exceptions by not using them and you can test for misplacement
> either manually using dumpbin or you can automate that effort as
> martin suggested. There is nothing else “under the hood” that is some
> mystery waiting to happen that needs special effort.
>
> Mark Roddy
>
> On Fri, May 20, 2011 at 1:04 PM, Dejan Maksimovic
> wrote:
> > >
> > > No, I mean whether something under the hood doesn’t work. The
> sections are good.
> > >
> > > Mark Roddy wrote:
> > >
> > >> Use dumpbin to examine the location of stuff.
> > >>
> > >> Mark Roddy
> > >>
> > >> On Fri, May 20, 2011 at 12:21 PM, Dejan Maksimovic
> wrote:
> > >> >
> > >> > Thanks. Somehow, I feel I need to test this a lot more than just
> DV fault injection though :frowning:
> > >> >
> > >> > Martin O’Brien wrote:
> > >> >
> > >> >> The simplest answer is that as long as you don’t page any code,
> you’ll have
> > >> >> no problems.
> > >> >>
> > >> >> Otherwise, it is possible that the compiler could locate some code
> it
> > >> >> generates (not just for templates) in a pagable section, which would
> > >> >> obviously be an IRQL issue.
> > >> >>
> > >> >> In my experience, I have never seen this happen in the wild, and I
> had to
> > >> >> try pretty hard to get it to occur intentionally.
> > >> >>
> > >> >> That being said, unless you have a really compelling reason not to
> do so, I
> > >> >> would take the simple answer - don’t page anything.
> > >> >>
> > >> >
> > >> > –
> > >> > Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
> > >> > http://www.alfasp.com
> > >> > File system audit, security and encryption kits.
> > >> >
> > >> >
> > >> >
> > >> > —
> > >> > NTDEV is sponsored by OSR
> > >> >
> > >> > 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
> > >> >
> > >>
> > >> —
> > >> NTDEV is sponsored by OSR
> > >>
> > >> 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
> > >
> > > –
> > > Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
> > > http://www.alfasp.com
> > > File system audit, security and encryption kits.
> > >
> > >
> > >
> > > —
> > > NTDEV is sponsored by OSR
> > >
> > > 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
> > >
> >
> > —
> > NTDEV is sponsored by OSR
> >
> > 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
>
> –
> Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
> http://www.alfasp.com
> File system audit, security and encryption kits.
>
> —
> NTDEV is sponsored by OSR
>
> 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
>
> —
> NTDEV is sponsored by OSR
>
> 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


Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
http://www.alfasp.com
File system audit, security and encryption kits.

Cool

mm

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Dejan Maksimovic
Sent: Friday, May 20, 2011 2:51 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] C++ support lib for kernel?

Not possible, it’s overridden also.

Martin O’Brien wrote:

You might want to check -GR as well.

mm
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Dejan Maksimovic
Sent: Friday, May 20, 2011 2:12 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] C++ support lib for kernel?

Cool. C++ exceptions cannot be used anyway (EHsc is always
overridden).
I’ll run dumpbin next.

D.

Mark Roddy wrote:

> The only things, other than programmer error, that don’t work “under
> the hood” are c++ exceptions and misplaced code and data. You avoid
> c++ exceptions by not using them and you can test for misplacement
> either manually using dumpbin or you can automate that effort as
> martin suggested. There is nothing else “under the hood” that is some
> mystery waiting to happen that needs special effort.
>
> Mark Roddy
>
> On Fri, May 20, 2011 at 1:04 PM, Dejan Maksimovic
> wrote:
> > >
> > > No, I mean whether something under the hood doesn’t work. The
> sections are good.
> > >
> > > Mark Roddy wrote:
> > >
> > >> Use dumpbin to examine the location of stuff.
> > >>
> > >> Mark Roddy
> > >>
> > >> On Fri, May 20, 2011 at 12:21 PM, Dejan Maksimovic
> wrote:
> > >> >
> > >> > Thanks. Somehow, I feel I need to test this a lot more than just
> DV fault injection though :frowning:
> > >> >
> > >> > Martin O’Brien wrote:
> > >> >
> > >> >> The simplest answer is that as long as you don’t page any code,
> you’ll have
> > >> >> no problems.
> > >> >>
> > >> >> Otherwise, it is possible that the compiler could locate some code
> it
> > >> >> generates (not just for templates) in a pagable section, which
would
> > >> >> obviously be an IRQL issue.
> > >> >>
> > >> >> In my experience, I have never seen this happen in the wild, and I
> had to
> > >> >> try pretty hard to get it to occur intentionally.
> > >> >>
> > >> >> That being said, unless you have a really compelling reason not to
> do so, I
> > >> >> would take the simple answer - don’t page anything.
> > >> >>
> > >> >
> > >> > –
> > >> > Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
> > >> > http://www.alfasp.com
> > >> > File system audit, security and encryption kits.
> > >> >
> > >> >
> > >> >
> > >> > —
> > >> > NTDEV is sponsored by OSR
> > >> >
> > >> > 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
> > >> >
> > >>
> > >> —
> > >> NTDEV is sponsored by OSR
> > >>
> > >> 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
> > >
> > > –
> > > Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
> > > http://www.alfasp.com
> > > File system audit, security and encryption kits.
> > >
> > >
> > >
> > > —
> > > NTDEV is sponsored by OSR
> > >
> > > 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
> > >
> >
> > —
> > NTDEV is sponsored by OSR
> >
> > 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
>
> –
> Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
> http://www.alfasp.com
> File system audit, security and encryption kits.
>
> —
> NTDEV is sponsored by OSR
>
> 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
>
> —
> NTDEV is sponsored by OSR
>
> 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


Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
http://www.alfasp.com
File system audit, security and encryption kits.


NTDEV is sponsored by OSR

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

> C++ exceptions cannot be used

For completeness note there is an effort to make C++ exceptions for kernel
usage. See thread:

http://www.osronline.com/showthread.cfm?link=203234

> So you’re saying that MSFT encourages use of operator overloading the kernel
in the GENERAL case

I illustrated operator overloading has a place in drivers and is being used
today thanks to Microsoft, that’s it. You can make fun of it all you want, but I
must have spent a half hour before I figured out how to compare a GUID in C. In
C++ it just worked.

There’s also this issue of all the kernels out there that people have
SOMEHOW managed to write in ‘C.’ Or Assembler. Or PL/I.

Sure, I’ve written very good systems level code in all of those languages. I
used to write a pretty mean rep movsd block of assembler, but found C’s memcpy
pretty cool and less error prone such as I didn’t have to worry about the CPU
direction flag anymore. And the same scenario played out again when I stepped up
to C++ and found it too removed complexity which in turn gave another increase
in productivity.

it’s unsupported. And you have to provide your own implementation.

90% of the things driver people do on a daily basis is make unsupported things
work. If anyone can make something unsupported work, it’s going to be us. It
says something when so many are too willing to add a few functions and pragma’s
to open the gates to C++. There are just too many worthwhile benefits to ignore.
And let’s not forget Microsoft has gone to the extent of publishing a document
on pros and cons of doing this.

if you look at the history of truly massive software failures…several of the
first large scale C++ projects…were spectacular failures

Amen, not just the first ones either. I have witnessed such examples. I even
hated anything C++ for years because the people using it said they were superior
people compared to C people. They claimed object orientation meant they would
write code twice as fast, they would have no bugs making QA irrelevant.
Management liked their story, but they failed over and over. But we aren’t
talking about that kind of C++ or those fools. We are talking about the nuts and
bolts technologies that have nothing to do with object orientation.

I’m not sure how you can argue that C++ is more suitable for writing
WINDOWS KERNEL MODE DRIVERS WITH THE WDK…

Many C++ elements are definitely better suited than C in the kernel and I can
show countless further examples of this. But it seems some people find it easier
to object rather than learn. Comparing guids and dynamic allocation discussed
here are pretty clearcut cases. Let’s just recap allocation once again:

// C

DATA *x = ExAllocatePoolWithTag(NonPagedPool, sizeof(*x), ‘xyzw’);

RtlZeroMemory(x, sizeof(*x));

// C++

DATA *x = new DATA();

C++ kicks the unnecessary fluff out of the code both vertically and horizontally
meanwhile alternate pools and pooltags can still be used when needed. If you
don’t see that as an advantage then I guess you are also one who enjoys
explicitly passing TRUE, TRUE, TRUE to the end of every single
IoSetCompletionRoutine call and FALSE to the end of every KeSetEvent. Anyway,
moving past the elegance of the C++ form, the C++ way also guarantees the right
size is allocated and the right area is zeroed, C does nothing there. And there
are other advantages…for the C++ way the compiler will check your code at
compile time for you unlike the C way. It checks if you try to use x without
checking for null first. It check that you free it somewhere down the line. It
checks that you don’t touch it after you free it, etc. Just so many
opportunities to enhance code quality and developer productivity. It rocks. And
maybe best of all, you are still completely free to use the C way if for any
reason you so choose.

Almost anything produced using tools with which you are less familiar is going
to suffer…

Agree. To me that has to be the most relevant argument against C++ in the
kernel. It’s a massive language and many here never learned any C++. The
language continues to be enhanced as time goes on too. Some parts can be used
well by anyone, others not. C can and is misused as well, but C++ more so.

I definitely am not on some forced march of Evangelism.

Me either. But knowing firsthand what C++ can do for drivers I will cry foul
when people make claims that it’s junk.