Problem with driver written in C++.

Hi,
I have a fully functional disk driver written in C. Recently I added some
CPP files to the driver project and rebuilt the driver. It built
successfully
after some errors, but now it is not possible to load the new driver.

The error message that I get is “The procedure could not be located”
when I load it from Devices applet from Control Panel.

The DriverEntry function is still in a .C file as before.

If somebody has any information about compiling drivers written in c++,
please let me know.

Taher

Hello,

I remember in OSR Insider, there was an exellent article about driver programming in C++.

Regards,
Giga.

Taher wrote:

Hi,
I have a fully functional disk driver written in C. Recently I added some
CPP files to the driver project and rebuilt the driver. It built
successfully
after some errors, but now it is not possible to load the new driver.

The error message that I get is “The procedure could not be located”
when I load it from Devices applet from Control Panel.

The DriverEntry function is still in a .C file as before.

If somebody has any information about compiling drivers written in c++,
please let me know.

Taher


You are currently subscribed to ntdev as: xxxxx@ParadigmGeo.com
To unsubscribe send a blank email to $subst(‘Email.Unsub’)

I have written a number of drivers with C++. The is no C++ support library available. Because of this you must:
Provide your own operator new and delete.
Not have any global/static objects that have constructors or destructors.
Not have any global/static objects that have virtual functions.

If you must have global objects with constructors or virtual functions you can write an operator new function that takes the address of the object as a parameter and use this operator new to call the constructor in your DriverEntry function.

Another restriction is you don’t have function by function control of segments. You can specify the segment on a file basis.

Bill Wandel

-----Original Message-----
From: Taher [SMTP:xxxxx@veritas.com]
Sent: Monday, June 12, 2000 5:27 AM
To: NT Developers Interest List
Subject: [ntdev] Problem with driver written in C++.

Hi,
I have a fully functional disk driver written in C. Recently I added some
CPP files to the driver project and rebuilt the driver. It built
successfully
after some errors, but now it is not possible to load the new driver.

The error message that I get is “The procedure could not be located”
when I load it from Devices applet from Control Panel.

The DriverEntry function is still in a .C file as before.

If somebody has any information about compiling drivers written in c++,
please let me know.

Taher


You are currently subscribed to ntdev as: xxxxx@smart.net
To unsubscribe send a blank email to $subst(‘Email.Unsub’)

The problem is most likely that you have not enclosed ntddk.h in your .cpp
files with the requisite:
extern “C” {

#include <ntddk.h>

}

form.

Or, your .C files have within them equally improper declarations of
functions defined in your .cpp files.

The point being that .c and .cpp objects have different names for variables
functions etc. and only the use of extern “C” can convince a single
link-object to be built correctly.

The other possibility is that you have introduced an explicit or implicit
reference to C++ runtime functions not supported by the DDK, specifically
global new and global delete operators. This problem can be resolved by
either defining class specific new and delete operators, or by defining your
own global new and delete.

My website has a fairly complete (and totally free) runtime library for C++
kernel development, plus some more or less lucid explanations of what is
going on.

Mark Roddy
Windows 2000/NT Consultant
Hollis Technology Solutions
www.hollistech.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Taher
Sent: Monday, June 12, 2000 5:27 AM
To: NT Developers Interest List
Subject: [ntdev] Problem with driver written in C++.

Hi,
I have a fully functional disk driver written in C. Recently I added some
CPP files to the driver project and rebuilt the driver. It built
successfully
after some errors, but now it is not possible to load the new driver.

The error message that I get is “The procedure could not be located”
when I load it from Devices applet from Control Panel.

The DriverEntry function is still in a .C file as before.

If somebody has any information about compiling drivers written in c++,
please let me know.

Taher


You are currently subscribed to ntdev as: xxxxx@wattanuck.mv.com
To unsubscribe send a blank email to $subst(‘Email.Unsub’)</ntddk.h>

Check this:
http://www.osr.com/ntinsider/1999/global.htm

Bye

Giga Giguashvili wrote:

Hello,

I remember in OSR Insider, there was an exellent article about driver programming in C++.

Regards,
Giga.

Taher wrote:

> Hi,
> I have a fully functional disk driver written in C. Recently I added some
> CPP files to the driver project and rebuilt the driver. It built
> successfully
> after some errors, but now it is not possible to load the new driver.
>
> The error message that I get is “The procedure could not be located”
> when I load it from Devices applet from Control Panel.
>
> The DriverEntry function is still in a .C file as before.
>
> If somebody has any information about compiling drivers written in c++,
> please let me know.
>
> Taher
>
> —
> You are currently subscribed to ntdev as: xxxxx@ParadigmGeo.com
> To unsubscribe send a blank email to $subst(‘Email.Unsub’)

It was quite a good article indeed. Whatever happened to the cranky b*stard
who wrote it :-?

-----Original Message-----
From: Giga Giguashvili [mailto:xxxxx@ParadigmGeo.com]
Sent: Monday, June 12, 2000 12:46 PM
To: NT Developers Interest List
Subject: [ntdev] Re: Problem with driver written in C++.

Check this:
http://www.osr.com/ntinsider/1999/global.htm

Bye

Giga Giguashvili wrote:

> Hello,
>
> I remember in OSR Insider, there was an exellent article
about driver programming in C++.
>
> Regards,
> Giga.
>
> Taher wrote:
>
> > Hi,
> > I have a fully functional disk driver
written in C. Recently I added some
> > CPP files to the driver project and
rebuilt the driver. It built
> > successfully
> > after some errors, but now it is not
possible to load the new driver.
> >
> > The error message that I get is “The
procedure could not be located”
> > when I load it from Devices applet from
Control Panel.
> >
> > The DriverEntry function is still in a .C
file as before.
> >
> > If somebody has any information about
compiling drivers written in c++,
> > please let me know.
> >
> > Taher
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@ParadigmGeo.com
> > To unsubscribe send a blank email to
$subst(‘Email.Unsub’)

Dunno, maybe he became a cranky curmudgeon?

Taher,

When you specify a .cpp file in your SOURCES file, the build utility will (I think) evoke the
C++ Compiler automatically. What this may mean, is that your .c file is being compiled by the
C++ compiler, and thus the DriverEntry() function is being name mangled.

Try enclosing DriverEntry() in exter C

extern “C”
{
DriverEntry()
}

blocks, as this will turn off name mangling of DriverEntry so the I/O manager can see it in
its non mangled name. You should not have to do this with any other driver functions, as
their addresses are being set in the DriverEntry routine and thus if they are mangled should
not matter to I/O manager

Hope this helps

-Chris

Taher wrote:

Hi,
I have a fully functional disk driver written in C. Recently I added some
CPP files to the driver project and rebuilt the driver. It built
successfully
after some errors, but now it is not possible to load the new driver.

The error message that I get is “The procedure could not be located”
when I load it from Devices applet from Control Panel.

The DriverEntry function is still in a .C file as before.

If somebody has any information about compiling drivers written in c++,
please let me know.

Taher


You are currently subscribed to ntdev as: xxxxx@vanteon.com
To unsubscribe send a blank email to $subst(‘Email.Unsub’)

That doesn’t sound like a C++ problem, but a problem with imports u linked
against. Like u maybe linked against something in ntdll, or u built u’re
driver with the W2K DDK, then ran it on NT 4, & have implicetly linked
against something (like _except_handler3) that’s not exported by kernel on
the version of NT u’re running.

Setting a break on & tracing through ntoskrnl!MiResolveImageReferences()
should give a quick answer.

----- Original Message -----
From: “Taher”
To: “NT Developers Interest List”
Sent: Monday, June 12, 2000 4:27 AM
Subject: [ntdev] Problem with driver written in C++.

>
> Hi,
> I have a fully functional disk driver written in C. Recently I added some
> CPP files to the driver project and rebuilt the driver. It built
> successfully
> after some errors, but now it is not possible to load the new driver.
>
> The error message that I get is “The procedure could not be located”
> when I load it from Devices applet from Control Panel.
>
> The DriverEntry function is still in a .C file as before.
>
> If somebody has any information about compiling drivers written in c++,
> please let me know.
>
>
> Taher
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@timesn.com
> To unsubscribe send a blank email to $subst(‘Email.Unsub’)
>
>

hi tahir,
Which os you are working on…???

-----Original Message-----
From: Taher [SMTP:xxxxx@veritas.com]
Sent: Monday, June 12, 2000 2:57 PM
To: NT Developers Interest List
Subject: [ntdev] Problem with driver written in C++.

Hi,
I have a fully functional disk driver written in C. Recently I added some
CPP files to the driver project and rebuilt the driver. It built
successfully
after some errors, but now it is not possible to load the new driver.

The error message that I get is “The procedure could not be located”
when I load it from Devices applet from Control Panel.

The DriverEntry function is still in a .C file as before.

If somebody has any information about compiling drivers written in c++,
please let me know.

Taher


You are currently subscribed to ntdev as: xxxxx@future.futsoft.com
To unsubscribe send a blank email to $subst(‘Email.Unsub’)