Hi there!
- I have problems reading a text file. I want to read
it (line by line if possible) and I do this:
PVOID pBuffer;
main (int Argc, char ** Argv )
{
NTSTATUS Status;
UNICODE_STRING UnicodeFilespec;
OBJECT_ATTRIBUTES ObjectAttributes;
HANDLE FileHandle;
IO_STATUS_BLOCK Iosb;
RtlInitUnicodeString(&UnicodeFilespec,
L"\DosDevices\C:\Temp\filetoread.txt");
InitializeObjectAttributes(&ObjectAttributes,
&UnicodeFilespec,OBJ_CASE_INSENSITIVE,NULL,NULL );
Status = NtCreateFile(&FileHandle,(GENERIC_READ |
SYNCHRONIZE),&ObjectAttributes,&Iosb,0,0,FILE_SHARE_READ,FILE_OPEN,FILE_SYNCHRONOUS_IO_NONALERT|FILE_NON_DIRECTORY_FILE,NULL,0);
if(!NT_SUCCESS(Iosb.Status) )
{
printf(“CREATE failed with status =
0x%0x\n”,Iosb.Status);
exit(0);
}
Status =
NtReadFile(FileHandle,0,NULL,NULL,&Iosb,(PVOID)pBuffer,sizeof(pBuffer),0,NULL);
if(!NT_SUCCESS(Status) )
{
printf(“NtReadFile request failed 0x%0x\n”, Status);
exit(0);
}
Status = NtClose(FileHandle);
if(!NT_SUCCESS(Status) )
{
printf(“NtClose request failed 0x%0x\n”,
Status);
exit(0);
}
printf(“Read buffer:\n”);
printf(“%s\n”,pBuffer);
exit(1);
}
After successfully opening the file, i get ACCESS
VIOLATION (0xc000005) as return value of NtReadFile.
What’s wrong?
- How can i detect (in my file system filter driver)
and stop an attempt to format the disk (DIRECT DISK
WRITE ACCESS)? Any ideas or code snippets?
Thank you!
Do You Yahoo!?
Yahoo! Sports - live college hoops coverage
http://sports.yahoo.com/