Hello,
I used PsSetLoadImageCallback routine to register a callback that is called whenewer a PE image is mapped. I have several questions about things I can do inside the callback:
1) Is it safe to read the mapped image (its base address and virtual size are stored in ImageBase and ImageSize members of the IMAGE_INFO structure)?
2) When my driver runs on 64-bit system, the callback is called multiple times for one PE image in case the target process runs under WOW64. It seems that the operating system attempts to map 64-bit image into the process' address space first, then it realizes that this is not the right executable, hence it attempts to find better one inside SysWOW64 directory. I noticed this behavior for kernel32.dll for example. Am I right or is there another explanation?
3) Is it possible to determine the type of the image (32-bit or 64-bit) without reading this information from its OptionalHeader?
4) Before I attempt to read contents of the image, I map it to kernel space via MDL. The problem is that MmProbeAndLockPages fails sometimes with STATUS_ACCESS_VIOLATION exception. It seems that the problem appears only in WOW64 processes again.
5) Additionally, the whole system usually hangs few seconds after my driver is loaded. And my driver uses MmProbeAndLockPages inside Image Notify Callback... However, I have an intention that the system hangs also in case I do not use MDL and touch the image contents directly. Does anybody know why this might be happening?
I test my driver on latest version of Windows 7 SP1 x64. I hope my post is not too confusing.
Thanks in advance
EDIT
When I connect WinDbg to the already freezed system, I get this:
I used PsSetLoadImageCallback routine to register a callback that is called whenewer a PE image is mapped. I have several questions about things I can do inside the callback:
1) Is it safe to read the mapped image (its base address and virtual size are stored in ImageBase and ImageSize members of the IMAGE_INFO structure)?
2) When my driver runs on 64-bit system, the callback is called multiple times for one PE image in case the target process runs under WOW64. It seems that the operating system attempts to map 64-bit image into the process' address space first, then it realizes that this is not the right executable, hence it attempts to find better one inside SysWOW64 directory. I noticed this behavior for kernel32.dll for example. Am I right or is there another explanation?
3) Is it possible to determine the type of the image (32-bit or 64-bit) without reading this information from its OptionalHeader?
4) Before I attempt to read contents of the image, I map it to kernel space via MDL. The problem is that MmProbeAndLockPages fails sometimes with STATUS_ACCESS_VIOLATION exception. It seems that the problem appears only in WOW64 processes again.
5) Additionally, the whole system usually hangs few seconds after my driver is loaded. And my driver uses MmProbeAndLockPages inside Image Notify Callback... However, I have an intention that the system hangs also in case I do not use MDL and touch the image contents directly. Does anybody know why this might be happening?
I test my driver on latest version of Windows 7 SP1 x64. I hope my post is not too confusing.
Thanks in advance
EDIT
When I connect WinDbg to the already freezed system, I get this:
Code: Select all
Assertion: *** DPC watchdog timeout
This is NOT a break in update time
This is most likely a BUG in an ISR
Perform a stack trace to find the culprit
The period will be doubled on continuation
Use gh to continue!!