mirror of
https://github.com/reactos/reactos.git
synced 2025-08-02 12:55:43 +00:00
[NDIS] NdisOpenFile: read file contents into buffer when opening it
NdisMapFile now returns a non-null buffer. CORE-20259
This commit is contained in:
parent
d72bcb149f
commit
e2904d3baf
1 changed files with 29 additions and 0 deletions
|
@ -207,6 +207,8 @@ NdisCloseFile(
|
||||||
|
|
||||||
if ( FileHandleObject->Mapped )
|
if ( FileHandleObject->Mapped )
|
||||||
NdisUnmapFile ( FileHandle );
|
NdisUnmapFile ( FileHandle );
|
||||||
|
if ( FileHandleObject->MapBuffer )
|
||||||
|
ExFreePool ( FileHandleObject->MapBuffer );
|
||||||
|
|
||||||
ZwClose ( FileHandleObject->FileHandle );
|
ZwClose ( FileHandleObject->FileHandle );
|
||||||
|
|
||||||
|
@ -321,6 +323,31 @@ NdisOpenFile(
|
||||||
}
|
}
|
||||||
NtFileLength = StandardInfo.EndOfFile.LowPart;
|
NtFileLength = StandardInfo.EndOfFile.LowPart;
|
||||||
|
|
||||||
|
FileHandleObject->MapBuffer = ExAllocatePool( NonPagedPool, NtFileLength );
|
||||||
|
if (!FileHandleObject->MapBuffer)
|
||||||
|
{
|
||||||
|
NDIS_DbgPrint(MIN_TRACE, ("ExAllocatePool failed Name %wZ\n", FileName));
|
||||||
|
*Status = NDIS_STATUS_ERROR_READING_FILE;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
NtStatus = ZwReadFile(
|
||||||
|
NtFileHandle,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
&IoStatusBlock,
|
||||||
|
FileHandleObject->MapBuffer,
|
||||||
|
NtFileLength,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
if ( !NT_SUCCESS(NtStatus) || IoStatusBlock.Information != NtFileLength )
|
||||||
|
{
|
||||||
|
NDIS_DbgPrint(MIN_TRACE, ("ZwReadFile failed (%x) Name %wZ\n", NtStatus, FileName));
|
||||||
|
*Status = NDIS_STATUS_ERROR_READING_FILE;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if ( FullFileName.Buffer != NULL )
|
if ( FullFileName.Buffer != NULL )
|
||||||
{
|
{
|
||||||
|
@ -331,6 +358,8 @@ cleanup:
|
||||||
{
|
{
|
||||||
if ( FileHandleObject )
|
if ( FileHandleObject )
|
||||||
{
|
{
|
||||||
|
if ( FileHandleObject->MapBuffer )
|
||||||
|
ExFreePool( FileHandleObject->MapBuffer );
|
||||||
ExFreePool ( FileHandleObject );
|
ExFreePool ( FileHandleObject );
|
||||||
}
|
}
|
||||||
*FileHandle = NULL;
|
*FileHandle = NULL;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue