The file paths you pass to ZwCreateFile are not the same as those passed to Win32 CreateFile. They are related, but not the same. The kernel namespace is a large topic, but you can gain a lot of knowledge just by downloading WinObj.exe (url below) and running it. This is the root namespace of the kernel, which is in-memory only (volatile; it’s not a filesystem), and not exposed directly to Win32. Long story short, the I/O manager uses this namespace when resolving names passed to it by NtCreateFile/ZwCreateFile. The Win32 function CreateFile changes the names you pass it, from the Win32 syntax to the NT syntax.
Try using ??\PhysicalDrive0. (Of course, quote it for C, such as L"\??\PhysicalDrive0".) If you are using WinObj, look in \GLOBAL??. There are some special rules about resolving names that begin with ??; these rules deal with session naming. Again, it’s a long topic, and I’m short on time, but this may unblock you.
http://www.microsoft.com/technet/sysinternals/SystemInformation/WinObj.mspx
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Tuesday, May 15, 2007 2:57 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] ZwCreatFile Failure
I’m trying to open a handle to the system drive, from a Native application on Windows Xp.
The call to ZwCreateFile is returning with status 0xC0000033, STATUS_OBJECT_NAME_INVALID
I am trying to mimic code from a W32 application which sends an ATA command using the ATA Passthrough layer.
PCWSTR deviceName = L"\\.\PhysicalDrive0";
RtlInitUnicodeString(&uniDevName, deviceName);
InitializeObjectAttributes (pObjectAttributes, &uniDevName, OBJ_CASE_INSENSITIVE, NULL, NULL);
NTStat = ZwCreateFile(pHandle, // pointer to handle
GENERIC_READ | GENERIC_WRITE,
pObjectAttributes,
&ioStatusblock,
NULL,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ|FILE_SHARE_WRITE,
FILE_OPEN,
FILE_NO_EA_KNOWLEDGE,
NULL,
0
);
Is it obvious to anyone why the call is failing?
Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer