Does CreateFile() executes differently with FAT32 and NTFS ?

Hi All,

I wrote a encryption virtual disk driver. After mounted, the virtual disk devices created by the driver doesn’t process any read/write/deviceioctl until a deviceioctl to authenticate user password has been passed. Another deviceIoctl is to make the authentication null, after this, the driver denies read/write/deviceioctl again until another authentication executed successfully. I use CreateFile() to open handle of the device before every deviceIoctl, and after execution of deviceIoctl, I call CloseHandle to close it.

In Windows 2000, the driver works well.
In Windows XP, the driver works well if the virtual disk is formatted into NTFS.
But if the virtual disk is formatted into FAT32, there is a problem!

Firstly, the virtual disk is mounted as a volume(such as Z: partition);
Secondly, the application call authentication deviceIoctl to verify user property;
-----Now we can use the virtual disk like a physical disk.
Then the application call the deviceIoctl to nullify the authentication;
-----Now the virtual disk denies all access.

Here comes the problem, Now if I want to get handle of the device, the CreateFile() function return failed! GetLastError() return error code 1(ERROR_INVALID_FUNCTION).

Who can tell me why I get different result for NTFS and FAT32?

Wrong list. NTDEV is more appropriate for this question.

There is not enough info to answer as it is possible to write virtual disk driver several ways and it is unclear what you did. Maybe I misunderstood but it seems as you’re sending IOCTLs to virtual drive device. If so, you should use one control device for all IOCTLs instead (and one device per virtual drive).

Generic answer is: debug you driver. Turn on traces and you’ll see what your driver does and the difference between both situations you described. Are you using traces, right?

Best regards,

Michal Vodicka
UPEK, Inc.
[xxxxx@upek.com, http://www.upek.com]


From: xxxxx@lists.osr.com[SMTP:xxxxx@lists.osr.com] on behalf of Bruce Zhang[SMTP:xxxxx@vip.sina.com]
Reply To: Windows File Systems Devs Interest List
Sent: Thursday, October 14, 2004 4:01 AM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] Does CreateFile() executes differently with FAT32 and NTFS ?

Hi All,

I wrote a encryption virtual disk driver. After mounted, the virtual disk devices created by the driver doesn’t process any read/write/deviceioctl until a deviceioctl to authenticate user password has been passed. Another deviceIoctl is to make the authentication null, after this, the driver denies read/write/deviceioctl again until another authentication executed successfully. I use CreateFile() to open handle of the device before every deviceIoctl, and after execution of deviceIoctl, I call CloseHandle to close it.

In Windows 2000, the driver works well.
In Windows XP, the driver works well if the virtual disk is formatted into NTFS.
But if the virtual disk is formatted into FAT32, there is a problem!

Firstly, the virtual disk is mounted as a volume(such as Z: partition);
Secondly, the application call authentication deviceIoctl to verify user property;
-----Now we can use the virtual disk like a physical disk.
Then the application call the deviceIoctl to nullify the authentication;
-----Now the virtual disk denies all access.

Here comes the problem, Now if I want to get handle of the device, the CreateFile() function return failed! GetLastError() return error code 1(ERROR_INVALID_FUNCTION).

Who can tell me why I get different result for NTFS and FAT32?

Questions? First check the IFS FAQ at https://www.osronline.com/article.cfm?id=17

You are currently subscribed to $subst(‘List.Name’) as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to $subst(‘Email.UnSub’)

I did trace my driver, but it seems that the dispatch routine to process IRP_MJ_CREATE doesn’t been touched when CreateFile() called.

----- Original Message -----
From: “Michal Vodicka”
To: “Windows File Systems Devs Interest List”
Sent: Thursday, October 14, 2004 11:04 AM
Subject: RE: [ntfsd] Does CreateFile() executes differently with FAT32 and NTFS ?

Wrong list. NTDEV is more appropriate for this question.

There is not enough info to answer as it is possible to write virtual disk driver several ways and it is unclear what you did. Maybe I misunderstood but it seems as you’re sending IOCTLs to virtual drive device. If so, you should use one control device for all IOCTLs instead (and one device per virtual drive).

Generic answer is: debug you driver. Turn on traces and you’ll see what your driver does and the difference between both situations you described. Are you using traces, right?

Best regards,

Michal Vodicka
UPEK, Inc.
[xxxxx@upek.com, http://www.upek.com]

> ----------
> From: xxxxx@lists.osr.com[SMTP:xxxxx@lists.osr.com] on behalf of Bruce Zhang[SMTP:xxxxx@vip.sina.com]
> Reply To: Windows File Systems Devs Interest List
> Sent: Thursday, October 14, 2004 4:01 AM
> To: Windows File Systems Devs Interest List
> Subject: [ntfsd] Does CreateFile() executes differently with FAT32 and NTFS ?
>
> Hi All,
>
> I wrote a encryption virtual disk driver. After mounted, the virtual disk devices created by the driver doesn’t process any read/write/deviceioctl until a deviceioctl to authenticate user password has been passed. Another deviceIoctl is to make the authentication null, after this, the driver denies read/write/deviceioctl again until another authentication executed successfully. I use CreateFile() to open handle of the device before every deviceIoctl, and after execution of deviceIoctl, I call CloseHandle to close it.
>
> In Windows 2000, the driver works well.
> In Windows XP, the driver works well if the virtual disk is formatted into NTFS.
> But if the virtual disk is formatted into FAT32, there is a problem!
>
> Firstly, the virtual disk is mounted as a volume(such as Z: partition);
> Secondly, the application call authentication deviceIoctl to verify user property;
> -----Now we can use the virtual disk like a physical disk.
> Then the application call the deviceIoctl to nullify the authentication;
> -----Now the virtual disk denies all access.
>
> Here comes the problem, Now if I want to get handle of the device, the CreateFile() function return failed! GetLastError() return error code 1(ERROR_INVALID_FUNCTION).
>
> Who can tell me why I get different result for NTFS and FAT32?
> —
> Questions? First check the IFS FAQ at https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: unknown lmsubst tag argument: ‘’
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>


Questions? First check the IFS FAQ at https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

Just a guess - are you using FILE_DEVICE_DISK in the IoCreateDevice? Using other device types may lead to similar simptoms.

Alexei.
“Bruce Zhang” wrote in message news:xxxxx@ntfsd…
Hi All,

I wrote a encryption virtual disk driver. After mounted, the virtual disk devices created by the driver doesn’t process any read/write/deviceioctl until a deviceioctl to authenticate user password has been passed. Another deviceIoctl is to make the authentication null, after this, the driver denies read/write/deviceioctl again until another authentication executed successfully. I use CreateFile() to open handle of the device before every deviceIoctl, and after execution of deviceIoctl, I call CloseHandle to close it.

In Windows 2000, the driver works well.
In Windows XP, the driver works well if the virtual disk is formatted into NTFS.
But if the virtual disk is formatted into FAT32, there is a problem!

Firstly, the virtual disk is mounted as a volume(such as Z: partition);
Secondly, the application call authentication deviceIoctl to verify user property;
-----Now we can use the virtual disk like a physical disk.
Then the application call the deviceIoctl to nullify the authentication;
-----Now the virtual disk denies all access.

Here comes the problem, Now if I want to get handle of the device, the CreateFile() function return failed! GetLastError() return error code 1(ERROR_INVALID_FUNCTION).

Who can tell me why I get different result for NTFS and FAT32?