阅读:2005回复:5
蓝屏代码求助
scan(PVOID base)
{ HANDLE hMod; IMAGE_DOS_HEADER * dosheader; IMAGE_OPTIONAL_HEADER * opthdr; IMAGE_EXPORT_DIRECTORY * pExportTable; DWORD * arrayOfFunctionAddresses; DWORD * arrayOfFunctionNames; WORD * arrayOfFunctionOrdinals; char* functionName; DWORD functionOrdinal,Baseaddr,functionAddress,ModuleAddress; int x,n=0; hMod = base; DbgPrint("hMod addr -- %08x \n",hMod); dosheader = (IMAGE_DOS_HEADER *)hMod; opthdr =(IMAGE_OPTIONAL_HEADER *) ((BYTE*)hMod+dosheader->e_lfanew+24); pExportTable =(IMAGE_EXPORT_DIRECTORY*)((BYTE*) hMod + opthdr->DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress); arrayOfFunctionAddresses = (DWORD*)( (BYTE*)hMod + pExportTable->AddressOfFunctions); arrayOfFunctionNames = (DWORD*)( (BYTE*)hMod + pExportTable->AddressOfNames); arrayOfFunctionOrdinals = (WORD*)( (BYTE*)hMod + pExportTable->AddressOfNameOrdinals); Baseaddr = pExportTable->Base; n=pExportTable->NumberOfFunctions; DbgPrint("pExportTable->Base -- %08x \n",Baseaddr); ModuleAddress = GetModuleBaseAddress(); for(x = 0; x<n; x++) { functionOrdinal = arrayOfFunctionOrdinals[x] + Baseaddr - 1; functionAddress= arrayOfFunctionAddresses[functionOrdinal]; functionName = (char*)( (BYTE*)hMod + arrayOfFunctionNames[x]); if(GetFunctionAddr(functionName)!=(functionAddress+ModuleAddress)) { DbgPrint("functionName -- %s \t function addr -- %08x \n",functionName,functionAddress); } /* lpFuncFileaddr = (LPVOID)( (DWORD)(functionAddress+(DWORD)hMod) ); lpFuncaddr=(LPVOID)((DWORD) (functionAddress+ModuleAddress ) ); //疯狂蓝苹 if( strncmp(lpFuncaddr,lpFuncFileaddr,2) ) { DbgPrint("%s \n",functionName); } */ } } |
|
沙发#
发布于:2007-02-28 18:25
/* lpFuncFileaddr = (LPVOID)( (DWORD)(functionAddress+(DWORD)hMod) );
lpFuncaddr=(LPVOID)((DWORD) (functionAddress+ModuleAddress ) ); //疯狂蓝苹 if( strncmp(lpFuncaddr,lpFuncFileaddr,2) ) { DbgPrint("%s \n",functionName); } */ 那位老大给看看 KeGetCurrentIrql()查看特权及正常,函数没有在物理内存的话应该能引起页故障应该能访问吧? |
|
板凳#
发布于:2007-02-28 18:58
不LockPage和ProbeForRead,而且也不用MmIsXX,简直就是冒险~
|
|
|
地板#
发布于:2007-03-01 11:00
看一下是不是EXPORT_SECTION已经被丢弃了?
|
|
地下室#
发布于:2007-03-01 20:14
谢谢老大指点,MmIsXX把不在的跳过去就好了
|
|
5楼#
发布于:2007-03-01 23:09
如果在passive-level访问,应该不需要lock
可能原因在于Baseaddr = pExportTable->Base;如果模块没有export BaseAddr==0, 这时你的程序就会出错 |
|
|