#include "ntddk.h"
ULONG GetCidAddr()
{
PUCHAR addr;
PUCHAR p;
UNICODE_STRING pslookup;
ULONG cid;
RtlInitUnicodeString (&pslookup, L"PsLookupProcessByProcessId");
//RtlInitUnicodeString (&pslookup, L"PsLookupProcessThreadbyCid");
addr = (PUCHAR) MmGetSystemRoutineAddress(&pslookup);//MmGetSystemRoutineAddress可以通过函数名获得函数地址
KdPrint(("PsLookupProcessByProcessId addr=0x%x\r\n", addr));
RtlInitUnicodeString (&pslookup, L"NtOpenProcess");
addr = (PUCHAR) MmGetSystemRoutineAddress(&pslookup);//MmGetSystemRoutineAddress可以通过函数名获得函数地址
KdPrint(("NtOpenProcess addr=0x%x\r\n", addr));
for (p=addr;p<addr+PAGE_SIZE;p++)
{
if((*(PUSHORT)p==0x35ff)&&(*(p+6)==0xe8))
{
cid=*(PULONG)(p+2);
return cid;
//break;
}
}
return 0;
}
VOID Uload(PDRIVER_OBJECT obj)
{
KdPrint(("驱动被卸载咯\n"));
}
NTSTATUS DriverEntry(
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath
)
{
DriverObject->DriverUnload = Uload;
GetCidAddr();
}
MmGetSystemRoutineAddress函数获取内存地址
最新推荐文章于 2022-11-01 01:08:09 发布