C28135

warning C28135: If the first argument to KeWaitForSingleObject is a local variable, the Mode parameter must be KernelMode

The driver is waiting in user mode. As such, the kernel stack can be swapped out during the wait. If the driver attempts to pass parameters on the stack, a system crash can result.

Example

The following code example elicits this warning.

KeWaitForSingleObject(&MyMutex, UserRequest, UserMode, false, NULL);

The following code example avoids this warning.

KeWaitForSingleObject(&MyMutex, UserRequest, KernelMode, false, NULL);