typedef NTSYSAPI NTSTATUS (*ZWCREATEFILE)(
OUT PHANDLE FileHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes,
OUT PIO_STATUS_BLOCK IoStatusBlock,
IN PLARGE_INTEGER AllocationSize OPTIONAL,
IN ULONG FileAttributes,
IN ULONG ShareAccess,
IN ULONG CreateDisposition,
IN ULONG CreateOptions,
IN PVOID EaBuffer OPTIONAL,
IN ULONG EaLength
);
ULONG gProcessNameOffset;
unsigned long OldCr0;
ZWCREATEFILE OldZwCreateFile;
extern ZWCREATEFILE OldZwCreateFile;
NTSTATUS NewZwCreateFile(OUT PHANDLE FileHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes,
OUT PIO_STATUS_BLOCK IoStatusBlock,
IN PLARGE_INTEGER AllocationSize OPTIONAL,
IN ULONG FileAttributes,
IN ULONG ShareAccess,
IN ULONG CreateDisposition,
IN ULONG CreateOptions,
IN PVOID EaBuffer OPTIONAL,
IN ULONG EaLength) {
NTSTATUS ntS = (NTSTATUS) NULL;
// on restaure la bonne adresse de ZeCreateFile dans la SDT
(ZWCREATEFILE) (SYSTEMSERVICE(ZwCreateFile)) = OldZwCreateFile;
_asm //开启内存保护
{
mov eax,OldCr0
mov cr0,eax
sti;
}
}