volume mount freeze - code question

Hi All,

I have a couple of code questions. In the first case the system becomes slow
an unusable. In the second I eventually get a page fault. I want to make
sure I am not doing something blatantly wrong.

1.) Detectting Volume mounts:

PDEVICE_OBJECT devObj = NULL;
status = FltGetDiskDeviceObject( FltObjects->Volume, &devObj );

if (NT_SUCCESS(status)) {
status = IoVolumeDeviceToDosName( devObj, &dosName );
}

This worked for 3 different USB flash drives I used but not a fourth one (it
did work w/o my filter driver).
I used SoftICE to debug. It fails in the call to IoVolumeDeviceToDosName. I
have never seen SoftICE behave that way, but it just prints a lot of Debug
statements that are in various parts of the driver (basiucally SoftICE is
crashing) It just becomes unusable and I need to reboot.

2.) I am trying to get the dos name in kernel space. Trying to get the drive
letter, than replace the harddisk name with drive letter to get the full
path. It fails even with only one RtlInitUnicode in it. It doesn’t fail
right away, just after a few seconds, complaining about RtlInitUnicode
string. Just wondering if there is something fundamentally wrong with these
calls. This is in post create:

UNICODE_STRING completeDosName;
UNICODE_STRING auxBuf;

status = FltGetDiskDeviceObject( FltObjects->Volume, &devObj );
status = IoVolumeDeviceToDosName( devObj, &dosName );

if (devObj) {
ObDereferenceObject( devObj );
}

RtlInitUnicodeString( &completeDosName, (PCWSTR)dosName.Buffer);
completeDosName.MaximumLength = 520;
RtlInitUnicodeString( &auxBuf, (PCWSTR)
((nameInfo->Name).Buffer+(volNameLength/2) ));
auxBuf.MaximumLength = (USHORT) (nameInfo->Name).Length;

completeDosName.MaximumLength = completeDosName.MaximumLength +
auxBuf.MaximumLength;
status = RtlAppendUnicodeStringToString( &completeDosName, &auxBuf);

Thanks, bjorn

Redesign the app to only use the volume GUIDs at kernel level, and only use
DOS drive letters in the UI. The main entity must be the volume GUID.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

----- Original Message -----
From: “bjorn haake”
Newsgroups: ntfsd
To: “Windows File Systems Devs Interest List”
Sent: Wednesday, February 01, 2006 3:29 AM
Subject: [ntfsd] volume mount freeze - code question

> Hi All,
>
> I have a couple of code questions. In the first case the system becomes slow
> an unusable. In the second I eventually get a page fault. I want to make
> sure I am not doing something blatantly wrong.
>
> 1.) Detectting Volume mounts:
>
> PDEVICE_OBJECT devObj = NULL;
> status = FltGetDiskDeviceObject( FltObjects->Volume, &devObj );
>
> if (NT_SUCCESS(status)) {
> status = IoVolumeDeviceToDosName( devObj, &dosName );
> }
>
> This worked for 3 different USB flash drives I used but not a fourth one (it
> did work w/o my filter driver).
> I used SoftICE to debug. It fails in the call to IoVolumeDeviceToDosName. I
> have never seen SoftICE behave that way, but it just prints a lot of Debug
> statements that are in various parts of the driver (basiucally SoftICE is
> crashing) It just becomes unusable and I need to reboot.
>
>
> 2.) I am trying to get the dos name in kernel space. Trying to get the drive
> letter, than replace the harddisk name with drive letter to get the full
> path. It fails even with only one RtlInitUnicode in it. It doesn’t fail
> right away, just after a few seconds, complaining about RtlInitUnicode
> string. Just wondering if there is something fundamentally wrong with these
> calls. This is in post create:
>
> UNICODE_STRING completeDosName;
> UNICODE_STRING auxBuf;
>
> status = FltGetDiskDeviceObject( FltObjects->Volume, &devObj );
> status = IoVolumeDeviceToDosName( devObj, &dosName );
>
> if (devObj) {
> ObDereferenceObject( devObj );
> }
>
> RtlInitUnicodeString( &completeDosName, (PCWSTR)dosName.Buffer);
> completeDosName.MaximumLength = 520;
> RtlInitUnicodeString( &auxBuf, (PCWSTR)
> ((nameInfo->Name).Buffer+(volNameLength/2) ));
> auxBuf.MaximumLength = (USHORT) (nameInfo->Name).Length;
>
> completeDosName.MaximumLength = completeDosName.MaximumLength +
> auxBuf.MaximumLength;
> status = RtlAppendUnicodeStringToString( &completeDosName, &auxBuf);
>
> Thanks, bjorn
>
>
>
> —
> Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com

Thanks. Someone pointed out to me that my Unicode Buffer might not be
null-terminated and that I shouldn’t change the Max Length.

I am still puzzled why IoVolumeDeviceToDosName works for some flash drives,
but n ot for others (and yes, I am running it on win xp, sp2)

bjorn

“Maxim S. Shatskih” wrote in message
news:xxxxx@ntfsd…
> Redesign the app to only use the volume GUIDs at kernel level, and only
> use
> DOS drive letters in the UI. The main entity must be the volume GUID.
>
> Maxim Shatskih, Windows DDK MVP
> StorageCraft Corporation
> xxxxx@storagecraft.com
> http://www.storagecraft.com
>
> ----- Original Message -----
> From: “bjorn haake”
> Newsgroups: ntfsd
> To: “Windows File Systems Devs Interest List”
> Sent: Wednesday, February 01, 2006 3:29 AM
> Subject: [ntfsd] volume mount freeze - code question
>
>
>> Hi All,
>>
>> I have a couple of code questions. In the first case the system becomes
>> slow
>> an unusable. In the second I eventually get a page fault. I want to make
>> sure I am not doing something blatantly wrong.
>>
>> 1.) Detectting Volume mounts:
>>
>> PDEVICE_OBJECT devObj = NULL;
>> status = FltGetDiskDeviceObject( FltObjects->Volume, &devObj );
>>
>> if (NT_SUCCESS(status)) {
>> status = IoVolumeDeviceToDosName( devObj, &dosName );
>> }
>>
>> This worked for 3 different USB flash drives I used but not a fourth one
>> (it
>> did work w/o my filter driver).
>> I used SoftICE to debug. It fails in the call to IoVolumeDeviceToDosName.
>> I
>> have never seen SoftICE behave that way, but it just prints a lot of
>> Debug
>> statements that are in various parts of the driver (basiucally SoftICE is
>> crashing) It just becomes unusable and I need to reboot.
>>
>>
>> 2.) I am trying to get the dos name in kernel space. Trying to get the
>> drive
>> letter, than replace the harddisk name with drive letter to get the full
>> path. It fails even with only one RtlInitUnicode in it. It doesn’t fail
>> right away, just after a few seconds, complaining about RtlInitUnicode
>> string. Just wondering if there is something fundamentally wrong with
>> these
>> calls. This is in post create:
>>
>> UNICODE_STRING completeDosName;
>> UNICODE_STRING auxBuf;
>>
>> status = FltGetDiskDeviceObject( FltObjects->Volume, &devObj );
>> status = IoVolumeDeviceToDosName( devObj, &dosName );
>>
>> if (devObj) {
>> ObDereferenceObject( devObj );
>> }
>>
>> RtlInitUnicodeString( &completeDosName, (PCWSTR)dosName.Buffer);
>> completeDosName.MaximumLength = 520;
>> RtlInitUnicodeString( &auxBuf, (PCWSTR)
>> ((nameInfo->Name).Buffer+(volNameLength/2) ));
>> auxBuf.MaximumLength = (USHORT) (nameInfo->Name).Length;
>>
>> completeDosName.MaximumLength = completeDosName.MaximumLength +
>> auxBuf.MaximumLength;
>> status = RtlAppendUnicodeStringToString( &completeDosName, &auxBuf);
>>
>> Thanks, bjorn
>>
>>
>>
>> —
>> Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cfm?id=17
>>
>> You are currently subscribed to ntfsd as: xxxxx@storagecraft.com
>> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>

Ok, I realize now I can’t do any FS calls during mounts…

thanks, bjorn

“bjorn haake” wrote in message news:xxxxx@ntfsd…
> Hi All,
>
> I have a couple of code questions. In the first case the system becomes
> slow an unusable. In the second I eventually get a page fault. I want to
> make sure I am not doing something blatantly wrong.
>
> 1.) Detectting Volume mounts:
>
> PDEVICE_OBJECT devObj = NULL;
> status = FltGetDiskDeviceObject( FltObjects->Volume, &devObj );
>
> if (NT_SUCCESS(status)) {
> status = IoVolumeDeviceToDosName( devObj, &dosName );
> }
>
> This worked for 3 different USB flash drives I used but not a fourth one
> (it did work w/o my filter driver).
> I used SoftICE to debug. It fails in the call to IoVolumeDeviceToDosName.
> I have never seen SoftICE behave that way, but it just prints a lot of
> Debug statements that are in various parts of the driver (basiucally
> SoftICE is crashing) It just becomes unusable and I need to reboot.
>
>
> 2.) I am trying to get the dos name in kernel space. Trying to get the
> drive letter, than replace the harddisk name with drive letter to get the
> full path. It fails even with only one RtlInitUnicode in it. It doesn’t
> fail right away, just after a few seconds, complaining about
> RtlInitUnicode string. Just wondering if there is something fundamentally
> wrong with these calls. This is in post create:
>
> UNICODE_STRING completeDosName;
> UNICODE_STRING auxBuf;
>
> status = FltGetDiskDeviceObject( FltObjects->Volume, &devObj );
> status = IoVolumeDeviceToDosName( devObj, &dosName );
>
> if (devObj) {
> ObDereferenceObject( devObj );
> }
>
> RtlInitUnicodeString( &completeDosName, (PCWSTR)dosName.Buffer);
> completeDosName.MaximumLength = 520;
> RtlInitUnicodeString( &auxBuf, (PCWSTR)
> ((nameInfo->Name).Buffer+(volNameLength/2) ));
> auxBuf.MaximumLength = (USHORT) (nameInfo->Name).Length;
>
> completeDosName.MaximumLength = completeDosName.MaximumLength +
> auxBuf.MaximumLength;
> status = RtlAppendUnicodeStringToString( &completeDosName, &auxBuf);
>
> Thanks, bjorn
>
>
>