Added DomitoReadFile
This commit is contained in:
parent
6313f01e22
commit
6c8144b646
@ -150,3 +150,17 @@ DomitoGetPortableExecutableDigestKind(
|
|||||||
_In_ PUCHAR pPeBytes,
|
_In_ PUCHAR pPeBytes,
|
||||||
_In_ PIMAGE_DATA_DIRECTORY pImgDataDirectory
|
_In_ PIMAGE_DATA_DIRECTORY pImgDataDirectory
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Reads from the beginning of a file until the end or the buffer size is reached
|
||||||
|
//
|
||||||
|
_Success_(return == STATUS_SUCCESS)
|
||||||
|
_Must_inspect_result_
|
||||||
|
_IRQL_requires_max_(PASSIVE_LEVEL)
|
||||||
|
EXTERN_C
|
||||||
|
NTSTATUS
|
||||||
|
DomitoReadFile(
|
||||||
|
_In_ HANDLE FileHandle,
|
||||||
|
_Out_ PVOID Buffer,
|
||||||
|
_In_ ULONG BufferSize
|
||||||
|
);
|
||||||
|
@ -316,3 +316,42 @@ DomitoGetPortableExecutableDigestKind(
|
|||||||
|
|
||||||
return CALG_SHA1;
|
return CALG_SHA1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_Success_(return == STATUS_SUCCESS)
|
||||||
|
_Must_inspect_result_
|
||||||
|
_IRQL_requires_max_(PASSIVE_LEVEL)
|
||||||
|
NTSTATUS
|
||||||
|
DomitoReadFile(
|
||||||
|
_In_ HANDLE FileHandle,
|
||||||
|
_Out_ PVOID Buffer,
|
||||||
|
_In_ ULONG BufferSize
|
||||||
|
)
|
||||||
|
{
|
||||||
|
NTSTATUS status = STATUS_SUCCESS;
|
||||||
|
IO_STATUS_BLOCK ioStatusBlock;
|
||||||
|
|
||||||
|
// Read the file into memory using ZwReadFile
|
||||||
|
if (!NT_SUCCESS(status = ZwReadFile(
|
||||||
|
FileHandle,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
&ioStatusBlock,
|
||||||
|
Buffer,
|
||||||
|
BufferSize,
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
|
)))
|
||||||
|
{
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the file was read successfully
|
||||||
|
if (!NT_SUCCESS(ioStatusBlock.Status))
|
||||||
|
{
|
||||||
|
return ioStatusBlock.Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
// File read successfully
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user