Help with "SetFileAttributes" in kernel mode

Hi !

I need a help with the following problem in Windows XP with Service Pack 2
and all updates:

My function NativeSetFileAttributes works fine with Native .exe (to execute
in BootExecute registry…),
but dont work inside .sys device-driver.

I debug the program and the error is in “RtlDosPathNameToNtPathName_U”. But
the error is only in the .sys. Native .exe works fine.

I try replace all “Nt*” API function names to “Zw*” API function names and
the error is the same.
I try change start mode device-driver to automatic, boot, system, etc and
dont work too.

What the error in this function ? Or exist another way to change file
attributes inside Kernel Mode ?

Thank you

void __stdcall NativeSetFileAttributes( short *FileName, DWORD attributes )
{
UNICODE_STRING uniString;
OBJECT_ATTRIBUTES obj;
IO_STATUS_BLOCK io;
NTSTATUS Status;
HANDLE Handle;

if ( RtlDosPathNameToNtPathName_U( FileName, &uniString, NULL, NULL ) )
{
InitializeObjectAttributes( &obj, &uniString, OBJ_CASE_INSENSITIVE,
NULL, NULL );

Status = NtOpenFile( &Handle,
FILE_WRITE_ATTRIBUTES,
&obj, &io,
0,
FILE_NON_DIRECTORY_FILE );

if ( NT_SUCCESS( Status ) )
{
FILE_BASIC_INFORMATION info = { 0 };
info.FileAttributes = attributes | FILE_ATTRIBUTE_NORMAL;

Status = NtSetInformationFile( Handle, &io, &info, sizeof(
info ), FileBasicInformation );
NtClose( Handle );
}
}
}

Do not use RtlDosPathNameToNtPathName_U.
Use IoVolumeDeviceToDosName or RtlVolumeDeviceToDosName instead.
I suggest getting the latest WDK and review this api.
BTW, as I recall RtlDosPathNameToNtPathName_U is not documented by MS.
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of MasvList
Sent: Tuesday, September 30, 2008 5:04 AM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] Help with “SetFileAttributes” in kernel mode

Hi !

I need a help with the following problem in Windows XP with Service Pack 2
and all updates:

My function NativeSetFileAttributes works fine with Native .exe (to execute
in BootExecute registry…),
but dont work inside .sys device-driver.

I debug the program and the error is in “RtlDosPathNameToNtPathName_U”. But

the error is only in the .sys. Native .exe works fine.

I try replace all “Nt*” API function names to “Zw*” API function names and
the error is the same.
I try change start mode device-driver to automatic, boot, system, etc and
dont work too.

What the error in this function ? Or exist another way to change file
attributes inside Kernel Mode ?

Thank you

void __stdcall NativeSetFileAttributes( short *FileName, DWORD attributes )
{
UNICODE_STRING uniString;
OBJECT_ATTRIBUTES obj;
IO_STATUS_BLOCK io;
NTSTATUS Status;
HANDLE Handle;

if ( RtlDosPathNameToNtPathName_U( FileName, &uniString, NULL, NULL ) )
{
InitializeObjectAttributes( &obj, &uniString, OBJ_CASE_INSENSITIVE,
NULL, NULL );

Status = NtOpenFile( &Handle,
FILE_WRITE_ATTRIBUTES,
&obj, &io,
0,
FILE_NON_DIRECTORY_FILE );

if ( NT_SUCCESS( Status ) )
{
FILE_BASIC_INFORMATION info = { 0 };
info.FileAttributes = attributes | FILE_ATTRIBUTE_NORMAL;

Status = NtSetInformationFile( Handle, &io, &info, sizeof(
info ), FileBasicInformation );
NtClose( Handle );
}
}
}


NTFSD is sponsored by OSR

For our schedule debugging and file system seminars
(including our new fs mini-filter seminar) visit:
http://www.osr.com/seminars

You are currently subscribed to ntfsd as: xxxxx@gmail.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Hi!
Thank you for your answer.

But “IoVolumeDeviceToDosName” and “RtlVolumeDeviceToDosName” return the same
result than
“RtlDosPathNameToNtPathName_U” ?

Because “RtlDosPathNameToNtPathName_U” convert a DOS path to NT path… and
“IoVolumeDeviceToDosName” and “RtlVolumeDeviceToDosName” convert NT path to
DOS path.

Thank you

----- Original Message -----
From: “Bercea Gabriel”
To: “Windows File Systems Devs Interest List”
Sent: Tuesday, September 30, 2008 6:13 AM
Subject: RE: [ntfsd] Help with “SetFileAttributes” in kernel mode

> Do not use RtlDosPathNameToNtPathName_U.
> Use IoVolumeDeviceToDosName or RtlVolumeDeviceToDosName instead.
> I suggest getting the latest WDK and review this api.
> BTW, as I recall RtlDosPathNameToNtPathName_U is not documented by MS.
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of MasvList
> Sent: Tuesday, September 30, 2008 5:04 AM
> To: Windows File Systems Devs Interest List
> Subject: [ntfsd] Help with “SetFileAttributes” in kernel mode
>
> Hi !
>
> I need a help with the following problem in Windows XP with Service Pack 2
> and all updates:
>
> My function NativeSetFileAttributes works fine with Native .exe (to
> execute
> in BootExecute registry…),
> but dont work inside .sys device-driver.
>
> I debug the program and the error is in “RtlDosPathNameToNtPathName_U”.
> But
>
> the error is only in the .sys. Native .exe works fine.
>
> I try replace all “Nt*” API function names to “Zw*” API function names and
> the error is the same.
> I try change start mode device-driver to automatic, boot, system, etc and
> dont work too.
>
> What the error in this function ? Or exist another way to change file
> attributes inside Kernel Mode ?
>
> Thank you
>
>
> void __stdcall NativeSetFileAttributes( short *FileName, DWORD
> attributes )
> {
> UNICODE_STRING uniString;
> OBJECT_ATTRIBUTES obj;
> IO_STATUS_BLOCK io;
> NTSTATUS Status;
> HANDLE Handle;
>
> if ( RtlDosPathNameToNtPathName_U( FileName, &uniString, NULL, NULL ) )
> {
> InitializeObjectAttributes( &obj, &uniString, OBJ_CASE_INSENSITIVE,
> NULL, NULL );
>
> Status = NtOpenFile( &Handle,
> FILE_WRITE_ATTRIBUTES,
> &obj, &io,
> 0,
> FILE_NON_DIRECTORY_FILE );
>
> if ( NT_SUCCESS( Status ) )
> {
> FILE_BASIC_INFORMATION info = { 0 };
> info.FileAttributes = attributes | FILE_ATTRIBUTE_NORMAL;
>
> Status = NtSetInformationFile( Handle, &io, &info, sizeof(
> info ), FileBasicInformation );
> NtClose( Handle );
> }
> }
> }
>
>
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule debugging and file system seminars
> (including our new fs mini-filter seminar) visit:
> http://www.osr.com/seminars
>
> You are currently subscribed to ntfsd as: xxxxx@gmail.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule debugging and file system seminars
> (including our new fs mini-filter seminar) visit:
> http://www.osr.com/seminars
>
> You are currently subscribed to ntfsd as: xxxxx@uol.com.br
> To unsubscribe send a blank email to xxxxx@lists.osr.com

It does not output the same result, but you do not need the whole path to be
translated, but only the NT Volume Device name. The rest of path is the
same.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of MasvList
Sent: Tuesday, September 30, 2008 1:23 PM
To: Windows File Systems Devs Interest List
Subject: Re: [ntfsd] Help with “SetFileAttributes” in kernel mode

Hi!
Thank you for your answer.

But “IoVolumeDeviceToDosName” and “RtlVolumeDeviceToDosName” return the same

result than
“RtlDosPathNameToNtPathName_U” ?

Because “RtlDosPathNameToNtPathName_U” convert a DOS path to NT path… and
“IoVolumeDeviceToDosName” and “RtlVolumeDeviceToDosName” convert NT path to
DOS path.

Thank you

----- Original Message -----
From: “Bercea Gabriel”
To: “Windows File Systems Devs Interest List”
Sent: Tuesday, September 30, 2008 6:13 AM
Subject: RE: [ntfsd] Help with “SetFileAttributes” in kernel mode

> Do not use RtlDosPathNameToNtPathName_U.
> Use IoVolumeDeviceToDosName or RtlVolumeDeviceToDosName instead.
> I suggest getting the latest WDK and review this api.
> BTW, as I recall RtlDosPathNameToNtPathName_U is not documented by MS.
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of MasvList
> Sent: Tuesday, September 30, 2008 5:04 AM
> To: Windows File Systems Devs Interest List
> Subject: [ntfsd] Help with “SetFileAttributes” in kernel mode
>
> Hi !
>
> I need a help with the following problem in Windows XP with Service Pack 2
> and all updates:
>
> My function NativeSetFileAttributes works fine with Native .exe (to
> execute
> in BootExecute registry…),
> but dont work inside .sys device-driver.
>
> I debug the program and the error is in “RtlDosPathNameToNtPathName_U”.
> But
>
> the error is only in the .sys. Native .exe works fine.
>
> I try replace all “Nt*” API function names to “Zw*” API function names and
> the error is the same.
> I try change start mode device-driver to automatic, boot, system, etc and
> dont work too.
>
> What the error in this function ? Or exist another way to change file
> attributes inside Kernel Mode ?
>
> Thank you
>
>
> void __stdcall NativeSetFileAttributes( short *FileName, DWORD
> attributes )
> {
> UNICODE_STRING uniString;
> OBJECT_ATTRIBUTES obj;
> IO_STATUS_BLOCK io;
> NTSTATUS Status;
> HANDLE Handle;
>
> if ( RtlDosPathNameToNtPathName_U( FileName, &uniString, NULL, NULL ) )
> {
> InitializeObjectAttributes( &obj, &uniString, OBJ_CASE_INSENSITIVE,
> NULL, NULL );
>
> Status = NtOpenFile( &Handle,
> FILE_WRITE_ATTRIBUTES,
> &obj, &io,
> 0,
> FILE_NON_DIRECTORY_FILE );
>
> if ( NT_SUCCESS( Status ) )
> {
> FILE_BASIC_INFORMATION info = { 0 };
> info.FileAttributes = attributes | FILE_ATTRIBUTE_NORMAL;
>
> Status = NtSetInformationFile( Handle, &io, &info, sizeof(
> info ), FileBasicInformation );
> NtClose( Handle );
> }
> }
> }
>
>
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule debugging and file system seminars
> (including our new fs mini-filter seminar) visit:
> http://www.osr.com/seminars
>
> You are currently subscribed to ntfsd as: xxxxx@gmail.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule debugging and file system seminars
> (including our new fs mini-filter seminar) visit:
> http://www.osr.com/seminars
>
> You are currently subscribed to ntfsd as: xxxxx@uol.com.br
> To unsubscribe send a blank email to xxxxx@lists.osr.com


NTFSD is sponsored by OSR

For our schedule debugging and file system seminars
(including our new fs mini-filter seminar) visit:
http://www.osr.com/seminars

You are currently subscribed to ntfsd as: xxxxx@gmail.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

But I have only the DOS file path like “c:\windows\notepad.exe”.

----- Original Message -----
From: “Bercea Gabriel”
To: “Windows File Systems Devs Interest List”
Sent: Tuesday, September 30, 2008 7:46 AM
Subject: RE: [ntfsd] Help with “SetFileAttributes” in kernel mode

> It does not output the same result, but you do not need the whole path to
> be
> translated, but only the NT Volume Device name. The rest of path is the
> same.
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of MasvList
> Sent: Tuesday, September 30, 2008 1:23 PM
> To: Windows File Systems Devs Interest List
> Subject: Re: [ntfsd] Help with “SetFileAttributes” in kernel mode
>
> Hi!
> Thank you for your answer.
>
> But “IoVolumeDeviceToDosName” and “RtlVolumeDeviceToDosName” return the
> same
>
> result than
> “RtlDosPathNameToNtPathName_U” ?
>
> Because “RtlDosPathNameToNtPathName_U” convert a DOS path to NT path…
> and
> “IoVolumeDeviceToDosName” and “RtlVolumeDeviceToDosName” convert NT path
> to
> DOS path.
>
> Thank you
>
>
>
> ----- Original Message -----
> From: “Bercea Gabriel”
> To: “Windows File Systems Devs Interest List”
> Sent: Tuesday, September 30, 2008 6:13 AM
> Subject: RE: [ntfsd] Help with “SetFileAttributes” in kernel mode
>
>
>> Do not use RtlDosPathNameToNtPathName_U.
>> Use IoVolumeDeviceToDosName or RtlVolumeDeviceToDosName instead.
>> I suggest getting the latest WDK and review this api.
>> BTW, as I recall RtlDosPathNameToNtPathName_U is not documented by MS.
>> -----Original Message-----
>> From: xxxxx@lists.osr.com
>> [mailto:xxxxx@lists.osr.com] On Behalf Of MasvList
>> Sent: Tuesday, September 30, 2008 5:04 AM
>> To: Windows File Systems Devs Interest List
>> Subject: [ntfsd] Help with “SetFileAttributes” in kernel mode
>>
>> Hi !
>>
>> I need a help with the following problem in Windows XP with Service Pack
>> 2
>> and all updates:
>>
>> My function NativeSetFileAttributes works fine with Native .exe (to
>> execute
>> in BootExecute registry…),
>> but dont work inside .sys device-driver.
>>
>> I debug the program and the error is in “RtlDosPathNameToNtPathName_U”.
>> But
>>
>> the error is only in the .sys. Native .exe works fine.
>>
>> I try replace all “Nt*” API function names to “Zw*” API function names
>> and
>> the error is the same.
>> I try change start mode device-driver to automatic, boot, system, etc and
>> dont work too.
>>
>> What the error in this function ? Or exist another way to change file
>> attributes inside Kernel Mode ?
>>
>> Thank you
>>
>>
>> void __stdcall NativeSetFileAttributes( short *FileName, DWORD
>> attributes )
>> {
>> UNICODE_STRING uniString;
>> OBJECT_ATTRIBUTES obj;
>> IO_STATUS_BLOCK io;
>> NTSTATUS Status;
>> HANDLE Handle;
>>
>> if ( RtlDosPathNameToNtPathName_U( FileName, &uniString, NULL,
>> NULL ) )
>> {
>> InitializeObjectAttributes( &obj, &uniString,
>> OBJ_CASE_INSENSITIVE,
>> NULL, NULL );
>>
>> Status = NtOpenFile( &Handle,
>> FILE_WRITE_ATTRIBUTES,
>> &obj, &io,
>> 0,
>> FILE_NON_DIRECTORY_FILE );
>>
>> if ( NT_SUCCESS( Status ) )
>> {
>> FILE_BASIC_INFORMATION info = { 0 };
>> info.FileAttributes = attributes | FILE_ATTRIBUTE_NORMAL;
>>
>> Status = NtSetInformationFile( Handle, &io, &info, sizeof(
>> info ), FileBasicInformation );
>> NtClose( Handle );
>> }
>> }
>> }
>>
>>
>>
>> —
>> NTFSD is sponsored by OSR
>>
>> For our schedule debugging and file system seminars
>> (including our new fs mini-filter seminar) visit:
>> http://www.osr.com/seminars
>>
>> You are currently subscribed to ntfsd as: xxxxx@gmail.com
>> To unsubscribe send a blank email to xxxxx@lists.osr.com
>>
>>
>> —
>> NTFSD is sponsored by OSR
>>
>> For our schedule debugging and file system seminars
>> (including our new fs mini-filter seminar) visit:
>> http://www.osr.com/seminars
>>
>> You are currently subscribed to ntfsd as: xxxxx@uol.com.br
>> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule debugging and file system seminars
> (including our new fs mini-filter seminar) visit:
> http://www.osr.com/seminars
>
> You are currently subscribed to ntfsd as: xxxxx@gmail.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule debugging and file system seminars
> (including our new fs mini-filter seminar) visit:
> http://www.osr.com/seminars
>
> You are currently subscribed to ntfsd as: xxxxx@uol.com.br
> To unsubscribe send a blank email to xxxxx@lists.osr.com

Yes but “C:” is a symbolic link to “\Device\HarddiskVolumeXXX”
Use object manager for this query. Read about NT’s object manager.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of MasvList
Sent: Tuesday, September 30, 2008 2:01 PM
To: Windows File Systems Devs Interest List
Subject: Re: [ntfsd] Help with “SetFileAttributes” in kernel mode

But I have only the DOS file path like “c:\windows\notepad.exe”.

----- Original Message -----
From: “Bercea Gabriel”
To: “Windows File Systems Devs Interest List”
Sent: Tuesday, September 30, 2008 7:46 AM
Subject: RE: [ntfsd] Help with “SetFileAttributes” in kernel mode

> It does not output the same result, but you do not need the whole path to
> be
> translated, but only the NT Volume Device name. The rest of path is the
> same.
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of MasvList
> Sent: Tuesday, September 30, 2008 1:23 PM
> To: Windows File Systems Devs Interest List
> Subject: Re: [ntfsd] Help with “SetFileAttributes” in kernel mode
>
> Hi!
> Thank you for your answer.
>
> But “IoVolumeDeviceToDosName” and “RtlVolumeDeviceToDosName” return the
> same
>
> result than
> “RtlDosPathNameToNtPathName_U” ?
>
> Because “RtlDosPathNameToNtPathName_U” convert a DOS path to NT path…
> and
> “IoVolumeDeviceToDosName” and “RtlVolumeDeviceToDosName” convert NT path
> to
> DOS path.
>
> Thank you
>
>
>
> ----- Original Message -----
> From: “Bercea Gabriel”
> To: “Windows File Systems Devs Interest List”
> Sent: Tuesday, September 30, 2008 6:13 AM
> Subject: RE: [ntfsd] Help with “SetFileAttributes” in kernel mode
>
>
>> Do not use RtlDosPathNameToNtPathName_U.
>> Use IoVolumeDeviceToDosName or RtlVolumeDeviceToDosName instead.
>> I suggest getting the latest WDK and review this api.
>> BTW, as I recall RtlDosPathNameToNtPathName_U is not documented by MS.
>> -----Original Message-----
>> From: xxxxx@lists.osr.com
>> [mailto:xxxxx@lists.osr.com] On Behalf Of MasvList
>> Sent: Tuesday, September 30, 2008 5:04 AM
>> To: Windows File Systems Devs Interest List
>> Subject: [ntfsd] Help with “SetFileAttributes” in kernel mode
>>
>> Hi !
>>
>> I need a help with the following problem in Windows XP with Service Pack
>> 2
>> and all updates:
>>
>> My function NativeSetFileAttributes works fine with Native .exe (to
>> execute
>> in BootExecute registry…),
>> but dont work inside .sys device-driver.
>>
>> I debug the program and the error is in “RtlDosPathNameToNtPathName_U”.
>> But
>>
>> the error is only in the .sys. Native .exe works fine.
>>
>> I try replace all “Nt*” API function names to “Zw*” API function names
>> and
>> the error is the same.
>> I try change start mode device-driver to automatic, boot, system, etc and
>> dont work too.
>>
>> What the error in this function ? Or exist another way to change file
>> attributes inside Kernel Mode ?
>>
>> Thank you
>>
>>
>> void __stdcall NativeSetFileAttributes( short *FileName, DWORD
>> attributes )
>> {
>> UNICODE_STRING uniString;
>> OBJECT_ATTRIBUTES obj;
>> IO_STATUS_BLOCK io;
>> NTSTATUS Status;
>> HANDLE Handle;
>>
>> if ( RtlDosPathNameToNtPathName_U( FileName, &uniString, NULL,
>> NULL ) )
>> {
>> InitializeObjectAttributes( &obj, &uniString,
>> OBJ_CASE_INSENSITIVE,
>> NULL, NULL );
>>
>> Status = NtOpenFile( &Handle,
>> FILE_WRITE_ATTRIBUTES,
>> &obj, &io,
>> 0,
>> FILE_NON_DIRECTORY_FILE );
>>
>> if ( NT_SUCCESS( Status ) )
>> {
>> FILE_BASIC_INFORMATION info = { 0 };
>> info.FileAttributes = attributes | FILE_ATTRIBUTE_NORMAL;
>>
>> Status = NtSetInformationFile( Handle, &io, &info, sizeof(
>> info ), FileBasicInformation );
>> NtClose( Handle );
>> }
>> }
>> }
>>
>>
>>
>> —
>> NTFSD is sponsored by OSR
>>
>> For our schedule debugging and file system seminars
>> (including our new fs mini-filter seminar) visit:
>> http://www.osr.com/seminars
>>
>> You are currently subscribed to ntfsd as: xxxxx@gmail.com
>> To unsubscribe send a blank email to xxxxx@lists.osr.com
>>
>>
>> —
>> NTFSD is sponsored by OSR
>>
>> For our schedule debugging and file system seminars
>> (including our new fs mini-filter seminar) visit:
>> http://www.osr.com/seminars
>>
>> You are currently subscribed to ntfsd as: xxxxx@uol.com.br
>> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule debugging and file system seminars
> (including our new fs mini-filter seminar) visit:
> http://www.osr.com/seminars
>
> You are currently subscribed to ntfsd as: xxxxx@gmail.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule debugging and file system seminars
> (including our new fs mini-filter seminar) visit:
> http://www.osr.com/seminars
>
> You are currently subscribed to ntfsd as: xxxxx@uol.com.br
> To unsubscribe send a blank email to xxxxx@lists.osr.com


NTFSD is sponsored by OSR

For our schedule debugging and file system seminars
(including our new fs mini-filter seminar) visit:
http://www.osr.com/seminars

You are currently subscribed to ntfsd as: xxxxx@gmail.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

In other words you don’t need to translate “c:”. You just have to prefix path with DOS devices prefix “??”. To be precise C literal is L"\??\".

-bg

Hi!
Sorry for disturb you. I dont found solution.

I need a user mode application and I write insite a .txt file the full path
for any files.
In the next boot, I need read .txt file and change all attributes.

But to change the attributes, I need have the \device name because without
this
name, the Zw / NtSetInformationFile dont work.

Any solution ?

Thank you

----- Original Message -----
From: “Bercea Gabriel”
To: “Windows File Systems Devs Interest List”
Sent: Tuesday, September 30, 2008 8:09 AM
Subject: RE: [ntfsd] Help with “SetFileAttributes” in kernel mode

> Yes but “C:” is a symbolic link to “\Device\HarddiskVolumeXXX”
> Use object manager for this query. Read about NT’s object manager.
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of MasvList
> Sent: Tuesday, September 30, 2008 2:01 PM
> To: Windows File Systems Devs Interest List
> Subject: Re: [ntfsd] Help with “SetFileAttributes” in kernel mode
>
> But I have only the DOS file path like “c:\windows\notepad.exe”.
>
>
> ----- Original Message -----
> From: “Bercea Gabriel”
> To: “Windows File Systems Devs Interest List”
> Sent: Tuesday, September 30, 2008 7:46 AM
> Subject: RE: [ntfsd] Help with “SetFileAttributes” in kernel mode
>
>
>> It does not output the same result, but you do not need the whole path to
>> be
>> translated, but only the NT Volume Device name. The rest of path is the
>> same.
>>
>> -----Original Message-----
>> From: xxxxx@lists.osr.com
>> [mailto:xxxxx@lists.osr.com] On Behalf Of MasvList
>> Sent: Tuesday, September 30, 2008 1:23 PM
>> To: Windows File Systems Devs Interest List
>> Subject: Re: [ntfsd] Help with “SetFileAttributes” in kernel mode
>>
>> Hi!
>> Thank you for your answer.
>>
>> But “IoVolumeDeviceToDosName” and “RtlVolumeDeviceToDosName” return the
>> same
>>
>> result than
>> “RtlDosPathNameToNtPathName_U” ?
>>
>> Because “RtlDosPathNameToNtPathName_U” convert a DOS path to NT path…
>> and
>> “IoVolumeDeviceToDosName” and “RtlVolumeDeviceToDosName” convert NT path
>> to
>> DOS path.
>>
>> Thank you
>>
>>
>>
>> ----- Original Message -----
>> From: “Bercea Gabriel”
>> To: “Windows File Systems Devs Interest List”
>> Sent: Tuesday, September 30, 2008 6:13 AM
>> Subject: RE: [ntfsd] Help with “SetFileAttributes” in kernel mode
>>
>>
>>> Do not use RtlDosPathNameToNtPathName_U.
>>> Use IoVolumeDeviceToDosName or RtlVolumeDeviceToDosName instead.
>>> I suggest getting the latest WDK and review this api.
>>> BTW, as I recall RtlDosPathNameToNtPathName_U is not documented by MS.
>>> -----Original Message-----
>>> From: xxxxx@lists.osr.com
>>> [mailto:xxxxx@lists.osr.com] On Behalf Of MasvList
>>> Sent: Tuesday, September 30, 2008 5:04 AM
>>> To: Windows File Systems Devs Interest List
>>> Subject: [ntfsd] Help with “SetFileAttributes” in kernel mode
>>>
>>> Hi !
>>>
>>> I need a help with the following problem in Windows XP with Service Pack
>>> 2
>>> and all updates:
>>>
>>> My function NativeSetFileAttributes works fine with Native .exe (to
>>> execute
>>> in BootExecute registry…),
>>> but dont work inside .sys device-driver.
>>>
>>> I debug the program and the error is in “RtlDosPathNameToNtPathName_U”.
>>> But
>>>
>>> the error is only in the .sys. Native .exe works fine.
>>>
>>> I try replace all “Nt*” API function names to “Zw*” API function names
>>> and
>>> the error is the same.
>>> I try change start mode device-driver to automatic, boot, system, etc
>>> and
>>> dont work too.
>>>
>>> What the error in this function ? Or exist another way to change file
>>> attributes inside Kernel Mode ?
>>>
>>> Thank you
>>>
>>>
>>> void __stdcall NativeSetFileAttributes( short *FileName, DWORD
>>> attributes )
>>> {
>>> UNICODE_STRING uniString;
>>> OBJECT_ATTRIBUTES obj;
>>> IO_STATUS_BLOCK io;
>>> NTSTATUS Status;
>>> HANDLE Handle;
>>>
>>> if ( RtlDosPathNameToNtPathName_U( FileName, &uniString, NULL,
>>> NULL ) )
>>> {
>>> InitializeObjectAttributes( &obj, &uniString,
>>> OBJ_CASE_INSENSITIVE,
>>> NULL, NULL );
>>>
>>> Status = NtOpenFile( &Handle,
>>> FILE_WRITE_ATTRIBUTES,
>>> &obj, &io,
>>> 0,
>>> FILE_NON_DIRECTORY_FILE );
>>>
>>> if ( NT_SUCCESS( Status ) )
>>> {
>>> FILE_BASIC_INFORMATION info = { 0 };
>>> info.FileAttributes = attributes | FILE_ATTRIBUTE_NORMAL;
>>>
>>> Status = NtSetInformationFile( Handle, &io, &info, sizeof(
>>> info ), FileBasicInformation );
>>> NtClose( Handle );
>>> }
>>> }
>>> }
>>>
>>>
>>>
>>> —
>>> NTFSD is sponsored by OSR
>>>
>>> For our schedule debugging and file system seminars
>>> (including our new fs mini-filter seminar) visit:
>>> http://www.osr.com/seminars
>>>
>>> You are currently subscribed to ntfsd as: xxxxx@gmail.com
>>> To unsubscribe send a blank email to xxxxx@lists.osr.com
>>>
>>>
>>> —
>>> NTFSD is sponsored by OSR
>>>
>>> For our schedule debugging and file system seminars
>>> (including our new fs mini-filter seminar) visit:
>>> http://www.osr.com/seminars
>>>
>>> You are currently subscribed to ntfsd as: xxxxx@uol.com.br
>>> To unsubscribe send a blank email to xxxxx@lists.osr.com
>>
>>
>> —
>> NTFSD is sponsored by OSR
>>
>> For our schedule debugging and file system seminars
>> (including our new fs mini-filter seminar) visit:
>> http://www.osr.com/seminars
>>
>> You are currently subscribed to ntfsd as: xxxxx@gmail.com
>> To unsubscribe send a blank email to xxxxx@lists.osr.com
>>
>>
>> —
>> NTFSD is sponsored by OSR
>>
>> For our schedule debugging and file system seminars
>> (including our new fs mini-filter seminar) visit:
>> http://www.osr.com/seminars
>>
>> You are currently subscribed to ntfsd as: xxxxx@uol.com.br
>> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule debugging and file system seminars
> (including our new fs mini-filter seminar) visit:
> http://www.osr.com/seminars
>
> You are currently subscribed to ntfsd as: xxxxx@gmail.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule debugging and file system seminars
> (including our new fs mini-filter seminar) visit:
> http://www.osr.com/seminars
>
> You are currently subscribed to ntfsd as: xxxxx@uol.com.br
> To unsubscribe send a blank email to xxxxx@lists.osr.com

If you prepend the path with ?\ then you should be able to open the files.

Bill Wandel

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of MasvList
Sent: Wednesday, October 01, 2008 8:31 PM
To: Windows File Systems Devs Interest List
Subject: Re: [ntfsd] Help with “SetFileAttributes” in kernel mode

Hi!
Sorry for disturb you. I dont found solution.

I need a user mode application and I write insite a .txt file the full path
for any files.
In the next boot, I need read .txt file and change all attributes.

But to change the attributes, I need have the \device name because without
this name, the Zw / NtSetInformationFile dont work.

Any solution ?

Thank you

----- Original Message -----
From: “Bercea Gabriel”
To: “Windows File Systems Devs Interest List”
Sent: Tuesday, September 30, 2008 8:09 AM
Subject: RE: [ntfsd] Help with “SetFileAttributes” in kernel mode

> Yes but “C:” is a symbolic link to “\Device\HarddiskVolumeXXX”
> Use object manager for this query. Read about NT’s object manager.
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of MasvList
> Sent: Tuesday, September 30, 2008 2:01 PM
> To: Windows File Systems Devs Interest List
> Subject: Re: [ntfsd] Help with “SetFileAttributes” in kernel mode
>
> But I have only the DOS file path like “c:\windows\notepad.exe”.
>
>
> ----- Original Message -----
> From: “Bercea Gabriel”
> To: “Windows File Systems Devs Interest List”
> Sent: Tuesday, September 30, 2008 7:46 AM
> Subject: RE: [ntfsd] Help with “SetFileAttributes” in kernel mode
>
>
>> It does not output the same result, but you do not need the whole path to
>> be
>> translated, but only the NT Volume Device name. The rest of path is the
>> same.
>>
>> -----Original Message-----
>> From: xxxxx@lists.osr.com
>> [mailto:xxxxx@lists.osr.com] On Behalf Of MasvList
>> Sent: Tuesday, September 30, 2008 1:23 PM
>> To: Windows File Systems Devs Interest List
>> Subject: Re: [ntfsd] Help with “SetFileAttributes” in kernel mode
>>
>> Hi!
>> Thank you for your answer.
>>
>> But “IoVolumeDeviceToDosName” and “RtlVolumeDeviceToDosName” return the
>> same
>>
>> result than
>> “RtlDosPathNameToNtPathName_U” ?
>>
>> Because “RtlDosPathNameToNtPathName_U” convert a DOS path to NT path…
>> and
>> “IoVolumeDeviceToDosName” and “RtlVolumeDeviceToDosName” convert NT path
>> to
>> DOS path.
>>
>> Thank you
>>
>>
>>
>> ----- Original Message -----
>> From: “Bercea Gabriel”
>> To: “Windows File Systems Devs Interest List”
>> Sent: Tuesday, September 30, 2008 6:13 AM
>> Subject: RE: [ntfsd] Help with “SetFileAttributes” in kernel mode
>>
>>
>>> Do not use RtlDosPathNameToNtPathName_U.
>>> Use IoVolumeDeviceToDosName or RtlVolumeDeviceToDosName instead.
>>> I suggest getting the latest WDK and review this api.
>>> BTW, as I recall RtlDosPathNameToNtPathName_U is not documented by MS.
>>> -----Original Message-----
>>> From: xxxxx@lists.osr.com
>>> [mailto:xxxxx@lists.osr.com] On Behalf Of MasvList
>>> Sent: Tuesday, September 30, 2008 5:04 AM
>>> To: Windows File Systems Devs Interest List
>>> Subject: [ntfsd] Help with “SetFileAttributes” in kernel mode
>>>
>>> Hi !
>>>
>>> I need a help with the following problem in Windows XP with Service Pack
>>> 2
>>> and all updates:
>>>
>>> My function NativeSetFileAttributes works fine with Native .exe (to
>>> execute
>>> in BootExecute registry…),
>>> but dont work inside .sys device-driver.
>>>
>>> I debug the program and the error is in “RtlDosPathNameToNtPathName_U”.
>>> But
>>>
>>> the error is only in the .sys. Native .exe works fine.
>>>
>>> I try replace all “Nt*” API function names to “Zw*” API function names
>>> and
>>> the error is the same.
>>> I try change start mode device-driver to automatic, boot, system, etc
>>> and
>>> dont work too.
>>>
>>> What the error in this function ? Or exist another way to change file
>>> attributes inside Kernel Mode ?
>>>
>>> Thank you
>>>
>>>
>>> void __stdcall NativeSetFileAttributes( short *FileName, DWORD
>>> attributes )
>>> {
>>> UNICODE_STRING uniString;
>>> OBJECT_ATTRIBUTES obj;
>>> IO_STATUS_BLOCK io;
>>> NTSTATUS Status;
>>> HANDLE Handle;
>>>
>>> if ( RtlDosPathNameToNtPathName_U( FileName, &uniString, NULL,
>>> NULL ) )
>>> {
>>> InitializeObjectAttributes( &obj, &uniString,
>>> OBJ_CASE_INSENSITIVE,
>>> NULL, NULL );
>>>
>>> Status = NtOpenFile( &Handle,
>>> FILE_WRITE_ATTRIBUTES,
>>> &obj, &io,
>>> 0,
>>> FILE_NON_DIRECTORY_FILE );
>>>
>>> if ( NT_SUCCESS( Status ) )
>>> {
>>> FILE_BASIC_INFORMATION info = { 0 };
>>> info.FileAttributes = attributes | FILE_ATTRIBUTE_NORMAL;
>>>
>>> Status = NtSetInformationFile( Handle, &io, &info, sizeof(
>>> info ), FileBasicInformation );
>>> NtClose( Handle );
>>> }
>>> }
>>> }
>>>
>>>
>>>
>>> —
>>> NTFSD is sponsored by OSR
>>>
>>> For our schedule debugging and file system seminars
>>> (including our new fs mini-filter seminar) visit:
>>> http://www.osr.com/seminars
>>>
>>> You are currently subscribed to ntfsd as: xxxxx@gmail.com
>>> To unsubscribe send a blank email to xxxxx@lists.osr.com
>>>
>>>
>>> —
>>> NTFSD is sponsored by OSR
>>>
>>> For our schedule debugging and file system seminars
>>> (including our new fs mini-filter seminar) visit:
>>> http://www.osr.com/seminars
>>>
>>> You are currently subscribed to ntfsd as: xxxxx@uol.com.br
>>> To unsubscribe send a blank email to xxxxx@lists.osr.com
>>
>>
>> —
>> NTFSD is sponsored by OSR
>>
>> For our schedule debugging and file system seminars
>> (including our new fs mini-filter seminar) visit:
>> http://www.osr.com/seminars
>>
>> You are currently subscribed to ntfsd as: xxxxx@gmail.com
>> To unsubscribe send a blank email to xxxxx@lists.osr.com
>>
>>
>> —
>> NTFSD is sponsored by OSR
>>
>> For our schedule debugging and file system seminars
>> (including our new fs mini-filter seminar) visit:
>> http://www.osr.com/seminars
>>
>> You are currently subscribed to ntfsd as: xxxxx@uol.com.br
>> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule debugging and file system seminars
> (including our new fs mini-filter seminar) visit:
> http://www.osr.com/seminars
>
> You are currently subscribed to ntfsd as: xxxxx@gmail.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule debugging and file system seminars
> (including our new fs mini-filter seminar) visit:
> http://www.osr.com/seminars
>
> You are currently subscribed to ntfsd as: xxxxx@uol.com.br
> To unsubscribe send a blank email to xxxxx@lists.osr.com


NTFSD is sponsored by OSR

For our schedule debugging and file system seminars
(including our new fs mini-filter seminar) visit:
http://www.osr.com/seminars

You are currently subscribed to ntfsd as: xxxxx@bwandel.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

I add the \??\ but the same error… attributes do not change

----- Original Message -----
From: “Bill Wandel”
To: “Windows File Systems Devs Interest List”
Sent: Wednesday, October 01, 2008 9:38 PM
Subject: RE: [ntfsd] Help with “SetFileAttributes” in kernel mode

> If you prepend the path with ?\ then you should be able to open the
> files.
>
> Bill Wandel
>
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of MasvList
> Sent: Wednesday, October 01, 2008 8:31 PM
> To: Windows File Systems Devs Interest List
> Subject: Re: [ntfsd] Help with “SetFileAttributes” in kernel mode
>
> Hi!
> Sorry for disturb you. I dont found solution.
>
> I need a user mode application and I write insite a .txt file the full
> path
> for any files.
> In the next boot, I need read .txt file and change all attributes.
>
> But to change the attributes, I need have the \device name because
> without
> this name, the Zw / NtSetInformationFile dont work.
>
> Any solution ?
>
> Thank you
>
>
> ----- Original Message -----
> From: “Bercea Gabriel”
> To: “Windows File Systems Devs Interest List”
> Sent: Tuesday, September 30, 2008 8:09 AM
> Subject: RE: [ntfsd] Help with “SetFileAttributes” in kernel mode
>
>
>> Yes but “C:” is a symbolic link to “\Device\HarddiskVolumeXXX”
>> Use object manager for this query. Read about NT’s object manager.
>>
>> -----Original Message-----
>> From: xxxxx@lists.osr.com
>> [mailto:xxxxx@lists.osr.com] On Behalf Of MasvList
>> Sent: Tuesday, September 30, 2008 2:01 PM
>> To: Windows File Systems Devs Interest List
>> Subject: Re: [ntfsd] Help with “SetFileAttributes” in kernel mode
>>
>> But I have only the DOS file path like “c:\windows\notepad.exe”.
>>
>>
>> ----- Original Message -----
>> From: “Bercea Gabriel”
>> To: “Windows File Systems Devs Interest List”
>> Sent: Tuesday, September 30, 2008 7:46 AM
>> Subject: RE: [ntfsd] Help with “SetFileAttributes” in kernel mode
>>
>>
>>> It does not output the same result, but you do not need the whole path
>>> to
>>> be
>>> translated, but only the NT Volume Device name. The rest of path is the
>>> same.
>>>
>>> -----Original Message-----
>>> From: xxxxx@lists.osr.com
>>> [mailto:xxxxx@lists.osr.com] On Behalf Of MasvList
>>> Sent: Tuesday, September 30, 2008 1:23 PM
>>> To: Windows File Systems Devs Interest List
>>> Subject: Re: [ntfsd] Help with “SetFileAttributes” in kernel mode
>>>
>>> Hi!
>>> Thank you for your answer.
>>>
>>> But “IoVolumeDeviceToDosName” and “RtlVolumeDeviceToDosName” return the
>>> same
>>>
>>> result than
>>> “RtlDosPathNameToNtPathName_U” ?
>>>
>>> Because “RtlDosPathNameToNtPathName_U” convert a DOS path to NT path…
>>> and
>>> “IoVolumeDeviceToDosName” and “RtlVolumeDeviceToDosName” convert NT path
>>> to
>>> DOS path.
>>>
>>> Thank you
>>>
>>>
>>>
>>> ----- Original Message -----
>>> From: “Bercea Gabriel”
>>> To: “Windows File Systems Devs Interest List”
>>> Sent: Tuesday, September 30, 2008 6:13 AM
>>> Subject: RE: [ntfsd] Help with “SetFileAttributes” in kernel mode
>>>
>>>
>>>> Do not use RtlDosPathNameToNtPathName_U.
>>>> Use IoVolumeDeviceToDosName or RtlVolumeDeviceToDosName instead.
>>>> I suggest getting the latest WDK and review this api.
>>>> BTW, as I recall RtlDosPathNameToNtPathName_U is not documented by MS.
>>>> -----Original Message-----
>>>> From: xxxxx@lists.osr.com
>>>> [mailto:xxxxx@lists.osr.com] On Behalf Of MasvList
>>>> Sent: Tuesday, September 30, 2008 5:04 AM
>>>> To: Windows File Systems Devs Interest List
>>>> Subject: [ntfsd] Help with “SetFileAttributes” in kernel mode
>>>>
>>>> Hi !
>>>>
>>>> I need a help with the following problem in Windows XP with Service
>>>> Pack
>>>> 2
>>>> and all updates:
>>>>
>>>> My function NativeSetFileAttributes works fine with Native .exe (to
>>>> execute
>>>> in BootExecute registry…),
>>>> but dont work inside .sys device-driver.
>>>>
>>>> I debug the program and the error is in “RtlDosPathNameToNtPathName_U”.
>>>> But
>>>>
>>>> the error is only in the .sys. Native .exe works fine.
>>>>
>>>> I try replace all “Nt*” API function names to “Zw*” API function names
>>>> and
>>>> the error is the same.
>>>> I try change start mode device-driver to automatic, boot, system, etc
>>>> and
>>>> dont work too.
>>>>
>>>> What the error in this function ? Or exist another way to change file
>>>> attributes inside Kernel Mode ?
>>>>
>>>> Thank you
>>>>
>>>>
>>>> void __stdcall NativeSetFileAttributes( short *FileName, DWORD
>>>> attributes )
>>>> {
>>>> UNICODE_STRING uniString;
>>>> OBJECT_ATTRIBUTES obj;
>>>> IO_STATUS_BLOCK io;
>>>> NTSTATUS Status;
>>>> HANDLE Handle;
>>>>
>>>> if ( RtlDosPathNameToNtPathName_U( FileName, &uniString, NULL,
>>>> NULL ) )
>>>> {
>>>> InitializeObjectAttributes( &obj, &uniString,
>>>> OBJ_CASE_INSENSITIVE,
>>>> NULL, NULL );
>>>>
>>>> Status = NtOpenFile( &Handle,
>>>> FILE_WRITE_ATTRIBUTES,
>>>> &obj, &io,
>>>> 0,
>>>> FILE_NON_DIRECTORY_FILE );
>>>>
>>>> if ( NT_SUCCESS( Status ) )
>>>> {
>>>> FILE_BASIC_INFORMATION info = { 0 };
>>>> info.FileAttributes = attributes | FILE_ATTRIBUTE_NORMAL;
>>>>
>>>> Status = NtSetInformationFile( Handle, &io, &info, sizeof(
>>>> info ), FileBasicInformation );
>>>> NtClose( Handle );
>>>> }
>>>> }
>>>> }
>>>>
>>>>
>>>>
>>>> —
>>>> NTFSD is sponsored by OSR
>>>>
>>>> For our schedule debugging and file system seminars
>>>> (including our new fs mini-filter seminar) visit:
>>>> http://www.osr.com/seminars
>>>>
>>>> You are currently subscribed to ntfsd as: xxxxx@gmail.com
>>>> To unsubscribe send a blank email to xxxxx@lists.osr.com
>>>>
>>>>
>>>> —
>>>> NTFSD is sponsored by OSR
>>>>
>>>> For our schedule debugging and file system seminars
>>>> (including our new fs mini-filter seminar) visit:
>>>> http://www.osr.com/seminars
>>>>
>>>> You are currently subscribed to ntfsd as: xxxxx@uol.com.br
>>>> To unsubscribe send a blank email to xxxxx@lists.osr.com
>>>
>>>
>>> —
>>> NTFSD is sponsored by OSR
>>>
>>> For our schedule debugging and file system seminars
>>> (including our new fs mini-filter seminar) visit:
>>> http://www.osr.com/seminars
>>>
>>> You are currently subscribed to ntfsd as: xxxxx@gmail.com
>>> To unsubscribe send a blank email to xxxxx@lists.osr.com
>>>
>>>
>>> —
>>> NTFSD is sponsored by OSR
>>>
>>> For our schedule debugging and file system seminars
>>> (including our new fs mini-filter seminar) visit:
>>> http://www.osr.com/seminars
>>>
>>> You are currently subscribed to ntfsd as: xxxxx@uol.com.br
>>> To unsubscribe send a blank email to xxxxx@lists.osr.com
>>
>>
>> —
>> NTFSD is sponsored by OSR
>>
>> For our schedule debugging and file system seminars
>> (including our new fs mini-filter seminar) visit:
>> http://www.osr.com/seminars
>>
>> You are currently subscribed to ntfsd as: xxxxx@gmail.com
>> To unsubscribe send a blank email to xxxxx@lists.osr.com
>>
>>
>> —
>> NTFSD is sponsored by OSR
>>
>> For our schedule debugging and file system seminars
>> (including our new fs mini-filter seminar) visit:
>> http://www.osr.com/seminars
>>
>> You are currently subscribed to ntfsd as: xxxxx@uol.com.br
>> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule debugging and file system seminars
> (including our new fs mini-filter seminar) visit:
> http://www.osr.com/seminars
>
> You are currently subscribed to ntfsd as: xxxxx@bwandel.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule debugging and file system seminars
> (including our new fs mini-filter seminar) visit:
> http://www.osr.com/seminars
>
> You are currently subscribed to ntfsd as: xxxxx@uol.com.br
> To unsubscribe send a blank email to xxxxx@lists.osr.com