Re: Re: Re: NtCreateFile and STATUS_OBJECT_PATH_NOT_FOUND (0x0000003A)

"Myria" <[email protected]>
Newsgroups gmane.linux.ports.xbox.devel
Message-ID <041d01c47799$cffbe4f0$0200a8c0@missy>
> On Sun, 18 Jul 2004 23:36:18 -0700, Myria <[email protected]>
> wrote:
> > They are only equivalent if the drive letter is currently mapped to that
> > same place using IoCreateSymbolicLink().  By default, only D: is mapped
> > (typically to either the CD-ROM drive or the directory containing the
> > current XBE); the rest must be mapped by an XBE.  EvoX only has a drive
> > C: because it creates one pointing to partition 2.
>
> Thanks very much for the detailed info.  Very informative... a quick
> followup, if I can.

No problem, that's what I'm with Xbox Linux for - NT kernel expert =^_^=

> What are the consequences of not mounting the drive via
> IoCreateSymbolicLink()?  Are there any technical implications of going
> through a mount/map vs accessing the device/partition directly?

Other than (very) negligible memory use and speed differences, no.  The
primary reason to do mounting at all is coding simplicity.

There is something I forgot to mention before.  You can omit the \??\ if you
call NtCreateFile in a certain way.

In NT, if you have an open handle to a directory - either a pseudo-directory
like \Device or an actual disk directory - you can open files inside the
directory by giving that handle and specifying only the part of the filename
from within that directory.  For example, if you have an open handle to
\Device\Harddisk0, you can call NtCreateFile with that handle and filename
parameter Partition2\BLAH.TXT to open EvoX's C:\BLAH.TXT.  (Getting this
open handle is a matter of choosing the correct access parameters to
NtCreateFile and I really can't remember which exact ones to use.)

This is generally not very useful.  In real Windows NT, it is used all the
time, but invisibly.  In NT, including Xbox, there is no kernel-level
concept of "current directory".  It is manufactured in user mode (or not at
all on Xbox).  The user-mode DLLs ntdll.dll and kernel32.dll keep an open
handle to a directory within each drive letter and uses it to fake a current
directory system and use them later when opening a relative filename.  (This
is why there is no such thing as chroot in NT!)

There is one use for Xbox that is interesting though: the \?? directory has
a pseudohandle that is a constant and is always open.  Using this
pseudohandle, you can omit the \?? from your filenames and use drive/path
expressions just like DOS.  The constant is known by M$ as ObDosDevices
(from NT DDK stuff), but since you probably don't have that definition, use
#define ObDosDevices ((HANDLE) 0xFFFFFFFD).

The RootDirectory member of the OBJECT_ATTRIBUTES structure given to
NtCreateFile is the handle to the directory inside which you want to open a
file.  Normally you use NULL for this parameter - NULL means start at the
root.  However, if you use ObDosDevices for this parameter instead, you will
already be inside \??, so you could pass C:\BLAH.TXT directly as the
filename, which might motivate you to create symbolic links for this
purpose.  Microsoft's XDK API call CreateFile uses this exact trick to allow
DOS path syntax for developers without having to translate the string.

> The reason I ask is that I am writing an API that takes a filename of the
> form "C:\BLAH.TXT", and then my API calls the NtCreateFile APIs.  Given
> that I need to translate to either "\\??\\C:\\BLAH.TXT" or
> "\\Device\\Harddisk0\\Partition2\\BLAH.TXT", I was figuring I wouldn't
> bother mounting if I didn't need to.  Cheers...

Most of what I've said here is just background information - you don't
really need to know it for what you're dooing, but it helps to understand
NT.  In general, I usually mount drives because I don't feel like typing
\Device\Harddisk0\Partition2 all the time. >_<  But there is no technical
reason behind it.

Melissa

>
> --
> Craig Edwards
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by BEA Weblogic Workshop
> FREE Java Enterprise J2EE developer tools!
> Get your free copy of BEA WebLogic Workshop 8.1 today.
> http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click
> _______________________________________________
> Xbox-linux-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/xbox-linux-devel
>



-------------------------------------------------------
This SF.Net email is sponsored by OSTG. Have you noticed the changes on
Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now,
one more big change to announce. We are now OSTG- Open Source Technology
Group. Come see the changes on the new OSTG site. www.ostg.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.