How to open a named mutex from kernel mode driver

Viney Kumar
Viney Kumar used Ask the Experts™
How can I open a named mutex from a kernel mode device driver? My user mode application is creating a named mutex and the driver needs to wait on it.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
the mutex is created by the os. in case of windows the CreateMutex would do the job. as first argument  there is 'lpMutexAttributes'. if NULL the mutex handle cannot inherited by child processes (following the docs). none of the other arguments would make a difference whether the mutex was created by a kernel mode thread or by a user mode thread. so both your app and the driver may call CreateMutex and would get a valid handle of the named mutex. by calling GetLastError you could find out whether you created the mutex or whether you opened an existing mutex. in the second case error is ERROR_ALREADY_EXISTS.
    IN PFAST_MUTEX  FastMutex

Fast mutexes and guarded mutexes can be used as a replacement for mutex objects.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial