RtlCompareUnicodeString IRQL problem

Hi,

I’m just running some code through prefast and it complains on one
particular piece of code.

Basically it’s access to a linked list of filenames, and the code goes
like this:

ExAcquireFastMutex( &inuseData.InuseListLock );

While(…)
RtlCompareUnicodeString(…)
ExReleaseFastMutex( &inuseData.InuseListLock );

Both arguments to the RtlCompare… routine are in nonpaged memory and
the code seems to work (and in fact has been doing for the last year or
so). OTOH I would prefer to fix it if it’s possible.

The problem seems to be that ExAcquireFastMutex changes the IRQL. I
can’t use a guarded mutex as they’re only in Win2003 and later.

I’ve been looking for code to replace this - could
ExAcquireResourceExclusiveLite be a solution in this situation? OTOH
that seems to require a call to KeEnterCriticalRegion which unless I’m
reading it wrong will have exactly the same effect of changing the IRQL.

Tony

Resources or kernel mutexes are your best bet, I would use resources.


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
http://www.windrvr.com
Remove StopSpam from the email to reply

“Tony Hoyle” wrote in message news:xxxxx@ntfsd…
> Hi,
>
> I’m just running some code through prefast and it complains on one
> particular piece of code.
>
> Basically it’s access to a linked list of filenames, and the code goes
> like this:
>
> ExAcquireFastMutex( &inuseData.InuseListLock );
>
> While(…)
> RtlCompareUnicodeString(…)
> ExReleaseFastMutex( &inuseData.InuseListLock );
>
> Both arguments to the RtlCompare… routine are in nonpaged memory and the
> code seems to work (and in fact has been doing for the last year or so).
> OTOH I would prefer to fix it if it’s possible.
>
> The problem seems to be that ExAcquireFastMutex changes the IRQL. I
> can’t use a guarded mutex as they’re only in Win2003 and later.
>
> I’ve been looking for code to replace this - could
> ExAcquireResourceExclusiveLite be a solution in this situation? OTOH
> that seems to require a call to KeEnterCriticalRegion which unless I’m
> reading it wrong will have exactly the same effect of changing the IRQL.
>
> Tony
>
>
>

If you want mutex semantics you could use dispatcher mutex or executive
resource always acquired exclusive,

“Tony Hoyle” wrote in message news:xxxxx@ntfsd…
> Hi,
>
> I’m just running some code through prefast and it complains on one
> particular piece of code.
>
> Basically it’s access to a linked list of filenames, and the code goes
> like this:
>
> ExAcquireFastMutex( &inuseData.InuseListLock );
>
> While(…)
> RtlCompareUnicodeString(…)
> ExReleaseFastMutex( &inuseData.InuseListLock );
>
> Both arguments to the RtlCompare… routine are in nonpaged memory and the
> code seems to work (and in fact has been doing for the last year or so).
> OTOH I would prefer to fix it if it’s possible.
>
> The problem seems to be that ExAcquireFastMutex changes the IRQL. I can’t
> use a guarded mutex as they’re only in Win2003 and later.
>
> I’ve been looking for code to replace this - could
> ExAcquireResourceExclusiveLite be a solution in this situation? OTOH that
> seems to require a call to KeEnterCriticalRegion which unless I’m reading
> it wrong will have exactly the same effect of changing the IRQL.
>
> Tony
>
>
>