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/


problems using CreateFile

OSR_Community_UserOSR_Community_User Member Posts: 110,217
Hi everybody, and sorry for troubling you with
newbies questions, but I have a problem with CreateFile
that I just can't figure out:

I have a driver, to which I want to connect from my application,
using CreateFile(), and I have 2 processes that try to
attach to the driver.

The first succeeds, and the second fails with error code #2
(ERROR_FILE_NOT_FOUND).

The CreateFile line is this:
CreateFile(SymbolicLinkName,
GENERIC_WRITE | GENERIC_READ,
0,
NULL,
CREATE_ALWAYS,
FILE_FLAG_OVERLAPPED,0);

My guess is that it's something with the flags, but I don't seem
to find the correct flag....

thanks in advance,

- Barak

--
----------------------------------------------------
Barak Mandelovich Mercury Interactive ltd.
[email protected] 19 Shabazi st.
Tel: +972 3 539 9286 Yehud, 56100
Fax: +972 3 533 1617 Israel
----------------------------------------------------

Comments

  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    When you called IoCreateDevice in the DriverEntry, how did you set the
    Exclusive parameter? To allow multiple processes access, you must set it to
    FALSE.

    Gary

    -----Original Message-----
    From: Barak Mandelovich [mailto:[email protected]]
    Sent: Tuesday, March 21, 2000 4:44 AM
    To: NT Developers Interest List
    Subject: [ntdev] problems using CreateFile

    I have a driver, to which I want to connect from my application,
    using CreateFile(), and I have 2 processes that try to
    attach to the driver.

    The first succeeds, and the second fails with error code #2
    (ERROR_FILE_NOT_FOUND).
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    Hmm, but should setting exclusive == TRUE cause ERROR_FILE_NOT_FOUND to be
    returned to the second process? I would have though ERROR_ACCESS_DENIED
    would be returned in that case.

    - Matt

    From: "Gary Little" <[email protected]>
    Sent: Tuesday, March 21, 2000 11:09 AM


    > When you called IoCreateDevice in the DriverEntry, how did you set the
    > Exclusive parameter? To allow multiple processes access, you must set it
    to
    > FALSE.

    [snip]

    > From: Barak Mandelovich [mailto:[email protected]]
    > To: NT Developers Interest List
    >
    > > I have a driver, to which I want to connect from my application,
    > > using CreateFile(), and I have 2 processes that try to
    > > attach to the driver.
    > >
    > > The first succeeds, and the second fails with error code #2
    > > (ERROR_FILE_NOT_FOUND).

    [snip]
  • Paul_BunnPaul_Bunn Member Posts: 251
    Have you verified that the value of SymbolicLinkName is identical in both
    cases ?

    You'll also need to set FILE_SHARE READ | FILE_SHARE_WRITE to the 3rd
    parameter of CreateFile.

    As previously pointed out, you'll need to set the Exclusive bit to FALSE
    when calling IoCreateDevice().

    Regards,

    Paul Bunn, UltraBac.Com, 425-644-6000
    Microsoft MVP - WindowsNT
    http://www.ultrabac.com


    -----Original Message-----
    From: Barak Mandelovich [mailto:[email protected]]
    Sent: Tuesday, March 21, 2000 4:44 AM
    To: NT Developers Interest List
    Subject: [ntdev] problems using CreateFile


    Hi everybody, and sorry for troubling you with
    newbies questions, but I have a problem with CreateFile
    that I just can't figure out:

    I have a driver, to which I want to connect from my application,
    using CreateFile(), and I have 2 processes that try to
    attach to the driver.

    The first succeeds, and the second fails with error code #2
    (ERROR_FILE_NOT_FOUND).

    The CreateFile line is this:
    CreateFile(SymbolicLinkName,
    GENERIC_WRITE | GENERIC_READ,
    0,
    NULL,
    CREATE_ALWAYS,
    FILE_FLAG_OVERLAPPED,0);

    My guess is that it's something with the flags, but I don't seem
    to find the correct flag....
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    > My guess is that it's something with the flags, but I don't seem
    > to find the correct flag....

    Maybe not. The symlink name is
    \\.\name
    where "name" is what will go after "\??\" in kernel mode.

    Max
  • Mark_ShnaiderMark_Shnaider Member Posts: 95
    Maby you need use NtCreateFile instead CreateFIle?
    Regards
    Mark
    Paul Bunn wrote:

    > Have you verified that the value of SymbolicLinkName is identical in both
    > cases ?
    >
    > You'll also need to set FILE_SHARE READ | FILE_SHARE_WRITE to the 3rd
    > parameter of CreateFile.
    >
    > As previously pointed out, you'll need to set the Exclusive bit to FALSE
    > when calling IoCreateDevice().
    >
    > Regards,
    >
    > Paul Bunn, UltraBac.Com, 425-644-6000
    > Microsoft MVP - WindowsNT
    > http://www.ultrabac.com
    >
    > -----Original Message-----
    > From: Barak Mandelovich [mailto:[email protected]]
    > Sent: Tuesday, March 21, 2000 4:44 AM
    > To: NT Developers Interest List
    > Subject: [ntdev] problems using CreateFile
    >
    > Hi everybody, and sorry for troubling you with
    > newbies questions, but I have a problem with CreateFile
    > that I just can't figure out:
    >
    > I have a driver, to which I want to connect from my application,
    > using CreateFile(), and I have 2 processes that try to
    > attach to the driver.
    >
    > The first succeeds, and the second fails with error code #2
    > (ERROR_FILE_NOT_FOUND).
    >
    > The CreateFile line is this:
    > CreateFile(SymbolicLinkName,
    > GENERIC_WRITE | GENERIC_READ,
    > 0,
    > NULL,
    > CREATE_ALWAYS,
    > FILE_FLAG_OVERLAPPED,0);
    >
    > My guess is that it's something with the flags, but I don't seem
    > to find the correct flag....
    >
    > ---
    > 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!
Internals & Software Drivers 19-23 June 2023 Live, Online
Writing WDF Drivers 10-14 July 2023 Live, Online
Kernel Debugging 16-20 October 2023 Live, Online
Developing Minifilters 13-17 November 2023 Live, Online