Re: [ntfsd] : Re: [ntfsd] Why ZwReadFile implement failure? But the ZwOpenFile implement success.

ZwReadFile generates IRP_MJ_READ certainly. You’ll have to avoid
re-enterance in your code or by other method to read the file.

Best regards,
lu0
TTC Senior Engineer
http://ttcone.com
Inside Programming
http://lu0.126.com
----- Original Message -----
From:
To: “Windows File Systems Devs Interest List”
Sent: Wednesday, January 19, 2005 11:24 AM
Subject: [ntfsd] ´ð¸´: Re: [ntfsd] Why ZwReadFile implement failure? But the
ZwOpenFile implement success.

>
> Oh, It’s very low-grade error.
>
> Thanks Lu0
>
> I have another question. Is ZwReadFile generate IRP_MJ_READ ? For
> instance,
> I implement ZwReadFile in my read dispatch routine, the operation whether
> result in IRP re-coming?
>
> Best Regards
>
> Ken Wang
>
>
>
>
> “lu0”
> ÊÕ¼þÈË£º “Windows
> File Systems Devs Interest List”
> ·¢¼þÈË£º
> xxxxx@lis ³­ËÍ£º
> ts.osr.com Ö÷Ì⣺ Re: [ntfsd] Why
> ZwReadFile implement failure? But the ZwOpenFile
> implement success.
>
> 2005-01-19 10:40
> Çë´ð¸´ ¸ø “Windows File
> Systems Devs Interest
> List”
>
>
>
>
>
> ntStatusOfFile = ZwReadFile( &hFile, NULL, NULL, NULL, &IoStatusBlock,
> pDataBuf, uFileSize, NULL, NULL );
>
> You are using the invalid handle for this call. ZwReadFile wants a
> handle,
>
> not a handle pointer.
>
> Best regards,
> lu0
> TTC Senior Engineer
> http://ttcone.com
> Inside Programming
> http://lu0.126.com
> ----- Original Message -----
> From:
> To: “Windows File Systems Devs Interest List”
> Sent: Wednesday, January 19, 2005 10:18 AM
> Subject: [ntfsd] Why ZwReadFile implement failure? But the ZwOpenFile
> implement success.
>
>
>> Hi,
>>
>> I want to read file Test.log by implement ZwReadFile function, but failed
>> always.
>>
>> Why ZwReadFile implement failure? But the ZwOpenFile implement success.
>>
>>
>>
>> ANDLE hFile = NULL;
>> NTSTATUS ntStatusOfFile;
>> WCHAR logFileNameBuffer = L"
>> \DosDevices\C:\Test.log";
>> UNICODE_STRING logFileUnicodeString;
>> OBJECT_ATTRIBUTES objectAttributes;
>> IO_STATUS_BLOCK IoStatusBlock;
>> CHAR chBuf[1024] = {0};
>> PCHAR pDataBuf = NULL;
>> ULONG uFileSize = 0;
>>
>> RtlInitUnicodeString( &logFileUnicodeString, logFileNameBuffer );
>> InitializeObjectAttributes( &objectAttributes, &logFileUnicodeString,
>> OBJ_CASE_INSENSITIVE, NULL, NULL );
>>
>> ntStatusOfFile = ZwOpenFile( &hFile, SYNCHRONIZE | GENERIC_READ,
>> &objectAttributes, &IoStatusBlock ,0, FILE_SYNCHRONOUS_IO_ALERT );
>>
>> if( !NT_SUCCESS(ntStatusOfFile))
>> {
>>
>> DbgPrint((“ZwOpenFile failed.\n”)); // failed
>> return;
>>
>> }
>>
>> uFileSize = 2048;
>>
>> pDataBuf = (char*)ExAllocatePool( NonPagedPool, uFileSize + 1);
>>
>>
>> if ( pDataBuf == NULL )
>> {
>> DbgPrint((“pDataBuf == NULL \n”));
>> return;
>>
>> }
>>
>> ntStatusOfFile = ZwReadFile( &hFile, NULL, NULL, NULL, &IoStatusBlock,
>> pDataBuf, uFileSize, NULL, NULL );
>> if( !NT_SUCCESS(ntStatusOfFile))
>> {
>>
>> DbgPrint((“ZwReadFile failed.\n”));
>> ZwClose( hFile );
>> hFile = NULL;
>> break;
>>
>> }
>>
>> ZwClose( hFile );
>> hFile = NULL;
>> ExFreePool( pDataBuf );
>> pDataBuf = NULL;
>>
>>
>> Best Regards
>>
>> Ken Wang
>>
>>
>>
>>
>>
>> —
>> Questions? First check the IFS FAQ at
>> https://www.osronline.com/article.cfm?id=17
>>
>> You are currently subscribed to ntfsd as: lulinsha@163.com
>> To unsubscribe send a blank email to xxxxx@lists.osr.com
>>
>>
>
>
>
> —
> Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: xxxxx@lenovo.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>
> —
> Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to $subst(‘List.Name’) as:
> $subst(‘Recip.EmailAddr’)
> To unsubscribe send a blank email to $subst(‘Email.UnSub’)