>First, does anyone have an idea of why MmProbeAndLockPages would be
bugchecking on me? I have the call within >try/except blocks, but it looks
like the call isn’t bugchecking because of any documented failure modes
(i.e. access violation).
MmProbeAndLockPages will only raise if the requestor mode is user or the bad
virtual address is a user virtual address. For a bad kernel virtual address
with a requestor mode of kernel the system is going to crash, errors of this
type cannot be caught in a try/except. I just looked and the docs don’t make
this very clear unfortunately.
Based on the information that you have provided, I’d say that the address
you’re trying to lock was in a discardable section. For example, if you put
your DriverEntry in an INIT section then after it is run then it will
possibly be removed from memory and the virtual address will no longer map
to anything. Resource sections are also often marked as discardable, for
example:
0: kd> !dh ntfs
File Type: EXECUTABLE IMAGE
FILE HEADER VALUES
14C machine (i386)
7 number of sections
48025BE5 time date stamp Sun Apr 13 15:15:49 2008
…
SECTION HEADER #6
.rsrc name
3E0 virtual size
88A00 virtual address
400 size of raw data
88A00 file pointer to raw data
0 file pointer to relocation table
0 file pointer to line numbers
0 number of relocations
0 number of line numbers
42000040 flags
Initialized Data
Discardable *****************
(no align specified)
Read Only
…
0: kd> !pte ntfs+88A00
VA f846da00
PDE at 00000000C0603E10 PTE at 00000000C07C2368
contains 0000000001030963 contains 0000000000000000
pfn 1030 -G-DA–KWEV
0: kd> dc ntfs+88A00
f846da00 ??? ??? ??? ??? ???
f846da10 ??? ??? ??? ??? ???
f846da20 ??? ??? ??? ??? ???
f846da30 ??? ??? ??? ??? ???
f846da40 ??? ??? ??? ??? ???
f846da50 ??? ??? ??? ??? ???
f846da60 ??? ??? ??? ??? ???
f846da70 ??? ??? ??? ??? ???
To confirm my theory, you could run !dh tsddd and figure out if the address
that you have falls in the range of a discardable section.
In terms of fixing it, you’re not expected to be poking around in other
people’s images so you’ll need to do some extra work to avoid crashing. You
could always just go with checking the on disk image, which would be much
safer.
-scott
–
Scott Noone
Consulting Associate
OSR Open Systems Resources, Inc.
http://www.osronline.com
wrote in message news:xxxxx@ntdev…
> Hi All,
>
> I have a WDM driver that is attempting to read a page of memory from the
> driver TSDDD.dll. Before reading the memory I’m using MmProbeAndLockPages
> to make sure that the page stays in memory while I read it. First I use
> IoAllocateMdl to create an MDL for the page I try to read. I’ve verified
> that the MDL is not null. When I call MmProbeAndLockPages the machine
> bugchecks, and when I analyze the crash dump the error I get is
> PAGE_FAULT_IN_NONPAGED_AREA. In the stack backtrace I can see the calls
> that caused the bugcheck were: nt!MmProbeAndLockPages > nt!KiTrap0E >
> MmAccessFault.
>
> When I load up the crash dump and enumerate drivers with “lm t n” the
> driver TSDDD.dll shows up in the list at address 0x978a0000 (this is the
> same address that windbg reports to have caused the
> PAGE_FAULT_IN_NONPAGED_AREA). If I use “dd 978a0000” all words of data
> that I get back are “???”. And finally, if I use the command “!pte
> 978a0000”, the page table entry for the address is 0x00000000.
>
> So there’s a few things that I’m trying to get answered here. First, does
> anyone have an idea of why MmProbeAndLockPages would be bugchecking on me?
> I have the call within try/except blocks, but it looks like the call isn’t
> bugchecking because of any documented failure modes (i.e. access
> violation). Secondly, is there any safe way for me to know when a driver
> can’t be accessed?
>
> My first thought is that the driver TSDDD.dll is somehow marked as
> nonpageable, but for some reason it’s not actually in memory. So when I
> try to page it in using MmProbeAndLockPages, the OS detects a page fault
> on what it thinks is a nonpageable region of memory, causing the bugcheck
> I’m seeing.
>
> If anyone could give me insight as to why this is happening and what I can
> do to prevent this from crashing I would appreciate it. Thanks.
>
> -Jeff
>
>