#include <ntifs.h>
VOID
Unload(
IN PDRIVER_OBJECT DriverObject
);
VOID GetAllProcess(ULONG Address);
NTSTATUS
DriverEntry( IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath )
{
NTSTATUS status = STATUS_SUCCESS;
ULONG Address;
ULONG oldAddress;
//得到当前进程的地址
Address = (ULONG)PsGetCurrentProcess();
//得到EPROCESS中链表的偏移
Address += 0x88;
//用oldAddress保存当前进程链表的地址
oldAddress = Address;
//遍历进程链表
do
{
GetAllProcess(Address);
//让Address指向当前链表的下一个进程链表的地址(注意是Flink)
Address = *(ULONG*)Address;
}while( oldAddress!=Address );//当得到的链表地址与保存的地址相等说明遍历完整个线程链表,返回
DriverObject->DriverUnload = Unload;
return status;
}
VOID
Unload(
IN PDRIVER_OBJECT DriverObject
)
{
}
VOID GetAllProcess(ULONG Address)
{
//得到对应的EPROCESS结构
Address -= 0x88;
//EPROCESS偏移0x174为ImageFileName(进程名)
DbgPrint("ProcessName %s \n",(char*)Address+0x174);
//EPROCESS偏移0x18为页目录物理地址
DbgPrint("Process Context %d \n",*(ULONG*)(Address+0x18));
}
posted on 2008-04-19 12:59
ViskerWong 阅读(974)
评论(0) 编辑 收藏 引用