一个很强的代码,谁能翻译成DELPHI的?高手来一下

dcrr64 2008-12-18 05:36:26
*************************************************************************************************************************** 
#include<ntddk.h>

typedef struct _SERVICE_DEscrīptOR_TABLE
{
PVOID ServiceTableBase;
PULONG ServiceCounterTableBase;
ULONG NumberOfService;
ULONG ParamTableBase;
}SERVICE_DEscrīptOR_TABLE,*PSERVICE_DEscrīptOR_TABLE; //由于KeServiceDescrīptorTable只有一项,这里就简单点了
extern PSERVICE_DEscrīptOR_TABLE KeServiceDescrīptorTable;//KeServiceDescrīptorTable为导出函数

/////////////////////////////////////
VOID Hook();
VOID Unhook();
VOID OnUnload(IN PDRIVER_OBJECT DriverObject);
//////////////////////////////////////
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");
__asm{
push 0C4h
push 804eb560h //共十个字节
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)KeServiceDescrīptorTable->ServiceTableBase + 0x7A * 4;//0x7A为NtOpenProcess服务ID
DbgPrint("Address:0x%08X",Address);

ōldServiceAddress = *(ULONG*)Address;//保存原来NtOpenProcess的地址
DbgPrint("OldServiceAddress:0x%08X",OldServiceAddress);

DbgPrint("MyNtOpenProcess:0x%08X",MyNtOpenProcess);

JmpAddress = (ULONG)NtOpenProcess + 10; //跳转到NtOpenProcess函数头+10的地方,这样在其前面写的JMP都失效了
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)KeServiceDescrīptorTable->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");
}
××××××××××××××××××××××××××××××××××××××××××××××××××××××××××
...全文
280 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
黑白赵 2008-12-26
  • 打赏
  • 举报
回复
看不懂..
zhao_yong 2008-12-22
  • 打赏
  • 举报
回复
关注
huangjacky 2008-12-22
  • 打赏
  • 举报
回复
关注下
tjg5202 2008-12-22
  • 打赏
  • 举报
回复
真的不懂。。哎。。。。。
yc_8301 2008-12-22
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 okmnji79513 的回复:]
不懂 只能先mark
[/Quote]
......
starluck 2008-12-22
  • 打赏
  • 举报
回复


這個技術性強。 MARK
okmnji79513 2008-12-21
  • 打赏
  • 举报
回复
不懂 只能先mark
僵哥 2008-12-19
  • 打赏
  • 举报
回复
提示一点,在Delphi当中要实现naked过程几乎不可能,所以建议使用硬编码,或者参考下面贴子七楼当中的办法来取得相应指令编码的首地址:http://topic.csdn.net/u/20081209/18/abf321b3-b524-469d-8c49-9b2613a54c96.html
gyk120 2008-12-19
  • 打赏
  • 举报
回复
晕,NTOpenProcess的SSDT内联?
http://forum.eviloctal.com/thread-32903-1-1.html
看看这个吧。。。
kampan 2008-12-18
  • 打赏
  • 举报
回复
汇编都整出来了。
scutLiu 2008-12-18
  • 打赏
  • 举报
回复
mark
panrongzeng 2008-12-18
  • 打赏
  • 举报
回复
一大堆汇编语言,看不明白
xmasxp 2008-12-18
  • 打赏
  • 举报
回复
看看
gwhdaxia 2008-12-18
  • 打赏
  • 举报
回复
mark
xmasxp 2008-12-18
  • 打赏
  • 举报
回复
呵呵这论坛没有热心人了啊,我想帮你但看不懂
pcfans007 2008-12-18
  • 打赏
  • 举报
回复
up
僵哥 2008-12-18
  • 打赏
  • 举报
回复
还是先学会使用Delphi编写和编译驱动吧。代码转换倒不难。有空帮你转一下。

1,183

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧