A forum for reverse engineering, OS internals and malware analysis 

Forum for discussion about kernel-mode development.
 #27217  by myid
 Fri Nov 13, 2015 8:07 am
I want to print IAT information of kernel module.
Sometimes, DataDir[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress is not a valid address (MmIsAddressValid return FALSE).
For example, DataDir[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress of NTOSKRNL is not valid.
But PCHunter32.exe can find out the IAT HOOK of NTOSKRNL.
Could someone tell me how to do that?
 #27220  by myid
 Fri Nov 13, 2015 9:41 am
EP_X0FF wrote:
myid wrote:But PCHunter32.exe can find out the IAT HOOK of NTOSKRNL.
Could someone tell me how to do that?
Load it from file and parse.
Load a file and parse its PE structure is very easy. But I still cannot get current address.
For example, NTOSKRNL imports KDCOM!KdSave, some one modify the IAT of NTOSKRNL to hook it.
Get the real address of KDCOM!KdSave is easy, but how can I know this import function (KDCOM!KdSave) is hooked?
(I said on above: NTOSKRNL's DataDir[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress is not a valid address)
 #27229  by Vrtule
 Sun Nov 15, 2015 10:31 am
MmIsAddress tells you whether an access to a given virtual address causes a page fault. That does not necessarily mean that address is invalid. It may be the case that the page to which the address points to is not currently present in the physical memory and that it will be loaded from the paging file if you attempt to access it.

So, you should look at how the addresses you are wxamining with MmIsAddressvalid look like (if they look as kernel addresses or not) and possibly try to access their pages. Yeah, they may be invalid but such things may happen when you are examining memory regins not belonging to you.
 #27233  by myid
 Sun Nov 15, 2015 4:32 pm
Vrtule wrote:MmIsAddress tells you whether an access to a given virtual address causes a page fault. That does not necessarily mean that address is invalid. It may be the case that the page to which the address points to is not currently present in the physical memory and that it will be loaded from the paging file if you attempt to access it.

So, you should look at how the addresses you are wxamining with MmIsAddressvalid look like (if they look as kernel addresses or not) and possibly try to access their pages. Yeah, they may be invalid but such things may happen when you are examining memory regins not belonging to you.
How to make the virtual address present in the physical memory?