Why there is no KeReadStateFastMutex() ?

Why there is no KeReadStateFastMutex() in DDK header files?
I want to use such function for asserts in a kernel driver.

Sure, I can use undocumented but exposed internals of the FAST_MUTEX
structure
or write something like the following:

Bool
MyKeReadStateFastMutex(FAST_MUTEX* mx)
{
Bool retval = FALSE;
if (ExTryToAcquireFastMutex(mx)) {
retval = TRUE;
ExReleaseFastMutex(mx);
}
return retval;
}

At times like that I undestand Alberto.

Dmitriy Budko VMware

In this case, since _FAST_MUTEX is defined in the ntddk.h, and since
ExInitializeFastMutex is declared as a macro that expands into code that
directly sets data members of that structure, Microsoft cannot change
the definition of _FAST_MUTEX without forcing a recompile of all
existing drivers. Therefore, it should be safe just to reference the
data members directly (although I agree it would have been nice if at
least a macro had been provided for this purposes).

Dmitriy Budko wrote:

Why there is no KeReadStateFastMutex() in DDK header files?
I want to use such function for asserts in a kernel driver.

Sure, I can use undocumented but exposed internals of the FAST_MUTEX
structure
or write something like the following:

Bool
MyKeReadStateFastMutex(FAST_MUTEX* mx)
{
Bool retval = FALSE;
if (ExTryToAcquireFastMutex(mx)) {
retval = TRUE;
ExReleaseFastMutex(mx);
}
return retval;
}

At times like that I undestand Alberto.

Dmitriy Budko VMware


Nick Ryan (MVP for DDK)