Can WDK support new operator

I want to know if WDK support “new” and “delete” operator?
I found my driver code with “new” operator cannot be compiled successfully.
but “new” can be used in driverstudio tool? why?

I found a article wrote by Microsoft, which said MS don’t advise driver engineer use C++ to write driver,especially the “new” operator.

thanks

Denny

You need to provide your own global new and delete (or provide them as static operators on your class(es))

d

Sent from my phone with no t9, all spilling mistakes are not intentional.

-----Original Message-----
From: xxxxx@gmail.com
Sent: Sunday, March 01, 2009 7:26 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Can WDK support new operator

I want to know if WDK support “new” and “delete” operator?
I found my driver code with “new” operator cannot be compiled successfully.
but “new” can be used in driverstudio tool? why?

I found a article wrote by Microsoft, which said MS don’t advise driver engineer use C++ to write driver,especially the “new” operator.

thanks

Denny


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

Did you “read” and understand the article from Microsoft? Was it:
http://www.microsoft.com/whdc/driver/kernel/KMcode.mspx ?
Answers for these two questions should be ‘yes’. If not, do it.

Are you fluent in C++ in user mode? Are you addicted to C++ exception
handling in your user mode code?
Answers for these two questions should be ‘no’ as it will be a major effort
on your part to retrain your mind to only think of kernel safe C++
constructs. C++ exceptions will NOT work in the kernel as only SEH is
supported.

Have you ever used ‘placement new’ constructs? Have you ever provided your
own ‘new’ operator in a class to override the standard C++ version available
in the RTL for user mode?

Using the words ‘driverstudio tool’ is a great way to prove your
inexperience, though it can be used to learn if you don’t think it really
works without a lot of effort to fix the bugs.

wrote in message news:xxxxx@ntdev…
>I want to know if WDK support “new” and “delete” operator?
> I found my driver code with “new” operator cannot be compiled
> successfully.
> but “new” can be used in driverstudio tool? why?
>
> I found a article wrote by Microsoft, which said MS don’t advise driver
> engineer use C++ to write driver,especially the “new” operator.
>
> thanks
>
> Denny
>

From:
>I want to know if WDK support “new” and “delete” operator?
> I found my driver code with “new” operator cannot be compiled
> successfully.
> but “new” can be used in driverstudio tool? why?
>
> I found a article wrote by Microsoft, which said MS don’t advise driver
> engineer use C++ to write driver,especially the “new” operator.

Using C++ in the kernel is something that only VERY experienced driver
programmers should attempt. If you didn’t immediately understand Doron’s
answer and how to do what he said, you should not use C++ in a driver.

Walter Oney
Consulting and Training
www.oneysoft.com

On Sun, Mar 01, 2009 at 10:25:15PM -0500, xxxxx@gmail.com wrote:

I want to know if WDK support “new” and “delete” operator?
I found my driver code with “new” operator cannot be compiled successfully.
but “new” can be used in driverstudio tool? why?

The include file <kcom.h> in the DDK includes kernel-friendly definitions
for operator new and operator delete. Even if you don’t use the rest of
the file, you can copy that section to your own include file.

Tim Roberts, xxxxx@probo.com
Providenza & Boeklheide, Inc.</kcom.h>

> but “new” can be used in driverstudio tool? why?

Write your own “operator new” routine, and note that C++ exceptions are not supported in the kernel, so, you will need to check each “new” call for a NULL return manually.

BTW - DriverStudio is a heap of bugs. The sooner you will abandon this product, the better. Use KMDF instead.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

From: “David Craig”
> Using the words ‘driverstudio tool’ is a great way to prove your
> inexperience,

That’s probably a language issue for the OP rather than a failure of
understanding.

Walter Oney
Consulting and Training
www.oneysoft.com

> >Using the words ‘driverstudio tool’ is a great way to prove your inexperience,

That’s probably a language issue for the OP rather than a failure of understanding.

No matter how you look at it, using a framework that had been officially retired 3 years ago , indeed, suggests lack of experience, rather than anything else - I fully agree with David here…

Anton Bassov

That’s because DriverStudio defined the class libraires and header files
needed to use classes in the kernel. However, DriverStudio, which is dead
and buried, produces a piece of crap that will fail PreFast and Driver
Verifier, unless you FIX the DriverStudio files yourself.


The personal opinion of
Gary G. Little

wrote in message news:xxxxx@ntdev…
>I want to know if WDK support “new” and “delete” operator?
> I found my driver code with “new” operator cannot be compiled
> successfully.
> but “new” can be used in driverstudio tool? why?
>
> I found a article wrote by Microsoft, which said MS don’t advise driver
> engineer use C++ to write driver,especially the “new” operator.
>
> thanks
>
> Denny
>

And I suspect you do not want to waste the time to do that, since the last
time I looked DriverStudio was producing over 1000 significant errors by
PreFast (and that was with a PreFast before the full annotations were
supported)! It really is a piece of crap.


Don Burn (MVP, Windows DDK)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr

“Gary G. Little” wrote in message news:xxxxx@ntdev…
> That’s because DriverStudio defined the class libraires and header files
> needed to use classes in the kernel. However, DriverStudio, which is dead
> and buried, produces a piece of crap that will fail PreFast and Driver
> Verifier, unless you FIX the DriverStudio files yourself.
>
> –
> The personal opinion of
> Gary G. Little
>
>
> wrote in message news:xxxxx@ntdev…
>>I want to know if WDK support “new” and “delete” operator?
>> I found my driver code with “new” operator cannot be compiled
>> successfully.
>> but “new” can be used in driverstudio tool? why?
>>
>> I found a article wrote by Microsoft, which said MS don’t advise driver
>> engineer use C++ to write driver,especially the “new” operator.
>>
>> thanks
>>
>> Denny
>>
>
>

From:
> No matter how you look at it, using a framework that had been officially
> retired 3 years ago , indeed, suggests lack of experience, rather than
> anything else - I fully agree with David here…

Hmm. I use Visual Studio v. 6 for all my development. So what does that make
me?

Walter Oney
Consulting and Training
www.oneysoft.com

Old.

Did you REALLY want us to answer that? :slight_smile:

Peter
OSR

From:
> Old.

I’m not old, I’m just thoroughly broken in :slight_smile:

Heck, I’m so old I remember making program drum cards for 026 keypunches,
submitting batch jobs on card decks, reading core dumps at midnight when
turnaround was good, Eisenhower’s first term, 27-cent gasoline, $15,000
houses, the Beatles on Sullivan, and much more…

Walter Oney
Consulting and Training
www.oneysoft.com

> Hmm. I use Visual Studio v. 6 for all my development. So what does that make me?

If we assume that your current work is not limited to the UM development (I am sure it is not), objectively, you just cannot use it for ALL your development - even if you generate your binaries with VC, rather than WDK compiler, you still need WDK headers and libraries. If you mean using Visual Studio v. 6 for writing and managing code…well, I don’t know about other posters, but I don’t see anything particularly wrong with it - after all, this is exactly how I was writing Windows drivers myself. Again, I don’t know about other posters, but my only requirement to code editor is highlighting. For example, my current tool of choice is Gedit, which is nothing more than just a Linux equivalent of Notepad - it does highlighting job fairly well, and this is the only thing I need.

However, we are speaking about totally different thing here - we are speaking about using a_framework_, i.e a set of classes, headers and libraries…

Anton Bassov

Don Burn wrote:

And I suspect you do not want to waste the time to do that,
since the last time I looked DriverStudio was producing over
1000 significant errors by PreFast (and that was with a PreFast
before the full annotations were supported)! It really is a piece
of crap.

Every time DB says DriverStudio has 1,000 errors in PREfast, you have to take a drink.

One drink per bug or one drink per mention :slight_smile: ?

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Monday, March 02, 2009 3:17 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Can WDK support new operator

Don Burn wrote:

And I suspect you do not want to waste the time to do that,
since the last time I looked DriverStudio was producing over
1000 significant errors by PreFast (and that was with a PreFast
before the full annotations were supported)! It really is a piece
of crap.

Every time DB says DriverStudio has 1,000 errors in PREfast, you have to take a drink.


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

Actually it is a lot more than 1000, I had a customer ask me to analyze why
they were crashing so often and the result of running things like PreFast
was their code was good, and Driver Studio was shit.


Don Burn (MVP, Windows DDK)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr

wrote in message news:xxxxx@ntdev…
> Don Burn wrote:
>
>> And I suspect you do not want to waste the time to do that,
>> since the last time I looked DriverStudio was producing over
>> 1000 significant errors by PreFast (and that was with a PreFast
>> before the full annotations were supported)! It really is a piece
>> of crap.
>
> Every time DB says DriverStudio has 1,000 errors in PREfast, you have to
> take a drink.
>

Don Burn wrote:

Actually it is a lot more than 1000, I had a customer ask me
to analyze why they were crashing so often and the result of
running things like PreFast was their code was good, and Driver
Studio was shit.

Room … starting to spin …

thank you everyone all your response.

Denny

Generally, the only type of driver you may use c++ to write is the AVStream
Driver, the driver that interacts with MS Kernel Streaming Framework.

On Mon, Mar 2, 2009 at 11:25 AM, wrote:

> I want to know if WDK support “new” and “delete” operator?
> I found my driver code with “new” operator cannot be compiled successfully.
> but “new” can be used in driverstudio tool? why?
>
> I found a article wrote by Microsoft, which said MS don’t advise driver
> engineer use C++ to write driver,especially the “new” operator.
>
> thanks
>
> Denny
>
> —
> 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
>