|
void EnumBySearchMemory( PVOID Buffer)
{
DWORD Index,Index2;
DWORD Address;
PHYSICAL_ADDRESS physical_address;
for ( Index=MmSystemRangeStart; Index<=0xFFFF0000; Index+=0x1000)
{
if ( !MmIsAddressValid((PVOID)Index))
continue;
// 需要 MmGetPhysicalAddress和MmGetVirtualForPhysical两个函数
// 的结果判断一下
physical_address = MmGetPhysicalAddress( (PVOID)Index);
if ( physical_address.HighPart > g_PhysicalPage.HighPart )
continue;
if ( physical_address.HighPart = g_PhysicalPage.HighPart &&
physical_address.LowPart > g_PhysicalPage.LowPart
)
continue;
Address = (DWORD)MmGetVirtualForPhysical( physical_address);
if ( Address != Index)
continue;
for ( Index2 = 0x1b5; Index2 != 0; Index2--,Address+=8)
{
if ( IsValidEproc( Address))
CopyProcessInfo( Address, Buffer);
}
}
return;
}
bool IsValidEproc( DWORD eproc)
{
DWORD Var;
if ( *(DWORD*)(eproc+HandleTableOffset) <= MmSystemRangeStart)
return false;
if ( *(DWORD*)(eproc+4) != 0 )
return false;
if ( *(DWORD*)(eproc+ExitTimeOffset) != 0 || *(DWORD*)(eproc+ExitTimeOffset+4) != 0 )
return false;
if ( *(DWORD*)(eproc+PIDOFFSET) >= 0x100000 )
return false;
if ( *(DWORD*)(eproc+PebOffset) >= MmSystemRangeStart)
return false;
if ( *(DWORD*)(eproc+PebOffset) <= 0x10000)
return false;
if( *(DWORD*)(eproc+0x88) <= MmSystemRangeStart ||
*(DWORD*)(eproc+0x8c) <= MmSystemRangeStart ||
*(DWORD*)(eproc+0x190) <= MmSystemRangeStart ||
*(DWORD*)(eproc+0x194) <= MmSystemRangeStart ||
*(DWORD*)(eproc+0x50) <= MmSystemRangeStart ||
*(DWORD*)(eproc+0x40) <= MmSystemRangeStart ||
*(DWORD*)(eproc+0x44) <= MmSystemRangeStart ||
*(DWORD*)(eproc+0x54) <= MmSystemRangeStart
)
return false;
if ( !MmIsAddressValid( *(PVOID*)(eproc+HandleTableOffset)) )
return false;
if ( !MmIsAddressValid( *(PVOID*)(eproc+0x50)) )
return false;
if ( !MmIsAddressValid( *(PVOID*)(eproc+0x54)) )
return false;
Var = *(DWORD*)(eproc+0x190)-0x224;
if ( !MmIsAddressValid( (PVOID)Var ) )
return false;
if ( !MmIsAddressValid( (PVOID)(Var+Eproc_Offset_TList) ) )
return false;
return true;
}
查找未导出函数的地址:
BOOLEAN IsAPI(ULONG Arr)
{
if (Arr >= start_address && Arr <= start_address+sys_info->Size)
{
return TRUE;
}
else
{
return FALSE;
}
}
typedef struct _SYSTEM_MODULE_INFORMATION { // Information Class 11
ULONG Reserved[2];
PVOID Base;
ULONG Size;
ULONG Flags;
USHORT Index;
USHORT Unknown;
USHORT LoadCount;
USHORT ModuleNameOffset;
CHAR ImageName[256];
} SYSTEM_MODULE_INFORMATION, *PSYSTEM_MODULE_INFORMATION; |
|