I set a global hook on ZwWriteFile
to encryption all write files.
It's my new instance of ZwWriteFile
:
function New_ZwWriteFile(FileHandle: HANDLE; Event: HANDLE;
ApcRoutine: PIO_APC_ROUTINE; ApcContext: PVOID;
IoStatusBlock: PIO_STATUS_BLOCK; Buffer: PVOID; Length: ULONG;
ByteOffset: PLARGE_INTEGER; Key: PULONG): THandle; stdcall;
Begin
///
End;
When i call the original ZwWriteFile
in New_ZwWriteFile
the file was corrupted because the buffer is null !
function New_ZwWriteFile(FileHandle: HANDLE; Event: HANDLE;
ApcRoutine: PIO_APC_ROUTINE; ApcContext: PVOID;
IoStatusBlock: PIO_STATUS_BLOCK; Buffer: PVOID; Length: ULONG;
ByteOffset: PLARGE_INTEGER; Key: PULONG): THandle; stdcall;
Begin
result := Old_ZwWriteFile(FileHandle, Event, ApcRoutine, ApcContext,
IoStatusBlock, Buffer, Length, ByteOffset, Key);
End;
I test @Buffer
also but get same result !
result := Old_ZwWriteFile(FileHandle, Event, ApcRoutine, ApcContext,
IoStatusBlock, @Buffer, Length, ByteOffset, Key);
, the buffer data type is Pointer
,How can i retrieve the content of it and write it to file.
Any idea???