hello
I have problem in using NtSetInformationFile function, it always return C0000003 error, when I try to set hidden attrib to a file
anybody can help me to understand why this code doesn't work.
I have problem in using NtSetInformationFile function, it always return C0000003 error, when I try to set hidden attrib to a file
anybody can help me to understand why this code doesn't work.
Code: Select all
thanks#include <windows.h>
#include <stdio.h>
#include "myntdll.h"
#pragma comment(lib, "C:\\WinDDK\\7600.16385.0\\lib\\win7\\i386\\ntdll.lib")
int main()
{
HANDLE hFile;
OBJECT_ATTRIBUTES fileObj;
IO_STATUS_BLOCK IoStack;
UNICODE_STRING ObjectName;
NTSTATUS NtStatus;
RtlInitUnicodeString(&ObjectName, L"\\DosDevices\\C:\\file.txt");
memset(&fileObj, 0, sizeof(OBJECT_ATTRIBUTES));
fileObj.Length = sizeof(OBJECT_ATTRIBUTES);
fileObj.ObjectName = &ObjectName;
fileObj.Attributes = OBJ_CASE_INSENSITIVE;
NtStatus = NtCreateFile(&hFile,
GENERIC_WRITE,
&fileObj,
&IoStack,
0,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ | FILE_SHARE_WRITE,
FILE_CREATE,
0,
NULL,
0);
if ( NT_ERROR(NtStatus) ){
fprintf(stderr, "cannot open file - error code: %x\n", NtStatus);
exit(1);
}
FILE_ATTRIBUTE_TAG_INFORMATION fileAttrib = {0};
fileAttrib.FileAttributes = FILE_ATTRIBUTE_HIDDEN;
//memset(&IoStack, 0, sizeof(IO_STATUS_BLOCK));
NtStatus = NtSetInformationFile(hFile,
&IoStack,
&fileAttrib,
sizeof(FILE_ATTRIBUTE_TAG_INFORMATION),
FileAttributeTagInformation);
if ( NT_ERROR(NtStatus) ){
NtClose(hFile);
fprintf(stderr, "cannot set file attrib - error code: %x\n", NtStatus);
exit(1);
}
NtClose(hFile);
return 0;
}