RE: A guide to writing device drivers in c++

No, I don’t think you have a long way to go. And you don’t even need
DriverStudio. :slight_smile:

Let me suggest an easy way into C++. I’d start by renaming my files “.cpp”.
That may require something like

extern “C”
{
#include <blah.h>
}

or whatever, and also prefix your function prototypes and declarations with
extern “C” as well, for example,

extern “C” NTSTATUS CdOpen(IN PDEVICE_OBJECT pdo, IN PIRP pIrp);

Once you get over that hump, you can just start structuring your code as
classes: whenever you have a structure, make a class instead, and put
methods in it. For example, if you have

struct BLAH
{

}
blah, *pblah;



NTSTATUS doMyBlah(pblah b, char *s);



if (doMyBlah(b,s) == STATUS_SUCCESS) { … }

Becomes

class blah
{
private:

public:

NTSTATUS doMyBlah(char *s = NULL)
{ … };
};



if (b.doMyBlah(s) == STATUS_SUCCESS) { … }

And now, as the first bonus, you can call it as

status = b.doMyBlah();

And so on, the rest is design. If all objects you create are on the stack,
you don’t need to worry, but if you create global objects you will have to
override the new() operator to make C++ get space from the NonPaged pool. No
big deal, just two additional functions in your class.

You can also take advantage of inheritance, for example,

class IRP { … } ;
class pnpIRP : IRP { … };
class startDeviceIRP : pnpIRP { … };
class stopDeviceIRP : pnpIRP { … };

and use virtual functions to improve your logic. We use a lot of C++ in
BoundsChecker, and both the TrueTime and TrueCoverage drivers were generated
by DriverWorks. Works fine.

Alberto.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Jamey Kirby
Sent: Wednesday, February 11, 2004 12:59 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A giuide to writing device drivers in c++

You have a long way to go baby!

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Robert Fernando
-ntlworld
Sent: Wednesday, February 11, 2004 3:00 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] A giuide to writing device drivers in c++

Hi all,
Is there a good guide / samples which will outline how you use c++ to
develop a windows device driver.
I know about developing windows device drivers in c.

thanks

Robert Fernando
www.rowanclose.com


Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.583 / Virus Database: 369 - Release Date: 10/02/2004


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@storagecraft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it.</blah.h>

DriverWorks 3.1 has a C Wizard !

Alberto.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Jamey Kirby
Sent: Wednesday, February 11, 2004 2:02 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A giuide to writing device drivers in c++

Because it promotes C++ in device drivers; no other reason…

Jamey

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Moreira, Alberto
Sent: Wednesday, February 11, 2004 10:26 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A giuide to writing device drivers in c++

Why ? Constructive criticism is always wanted, we’ll do our best to
incorporate it in our next releases.

Alberto.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Jamey Kirby
Sent: Wednesday, February 11, 2004 1:00 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A giuide to writing device drivers in c++

Sucks

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Loren Wilton
Sent: Wednesday, February 11, 2004 3:25 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] A giuide to writing device drivers in c++

DriverStudio.

Hi all,
Is there a good guide / samples which will outline how you use c++ to
develop a windows device driver.
I know about developing windows device drivers in c.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@storagecraft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@storagecraft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it.

> You can also take advantage of inheritance, for example,

class IRP { … } ;
class pnpIRP : IRP { … };
class startDeviceIRP : pnpIRP { … };
class stopDeviceIRP : pnpIRP { … };

class BIT {…};
class BYTE:BIT {…};
class U16:BYTE {…};
class U32:U16 {…};

-:wink:

Calvin Guan Software Engineer
ATI Technologies Inc. www.ati.com

Depends on your granularity, no ? If you need a lot of bit-level
functionality, maybe set things up in your way makes sense.

Alberto.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Calvin Guan
Sent: Wednesday, February 11, 2004 3:05 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device drivers in c++

You can also take advantage of inheritance, for example,

class IRP { … } ;
class pnpIRP : IRP { … };
class startDeviceIRP : pnpIRP { … };
class stopDeviceIRP : pnpIRP { … };

class BIT {…};
class BYTE:BIT {…};
class U16:BYTE {…};
class U32:U16 {…};

-:wink:

Calvin Guan Software Engineer
ATI Technologies Inc. www.ati.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it.

Nice. Now remind me why I need it? What does it give me that the DDK does
not give me; except maybe 500 more APIs to learn

Jamey

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Moreira, Alberto
Sent: Wednesday, February 11, 2004 11:05 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device drivers in c++

DriverWorks 3.1 has a C Wizard !

Alberto.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Jamey Kirby
Sent: Wednesday, February 11, 2004 2:02 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A giuide to writing device drivers in c++

Because it promotes C++ in device drivers; no other reason…

Jamey

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Moreira, Alberto
Sent: Wednesday, February 11, 2004 10:26 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A giuide to writing device drivers in c++

Why ? Constructive criticism is always wanted, we’ll do our best to
incorporate it in our next releases.

Alberto.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Jamey Kirby
Sent: Wednesday, February 11, 2004 1:00 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A giuide to writing device drivers in c++

Sucks

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Loren Wilton
Sent: Wednesday, February 11, 2004 3:25 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] A giuide to writing device drivers in c++

DriverStudio.

Hi all,
Is there a good guide / samples which will outline how you use c++ to
develop a windows device driver.
I know about developing windows device drivers in c.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@storagecraft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@storagecraft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@storagecraft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Keep on preaching.


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Calvin Guan
Sent: Wednesday, February 11, 2004 12:05 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device drivers in c++

You can also take advantage of inheritance, for example,

class IRP { … } ;
class pnpIRP : IRP { … };
class startDeviceIRP : pnpIRP { … };
class stopDeviceIRP : pnpIRP { … };

class BIT {…};
class BYTE:BIT {…};
class U16:BYTE {…};
class U32:U16 {…};

-:wink:

Calvin Guan Software Engineer
ATI Technologies Inc. www.ati.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@storagecraft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

So, it is better to call a class rather than X |= 0x01?

Maybe I am getting to old; I can even figure out how to use 1/3rd of my cell
phones features.


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Moreira, Alberto
Sent: Wednesday, February 11, 2004 12:12 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device drivers in c++

Depends on your granularity, no ? If you need a lot of bit-level
functionality, maybe set things up in your way makes sense.

Alberto.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Calvin Guan
Sent: Wednesday, February 11, 2004 3:05 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device drivers in c++

You can also take advantage of inheritance, for example,

class IRP { … } ;
class pnpIRP : IRP { … };
class startDeviceIRP : pnpIRP { … };
class stopDeviceIRP : pnpIRP { … };

class BIT {…};
class BYTE:BIT {…};
class U16:BYTE {…};
class U32:U16 {…};

-:wink:

Calvin Guan Software Engineer
ATI Technologies Inc. www.ati.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@storagecraft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it.

RE: [ntdev] A guide to writing device drivers in c++> “Jamey Kirby”
wrote in message news:xxxxx@ntdev…
> So, it is better to call a class rather than X |= 0x01?
> Maybe I am getting to old; I can even figure out how to use 1/3rd of my
cell phones features.

Hi!

Maybe you never write an audio minidriver? Please, only think how to
implement COM objects
on C! (I believe it’s possible, but IMHO it simply terrible);

S.Y.
Igor

In C++, the scribble “|=” stands for an operator. So, I can overload it
inside my class and get it to be whatever I need it to be.

Alberto.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Jamey Kirby
Sent: Wednesday, February 11, 2004 6:27 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device drivers in c++

So, it is better to call a class rather than X |= 0x01?

Maybe I am getting to old; I can even figure out how to use 1/3rd of my cell
phones features.


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Moreira, Alberto
Sent: Wednesday, February 11, 2004 12:12 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device drivers in c++

Depends on your granularity, no ? If you need a lot of bit-level
functionality, maybe set things up in your way makes sense.

Alberto.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Calvin Guan
Sent: Wednesday, February 11, 2004 3:05 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device drivers in c++

You can also take advantage of inheritance, for example,

class IRP { … } ;
class pnpIRP : IRP { … };
class startDeviceIRP : pnpIRP { … };
class stopDeviceIRP : pnpIRP { … };

class BIT {…};
class BYTE:BIT {…};
class U16:BYTE {…};
class U32:U16 {…};

-:wink:

Calvin Guan Software Engineer
ATI Technologies Inc. www.ati.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@storagecraft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it.

The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it.

Great, that must be fun code to read through. X |= 0x04 equals 42 for all
values of X being prime

Peter Scott
xxxxx@KernelDrivers.com
www.KernelDrivers.com


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Moreira, Alberto
Sent: Thursday, February 12, 2004 7:54 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device drivers in c++

In C++, the scribble “|=” stands for an operator. So, I can overload it
inside my class and get it to be whatever I need it to be.

Alberto.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Jamey Kirby
Sent: Wednesday, February 11, 2004 6:27 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device drivers in c++

So, it is better to call a class rather than X |= 0x01?

Maybe I am getting to old; I can even figure out how to use 1/3rd of my cell
phones features.


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Moreira, Alberto
Sent: Wednesday, February 11, 2004 12:12 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device drivers in c++

Depends on your granularity, no ? If you need a lot of bit-level
functionality, maybe set things up in your way makes sense.

Alberto.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Calvin Guan
Sent: Wednesday, February 11, 2004 3:05 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device drivers in c++

You can also take advantage of inheritance, for example,

class IRP { … } ;
class pnpIRP : IRP { … };
class startDeviceIRP : pnpIRP { … };
class stopDeviceIRP : pnpIRP { … };

class BIT {…};
class BYTE:BIT {…};
class U16:BYTE {…};
class U32:U16 {…};

-:wink:

Calvin Guan Software Engineer
ATI Technologies Inc. www.ati.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@storagecraft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@kerneldrivers.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it.

You said that DriverWorks “sucks” because it promotes C++. I say, we do C as
well. Now, if you want to use the DDK only, more power to you - but that’s
your own choice, just don’t blame it on our product !

Alberto.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Jamey Kirby
Sent: Wednesday, February 11, 2004 6:21 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device drivers in c++

Nice. Now remind me why I need it? What does it give me that the DDK does
not give me; except maybe 500 more APIs to learn

Jamey

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Moreira, Alberto
Sent: Wednesday, February 11, 2004 11:05 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device drivers in c++

DriverWorks 3.1 has a C Wizard !

Alberto.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Jamey Kirby
Sent: Wednesday, February 11, 2004 2:02 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A giuide to writing device drivers in c++

Because it promotes C++ in device drivers; no other reason…

Jamey

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Moreira, Alberto
Sent: Wednesday, February 11, 2004 10:26 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A giuide to writing device drivers in c++

Why ? Constructive criticism is always wanted, we’ll do our best to
incorporate it in our next releases.

Alberto.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Jamey Kirby
Sent: Wednesday, February 11, 2004 1:00 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A giuide to writing device drivers in c++

Sucks

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Loren Wilton
Sent: Wednesday, February 11, 2004 3:25 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] A giuide to writing device drivers in c++

DriverStudio.

Hi all,
Is there a good guide / samples which will outline how you use c++ to
develop a windows device driver.
I know about developing windows device drivers in c.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@storagecraft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@storagecraft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@storagecraft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it.

It takes to learn that operator semantics, just like function semantics, now
belong *inside their class*, they’re no longer global. So, if I say c=a+b,
the result I get depends on the definition of the operator “+”. If a, b and
c are strings, for example, “+” may mean concatenation. Welcome to object
orientation !

If you want the definition of |=, just look at the declaration of the
respective class in the .h file.

Alberto.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Peter Scott
Sent: Thursday, February 12, 2004 11:20 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device drivers in c++

Great, that must be fun code to read through. X |= 0x04 equals 42 for all
values of X being prime

Peter Scott
xxxxx@KernelDrivers.com
www.KernelDrivers.com


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Moreira, Alberto
Sent: Thursday, February 12, 2004 7:54 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device drivers in c++

In C++, the scribble “|=” stands for an operator. So, I can overload it
inside my class and get it to be whatever I need it to be.

Alberto.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Jamey Kirby
Sent: Wednesday, February 11, 2004 6:27 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device drivers in c++

So, it is better to call a class rather than X |= 0x01?

Maybe I am getting to old; I can even figure out how to use 1/3rd of my cell
phones features.


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Moreira, Alberto
Sent: Wednesday, February 11, 2004 12:12 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device drivers in c++

Depends on your granularity, no ? If you need a lot of bit-level
functionality, maybe set things up in your way makes sense.

Alberto.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Calvin Guan
Sent: Wednesday, February 11, 2004 3:05 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device drivers in c++

You can also take advantage of inheritance, for example,

class IRP { … } ;
class pnpIRP : IRP { … };
class startDeviceIRP : pnpIRP { … };
class stopDeviceIRP : pnpIRP { … };

class BIT {…};
class BYTE:BIT {…};
class U16:BYTE {…};
class U32:U16 {…};

-:wink:

Calvin Guan Software Engineer
ATI Technologies Inc. www.ati.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@storagecraft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@kerneldrivers.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it.

The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it.

Operator overload is hardly ever justified as it makes code comprehension
very difficult and consequently causes unintended consequence bugs as a
software product evolves over time. You could not have picked a better
example of why NOT to use C++.

=====================
Mark Roddy


From: Moreira, Alberto [mailto:xxxxx@compuware.com]
Sent: Thursday, February 12, 2004 11:25 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device drivers in c++

It takes to learn that operator semantics, just like function
semantics, now belong *inside their class*, they’re no longer global. So, if
I say c=a+b, the result I get depends on the definition of the operator “+”.
If a, b and c are strings, for example, “+” may mean concatenation. Welcome
to object orientation !

If you want the definition of |=, just look at the declaration of
the respective class in the .h file.

Alberto.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Peter Scott
Sent: Thursday, February 12, 2004 11:20 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device drivers in
c++

Great, that must be fun code to read through. X |= 0x04
equals 42 for all values of X being prime

Peter Scott
xxxxx@KernelDrivers.com
www.KernelDrivers.com


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Moreira, Alberto
Sent: Thursday, February 12, 2004 7:54 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device drivers in
c++

In C++, the scribble “|=” stands for an operator. So, I can
overload it inside my class and get it to be whatever I need it to be.

Alberto.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Jamey Kirby
Sent: Wednesday, February 11, 2004 6:27 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device drivers in
c++

So, it is better to call a class rather than X |=
0x01?

Maybe I am getting to old; I can even figure out how
to use 1/3rd of my cell phones features.


From:
xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com]
On Behalf Of Moreira, Alberto
Sent: Wednesday, February 11, 2004 12:12 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device
drivers in c++

Depends on your granularity, no ? If you need a lot
of bit-level functionality, maybe set things up in your way makes sense.

Alberto.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Calvin Guan
Sent: Wednesday, February 11, 2004 3:05 PM
To: Windows System Software Devs Interest
List
Subject: RE: [ntdev] A guide to writing
device drivers in c++

You can also take advantage of
inheritance, for example,
>
> class IRP { … } ;
> class pnpIRP : IRP { … };
> class startDeviceIRP : pnpIRP { … };
> class stopDeviceIRP : pnpIRP { … };

class BIT {…};
class BYTE:BIT {…};
class U16:BYTE {…};
class U32:U16 {…};

-:wink:

Calvin Guan Software Engineer
ATI Technologies Inc. www.ati.com


Questions? First check the Kernel Driver FAQ
at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as:
xxxxx@compuware.com
To unsubscribe send a blank email to
xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as:
xxxxx@storagecraft.com
To unsubscribe send a blank email to
xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as:
xxxxx@compuware.com
To unsubscribe send a blank email to
xxxxx@lists.osr.com

The contents of this e-mail are intended for the
named addressee only. It contains information that may be confidential.
Unless you are the named addressee or an authorized designee, you may not
copy or use it, or disclose it to anyone else. If you received it in error
please notify us immediately and then destroy it.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as:
xxxxx@kerneldrivers.com
To unsubscribe send a blank email to
xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as:
xxxxx@compuware.com
To unsubscribe send a blank email to
xxxxx@lists.osr.com

The contents of this e-mail are intended for the named
addressee only. It contains information that may be confidential. Unless you
are the named addressee or an authorized designee, you may not copy or use
it, or disclose it to anyone else. If you received it in error please notify
us immediately and then destroy it.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@stratus.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

The contents of this e-mail are intended for the named addressee
only. It contains information that may be confidential. Unless you are the
named addressee or an authorized designee, you may not copy or use it, or
disclose it to anyone else. If you received it in error please notify us
immediately and then destroy it.

So, for our nbits math (to reflect hardware registers, buffers, etc that
have n bit width), we should use
AddInt3(&a, a, b);
instead of
a += b;
when a and/or b is a int3 that is a three-bit value?

Just teasing. :wink:

I know what you mean, and agree. There are very good reasons to sometimes
use operator overload. But it should be used sparingly and with good
thoughs.

It’s very easy to have overload overload (pun intended) and start using
overloads here, there and everywhere, because it seems like a “neat idea”.

But at the same time, it really IS brilliant to be able to do simple math
with integers of varying width in our simulator. And it would be MUCH harder
to do if we didn’t use overloaded operators in C++. In fact, it’s probably
one of the best features in C++ when used to write a simulator for a chip.
(Another alternative would of course to write a VHDL compiler, and use VHDL
to describe registers and other parts as n bits wide, and then get the
correct result).

Complex number math and String assignment with = or concatenation with + are
some other examples of reasonable use of operator overloads, but it’s easy
for a novice to think that the simple operator sign is actually just a
single instruction (or a few instructions), when in fact it’s copying, say,
200 bytes of data.

C++ is a good tool when used correctly, but same as with a chainsaw, it’s
got enough power to make it very dangerous if used incorrectly.

I’m by no means saying that writing drivers in C++ is a particularly good
idea, but sometimes I actually think to myself “This would be so much easier
if we could just inherit the original structure and override the three
functions that are different”. This is particularly when (like now) I’m
writing a piece of code that is for a variation on a previous chip, just
slightly different in a few places. You end up with lots of “if (x)
something; else someother;” in the code. With classes and inheritance, it
would be fairly trivial to implement a different member function for
particular functionalities that are different, and keeping the other bits
the same. I’m essentially doing this anyway, but we’re using function
pointers, so I’m calling InitTypeB, which calls InitTypeA and then
overwrites a few of the function pointers… This type of thing would happen
automatically in C++…

But at the same time, things that happen automatically is dangerous. If it’s
written explicitly in the code, you know it’s happening. If it’s not written
in the code, you need to understand more about what’s going on in the system
to understand what’s actually happening. That’s a big danger with C++.


Mats

-----Original Message-----
From: Roddy, Mark [mailto:xxxxx@stratus.com]
Sent: Thursday, February 12, 2004 5:38 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device drivers in c++

Operator overload is hardly ever justified as it makes code
comprehension
very difficult and consequently causes unintended consequence
bugs as a
software product evolves over time. You could not have picked a better
example of why NOT to use C++.

=====================
Mark Roddy


From: Moreira, Alberto [mailto:xxxxx@compuware.com]
Sent: Thursday, February 12, 2004 11:25 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device drivers in c++

It takes to learn that operator semantics, just like function
semantics, now belong *inside their class*, they’re no longer
global. So, if
I say c=a+b, the result I get depends on the definition of
the operator “+”.
If a, b and c are strings, for example, “+” may mean
concatenation. Welcome
to object orientation !

If you want the definition of |=, just look at the
declaration of
the respective class in the .h file.

Alberto.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Peter Scott
Sent: Thursday, February 12, 2004 11:20 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device
drivers in
c++

Great, that must be fun code to read through. X |= 0x04
equals 42 for all values of X being prime

Peter Scott
xxxxx@KernelDrivers.com
www.KernelDrivers.com


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
Moreira, Alberto
Sent: Thursday, February 12, 2004 7:54 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device
drivers in
c++

In C++, the scribble “|=” stands for an
operator. So, I can
overload it inside my class and get it to be whatever I need
it to be.

Alberto.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Jamey Kirby
Sent: Wednesday, February 11, 2004 6:27 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device
drivers in
c++

So, it is better to call a class rather
than X |=
0x01?

Maybe I am getting to old; I can even
figure out how
to use 1/3rd of my cell phones features.


From:
xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]
On Behalf Of Moreira, Alberto
Sent: Wednesday, February 11, 2004 12:12 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device
drivers in c++

Depends on your granularity, no ? If
you need a lot
of bit-level functionality, maybe set things up in your way
makes sense.

Alberto.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Calvin Guan
Sent: Wednesday, February 11,
2004 3:05 PM
To: Windows System Software
Devs Interest
List
Subject: RE: [ntdev] A guide to writing
device drivers in c++

> You can also take advantage of
inheritance, for example,
>
> class IRP { … } ;
> class pnpIRP : IRP { … };
> class startDeviceIRP : pnpIRP
{ … };
> class stopDeviceIRP : pnpIRP
{ … };

class BIT {…};
class BYTE:BIT {…};
class U16:BYTE {…};
class U32:U16 {…};

-:wink:

Calvin Guan Software Engineer
ATI Technologies Inc. www.ati.com


Questions? First check the
Kernel Driver FAQ
at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to
ntdev as:
xxxxx@compuware.com
To unsubscribe send a blank email to
xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as:
xxxxx@storagecraft.com
To unsubscribe send a blank email to
xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as:
xxxxx@compuware.com
To unsubscribe send a blank email to
xxxxx@lists.osr.com

The contents of this e-mail are intended for the
named addressee only. It contains information that may be
confidential.
Unless you are the named addressee or an authorized designee,
you may not
copy or use it, or disclose it to anyone else. If you
received it in error
please notify us immediately and then destroy it.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as:
xxxxx@kerneldrivers.com
To unsubscribe send a blank email to
xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as:
xxxxx@compuware.com
To unsubscribe send a blank email to
xxxxx@lists.osr.com

The contents of this e-mail are intended for the named
addressee only. It contains information that may be
confidential. Unless you
are the named addressee or an authorized designee, you may
not copy or use
it, or disclose it to anyone else. If you received it in
error please notify
us immediately and then destroy it.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@stratus.com
To unsubscribe send a blank email to
xxxxx@lists.osr.com

The contents of this e-mail are intended for the named addressee
only. It contains information that may be confidential.
Unless you are the
named addressee or an authorized designee, you may not copy
or use it, or
disclose it to anyone else. If you received it in error
please notify us
immediately and then destroy it.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@3dlabs.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Well that is why I said “hardly ever justified”, it left me with plausible
deniability, which seems to be the modus operandi for public utterances
these days :slight_smile:

=====================
Mark Roddy

-----Original Message-----
From: xxxxx@3Dlabs.com [mailto:xxxxx@3Dlabs.com]
Sent: Thursday, February 12, 2004 1:00 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device drivers in c++

So, for our nbits math (to reflect hardware registers,
buffers, etc that have n bit width), we should use
AddInt3(&a, a, b);
instead of
a += b;
when a and/or b is a int3 that is a three-bit value?

Just teasing. :wink:

I know what you mean, and agree. There are very good reasons
to sometimes use operator overload. But it should be used
sparingly and with good thoughs.

It’s very easy to have overload overload (pun intended) and
start using overloads here, there and everywhere, because it
seems like a “neat idea”.

But at the same time, it really IS brilliant to be able to do
simple math with integers of varying width in our simulator.
And it would be MUCH harder to do if we didn’t use overloaded
operators in C++. In fact, it’s probably one of the best
features in C++ when used to write a simulator for a chip.
(Another alternative would of course to write a VHDL
compiler, and use VHDL to describe registers and other parts
as n bits wide, and then get the correct result).

Complex number math and String assignment with = or
concatenation with + are some other examples of reasonable
use of operator overloads, but it’s easy for a novice to
think that the simple operator sign is actually just a single
instruction (or a few instructions), when in fact it’s
copying, say, 200 bytes of data.

C++ is a good tool when used correctly, but same as with a chainsaw,
C++ it’s
got enough power to make it very dangerous if used incorrectly.

I’m by no means saying that writing drivers in C++ is a
particularly good idea, but sometimes I actually think to
myself “This would be so much easier if we could just inherit
the original structure and override the three functions that
are different”. This is particularly when (like now) I’m
writing a piece of code that is for a variation on a previous
chip, just slightly different in a few places. You end up
with lots of “if (x) something; else someother;” in the code.
With classes and inheritance, it would be fairly trivial to
implement a different member function for particular
functionalities that are different, and keeping the other
bits the same. I’m essentially doing this anyway, but we’re
using function pointers, so I’m calling InitTypeB, which
calls InitTypeA and then overwrites a few of the function
pointers… This type of thing would happen automatically in C++…

But at the same time, things that happen automatically is
dangerous. If it’s written explicitly in the code, you know
it’s happening. If it’s not written in the code, you need to
understand more about what’s going on in the system to
understand what’s actually happening. That’s a big danger with C++.


Mats

> -----Original Message-----
> From: Roddy, Mark [mailto:xxxxx@stratus.com]
> Sent: Thursday, February 12, 2004 5:38 PM
> To: Windows System Software Devs Interest List
> Subject: RE: [ntdev] A guide to writing device drivers in c++
>
>
> Operator overload is hardly ever justified as it makes code
> comprehension very difficult and consequently causes unintended
> consequence bugs as a software product evolves over time. You could
> not have picked a better example of why NOT to use C++.
>
>
> =====================
> Mark Roddy
>
>
>
>
>
> ________________________________
>
> From: Moreira, Alberto [mailto:xxxxx@compuware.com]
> Sent: Thursday, February 12, 2004 11:25 AM
> To: Windows System Software Devs Interest List
> Subject: RE: [ntdev] A guide to writing device drivers in c++
>
>
> It takes to learn that operator semantics, just like function
> semantics, now belong *inside their class*, they’re no longer
> global. So, if
> I say c=a+b, the result I get depends on the definition of
> the operator “+”.
> If a, b and c are strings, for example, “+” may mean
> concatenation. Welcome
> to object orientation !
>
> If you want the definition of |=, just look at the
> declaration of
> the respective class in the .h file.
>
> Alberto.
>
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com]On Behalf Of Peter Scott
> Sent: Thursday, February 12, 2004 11:20 AM
> To: Windows System Software Devs Interest List
> Subject: RE: [ntdev] A guide to writing device
> drivers in
> c++
>
>
>
>
>
> Great, that must be fun code to read through. X |= 0x04
> equals 42 for all values of X being prime
>
> Peter Scott
> xxxxx@KernelDrivers.com
> www.KernelDrivers.com
>
>
> ________________________________
>
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of
> Moreira, Alberto
> Sent: Thursday, February 12, 2004 7:54 AM
> To: Windows System Software Devs Interest List
> Subject: RE: [ntdev] A guide to writing device
> drivers in
> c++
>
>
>
> In C++, the scribble “|=” stands for an
> operator. So, I can
> overload it inside my class and get it to be whatever I need
> it to be.
>
>
>
> Alberto.
>
>
>
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com]On Behalf Of Jamey Kirby
> Sent: Wednesday, February 11, 2004 6:27 PM
> To: Windows System Software Devs Interest List
> Subject: RE: [ntdev] A guide to writing device
> drivers in
> c++
>
> So, it is better to call a class rather
> than X |=
> 0x01?
>
>
>
> Maybe I am getting to old; I can even
> figure out how
> to use 1/3rd of my cell phones features.
>
>
>
> ________________________________
>
> From:
> xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com]
> On Behalf Of Moreira, Alberto
> Sent: Wednesday, February 11, 2004 12:12 PM
> To: Windows System Software Devs Interest List
> Subject: RE: [ntdev] A guide to writing device
> drivers in c++
>
>
>
> Depends on your granularity, no ? If
> you need a lot
> of bit-level functionality, maybe set things up in your way
> makes sense.
>
>
>
> Alberto.
>
>
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com]On Behalf Of Calvin Guan
> Sent: Wednesday, February 11,
> 2004 3:05 PM
> To: Windows System Software
> Devs Interest
> List
> Subject: RE: [ntdev] A guide to writing
> device drivers in c++
>
> > You can also take advantage of
> inheritance, for example,
> >
> > class IRP { … } ;
> > class pnpIRP : IRP { … };
> > class startDeviceIRP : pnpIRP
> { … };
> > class stopDeviceIRP : pnpIRP
> { … };
>
> class BIT {…};
> class BYTE:BIT {…};
> class U16:BYTE {…};
> class U32:U16 {…};
>
> -:wink:
>
> -
> Calvin Guan Software Engineer
> ATI Technologies Inc. www.ati.com
>
> —
> Questions? First check the
> Kernel Driver FAQ
> at http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to
> ntdev as:
> xxxxx@compuware.com
> To unsubscribe send a blank email to
> xxxxx@lists.osr.com
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as:
> xxxxx@storagecraft.com
> To unsubscribe send a blank email to
> xxxxx@lists.osr.com
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as:
> xxxxx@compuware.com
> To unsubscribe send a blank email to
> xxxxx@lists.osr.com
>
>
>
> The contents of this e-mail are intended for the
> named addressee only. It contains information that may be
> confidential.
> Unless you are the named addressee or an authorized designee,
> you may not
> copy or use it, or disclose it to anyone else. If you
> received it in error
> please notify us immediately and then destroy it.
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as:
> xxxxx@kerneldrivers.com
> To unsubscribe send a blank email to
> xxxxx@lists.osr.com
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as:
> xxxxx@compuware.com
> To unsubscribe send a blank email to
> xxxxx@lists.osr.com
>
>
>
>
> The contents of this e-mail are intended for the named
> addressee only. It contains information that may be
> confidential. Unless you
> are the named addressee or an authorized designee, you may
> not copy or use
> it, or disclose it to anyone else. If you received it in
> error please notify
> us immediately and then destroy it.
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@stratus.com
> To unsubscribe send a blank email to
> xxxxx@lists.osr.com
>
>
>
>
>
> The contents of this e-mail are intended for the named addressee
> only. It contains information that may be confidential.
> Unless you are the
> named addressee or an authorized designee, you may not copy
> or use it, or
> disclose it to anyone else. If you received it in error
> please notify us
> immediately and then destroy it.
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@3dlabs.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@stratus.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

I disagree. I’d rather say a=b+c and let the class handle the complexity of
adding three matrices than to code the loop by hand, talk about 3D driver
code ? I’d rather say a<operator - and the synchronization involved - than do it by hand. I’d rather
say myIrp.dispatch(&fdo) then to code if and case statements.

But if what you want is to program in a glorified assembler style, hey, more
power to you.

Alberto.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Roddy, Mark
Sent: Thursday, February 12, 2004 12:38 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device drivers in c++

Operator overload is hardly ever justified as it makes code comprehension
very difficult and consequently causes unintended consequence bugs as a
software product evolves over time. You could not have picked a better
example of why NOT to use C++.

=====================
Mark Roddy



From: Moreira, Alberto [mailto:xxxxx@compuware.com]
Sent: Thursday, February 12, 2004 11:25 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device drivers in c++

It takes to learn that operator semantics, just like function
semantics, now belong inside their class, they’re no longer global. So, if
I say c=a+b, the result I get depends on the definition of the operator “+”.
If a, b and c are strings, for example, “+” may mean concatenation. Welcome
to object orientation !

If you want the definition of |=, just look at the declaration of
the respective class in the .h file.

Alberto.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Peter Scott
Sent: Thursday, February 12, 2004 11:20 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device drivers in
c++

Great, that must be fun code to read through. X |= 0x04
equals 42 for all values of X being prime

Peter Scott
xxxxx@KernelDrivers.com
www.KernelDrivers.com



From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Moreira, Alberto
Sent: Thursday, February 12, 2004 7:54 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device drivers in
c++

In C++, the scribble “|=” stands for an operator. So, I can
overload it inside my class and get it to be whatever I need it to be.

Alberto.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Jamey Kirby
Sent: Wednesday, February 11, 2004 6:27 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device drivers in
c++

So, it is better to call a class rather than X |=
0x01?

Maybe I am getting to old; I can even figure out how
to use 1/3rd of my cell phones features.

________________________________

From:
xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com]
On Behalf Of Moreira, Alberto
Sent: Wednesday, February 11, 2004 12:12 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device
drivers in c++

Depends on your granularity, no ? If you need a lot
of bit-level functionality, maybe set things up in your way makes sense.

Alberto.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Calvin Guan
Sent: Wednesday, February 11, 2004 3:05 PM
To: Windows System Software Devs Interest
List
Subject: RE: [ntdev] A guide to writing
device drivers in c++

> You can also take advantage of
inheritance, for example,
>
> class IRP { … } ;
> class pnpIRP : IRP { … };
> class startDeviceIRP : pnpIRP { … };
> class stopDeviceIRP : pnpIRP { … };

class BIT {…};
class BYTE:BIT {…};
class U16:BYTE {…};
class U32:U16 {…};

-:wink:

-
Calvin Guan Software Engineer
ATI Technologies Inc. www.ati.com


Questions? First check the Kernel Driver FAQ
at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as:
xxxxx@compuware.com
To unsubscribe send a blank email to
xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as:
xxxxx@storagecraft.com
To unsubscribe send a blank email to
xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as:
xxxxx@compuware.com
To unsubscribe send a blank email to
xxxxx@lists.osr.com

The contents of this e-mail are intended for the
named addressee only. It contains information that may be confidential.
Unless you are the named addressee or an authorized designee, you may not
copy or use it, or disclose it to anyone else. If you received it in error
please notify us immediately and then destroy it.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as:
xxxxx@kerneldrivers.com
To unsubscribe send a blank email to
xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as:
xxxxx@compuware.com
To unsubscribe send a blank email to
xxxxx@lists.osr.com

The contents of this e-mail are intended for the named
addressee only. It contains information that may be confidential. Unless you
are the named addressee or an authorized designee, you may not copy or use
it, or disclose it to anyone else. If you received it in error please notify
us immediately and then destroy it.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@stratus.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

The contents of this e-mail are intended for the named addressee
only. It contains information that may be confidential. Unless you are the
named addressee or an authorized designee, you may not copy or use it, or
disclose it to anyone else. If you received it in error please notify us
immediately and then destroy it.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it.

RE: [ntdev] A guide to writing device drivers in c++Anyone can write bad code in any language. Anyone can write unreadable code in any language. Anyone sufficiently clever can usually find some perversion of a #define or equivalent to turn everone else in the world on their head when trying to read his code. Apologies to Knuth & crew, but this ability doesn’t make a language bad, it just proves that the programmer is an idiot, incompetent, or trying for the obfuscated language competition rather than making production code.

Suppose you needed to deal with 128 bit integers for a project. How are you going to do that? Make a structure of 4 DWORDs? How are you going to deal with shift, or, add? Write functions? How many, one for each possible operand type? Why not instead write a class that stores 4 dwords, or 2 int64s, or 16 bytes, or whatever the hardware under you can support, and create an overloaded |= function that does just what anyone in their right mind would expect it to do on a computational number? Why would that be bad?

Sheesh. Reminds me of the Algol programmer that told me that C was a terrible language because “you can write bad code in C”. It apparently never occurred to him that you can write bad code in Algol. And many people had.

Loren
----- Original Message -----
From: Peter Scott
To: Windows System Software Devs Interest List
Sent: Thursday, February 12, 2004 8:20 AM
Subject: RE: [ntdev] A guide to writing device drivers in c++

Great, that must be fun code to read through. X |= 0x04 equals 42 for all values of X being prime

Peter Scott
xxxxx@KernelDrivers.com
www.KernelDrivers.com


From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Moreira, Alberto
Sent: Thursday, February 12, 2004 7:54 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device drivers in c++

In C++, the scribble “|=” stands for an operator. So, I can overload it inside my class and get it to be whatever I need it to be.

Alberto.

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com]On Behalf Of Jamey Kirby
Sent: Wednesday, February 11, 2004 6:27 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device drivers in c++

So, it is better to call a class rather than X |= 0x01?

Maybe I am getting to old; I can even figure out how to use 1/3rd of my cell phones features.


From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Moreira, Alberto
Sent: Wednesday, February 11, 2004 12:12 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device drivers in c++

Depends on your granularity, no ? If you need a lot of bit-level functionality, maybe set things up in your way makes sense.

Alberto.

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com]On Behalf Of Calvin Guan
Sent: Wednesday, February 11, 2004 3:05 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device drivers in c++

You can also take advantage of inheritance, for example,
>
> class IRP { … } ;
> class pnpIRP : IRP { … };
> class startDeviceIRP : pnpIRP { … };
> class stopDeviceIRP : pnpIRP { … };

class BIT {…};
class BYTE:BIT {…};
class U16:BYTE {…};
class U32:U16 {…};

-:wink:

Calvin Guan Software Engineer
ATI Technologies Inc. www.ati.com


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@storagecraft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

The contents of this e-mail are intended for the named addressee only. It contains information that may be confidential. Unless you are the named addressee or an authorized designee, you may not copy or use it, or disclose it to anyone else. If you received it in error please notify us immediately and then destroy it.


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@kerneldrivers.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@earthlink.net
To unsubscribe send a blank email to xxxxx@lists.osr.com

The contents of this e-mail are intended for the named addressee only. It contains information that may be confidential. Unless you are the named addressee or an authorized designee, you may not copy or use it, or disclose it to anyone else. If you received it in error please notify us immediately and then destroy it.

RE: [ntdev] A guide to writing device drivers in c++ No, welcome to Ada’s “abstract datatype” feature which does NOTHING useful except saving the typist labor, and the cost of making the code more obscure.

I would always prefer:

a.Add(b);

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

----- Original Message -----
From: Moreira, Alberto
To: Windows System Software Devs Interest List
Sent: Thursday, February 12, 2004 7:25 PM
Subject: RE: [ntdev] A guide to writing device drivers in c++

It takes to learn that operator semantics, just like function semantics, now belong *inside their class*, they’re no longer global. So, if I say c=a+b, the result I get depends on the definition of the operator “+”. If a, b and c are strings, for example, “+” may mean concatenation. Welcome to object orientation !

If you want the definition of |=, just look at the declaration of the respective class in the .h file.

Alberto.

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com]On Behalf Of Peter Scott
Sent: Thursday, February 12, 2004 11:20 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device drivers in c++

Great, that must be fun code to read through. X |= 0x04 equals 42 for all values of X being prime

Peter Scott
xxxxx@KernelDrivers.com
www.KernelDrivers.com


From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Moreira, Alberto
Sent: Thursday, February 12, 2004 7:54 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device drivers in c++

In C++, the scribble “|=” stands for an operator. So, I can overload it inside my class and get it to be whatever I need it to be.

Alberto.

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com]On Behalf Of Jamey Kirby
Sent: Wednesday, February 11, 2004 6:27 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device drivers in c++

So, it is better to call a class rather than X |= 0x01?

Maybe I am getting to old; I can even figure out how to use 1/3rd of my cell phones features.


From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Moreira, Alberto
Sent: Wednesday, February 11, 2004 12:12 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device drivers in c++

Depends on your granularity, no ? If you need a lot of bit-level functionality, maybe set things up in your way makes sense.

Alberto.

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com]On Behalf Of Calvin Guan
Sent: Wednesday, February 11, 2004 3:05 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A guide to writing device drivers in c++

You can also take advantage of inheritance, for example,
>
> class IRP { … } ;
> class pnpIRP : IRP { … };
> class startDeviceIRP : pnpIRP { … };
> class stopDeviceIRP : pnpIRP { … };

class BIT {…};
class BYTE:BIT {…};
class U16:BYTE {…};
class U32:U16 {…};

-:wink:

Calvin Guan Software Engineer
ATI Technologies Inc. www.ati.com


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@storagecraft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

The contents of this e-mail are intended for the named addressee only. It contains information that may be confidential. Unless you are the named addressee or an authorized designee, you may not copy or use it, or disclose it to anyone else. If you received it in error please notify us immediately and then destroy it.


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@kerneldrivers.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

The contents of this e-mail are intended for the named addressee only. It contains information that may be confidential. Unless you are the named addressee or an authorized designee, you may not copy or use it, or disclose it to anyone else. If you received it in error please notify us immediately and then destroy it.


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@storagecraft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

The contents of this e-mail are intended for the named addressee only. It contains information that may be confidential. Unless you are the named addressee or an authorized designee, you may not copy or use it, or disclose it to anyone else. If you received it in error please notify us immediately and then destroy it.

Well … it’s happened again. From all sides we gather to watch the great
battle for control of the programming universe. Will C prevail or will the
evil C++ Empire finally prove victorious!?!?!? As the Abo said to Crocodile
dunDee, “Na. Tastes like shit, but you can live on it.”

In summation — them that love C, still love C and still hate C++. Them
that love C++ still think there is room for both. Those of us in the middle
are still in the middle.

Nonsequitor.

Gary