int call_failed(
IN HANDLE Handle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_TYPE ObjectType,
IN KPROCESSOR_MODE AccessMode,
OUT PVOID *Object,
OUT POBJECT_HANDLE_INFORMATION HandleInfo
)
{
KIRQL irql;
//this routine return 0 success run ObReferenceObjectByHandle()
//this routine return 1 failed run ObReferenceObjectByHandle()
int call_failed(
IN HANDLE Handle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_TYPE ObjectType,
IN KPROCESSOR_MODE AccessMode,
OUT PVOID *Object,
OUT POBJECT_HANDLE_INFORMATION HandleInfo
)
{
PEPROCESS process;
KIRQL irql;
//this object is a process
if(ObjectType == *PsProcessType)
{
irql = KeRaiseIrqlToDpcLevel();
close_write_protected();
//Unload inline hook in ObReferenceObjectByHandle()
RtlCopyMemory(ObReferenceObjectByHandle,routine_head,5);
//run the kernel routine
ObReferenceObjectByHandle(Handle,DesiredAccess,ObjectType,AccessMode,&process,NULL);
//install inline hook to ObReferenceObjectByHandle()
RtlCopyMemory(ObReferenceObjectByHandle,jmp_code,5);
//this request point to notepad.exe
if(_stricmp((char *)((char *)process+0x174),"notepad.exe") == 0)
return 1;
else
return 0;
open_write_protected();
KeLowerIrql(irql);
}
else //this object not a process
{
return 0;
}
}
//jmp this routine
__declspec(naked) my_routine(
IN HANDLE Handle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_TYPE ObjectType,
IN KPROCESSOR_MODE AccessMode,
OUT PVOID *Object,
OUT POBJECT_HANDLE_INFORMATION HandleInfor
)
{
__asm
{
mov edi,edi
//create next stack for sub routine using
push ebp
mov ebp,esp
//parameter enter the stack
push [ebp+0x1c]
push [ebp+0x18]
push [ebp+0x14]
push [ebp+0x10]
push [ebp+0xc]
push [ebp+8]
//enter the routine
call call_failed
cmp eax,1
jz start_new
//in this routine install inline hook
NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject,IN PUNICODE_STRING RegistryPath)
{
//this is offset of jmp to my routine
int jmp_offset;
KIRQL irql;
//set current driver unload routine
DriverObject->DriverUnload = DriverUnload;
DRIVER_IRQL_NOT_LESS_OR_EQUAL (d1)
An attempt was made to access a pageable (or completely invalid) address at an
interrupt request level (IRQL) that is too high. This is usually
caused by drivers using improper addresses.
If kernel debugger is available get stack backtrace.
Arguments:
Arg1: 0041f4a4, memory referenced
Arg2: 00000002, IRQL
Arg3: 00000000, value 0 = read operation, 1 = write operation
Arg4: 0041f4a4, address which referenced memory
Debugging Details:
------------------
PEB is paged out (Peb.Ldr = 7ffde00c). Type ".hh dbgerr001" for details
PEB is paged out (Peb.Ldr = 7ffde00c). Type ".hh dbgerr001" for details
STACK_TEXT:
f318c854 0041f4a4 badb0d00 0012f370 00000000 nt!KiTrap0E+0x233
WARNING: Frame IP not in any known module. Following frames may be wrong.
0012f354 00000000 00000000 00000000 00000000 0x41f4a4
STACK_COMMAND: kb
FOLLOWUP_IP:
nt!KiTrap0E+233
804e287f f7457000000200 test dword ptr [ebp+70h],20000h