end:
mov [ebp+8],-1 //如果不想让这个函数正常运行..无效句柄就可以
mov eax,ObReferenceObjectByHandle
add eax,5 //protected the function can success runing
jmp eax //start run ObReferenceObjectByHandle
}
//对原来函数是否要让其正常运行的判断由MyObReferenceObjectByHandle完成
int MyObReferenceObjectByHandle(
IN HANDLE Handle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_TYPE ObjectType OPTIONAL,
IN KPROCESSOR_MODE AccessMode,
OUT PVOID *Object,
OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL
)
{
PEPROCESS Process;
KIRQL oldIrql;
int JmpOffSet;
unsigned char Code[5]={0x8b,0xff,0x55,0x8b,0xec}; //mov edi,edi push ebp mov ebp,esp
unsigned char JmpCode[5] = { 0xe9, 0x00, 0x00, 0x00, 0x00 }; //jmp address
//Procee + 0x174 is this process file name
//this file is im protected
if(_stricmp((char*)((char*)Process+0x174), ProtectName) == 0 )//判断是不是我们要保护的进程
{
//JmpOffset is int type
//JmpOffset Pointer the function qian 5 byte
JmpOffSet = (char*)T_ObReferenceObjectByHandle - (char*)ObReferenceObjectByHandle - 5;