Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Home NTDEV

Before Posting...

Please check out the Community Guidelines in the Announcements and Administration Category.

More Info on Driver Writing and Debugging


The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.


Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/


Problem with driver written in C++.

OSR_Community_UserOSR_Community_User Member Posts: 110,217
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

Comments

  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    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: [email protected]
    > To unsubscribe send a blank email to $subst('Email.Unsub')
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    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:[email protected]]
    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: [email protected]
    To unsubscribe send a blank email to $subst('Email.Unsub')
  • Mark_RoddyMark_Roddy Member - All Emails Posts: 4,752
    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: [email protected]
    [mailto:[email protected]]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: [email protected]
    To unsubscribe send a blank email to $subst('Email.Unsub')
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    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: [email protected]
    > > To unsubscribe send a blank email to $subst('Email.Unsub')
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    It was quite a good article indeed. Whatever happened to the cranky b*stard
    who wrote it :-?



    > -----Original Message-----
    > From: Giga Giguashvili [mailto:[email protected]]
    > 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: [email protected]
    > > > To unsubscribe send a blank email to
    > $subst('Email.Unsub')
    >
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    Dunno, maybe he became a cranky curmudgeon?
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    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: [email protected]
    > To unsubscribe send a blank email to $subst('Email.Unsub')
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    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" <[email protected]>
    To: "NT Developers Interest List" <[email protected]>
    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: [email protected]
    > To unsubscribe send a blank email to $subst('Email.Unsub')
    >
    >
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    hi tahir,
    Which os you are working on...???

    -----Original Message-----
    From: Taher [SMTP:[email protected]]
    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: [email protected]
    To unsubscribe send a blank email to $subst('Email.Unsub')
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Kernel Debugging 13-17 May 2024 Live, Online
Developing Minifilters 1-5 Apr 2024 Live, Online
Internals & Software Drivers 11-15 Mar 2024 Live, Online
Writing WDF Drivers 20-24 May 2024 Live, Online