|

提醒:若下载的软件是收费的"请不要付款",可能是骗子,请立即联系本站举报,执意要付款被骗后本站概不负责。(任何交易请走第三方中介,请勿直接付款交易以免被骗!切记).
- #include<ntddk.h>
- #include<windef.h>
- typedef struct _SERVICE_DESCRIPTOR_TABLE
- {
- PVOID ServiceTableBase;
- PULONG ServiceCounterTableBase;
- ULONG NumberTableBase;
- ULONG ParamTableBase;
- }SERVICE_DESCRIPTOR_TABLE,*PSERVICE_DESCRIPTOR_TABLE;
-
- extern PSERVICE_DESCRIPTOR_TABLE KeServiceDescriptorTable;
-
-
- typedef NTSTATUS (*REALZWOPENPROCESS)
- (
- OUT PHANDLE ProcessHandle,
- IN ACCESS_MASK AccessMask,
- IN POBJECT_ATTRIBUTES ObjectAttributes,
- IN PCLIENT_ID ClientId);
-
- REALZWOPENPROCESS RealZwOpenProcess;
-
- //***************************************************************************
- VOID Hook();
- VOID Unhook();
- VOID OnUnload(IN PDRIVER_OBJECT DriverObject);
- NTSTATUS rc;
- //////////////////////////////////////
- ULONG JmpAddress;//跳转到NtOpenProcess里的地址
- ULONG OldServiceAddress;//原来NtOpenProcess的服务地址
- //////////////////////////////////////
- __declspec(naked) NTSTATUS __stdcall MyNtOpenProcess(PHANDLE ProcessHandle,
- ACCESS_MASK DesiredAccess,
- POBJECT_ATTRIBUTES ObjectAttributes,
- PCLIENT_ID ClientId)
- {
- //DbgPrint("NtOpenProcess() called");
- //DbgPrint("RealZwOpenProcess:0x%08X",RealZwOpenProcess);
- rc = (NTSTATUS)(REALZWOPENPROCESS)RealZwOpenProcess( ProcessHandle, DesiredAccess, ObjectAttributes, ClientId );
-
-
- __asm{
- push 0C4h
- push 804daab0h //共十个字节
- jmp [JmpAddress]
- }
- }
-
-
- NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject,PUNICODE_STRING RegistryPath)
- {
- DriverObject->DriverUnload = OnUnload;
- DbgPrint("Unhooker load");
- Hook();
- return STATUS_SUCCESS;
- }
- /////////////////////////////////////////////////////
- VOID OnUnload(IN PDRIVER_OBJECT DriverObject)
- {
- DbgPrint("Unhooker unload!");
- Unhook();
- }
- /////////////////////////////////////////////////////
-
- VOID Hook()
- {
- ULONG Address;
- Address=(ULONG)KeServiceDescriptorTable->ServiceTableBase+0x7A*4;
- DbgPrint("Address:0x%08X",Address);
- OldServiceAddress=*(ULONG*)Address;
- RealZwOpenProcess=(REALZWOPENPROCESS)OldServiceAddress;
- DbgPrint("OldServiceAddress:0x%08X",OldServiceAddress);
- DbgPrint("MyNtOpenProcess:0x%08X",MyNtOpenProcess);
- JmpAddress=OldServiceAddress+10;
- DbgPrint("JmpAddress:0x%08X",JmpAddress);
-
- __asm{//去掉内存保护
- cli
- mov eax,cr0
- and eax,not 10000h
- mov cr0,eax
- }
-
-
- *((ULONG*)Address) = (ULONG)MyNtOpenProcess;//HOOK SSDT
-
- __asm{//恢复内存保护
- mov eax,cr0
- or eax,10000h
- mov cr0,eax
- sti
- }
-
- }
-
-
- VOID Unhook()
- {
- ULONG Address;
- Address = (ULONG)KeServiceDescriptorTable->ServiceTableBase + 0x7A * 4;//查找SSDT
-
- __asm{
- cli
- mov eax,cr0
- and eax,not 10000h
- mov cr0,eax
- }
-
- *((ULONG*)Address) = (ULONG)OldServiceAddress;//还原SSDT
-
- __asm{
- mov eax,cr0
- or eax,10000h
- mov cr0,eax
- sti
- }
-
- DbgPrint("Unhook");
- }
复制代码
联系我时,请说是在 挂海论坛 上看到的,谢谢! |
上一篇: 过名将三国驱动保护下一篇: 新手过驱动HOOK保护的常见方法
免责声明:
1、本主题所有言论和图片纯属会员个人意见,与本论坛立场无关。一切关于该内容及资源商业行为与www.52ghai.com无关。
2、本站提供的一切资源内容信息仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。
3、本站信息来自第三方用户,非本站自制,版权归原作者享有,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑或手机中彻底删除上述内容。
4、如果您喜欢该程序,请支持正版,购买注册,得到更好的正版服务。如有侵犯你版权的,请邮件与我们联系删除(邮箱:xhzlw@foxmail.com),本站将立即改正。
|