求助:KeAttachProcess后无法访问进程内存
Windows内核调试
求助:KeAttachProcess后无法访问进程内存
堕落的神曲
2008-09-26, 22:09 下午
void EnumUserModules(PEPROCESS pEprocess,PPEB pPeb)
{
PLIST_ENTRY pUserModuleListHead=NULL, pUserModuleListPtr=NULL;
PPEB_LDR_DATA pLdrData;
PUNICODE_STRING pImageName;
PLDR_MODULE pLdrModule;
//KeStackAttachProcess((ULONG)pEprocess,&kaps);
KeAttachProcess((ULONG)pEprocess);
if(KeGetCurrentIrql()!=PASSIVE_LEVEL){
DbgPrint("irql error");
return;
}
pLdrData=(PPEB_LDR_DATA)((ULONG)pPeb+PEB_LDR_DATA_OFFSET);
DbgPrint("pLdrData:%x",(ULONG)pLdrData);
//pUserModuleListHead=(PLIST_ENTRY)(&(pLdrData->InLoadOrderModuleList));
pUserModuleListHead=(PLIST_ENTRY)((ULONG)pLdrData+0xc);
pUserModuleListPtr=pUserModuleListHead;
do{
try{
//DbgPrint("pUserModuleListPtr:%x Flink:%x",pUserModuleListPtr,pUserModuleListPtr->Flink);
ProbeForRead (
pUserModuleListPtr,
sizeof(LDR_MODULE),
sizeof(ULONG)
);
// pLdrModule=(PLDR_MODULE)pUserModuleListPtr;
pUserModuleListPtr=pUserModuleListPtr->Flink;
}
except( EXCEPTION_EXECUTE_HANDLER ) {
DbgPrint("an error occured:%0x",GetExceptionCode());//得到的错误总是0xc0000005,即内存访问错误
break;
}
}
while(pUserModuleListPtr->Flink!=pUserModuleListHead);
KeDetachProcess();
}