I am writing a debugger with the capability of reading kernel RAM to show
extra information about the process. Sometimes I follow pointers around the
kernel but not all the pointers are valid, so I manually check pagetable.
#1: I currently check PTE.V (valid) || PTE.PAGED (paged to disk) (bits 0 and
11) and if either is set I consider the page valid for reading. This seemed
to be working well until this morning when I got a blue screen of death.
-> Am I checking the right things? If not, what should I be checking?
#2: Checking the pagetable is apparently not safe, even though I was in
dispatch level on a single-processor machine.
-> Could I patch the page fault vector in the IDT and manually rescue myself
if I end up reading invalid kernel RAM?
#3.1: If patching the IDT is a solid plan for the simple thing I am trying
to do, what are some good resources showing how to do this? I have a few but
they aren’t so hot.
#3.2: What precautions should I take while patching to ensure stability? My
understanding is my patch will work only on the current processor, so I don’t
have to worry about other processors accessing vector 14 while I am changing
it. I plan to apply the patch only when I start to read kernel RAM and apply
the original back when I am done, and I will be in dispatch level for both
the apply and unapply (but not inbetween since I could not raise exceptions
then). Anything else about which I should be careful?
Also, just a quick miscellaneous. How do I get the page size for the system
from kernel? I use GetSystemInfo() in user mode and could pass that to my
driver, but I prefer to get it from the kernel directly.
Thank you,
L. Spiro
|