Determining boot disk from a driver

Is it possible to determine the boot disk (e.g., C:, D:, etc.) from a
driver? I’d like to open a file on the disk and the ZwCreateFile and
ZwOpenFile want the full path to it. I’m not sure the best way of
determining the disk from within the driver.

Thanks
Dan


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Using \SystemRoot.… will help you determine the boot disk.

\SystemRoot is a symbolic link that effectively converts to
\Device\HarddiskX\PartitionX<windows directory>

This will let you access the files in the directory or the
sub directories because that’s the only form of name that
will work no matter when your driver is being loaded.

Niraj

-----Original Message-----
From: xxxxx@emulex.com [mailto:xxxxx@emulex.com]
Sent: Monday, May 14, 2001 6:01 PM
To: NT Developers Interest List
Subject: [ntdev] Determining boot disk from a driver

Is it possible to determine the boot disk (e.g., C:, D:, etc.) from a
driver? I’d like to open a file on the disk and the ZwCreateFile and
ZwOpenFile want the full path to it. I’m not sure the best way of
determining the disk from within the driver.

Thanks
Dan


You are currently subscribed to ntdev as: xxxxx@netapp.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Niraj,

Thanks for getting back to me with this help.

Let me see if I understand what you are saying. If I code up my call to
IoInitializeObject Attributes() like so, I will open a file on the boot disk

RtlInitUnicodeString(&FileName,
L"\??\SystemRoot\WINNT\system32\drivers\file.txt");
InitializeObjectAttributes(&Attributes,
&FileName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Jaiswal, Niraj
Sent: Tuesday, May 15, 2001 3:53 PM
To: NT Developers Interest List
Subject: [ntdev] RE: Determining boot disk from a driver

Using \SystemRoot.… will help you determine the boot disk.

\SystemRoot is a symbolic link that effectively converts to
\Device\HarddiskX\PartitionX<windows directory>

This will let you access the files in the directory or the
sub directories because that’s the only form of name that
will work no matter when your driver is being loaded.

Niraj

-----Original Message-----
From: xxxxx@emulex.com [mailto:xxxxx@emulex.com]
Sent: Monday, May 14, 2001 6:01 PM
To: NT Developers Interest List
Subject: [ntdev] Determining boot disk from a driver

Is it possible to determine the boot disk (e.g., C:, D:, etc.) from a
driver? I’d like to open a file on the disk and the ZwCreateFile and
ZwOpenFile want the full path to it. I’m not sure the best way of
determining the disk from within the driver.

Thanks
Dan


You are currently subscribed to ntdev as: xxxxx@netapp.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: xxxxx@emulex.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

No, the SystemRoot is a symbolic link object right in the root directory
of the object manager’s tree. And it points to “system boot partition:\
windows directory”, se there is an error to append the WINNT string
(which can be changed in the installation time to anything).

Your string should look like
L"\SystemRoot\system32\drivers\file.txt",
because all except the last component is really stable - from version to
version and in all installations.

Hope this helps
Paul

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Dan Sullivan
Sent: Tuesday, May 15, 2001 10:17 PM
To: NT Developers Interest List
Subject: [ntdev] RE: Determining boot disk from a driver

Niraj,

Thanks for getting back to me with this help.

Let me see if I understand what you are saying. If I code up my call to
IoInitializeObject Attributes() like so, I will open a file on the boot
disk

RtlInitUnicodeString(&FileName,
L"\??\SystemRoot\WINNT\system32\drivers\file.txt");
InitializeObjectAttributes(&Attributes,
&FileName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Jaiswal, Niraj
Sent: Tuesday, May 15, 2001 3:53 PM
To: NT Developers Interest List
Subject: [ntdev] RE: Determining boot disk from a driver

Using \SystemRoot.… will help you determine the boot disk.

\SystemRoot is a symbolic link that effectively converts to
\Device\HarddiskX\PartitionX<windows directory>

This will let you access the files in the directory or the
sub directories because that’s the only form of name that
will work no matter when your driver is being loaded.

Niraj

-----Original Message-----
From: xxxxx@emulex.com [mailto:xxxxx@emulex.com]
Sent: Monday, May 14, 2001 6:01 PM
To: NT Developers Interest List
Subject: [ntdev] Determining boot disk from a driver

Is it possible to determine the boot disk (e.g., C:, D:, etc.) from a
driver? I’d like to open a file on the disk and the ZwCreateFile and
ZwOpenFile want the full path to it. I’m not sure the best way of
determining the disk from within the driver.

Thanks
Dan


You are currently subscribed to ntdev as: xxxxx@netapp.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: xxxxx@emulex.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: xxxxx@compelson.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

RE: [ntdev] RE: Determining boot disk from a driverThanks, I understand now.

Works like a charm.

Dan
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Hrdina Pavel
Sent: Tuesday, May 15, 2001 4:36 PM
To: NT Developers Interest List
Subject: [ntdev] RE: Determining boot disk from a driver

No, the SystemRoot is a symbolic link object right in the root directory
of the object manager’s tree. And it points to “system boot partition:\
windows directory”, se there is an error to append the WINNT string
(which can be changed in the installation time to anything).

Your string should look like L"\SystemRoot\system32\drivers\file.txt",
because all except the last component is really stable - from version to
version and in all installations.

Hope this helps
Paul

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Dan Sullivan
Sent: Tuesday, May 15, 2001 10:17 PM
To: NT Developers Interest List
Subject: [ntdev] RE: Determining boot disk from a driver

Niraj,

Thanks for getting back to me with this help.

Let me see if I understand what you are saying. If I code up my call to
IoInitializeObject Attributes() like so, I will open a file on the boot
disk

RtlInitUnicodeString(&FileName,
L"\??\SystemRoot\WINNT\system32\drivers\file.txt");
InitializeObjectAttributes(&Attributes,
&FileName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Jaiswal, Niraj
Sent: Tuesday, May 15, 2001 3:53 PM
To: NT Developers Interest List
Subject: [ntdev] RE: Determining boot disk from a driver

Using \SystemRoot.… will help you determine the boot disk.

\SystemRoot is a symbolic link that effectively converts to
\Device\HarddiskX\PartitionX<windows directory>

This will let you access the files in the directory or the
sub directories because that’s the only form of name that
will work no matter when your driver is being loaded.

Niraj

-----Original Message-----
From: xxxxx@emulex.com [mailto:xxxxx@emulex.com]
Sent: Monday, May 14, 2001 6:01 PM
To: NT Developers Interest List
Subject: [ntdev] Determining boot disk from a driver

Is it possible to determine the boot disk (e.g., C:, D:, etc.) from a
driver? I’d like to open a file on the disk and the ZwCreateFile and
ZwOpenFile want the full path to it. I’m not sure the best way of
determining the disk from within the driver.

Thanks
Dan


You are currently subscribed to ntdev as: xxxxx@netapp.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: xxxxx@emulex.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: xxxxx@compelson.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: xxxxx@emulex.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

I think, I made a typo. Your path should read.

L"\SystemRoot\system32\drivers\file.txt"

From Walter Oney’s White paper on file I/O
(http://www.oneysoft.com/whitepaper.htm)

File Naming

Windows 98 and Windows 2000 both use the same file system model,
wherein disks identified by driver letters have a hierarchy of
directories containing files. If you’re trying to open a file
during what might turn out to be the initialization phase of
Windows 2000, however, you can’t use normal drive letters because
the file system infrastructure supporting drive letters won’t
yet have been initialized. You can, however, freely access files
that are located within the Windows directory (\WINNT on some
disk, for example) by using the special name prefix "\SystemRoot".
For example, this filename:

\SystemRoot\system32\drivers\fileio.jnk

identifies a file named “fileio.jnk” in the drivers directory.
The advantage of naming the file this way is that ZwCreateFile
can always find it, no matter what stage of initialization the
system happens to be in.

Niraj

-----Original Message-----
From: Dan Sullivan [mailto:xxxxx@emulex.com]
Sent: Tuesday, May 15, 2001 1:17 PM
To: NT Developers Interest List
Subject: [ntdev] RE: Determining boot disk from a driver

Niraj,

Thanks for getting back to me with this help.

Let me see if I understand what you are saying. If I code up my call to
IoInitializeObject Attributes() like so, I will open a file on the boot disk

RtlInitUnicodeString(&FileName,
L"\??\SystemRoot\WINNT\system32\drivers\file.txt");
InitializeObjectAttributes(&Attributes,
&FileName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Jaiswal, Niraj
Sent: Tuesday, May 15, 2001 3:53 PM
To: NT Developers Interest List
Subject: [ntdev] RE: Determining boot disk from a driver

Using \SystemRoot.… will help you determine the boot disk.

\SystemRoot is a symbolic link that effectively converts to
\Device\HarddiskX\PartitionX<windows directory>

This will let you access the files in the directory or the
sub directories because that’s the only form of name that
will work no matter when your driver is being loaded.

Niraj

-----Original Message-----
From: xxxxx@emulex.com [mailto:xxxxx@emulex.com]
Sent: Monday, May 14, 2001 6:01 PM
To: NT Developers Interest List
Subject: [ntdev] Determining boot disk from a driver

Is it possible to determine the boot disk (e.g., C:, D:, etc.) from a
driver? I’d like to open a file on the disk and the ZwCreateFile and
ZwOpenFile want the full path to it. I’m not sure the best way of
determining the disk from within the driver.

Thanks
Dan


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Almost. If you are the boot disk adapter driver, you are totally out of
options for opening files during initialization. ZwCreateFile interrupts
into NtCreateFile, which then calls IoCreateFile, which will fail if the
boot disk adapter driver is still initializing… There are solutions, but
none of them are especially pretty.

Phil

-----Original Message-----
From: Jaiswal, Niraj [mailto:xxxxx@netapp.com]
Sent: Tuesday, May 15, 2001 12:53 PM
To: NT Developers Interest List
Subject: [ntdev] RE: Determining boot disk from a driver

Using \SystemRoot.… will help you determine the boot disk.

\SystemRoot is a symbolic link that effectively converts to
\Device\HarddiskX\PartitionX<windows directory>

This will let you access the files in the directory or the
sub directories because that’s the only form of name that
will work no matter when your driver is being loaded.

Niraj

-----Original Message-----
From: xxxxx@emulex.com [mailto:xxxxx@emulex.com]
Sent: Monday, May 14, 2001 6:01 PM
To: NT Developers Interest List
Subject: [ntdev] Determining boot disk from a driver

Is it possible to determine the boot disk (e.g., C:, D:, etc.) from a
driver? I’d like to open a file on the disk and the ZwCreateFile and
ZwOpenFile want the full path to it. I’m not sure the best way of
determining the disk from within the driver.

Thanks
Dan


You are currently subscribed to ntdev as: xxxxx@netapp.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: xxxxx@intel.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com