Home | Info | Community | Development | myReactOS | Contact Us
Definition at line 295 of file mutant.c.
{ PKMUTANT Mutant; KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); NTSTATUS Status; PAGED_CODE(); DPRINT("NtReleaseMutant(MutantHandle 0x%p PreviousCount 0x%p)\n", MutantHandle, PreviousCount); /* Check if we were called from user-mode */ if ((PreviousCount) && (PreviousMode != KernelMode)) { /* Entry SEH Block */ _SEH2_TRY { /* Make sure the state pointer is valid */ ProbeForWriteLong(PreviousCount); } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { /* Return the exception code */ _SEH2_YIELD(return _SEH2_GetExceptionCode()); } _SEH2_END; } /* Open the Object */ Status = ObReferenceObjectByHandle(MutantHandle, MUTANT_QUERY_STATE, ExMutantObjectType, PreviousMode, (PVOID*)&Mutant, NULL); /* Check for Success and release if such */ if (NT_SUCCESS(Status)) { /* * Release the mutant. doing so might raise an exception which we're * required to catch! */ _SEH2_TRY { /* Release the mutant */ LONG Prev = KeReleaseMutant(Mutant, MUTANT_INCREMENT, FALSE, FALSE); /* Return the previous count if requested */ if (PreviousCount) *PreviousCount = Prev; } _SEH2_EXCEPT(ExSystemExceptionFilter()) { /* Get the exception code */ Status = _SEH2_GetExceptionCode(); } _SEH2_END; /* Dereference it */ ObDereferenceObject(Mutant); } /* Return Status */ return Status; }