/* FUNCTIONS *****************************************************************/
+#ifndef LIBCAPTIVE
+
VOID STDCALL
KeInitializeMutex(IN PKMUTEX Mutex,
IN ULONG Level)
return(KeWaitForSingleObject(Mutex,WaitReason,WaitMode,Alertable,Timeout));
}
+#endif /* LIBCAPTIVE */
VOID STDCALL
KeInitializeMutant(IN PKMUTANT Mutant,
Mutant->ApcDisable = 0;
}
+#ifndef LIBCAPTIVE
+
LONG STDCALL
KeReadStateMutant(IN PKMUTANT Mutant)
{
return(Mutant->Header.SignalState);
}
+#endif /* LIBCAPTIVE */
+
LONG STDCALL
KeReleaseMutant(IN PKMUTANT Mutant,
IN KPRIORITY Increment,
KeGetCurrentThread());
KeBugCheck(0); /* THREAD_NOT_MUTEX_OWNER */
}
- Mutant->Header.SignalState++;
+ if (Mutant->Header.SignalState==0)
+ {
+ Mutant->Header.SignalState++;
+ }
+ else
+ {
+ /* ntfs.sys behaviour: KeInitializeMutant(,FALSE); KeReleaseMutant(,0,FALSE,FALSE;
+ * Ugh.
+ */
+ DbgPrint("WARNING: Releasing already unlocked KMUTANT %p CurrentThread %p !!!\n",
+ Mutant,KeGetCurrentThread());
+ }
assert(Mutant->Header.SignalState <= 1);
}
else
Mutant->OwnerThread = NULL;
if (Mutant->MutantListEntry.Flink && Mutant->MutantListEntry.Blink)
RemoveEntryList(&Mutant->MutantListEntry);
+#ifndef LIBCAPTIVE
KeDispatcherObjectWake(&Mutant->Header);
+#endif /* LIBCAPTIVE */
}
KeReleaseDispatcherDatabaseLock(Wait);