Hello, I am using DefineDosDevice() to associate my device with a Volume
(which succeeds and an icon for my drive shows up in explorer), but when
I call CreateFile to get the device handle, it fails with the error “The
system cannot find the file specified.”
The device name I pass to DefineDosDevice is “f:”, and the filename I
pass to CreateFile() is “\.\f:”. Any ideas why CreateFile would fail?
Thanks,
–Jeremy
Try F: instead of f:
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Jeremy Chaney
Sent: Monday, July 10, 2006 7:09 PM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] DefineDosDevice succeeds, but CreateFile fails to open the
device??
Hello, I am using DefineDosDevice() to associate my device with a Volume
(which succeeds and an icon for my drive shows up in explorer), but when
I call CreateFile to get the device handle, it fails with the error “The
system cannot find the file specified.”
The device name I pass to DefineDosDevice is “f:”, and the filename I
pass to CreateFile() is “\.\f:”. Any ideas why CreateFile would fail?
Thanks,
–Jeremy
Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
You are currently subscribed to ntfsd as: xxxxx@privtek.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
No luck.
When looking at WinObj, is there any particular entry that I should look
at that will tell me whether or not CreateFile should succeed? Under the
“Device” tree I see my driver (“VDisk”), and when I click on it I see my
device (“VDisk1”). The Type column shows “Device” and the SymLink column
is blank.
Under the “GLOBAL??” tree I see my other drives (A:,C:,D:,…), but not
F: (the drive I created with DefineDosDevice, which ~is~ showing up in
explorer).
Thanks,
–Jeremy
Dan Kyler wrote:
Try F: instead of f:
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Jeremy Chaney
Sent: Monday, July 10, 2006 7:09 PM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] DefineDosDevice succeeds, but CreateFile fails to open the
device??
Hello, I am using DefineDosDevice() to associate my device with a Volume
(which succeeds and an icon for my drive shows up in explorer), but when
I call CreateFile to get the device handle, it fails with the error “The
system cannot find the file specified.”
The device name I pass to DefineDosDevice is “f:”, and the filename I
pass to CreateFile() is “\.\f:”. Any ideas why CreateFile would fail?
Thanks,
–Jeremy
Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
You are currently subscribed to ntfsd as: xxxxx@privtek.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
Hi,
You’ll find the link to F in the \Sessions directory (see “Defining an
MS-DOS Name” in the SDK for info about local vs global).
What does your call to DefineDosDevice look like? Make sure you set the
“don’t convert” bit if you’re specifying a device name (\device\whateva) as
the target
Regards,
-scott
–
Scott Noone
Software Engineer
OSR Open Systems Resources, Inc.
http://www.osronline.com
“Jeremy Chaney” wrote in message
news:xxxxx@ntfsd…
> No luck.
>
> When looking at WinObj, is there any particular entry that I should look
> at that will tell me whether or not CreateFile should succeed? Under the
> “Device” tree I see my driver (“VDisk”), and when I click on it I see my
> device (“VDisk1”). The Type column shows “Device” and the SymLink column
> is blank.
> Under the “GLOBAL??” tree I see my other drives (A:,C:,D:,…), but not F:
> (the drive I created with DefineDosDevice, which ~is~ showing up in
> explorer).
>
>
> Thanks,
> --Jeremy
>
>
> Dan Kyler wrote:
>> Try F: instead of f:
>>
>> - Dan.
>>
>> -----Original Message-----
>> From: xxxxx@lists.osr.com
>> [mailto:xxxxx@lists.osr.com] On Behalf Of Jeremy Chaney
>> Sent: Monday, July 10, 2006 7:09 PM
>> To: Windows File Systems Devs Interest List
>> Subject: [ntfsd] DefineDosDevice succeeds, but CreateFile fails to open
>> the
>> device??
>>
>>
>> Hello, I am using DefineDosDevice() to associate my device with a Volume
>> (which succeeds and an icon for my drive shows up in explorer), but when
>> I call CreateFile to get the device handle, it fails with the error “The
>> system cannot find the file specified.”
>>
>> The device name I pass to DefineDosDevice is “f:”, and the filename I
>> pass to CreateFile() is “\.\f:”. Any ideas why CreateFile would fail?
>>
>> Thanks,
>> --Jeremy
>>
>> —
>> Questions? First check the IFS FAQ at
>> https://www.osronline.com/article.cfm?id=17
>>
>> You are currently subscribed to ntfsd as: xxxxx@privtek.com
>> To unsubscribe send a blank email to xxxxx@lists.osr.com
>>
>>
>
*Here is my call to DefineDosDevice:
DefineDosDevice( DDD_RAW_TARGET_PATH, “f:”, “\Device\VDisk\VDisk1”)
*Here is my call to CreateFile:
CreateFile( “\\.\f:”, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ |
FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_NO_BUFFERING, NULL );
*I found the F: drive under the Sessions tree. It is symbolically linked
to ‘\Device\VDisk\VDisk1’
Thanks for you help,
–Jeremy
Scott Noone wrote:
Hi,
You’ll find the link to F in the \Sessions directory (see “Defining an
MS-DOS Name” in the SDK for info about local vs global).
What does your call to DefineDosDevice look like? Make sure you set the
“don’t convert” bit if you’re specifying a device name (\device\whateva) as
the target
Regards,
-scott
Hi,
My guess is that it’s your namespace that is killing you. The object manager
is going to stop parsing the name once it hits your device object
(\device\vdisk) and then pass whatever is left over to the device at the top
of the stack, in this case the FSD. So, your open below won’t actually show
up as an open of F: but as an open of F:\VDisk1.
-scott
–
Scott Noone
Software Engineer
OSR Open Systems Resources, Inc.
http://www.osronline.com
“Jeremy Chaney” wrote in message
news:xxxxx@ntfsd…
> *Here is my call to DefineDosDevice:
> DefineDosDevice( DDD_RAW_TARGET_PATH, “f:”, “\Device\VDisk\VDisk1”)
>
> *Here is my call to CreateFile:
> CreateFile( “\\.\f:”, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ |
> FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_NO_BUFFERING, NULL );
>
> *I found the F: drive under the Sessions tree. It is symbolically linked
> to ‘\Device\VDisk\VDisk1’
>
>
> Thanks for you help,
> --Jeremy
>
> Scott Noone wrote:
>> Hi,
>>
>> You’ll find the link to F in the \Sessions directory (see “Defining an
>> MS-DOS Name” in the SDK for info about local vs global).
>>
>> What does your call to DefineDosDevice look like? Make sure you set the
>> “don’t convert” bit if you’re specifying a device name (\device\whateva)
>> as the target
>>
>> Regards,
>>
>> -scott
>>
>
So are you saying that if I call CreateFile and pass it “F:\VDisk1” then
it might work? 'Cause I tried it and it didn’t.
At one point I had all of this working, but at that point I was hard
coding the device name in my kernel driver to match the device name that
my user mode loader was going to use. I need to support the mounting
multiple images though, so added code to create a “controller” device
(IOCreateDevice + IOCreateSymbolicLink) that I use to send custom IOCTL
commands to the controller to create the specific virtual device that I
need. Creating the controller works, and sending it the custom IOCTL
commands works, and creating the new devices appears to work, Defining
the DOS device works, but not CreateFile…??
I’ve compared my new code to my old code, and it appears to follow the
exact same steps. I’m almost ready to just roll everything back and
start again (and test the code at each step to see when it breaks), but
I’m hoping to avoid such drastic measures.
–Jeremy
Scott Noone wrote:
Hi,
My guess is that it’s your namespace that is killing you. The object manager
is going to stop parsing the name once it hits your device object
(\device\vdisk) and then pass whatever is left over to the device at the top
of the stack, in this case the FSD. So, your open below won’t actually show
up as an open of F: but as an open of F:\VDisk1.
-scott
No, I’m saying that when you try to open “f:” it ends up as an attempt to
open “f:\vdisk1”. If you try to open “f:\vdisk1” then it ends up as an
attempt to open “f:\vdisk1\vdisk1”
Try changing your DefineDosDevice to this and see if it works (or is at
least different, which is sometimes one step closer to working :)):
DefineDosDevice( DDD_RAW_TARGET_PATH, “f:”, “\Device\VDisk”)
-scott
–
Scott Noone
Software Engineer
OSR Open Systems Resources, Inc.
http://www.osronline.com
“Jeremy Chaney” wrote in message
news:xxxxx@ntfsd…
> So are you saying that if I call CreateFile and pass it “F:\VDisk1” then
> it might work? 'Cause I tried it and it didn’t.
>
> At one point I had all of this working, but at that point I was hard
> coding the device name in my kernel driver to match the device name that
> my user mode loader was going to use. I need to support the mounting
> multiple images though, so added code to create a “controller” device
> (IOCreateDevice + IOCreateSymbolicLink) that I use to send custom IOCTL
> commands to the controller to create the specific virtual device that I
> need. Creating the controller works, and sending it the custom IOCTL
> commands works, and creating the new devices appears to work, Defining the
> DOS device works, but not CreateFile…??
>
> I’ve compared my new code to my old code, and it appears to follow the
> exact same steps. I’m almost ready to just roll everything back and start
> again (and test the code at each step to see when it breaks), but I’m
> hoping to avoid such drastic measures.
>
> --Jeremy
>
>
>
> Scott Noone wrote:
>> Hi,
>>
>> My guess is that it’s your namespace that is killing you. The object
>> manager is going to stop parsing the name once it hits your device object
>> (\device\vdisk) and then pass whatever is left over to the device at the
>> top of the stack, in this case the FSD. So, your open below won’t
>> actually show up as an open of F: but as an open of F:\VDisk1.
>>
>> -scott
>>
>
In my opinion, when you use DefineDosDevice() to define a volume, you aslo
have to let the virtual volume’s data accord to the volume’s normal
data(partition’s size, partition’s cluster size and so on). Not only the the
icon can show in explorer, but also the volume can visit normally. Then you
can use Createfile() to get its handle.
Sourceforge have a project about virtual volume
http://sourceforge.net/projects/storeddrive
It based on Bo Branten “FileDisk” Project.
And you also can find the FileDisk source code to check it
“Jeremy Chaney” ???:xxxxx@ntfsd…
> Hello, I am using DefineDosDevice() to associate my device with a Volume
> (which succeeds and an icon for my drive shows up in explorer), but when I
> call CreateFile to get the device handle, it fails with the error “The
> system cannot find the file specified.”
>
> The device name I pass to DefineDosDevice is “f:”, and the filename I pass
> to CreateFile() is “\.\f:”. Any ideas why CreateFile would fail?
>
> Thanks,
> --Jeremy
>
I do wish all these people would quit advertising stolen code as something
to be used. See MANY prior posts about this subject.
“Sun Jiajie” wrote in message news:xxxxx@ntfsd…
> In my opinion, when you use DefineDosDevice() to define a volume, you aslo
> have to let the virtual volume’s data accord to the volume’s normal
> data(partition’s size, partition’s cluster size and so on). Not only the
> the icon can show in explorer, but also the volume can visit normally.
> Then you can use Createfile() to get its handle.
>
> Sourceforge have a project about virtual volume
> http://sourceforge.net/projects/storeddrive
> It based on Bo Branten “FileDisk” Project.
> And you also can find the FileDisk source code to check it
>
>
> “Jeremy Chaney” ???:xxxxx@ntfsd…
>> Hello, I am using DefineDosDevice() to associate my device with a Volume
>> (which succeeds and an icon for my drive shows up in explorer), but when
>> I call CreateFile to get the device handle, it fails with the error “The
>> system cannot find the file specified.”
>>
>> The device name I pass to DefineDosDevice is “f:”, and the filename I
>> pass to CreateFile() is “\.\f:”. Any ideas why CreateFile would fail?
>>
>> Thanks,
>> --Jeremy
>>
>
>
>
When I tried your version of DefineDosDevice I got an “Invalid Handle”
error.
I did discover another clue, though.
If create my device (\Device\VDisk\VDisk1) in my DriverEntry
function, everything works fine, but if I create it in response to my
custom IOCTL command, then CreateFile fails…
The driver creation code is in its own function, and I simply copied the
call from DriverEntry into the IOCTL handler, so I don’t think it is a
problem with passing incorrect params- are there rules about when I
can/can’t call IoCreateDevice()? In the docs it says that calls must be
runnign at IRQL < DISPATCH_LEVEL- how do I know what the dispatch level
of IRP_MJ_DEVICE_CONTROL is? Does it depend on the IOCTL? How do I
know/set the dispatch level for custom IOCTLs?
Thanks,
–Jeremy
Scott Noone wrote:
No, I’m saying that when you try to open “f:” it ends up as an attempt to
open “f:\vdisk1”. If you try to open “f:\vdisk1” then it ends up as an
attempt to open “f:\vdisk1\vdisk1”
Try changing your DefineDosDevice to this and see if it works (or is at
least different, which is sometimes one step closer to working :)):
DefineDosDevice( DDD_RAW_TARGET_PATH, “f:”, “\Device\VDisk”)
-scott
If you create a device object outside of DriverEntry you need to manually
clear DO_DEVICE_INITIALIZING before you can open it.
-scott
–
Scott Noone
Software Engineer
OSR Open Systems Resources, Inc.
http://www.osronline.com
“Jeremy Chaney” wrote in message
news:xxxxx@ntfsd…
> When I tried your version of DefineDosDevice I got an “Invalid Handle”
> error.
>
> I did discover another clue, though.
>
> If create my device (\Device\VDisk\VDisk1) in my DriverEntry function,
> everything works fine, but if I create it in response to my custom IOCTL
> command, then CreateFile fails…
>
> The driver creation code is in its own function, and I simply copied the
> call from DriverEntry into the IOCTL handler, so I don’t think it is a
> problem with passing incorrect params- are there rules about when I
> can/can’t call IoCreateDevice()? In the docs it says that calls must be
> runnign at IRQL < DISPATCH_LEVEL- how do I know what the dispatch level of
> IRP_MJ_DEVICE_CONTROL is? Does it depend on the IOCTL? How do I know/set
> the dispatch level for custom IOCTLs?
>
> Thanks,
> --Jeremy
>
>
>
> Scott Noone wrote:
>> No, I’m saying that when you try to open “f:” it ends up as an attempt to
>> open “f:\vdisk1”. If you try to open “f:\vdisk1” then it ends up as an
>> attempt to open “f:\vdisk1\vdisk1”
>>
>> Try changing your DefineDosDevice to this and see if it works (or is at
>> least different, which is sometimes one step closer to working :)):
>>
>> DefineDosDevice( DDD_RAW_TARGET_PATH, “f:”, “\Device\VDisk”)
>>
>> -scott
>>
>
Also symbolic links created in DriverEntry are running in a system thread.
The IoCtl is running in the user’s context. That can control if the link is
created in the Global namespace or not.
“Jeremy Chaney” wrote in message
news:xxxxx@ntfsd…
> When I tried your version of DefineDosDevice I got an “Invalid Handle”
> error.
>
> I did discover another clue, though.
>
> If create my device (\Device\VDisk\VDisk1) in my DriverEntry function,
> everything works fine, but if I create it in response to my custom IOCTL
> command, then CreateFile fails…
>
> The driver creation code is in its own function, and I simply copied the
> call from DriverEntry into the IOCTL handler, so I don’t think it is a
> problem with passing incorrect params- are there rules about when I
> can/can’t call IoCreateDevice()? In the docs it says that calls must be
> runnign at IRQL < DISPATCH_LEVEL- how do I know what the dispatch level of
> IRP_MJ_DEVICE_CONTROL is? Does it depend on the IOCTL? How do I know/set
> the dispatch level for custom IOCTLs?
>
> Thanks,
> --Jeremy
>
>
>
> Scott Noone wrote:
>> No, I’m saying that when you try to open “f:” it ends up as an attempt to
>> open “f:\vdisk1”. If you try to open “f:\vdisk1” then it ends up as an
>> attempt to open “f:\vdisk1\vdisk1”
>>
>> Try changing your DefineDosDevice to this and see if it works (or is at
>> least different, which is sometimes one step closer to working :)):
>>
>> DefineDosDevice( DDD_RAW_TARGET_PATH, “f:”, “\Device\VDisk”)
>>
>> -scott
>>
>
If the source code is not free, or use free code to business. It means
stealing code! But now it’s not this situation.
“David J. Craig” дÈëÏûÏ¢ÐÂÎÅ:xxxxx@ntfsd…
>I do wish all these people would quit advertising stolen code as something
>to be used. See MANY prior posts about this subject.
>
> “Sun Jiajie” wrote in message
> news:xxxxx@ntfsd…
>> In my opinion, when you use DefineDosDevice() to define a volume, you
>> aslo have to let the virtual volume’s data accord to the volume’s normal
>> data(partition’s size, partition’s cluster size and so on). Not only the
>> the icon can show in explorer, but also the volume can visit normally.
>> Then you can use Createfile() to get its handle.
>>
>> Sourceforge have a project about virtual volume
>> http://sourceforge.net/projects/storeddrive
>> It based on Bo Branten “FileDisk” Project.
>> And you also can find the FileDisk source code to check it
>>
>>
>> “Jeremy Chaney” ???:xxxxx@ntfsd…
>>> Hello, I am using DefineDosDevice() to associate my device with a Volume
>>> (which succeeds and an icon for my drive shows up in explorer), but when
>>> I call CreateFile to get the device handle, it fails with the error “The
>>> system cannot find the file specified.”
>>>
>>> The device name I pass to DefineDosDevice is “f:”, and the filename I
>>> pass to CreateFile() is “\.\f:”. Any ideas why CreateFile would fail?
>>>
>>> Thanks,
>>> --Jeremy
>>>
>>
>>
>>
>
>
>
If you IoCreateDevice at DriveEntry, it will works on.
If you create the device at other routine, Please do initializing.
device_object->Flags &= ~DO_DEVICE_INITIALIZING;
“Jeremy Chaney” ???:xxxxx@ntfsd…
> When I tried your version of DefineDosDevice I got an “Invalid Handle”
> error.
>
> I did discover another clue, though.
>
> If create my device (\Device\VDisk\VDisk1) in my DriverEntry function,
> everything works fine, but if I create it in response to my custom IOCTL
> command, then CreateFile fails…
>
> The driver creation code is in its own function, and I simply copied the
> call from DriverEntry into the IOCTL handler, so I don’t think it is a
> problem with passing incorrect params- are there rules about when I
> can/can’t call IoCreateDevice()? In the docs it says that calls must be
> runnign at IRQL < DISPATCH_LEVEL- how do I know what the dispatch level of
> IRP_MJ_DEVICE_CONTROL is? Does it depend on the IOCTL? How do I know/set
> the dispatch level for custom IOCTLs?
>
> Thanks,
> --Jeremy
>
>
>
> Scott Noone wrote:
>> No, I’m saying that when you try to open “f:” it ends up as an attempt to
>> open “f:\vdisk1”. If you try to open “f:\vdisk1” then it ends up as an
>> attempt to open “f:\vdisk1\vdisk1”
>>
>> Try changing your DefineDosDevice to this and see if it works (or is at
>> least different, which is sometimes one step closer to working :)):
>>
>> DefineDosDevice( DDD_RAW_TARGET_PATH, “f:”, “\Device\VDisk”)
>>
>> -scott
>>
>
That did the trick. Thanks! I scoured the OSR forums, the DDK docs,
Google,… for a week trying to figure out why CreateFile was failing.
I post my question and within a day I have my answer. 
Thanks all.
–Jeremy
Sun Jiajie wrote:
If you IoCreateDevice at DriveEntry, it will works on.
If you create the device at other routine, Please do initializing.
device_object->Flags &= ~DO_DEVICE_INITIALIZING;
“Jeremy Chaney” ???:xxxxx@ntfsd…
>> When I tried your version of DefineDosDevice I got an “Invalid Handle”
>> error.
>>
>> I did discover another clue, though.
>>
>> If create my device (\Device\VDisk\VDisk1) in my DriverEntry function,
>> everything works fine, but if I create it in response to my custom IOCTL
>> command, then CreateFile fails…
>>
>> The driver creation code is in its own function, and I simply copied the
>> call from DriverEntry into the IOCTL handler, so I don’t think it is a
>> problem with passing incorrect params- are there rules about when I
>> can/can’t call IoCreateDevice()? In the docs it says that calls must be
>> runnign at IRQL < DISPATCH_LEVEL- how do I know what the dispatch level of
>> IRP_MJ_DEVICE_CONTROL is? Does it depend on the IOCTL? How do I know/set
>> the dispatch level for custom IOCTLs?
>>
>> Thanks,
>> --Jeremy
>>
>>
>>
>> Scott Noone wrote:
>>> No, I’m saying that when you try to open “f:” it ends up as an attempt to
>>> open “f:\vdisk1”. If you try to open “f:\vdisk1” then it ends up as an
>>> attempt to open “f:\vdisk1\vdisk1”
>>>
>>> Try changing your DefineDosDevice to this and see if it works (or is at
>>> least different, which is sometimes one step closer to working :)):
>>>
>>> DefineDosDevice( DDD_RAW_TARGET_PATH, “f:”, “\Device\VDisk”)
>>>
>>> -scott
>>>
>
>
>
Interesting sentences that seem to impart nothing. The FileDisk code is
stolen. Anything based upon it could be subject of a lawsuit if the
copyright holder decides they want to stop it. If the copyright is sold to
another person/company they could decide to sue later so I would never base
any commercial product on that code. This thread and other threads will
give a good history that those using that code knew or should have known the
code was stolen, but went ahead anyway.
“Sun Jiajie” wrote in message news:xxxxx@ntfsd…
> If the source code is not free, or use free code to business. It means
> stealing code! But now it’s not this situation.
>
>
> “David J. Craig” дÈëÏûÏ¢ÐÂÎÅ:xxxxx@ntfsd…
>>I do wish all these people would quit advertising stolen code as something
>>to be used. See MANY prior posts about this subject.
>>
>> “Sun Jiajie” wrote in message
>> news:xxxxx@ntfsd…
>>> In my opinion, when you use DefineDosDevice() to define a volume, you
>>> aslo have to let the virtual volume’s data accord to the volume’s
>>> normal data(partition’s size, partition’s cluster size and so on). Not
>>> only the the icon can show in explorer, but also the volume can visit
>>> normally. Then you can use Createfile() to get its handle.
>>>
>>> Sourceforge have a project about virtual volume
>>> http://sourceforge.net/projects/storeddrive
>>> It based on Bo Branten “FileDisk” Project.
>>> And you also can find the FileDisk source code to check it
>>>
>>>
>>> “Jeremy Chaney” ???:xxxxx@ntfsd…
>>>> Hello, I am using DefineDosDevice() to associate my device with a
>>>> Volume (which succeeds and an icon for my drive shows up in explorer),
>>>> but when I call CreateFile to get the device handle, it fails with the
>>>> error “The system cannot find the file specified.”
>>>>
>>>> The device name I pass to DefineDosDevice is “f:”, and the filename I
>>>> pass to CreateFile() is “\.\f:”. Any ideas why CreateFile would fail?
>>>>
>>>> Thanks,
>>>> --Jeremy
>>>>
>>>
>>>
>>>
>>
>>
>>
>
>
>