#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 閱讀(978)
評論(0) 編輯 收藏 引用