HI,
In my driver I often use the following construction in order to make
sure I don’t touch any weird memory address:
if ( (p != NULL) && (MmIsAddressValid(p)) )
{
…
}
Does MmIsAddressValid also perform a NULL-pointer check ? Do you guys
have other means for validating pointers ?
–
Bartjan.
MmIsSytemAddressValid will tell you if you can touch the specified virtual
address without causing a page fault.
It aint explicitly check for a NULL pointer. I assume it checks for a valid
PTE. Note that even if this function return true,
the probed address can still later cause page faults, unless you probe
nonpaged memory, or you probe a locked down page.
> Do you guys have other means for validating pointers ?
I dont validate my pointers all over the place, is kinda useless. I doit
only in complex routines, and only in for checked builds , and I usee
ASSERTS usually. I do however employee __try // __except to protect myself .
----- Original Message -----
From: “Bartjan Wattel”
To: “NT Developers Interest List”
Sent: Friday, June 28, 2002 4:56 PM
Subject: [ntdev] What does MmIsAddressValid exactly do ?
> HI,
>
> In my driver I often use the following construction in order to make
> sure I don’t touch any weird memory address:
>
> if ( (p != NULL) && (MmIsAddressValid(p)) )
> {
> …
> }
>
> Does MmIsAddressValid also perform a NULL-pointer check ? Do you guys
> have other means for validating pointers ?
>
> –
> Bartjan.
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@rdsor.ro
> To unsubscribe send a blank email to %%email.unsub%%
>
Using this API is not a good idea. If you are accessing user mode addresses
you should already know that they may not be valid and hence probe and lock
them. Its not a way to protect a driver and make it more robust. Using
try{}except{} to hide access violations inside the driver is also not very
good. We have had lots of trouble debugging such problems.
–
Nar Ganapathy
Windows Core OS group
This posting is provided “AS IS” with no warranties, and confers no rights.
“Dan Partelly” wrote in message news:xxxxx@ntdev…
>
> MmIsSytemAddressValid will tell you if you can touch the specified virtual
> address without causing a page fault.
> It aint explicitly check for a NULL pointer. I assume it checks for a
valid
> PTE. Note that even if this function return true,
> the probed address can still later cause page faults, unless you probe
> nonpaged memory, or you probe a locked down page.
>
>
> >> Do you guys have other means for validating pointers ?
>
> I dont validate my pointers all over the place, is kinda useless. I doit
> only in complex routines, and only in for checked builds , and I usee
> ASSERTS usually. I do however employee try // except to protect myself
.
>
>
> ----- Original Message -----
> From: “Bartjan Wattel”
> To: “NT Developers Interest List”
> Sent: Friday, June 28, 2002 4:56 PM
> Subject: [ntdev] What does MmIsAddressValid exactly do ?
>
>
> > HI,
> >
> > In my driver I often use the following construction in order to make
> > sure I don’t touch any weird memory address:
> >
> > if ( (p != NULL) && (MmIsAddressValid(p)) )
> > {
> > …
> > }
> >
> > Does MmIsAddressValid also perform a NULL-pointer check ? Do you guys
> > have other means for validating pointers ?
> >
> > –
> > Bartjan.
> >
> >
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@rdsor.ro
> > To unsubscribe send a blank email to %%email.unsub%%
> >
>
>
>
>> Using try{}except{} to hide access violations inside the driver is also
not very
> good. We have had lots of trouble debugging such problems.
I dont think the term hidding is appropiate in this context. You just get a
chanche to look at that exception, using SEH, thats all.
While for validating a pointer try / except is certainly not very usefull,
my experience with using SEH mechanism to trap exceptions was a pleasent
one, and it did in some cases even speed up the development process.
Dan
----- Original Message -----
From: “Nar Ganapathy [MS]”
Newsgroups: ntdev
To: “NT Developers Interest List”
Sent: Friday, June 28, 2002 7:45 PM
Subject: [ntdev] Re: What does MmIsAddressValid exactly do ?
> Using this API is not a good idea. If you are accessing user mode
addresses
> you should already know that they may not be valid and hence probe and
lock
> them. Its not a way to protect a driver and make it more robust. >
> –
> Nar Ganapathy
> Windows Core OS group
> This posting is provided “AS IS” with no warranties, and confers no
rights.
> “Dan Partelly” wrote in message
news:xxxxx@ntdev…
> >
> > MmIsSytemAddressValid will tell you if you can touch the specified
virtual
> > address without causing a page fault.
> > It aint explicitly check for a NULL pointer. I assume it checks for a
> valid
> > PTE. Note that even if this function return true,
> > the probed address can still later cause page faults, unless you probe
> > nonpaged memory, or you probe a locked down page.
> >
> >
> > >> Do you guys have other means for validating pointers ?
> >
> > I dont validate my pointers all over the place, is kinda useless. I doit
> > only in complex routines, and only in for checked builds , and I usee
> > ASSERTS usually. I do however employee try // except to protect
myself
> .
> >
> >
> > ----- Original Message -----
> > From: “Bartjan Wattel”
> > To: “NT Developers Interest List”
> > Sent: Friday, June 28, 2002 4:56 PM
> > Subject: [ntdev] What does MmIsAddressValid exactly do ?
> >
> >
> > > HI,
> > >
> > > In my driver I often use the following construction in order to make
> > > sure I don’t touch any weird memory address:
> > >
> > > if ( (p != NULL) && (MmIsAddressValid(p)) )
> > > {
> > > …
> > > }
> > >
> > > Does MmIsAddressValid also perform a NULL-pointer check ? Do you guys
> > > have other means for validating pointers ?
> > >
> > > –
> > > Bartjan.
> > >
> > >
> > >
> > > —
> > > You are currently subscribed to ntdev as: xxxxx@rdsor.ro
> > > To unsubscribe send a blank email to %%email.unsub%%
> > >
> >
> >
> >
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@rdsor.ro
> To unsubscribe send a blank email to %%email.unsub%%
>
I do not see any funcion called MmIsSystemAddressValid. Do you guys see this
function? I see MmIsAddressValid and MmIsNonPagedSystemAddressValid
(Obsolete).
-Srin.
-----Original Message-----
From: Dan Partelly [mailto:xxxxx@rdsor.ro]
Sent: Friday, June 28, 2002 7:42 AM
To: NT Developers Interest List
Subject: [ntdev] Re: What does MmIsAddressValid exactly do ?
MmIsSytemAddressValid will tell you if you can touch the specified virtual
address without causing a page fault.
It aint explicitly check for a NULL pointer. I assume it checks for a valid
PTE. Note that even if this function return true,
the probed address can still later cause page faults, unless you probe
nonpaged memory, or you probe a locked down page.
> Do you guys have other means for validating pointers ?
I dont validate my pointers all over the place, is kinda useless. I doit
only in complex routines, and only in for checked builds , and I usee
ASSERTS usually. I do however employee __try // __except to protect myself .
----- Original Message -----
From: “Bartjan Wattel”
To: “NT Developers Interest List”
Sent: Friday, June 28, 2002 4:56 PM
Subject: [ntdev] What does MmIsAddressValid exactly do ?
> HI,
>
> In my driver I often use the following construction in order to make
> sure I don’t touch any weird memory address:
>
> if ( (p != NULL) && (MmIsAddressValid(p)) )
> {
> …
> }
>
> Does MmIsAddressValid also perform a NULL-pointer check ? Do you guys
> have other means for validating pointers ?
>
> –
> Bartjan.
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@rdsor.ro
> To unsubscribe send a blank email to %%email.unsub%%
>
—
You are currently subscribed to ntdev as: xxxxx@nai.com
To unsubscribe send a blank email to %%email.unsub%%
I had some too much of the word “System” in my head , so I added it to
this function in hurry. Its a mistake. I meant MmIsAdressValid.
Dan
Yes if you are using it just for debugging then its a different issue. We
have debugged drivers that used SEH to hide random AVs because the
developers could not track it down.
–
Nar Ganapathy
Windows Core OS group
This posting is provided “AS IS” with no warranties, and confers no rights.
“Dan Partelly” wrote in message news:xxxxx@ntdev…
>
>
> >> Using try{}except{} to hide access violations inside the driver is
also
> not very
> >> good. We have had lots of trouble debugging such problems.
>
> I dont think the term hidding is appropiate in this context. You just get
a
> chanche to look at that exception, using SEH, thats all.
> While for validating a pointer try / except is certainly not very usefull,
> my experience with using SEH mechanism to trap exceptions was a pleasent
> one, and it did in some cases even speed up the development process.
>
> Dan
>
> ----- Original Message -----
> From: “Nar Ganapathy [MS]”
> Newsgroups: ntdev
> To: “NT Developers Interest List”
> Sent: Friday, June 28, 2002 7:45 PM
> Subject: [ntdev] Re: What does MmIsAddressValid exactly do ?
>
>
> > Using this API is not a good idea. If you are accessing user mode
> addresses
> > you should already know that they may not be valid and hence probe and
> lock
> > them. Its not a way to protect a driver and make it more robust. >
> > –
> > Nar Ganapathy
> > Windows Core OS group
> > This posting is provided “AS IS” with no warranties, and confers no
> rights.
> > “Dan Partelly” wrote in message
> news:xxxxx@ntdev…
> > >
> > > MmIsSytemAddressValid will tell you if you can touch the specified
> virtual
> > > address without causing a page fault.
> > > It aint explicitly check for a NULL pointer. I assume it checks for a
> > valid
> > > PTE. Note that even if this function return true,
> > > the probed address can still later cause page faults, unless you probe
> > > nonpaged memory, or you probe a locked down page.
> > >
> > >
> > > >> Do you guys have other means for validating pointers ?
> > >
> > > I dont validate my pointers all over the place, is kinda useless. I
doit
> > > only in complex routines, and only in for checked builds , and I usee
> > > ASSERTS usually. I do however employee try // except to protect
> myself
> > .
> > >
> > >
> > > ----- Original Message -----
> > > From: “Bartjan Wattel”
> > > To: “NT Developers Interest List”
> > > Sent: Friday, June 28, 2002 4:56 PM
> > > Subject: [ntdev] What does MmIsAddressValid exactly do ?
> > >
> > >
> > > > HI,
> > > >
> > > > In my driver I often use the following construction in order to make
> > > > sure I don’t touch any weird memory address:
> > > >
> > > > if ( (p != NULL) && (MmIsAddressValid(p)) )
> > > > {
> > > > …
> > > > }
> > > >
> > > > Does MmIsAddressValid also perform a NULL-pointer check ? Do you
guys
> > > > have other means for validating pointers ?
> > > >
> > > > –
> > > > Bartjan.
> > > >
> > > >
> > > >
> > > > —
> > > > You are currently subscribed to ntdev as: xxxxx@rdsor.ro
> > > > To unsubscribe send a blank email to %%email.unsub%%
> > > >
> > >
> > >
> > >
> >
> >
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@rdsor.ro
> > To unsubscribe send a blank email to %%email.unsub%%
> >
>
>
>
> Does MmIsAddressValid also perform a NULL-pointer check ? Do you
guys
have other means for validating pointers ?
No.
- Stepping on a NULL pointer will immediately produce bugcheck, so,
there is no need in additional bug-catching code.
- The majority of severe bugs are races, and this validation will
usually not help.
Max
Max is, as usual, right. But it’s important to add that
MmIsAddressValid is only really useful in an assertion, or other
debugging code. It checks that, at the time you called it, an access
would not cause a fault. Nothing guarantees that a fault won’t occur on
that address a moment later. A fault might occur even at the next
instruction, the one that tries to use the pointer that you just
checked.
It’s better to validate your pointer in other ways, ones that don’t rely
on checking after the fact for validity. Remember that even a pointer
that passes the tests implied by MmIsAddressValid may point to the wrong
data, or even to code.
If you’re concerned about pointers that have come from user-mode, then
use ProbeForRead and ProbeForWrite. These will guarantee that your
pointer is both valid and from user-mode.
This posting is provided “AS IS” with no warranties, and confers no
rights.
-----Original Message-----
Subject: Re: What does MmIsAddressValid exactly do ?
From: “Maxim S. Shatskih”
Date: Sat, 29 Jun 2002 00:42:16 +0400
X-Message-Number: 5
> Does MmIsAddressValid also perform a NULL-pointer check ? Do you
guys
> have other means for validating pointers ?
No.
1) Stepping on a NULL pointer will immediately produce bugcheck, so,
there is no need in additional bug-catching code.
2) The majority of severe bugs are races, and this validation will
usually not help.
Max