I want to put trace information from my driver into a log-file.
But I have a BIG problem with the ZwCreateFile()-Call!
It returns always an error code of STATUS_OBJECT_NAME_INVALID.
The filename which I generated has the format which the DDK-docs demands!
Following is my code:
// -----
HANDLE hFile;
NTSTATUS ntStatus;
OBJECT_ATTRIBUTES stObjAttr;
IO_STATUS_BLOCK stIoStatus;
UNICODE_STRING strTemp;
wchar_t* pwszFile = L"\\??\\C:\\Temp\\test.dat";
strTemp.Length = strTemp.MaximumLength =
(wcslen(pwszFile) * sizeof(wchar_t)) + 2;
strTemp.Buffer = pwszFile;
RtlZeroMemory(&stObjAttr, sizeof(OBJECT_ATTRIBUTES));
RtlZeroMemory(&stIoStatus, sizeof(IO_STATUS_BLOCK));
InitializeObjectAttributes(&stObjAttr,
&strTemp,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
ntStatus = ZwCreateFile(&hFile,
FILE_WRITE_DATA,
&stObjAttr,
&stIoStatus,
0,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ,
FILE_CREATE |
FILE_OVERWRITE_IF,
FILE_SYNCHRONOUS_IO_NONALERT,
NULL,
0);
// ----
Anyone who has an idea?
Thanks
Reiner
--
Tom
"Reiner Ziegler" <reiner....@mail.regio.net> wrote in message
news:uv#pB$cqCHA.1808@TK2MSFTNGP09...
sorry, but thats not the reason. This is not an UNC-Path.
I've always tried this.
regards
Reiner
"Tom Stewart" <tast...@msdn.microsoft.com> schrieb im Newsbeitrag
news:OgwpaioqCHA.2548@TK2MSFTNGP10...
Windows NT/2000/XP: In the ANSI version of this function, the name is
limited to MAX_PATH characters. To extend this limit to nearly 32,000 wide
characters, call the Unicode version of the function and prepend "\\?\" to
the path.
Suggests perhaps the double question mark is wrong. So perhaps you should be
using "double backslash question mark backslash" which would in C be
"quadruple backslash question mark double backslash." Anyway, good luck.
--
Tom
"Reiner Ziegler" <reiner....@mail.regio.net> wrote in message
news:O2jQN9oqCHA.456@TK2MSFTNGP09...
And the confusion about the number of question marks and backslash
characters arises because you're talking about two different things. The
"\\\\?\\C:\\" rule that Tom Stuart espouses only applies to the Win32 API,
and how to go beyond the MAX_PATH limitation for file names. But
ZwCreateFile isn't part of the Win32 API, so that rule doesn't apply.
Instead, you use "\\??\\C:" to indicate that ZwCreateFile should use the NT
Object manager's top level "??" directory to look up a symbolic link
corresponding to "C:" to build the real internal NT object name for the
create. So your original example was almost correct, except for the length
of the string.
By the way, I would just use RtlInitUnicodeString(&strTemp, pwszFile) to set
up the UNICODE_STRING
Carl Appellof
"Reiner Ziegler" <reiner....@mail.regio.net> wrote in message
news:uv#pB$cqCHA.1808@TK2MSFTNGP09...
"Carl Appellof" <carl.a...@nospam.veritas.com> wrote in message
news:OizrTiPsCHA.868@TK2MSFTNGP12...