|

提醒:若下载的软件是收费的"请不要付款",可能是骗子,请立即联系本站举报,执意要付款被骗后本站概不负责。(任何交易请走第三方中介,请勿直接付款交易以免被骗!切记).
- #include<ntddk.h>
- #include<windef.h>
-
- typedef struct _SERVICE_DESCRIPTOR_TABLE
- {
- unsigned int *ServiceTableBase;
- unsigned int *ServiceCounterTableBase;
- unsigned int NumberTableBase;
- unsigned char *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);
-
- typedef NTSTATUS (*READVIRTUALMEMORY)(
- IN HANDLE ProcessHandle,
- IN PVOID BaseAddress,
- OUT PVOID Buffer,
- IN ULONG BufferLength,
- OUT PULONG ReturnLength OPTIONAL);
-
- typedef NTSTATUS (*WRITEVIRTUALMEMORY)(
- IN HANDLE ProcessHandle,
- IN PVOID BaseAddress,
- IN PVOID Buffer,
- IN ULONG BufferLength,
- OUT PULONG ReturnLength OPTIONAL
- );
-
-
- REALZWOPENPROCESS RealZwOpenProcess;
- READVIRTUALMEMORY RealNtReadVirtualMemory;
- WRITEVIRTUALMEMORY RealNtWriteVirtualMemory;
- //***************************************************************************
- VOID Hook();
- VOID Unhook();
- VOID OnUnload(IN PDRIVER_OBJECT DriverObject);
- NTSTATUS rc;
- //NTSTATUS rc1;
- //NTSTATUS rc2;
- DWORD bix,tiao;
- //////////////////////////////////////
- ULONG JmpAddress;//跳转到NtOpenProcess里的地址
- ULONG JmpAddress1;
- ULONG JmpAddress2;
- ULONG OldServiceAddress;//原来NtOpenProcess的服务地址
- ULONG OldServiceAddress1;
- ULONG OldServiceAddress2;
- //////////////////////////////////////
- __declspec(naked) NTSTATUS __stdcall MyNtOpenProcess(PHANDLE ProcessHandle,
- ACCESS_MASK DesiredAccess,
- POBJECT_ATTRIBUTES ObjectAttributes,
- PCLIENT_ID ClientId)
- {
-
- //RealZwOpenProcess=(REALZWOPENPROCESS)OldServiceAddress;
-
- //rc = (NTSTATUS)(REALZWOPENPROCESS)RealZwOpenProcess( ProcessHandle, DesiredAccess, ObjectAttributes, ClientId );
-
- __asm{
-
- push 0C4h
- push 804daab0h //共十个字节
- mov eax,80538d00h
- call eax
- jmp [JmpAddress]
- }
- }
-
- __declspec(naked) NTSTATUS __stdcall MyNtReadVirtualMemory(
- IN HANDLE ProcessHandle,
- IN PVOID BaseAddress,
- OUT PVOID Buffer,
- IN ULONG BufferLength,
- OUT PULONG ReturnLength OPTIONAL)
-
- {
-
- //RealNtReadVirtualMemory=(READVIRTUALMEMORY)OldServiceAddress1;
- //rc1 = (NTSTATUS)(READVIRTUALMEMORY)RealNtReadVirtualMemory( ProcessHandle, BaseAddress, Buffer, BufferLength,ReturnLength );
-
-
- __asm{
- push 1Ch
- push 804da4e0h //共十个字节
- mov eax,80538d00h
- call eax
- jmp [JmpAddress1]
- }
-
-
-
- }
-
-
-
- __declspec(naked) NTSTATUS __stdcall MyNtWriteVirtualMemory(
- IN HANDLE ProcessHandle,
- IN PVOID BaseAddress,
- OUT PVOID Buffer,
- IN ULONG BufferLength,
- OUT PULONG ReturnLength OPTIONAL)
-
- {
-
- //RealNtWriteVirtualMemory=(WRITEVIRTUALMEMORY)OldServiceAddress2;
- //rc2=(NTSTATUS)(WRITEVIRTUALMEMORY)RealNtWriteVirtualMemory(ProcessHandle, BaseAddress, Buffer, BufferLength,ReturnLength);
-
-
- __asm{
- push 1Ch
- push 804da4f8h //共十个字节
- mov eax,80538d00h
- call eax
- jmp [JmpAddress2]
- }
-
-
-
- }
-
-
- 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;
- ULONG Address1;
- ULONG Address2;
- Address=(ULONG)KeServiceDescriptorTable->ServiceTableBase+0x7A*4;
- Address1=(ULONG)KeServiceDescriptorTable->ServiceTableBase+0x0ba*4;
- Address2=(ULONG)KeServiceDescriptorTable->ServiceTableBase+0x115*4;
- DbgPrint("Address:0x%08X",Address);
- DbgPrint("Address1:0x%08X",Address1);
- DbgPrint("Address2:0x%08X",Address2);
-
- OldServiceAddress=*(ULONG*)Address;
- OldServiceAddress1=*(ULONG*)Address1;
- OldServiceAddress2=*(ULONG*)Address2;
- RealZwOpenProcess=(REALZWOPENPROCESS)OldServiceAddress;
- DbgPrint("OldServiceAddress:0x%08X",OldServiceAddress);
- DbgPrint("OldServiceAddress1:0x%08X",OldServiceAddress1);
- DbgPrint("OldServiceAddress2:0x%08X",OldServiceAddress2);
-
- JmpAddress=OldServiceAddress+15;
- JmpAddress1=OldServiceAddress1+12;
- JmpAddress2=OldServiceAddress2+12;
- //JmpAddress=2153521239;
- DbgPrint("JmpAddress:0x%08X",JmpAddress);
- DbgPrint("JmpAddress1:0x%08X",JmpAddress1);
- DbgPrint("JmpAddress2:0x%08X",JmpAddress2);
- __asm{//去掉内存保护
- cli
- mov eax,cr0
- and eax,not 10000h
- mov cr0,eax
- }
-
-
- *((ULONG*)Address) = (ULONG)MyNtOpenProcess;//HOOK SSDT
- *((ULONG*)Address1) = (ULONG)MyNtReadVirtualMemory;
- *((ULONG*)Address2) = (ULONG)MyNtWriteVirtualMemory;
- __asm{//恢复内存保护
- mov eax,cr0
- or eax,10000h
- mov cr0,eax
- sti
- }
-
- }
-
-
- VOID Unhook()
- {
- ULONG Address;
- ULONG Address1;
- ULONG Address2;
- Address = (ULONG)KeServiceDescriptorTable->ServiceTableBase + 0x7A * 4;//查找SSDT
- Address1=(ULONG)KeServiceDescriptorTable->ServiceTableBase+0x0ba*4;
- Address2=(ULONG)KeServiceDescriptorTable->ServiceTableBase+0x115*4;
-
- __asm{
- cli
- mov eax,cr0
- and eax,not 10000h
- mov cr0,eax
- }
-
- *((ULONG*)Address) = (ULONG)OldServiceAddress;//还原SSDT
- *((ULONG*)Address1) = (ULONG)OldServiceAddress1;
- *((ULONG*)Address2) = (ULONG)OldServiceAddress2;
- __asm{
- mov eax,cr0
- or eax,10000h
- mov cr0,eax
- sti
- }
-
- DbgPrint("Unhook");
- }
复制代码
联系我时,请说是在 挂海论坛 上看到的,谢谢! |
上一篇: 疾风之刃OD附加下一篇: 恢复游戏的InlineHook ZwOpenProcess
免责声明:
1、本主题所有言论和图片纯属会员个人意见,与本论坛立场无关。一切关于该内容及资源商业行为与www.52ghai.com无关。
2、本站提供的一切资源内容信息仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。
3、本站信息来自第三方用户,非本站自制,版权归原作者享有,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑或手机中彻底删除上述内容。
4、如果您喜欢该程序,请支持正版,购买注册,得到更好的正版服务。如有侵犯你版权的,请邮件与我们联系删除(邮箱:xhzlw@foxmail.com),本站将立即改正。
|