#ifdef __cplusplus
extern "C" {
#endif
//////////////////////////////
typedef struct _ServiceDescriptorTable {
PVOID ServiceTableBase;
PVOID ServiceCounterTable;
unsigned int NumberOfServices;
PVOID ParamTableBase;}*psstd;
extern psstd KeServiceDescriptorTable;
/////////////////////////////////////////
typedef NTSTATUS _ZwReadVirtualMemory(
IN HANDLE ProcessHandle,
IN PVOID BaseAddress,
OUT PVOID Buffer,
IN ULONG BufferLength,
OUT PULONG ReturnLength OPTIONAL
);
_ZwReadVirtualMemory* ZwReadVirtualMemory;
//////////////////////////////////////////////////////
UINT ProcessID=0;
ULONG ProcessHandle=0;
#ifdef __cplusplus
}; // extern "C"
#endif
/////////openprocess//////////////////////////////
ULONG OpenProcess(ULONG ProcessID)
{
HANDLE a=(HANDLE)0;
CLIENT_ID id;
OBJECT_ATTRIBUTES ObjectAttributes;
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
ObjectAttributes.RootDirectory=0;
ObjectAttributes.ObjectName = NULL;
ObjectAttributes.Attributes = 0;
ObjectAttributes.SecurityDescriptor = NULL;
ObjectAttributes.SecurityQualityOfService =NULL;
id.UniqueProcess=(HANDLE)ProcessID;
id.UniqueThread=(HANDLE)0;
ZwOpenProcess(&a,1040,&ObjectAttributes,&id);
return (ULONG)a;
}
/////以上是声明部分////////////////////////////////////////////////////////////////////////
////以下是调用部分/////////////////////////////////////////////////////////////////////
ProcessHandle=OpenProcess((ULONG)ProcessID);///
这里OpenProcess 调用成功的//
KdPrint(("收到大:%d PId :%d",ProcessHandle,ProcessID));
///////////////读内存///////////////////////////////////////////////////////
ULONG a=0;
a=(ULONG)KeServiceDescriptorTable->ServiceTableBase;
//a=0x7A*4+a;
PULONG b=(PULONG)a;
a=*(PULONG)((ULONG)b+186*4);
ZwReadVirtualMemory=(_ZwReadVirtualMemory*)a;
/////ZwReadVirtualMemory函数所取的地址是正确的/// ULONG aa=0;
ULONG bb=0;
ZwReadVirtualMemory((HANDLE)ProcessHandle,(PULONG)0x0007D2AC,&aa,4,&bb);
KdPrint(("地址:%X 内容:%d",a,aa));
注:pid自已写的驱动加载代码传进去的,调试过,pid是正确的
为什么内存读出来的都是0呢,正常是80(加载代码读的)'
请高手们指点一下(用windbg跟了一下,也确实进入了NtReadVirtualMemory地址,参数也都有传进去了);
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课