release the dispatcher lock in KeReleaseMutant before raising an exception and handle the exception in NtReleaseMutant

svn path=/trunk/; revision=14363
This commit is contained in:
Thomas Bluemel 2005-03-28 15:17:54 +00:00
parent f3fc2ca494
commit d295d5da57
2 changed files with 28 additions and 14 deletions

View File

@ -332,23 +332,35 @@ NtReleaseMutant(IN HANDLE MutantHandle,
LONG Prev;
/* Save the Old State */
DPRINT("Releasing Mutant\n");
Prev = KeReleaseMutant(Mutant, MUTANT_INCREMENT, FALSE, FALSE);
/* release the mutant. doing so might raise an exception which we're
required to catch! */
_SEH_TRY {
Prev = KeReleaseMutant(Mutant, MUTANT_INCREMENT, FALSE, FALSE);
} _SEH_HANDLE {
Status = _SEH_GetExceptionCode();
} _SEH_END;
ObDereferenceObject(Mutant);
/* Return it */
if(PreviousCount) {
_SEH_TRY {
if(NT_SUCCESS(Status)) {
/* Return it */
if(PreviousCount) {
_SEH_TRY {
*PreviousCount = Prev;
} _SEH_HANDLE {
*PreviousCount = Prev;
} _SEH_HANDLE {
Status = _SEH_GetExceptionCode();
} _SEH_END;
Status = _SEH_GetExceptionCode();
} _SEH_END;
}
}
}

View File

@ -144,6 +144,8 @@ KeReleaseMutant(IN PKMUTANT Mutant,
/* Make sure that the Owner Thread is the current Thread */
if (Mutant->OwnerThread != CurrentThread) {
KeReleaseDispatcherDatabaseLock(OldIrql);
DPRINT1("Trying to touch a Mutant that the caller doesn't own!\n");
ExRaiseStatus(STATUS_MUTANT_NOT_OWNED);
}