/* We failed, this is bad... */
DPRINT1("Failed to Create Event!\n");
- _InterlockedDecrement(&CriticalSection->LockCount);
+ InterlockedDecrement(&CriticalSection->LockCount);
RtlRaiseStatus(Status);
return;
}
DPRINT("Created Event: %p \n", hNewEvent);
- if ((hEvent = _InterlockedCompareExchangePointer((PVOID*)&CriticalSection->LockSemaphore,
- (PVOID)hNewEvent,
- 0))) {
+ if (InterlockedCompareExchangePointer((PVOID*)&CriticalSection->LockSemaphore,
+ (PVOID)hNewEvent,
+ 0)) {
/* Some just created an event */
DPRINT("Closing already created event: %p\n", hNewEvent);
DPRINT("Waiting on Critical Section Event: %p %p\n",
CriticalSection,
CriticalSection->LockSemaphore);
- CriticalSection->DebugInfo->EntryCount++;
+
+ if (CriticalSection->DebugInfo)
+ CriticalSection->DebugInfo->EntryCount++;
for (;;) {
/* Increase the number of times we've had contention */
- CriticalSection->DebugInfo->ContentionCount++;
+ if (CriticalSection->DebugInfo)
+ CriticalSection->DebugInfo->ContentionCount++;
/* Wait on the Event */
Status = NtWaitForSingleObject(CriticalSection->LockSemaphore,
DPRINT("Freeing from Buffer: %p. Entry: %lu inside Process: %p\n",
DebugInfo,
EntryId,
- NtCurrentTeb()->Cid.UniqueProcess);
+ NtCurrentTeb()->ClientId.UniqueProcess);
RtlpDebugInfoFreeList[EntryId] = FALSE;
} else {
/* It's a dynamic one, so free from the heap */
DPRINT("Freeing from Heap: %p inside Process: %p\n",
DebugInfo,
- NtCurrentTeb()->Cid.UniqueProcess);
+ NtCurrentTeb()->ClientId.UniqueProcess);
RtlFreeHeap(NtCurrentPeb()->ProcessHeap, 0, DebugInfo);
}
/* Protect List */
RtlEnterCriticalSection(&RtlCriticalSectionLock);
- /* Remove it from the list */
- RemoveEntryList(&CriticalSection->DebugInfo->ProcessLocksList);
+ if (CriticalSection->DebugInfo)
+ {
+ /* Remove it from the list */
+ RemoveEntryList(&CriticalSection->DebugInfo->ProcessLocksList);
+ RtlZeroMemory(CriticalSection->DebugInfo, sizeof(RTL_CRITICAL_SECTION_DEBUG));
+ }
/* Unprotect */
RtlLeaveCriticalSection(&RtlCriticalSectionLock);
- /* Free it */
- RtlpFreeDebugInfo(CriticalSection->DebugInfo);
+ if (CriticalSection->DebugInfo)
+ {
+ /* Free it */
+ RtlpFreeDebugInfo(CriticalSection->DebugInfo);
+ }
/* Wipe it out */
RtlZeroMemory(CriticalSection, sizeof(RTL_CRITICAL_SECTION));
NTAPI
RtlEnterCriticalSection(PRTL_CRITICAL_SECTION CriticalSection)
{
- HANDLE Thread = (HANDLE)NtCurrentTeb()->Cid.UniqueThread;
+ HANDLE Thread = (HANDLE)NtCurrentTeb()->ClientId.UniqueThread;
/* Try to Lock it */
- if (_InterlockedIncrement(&CriticalSection->LockCount) != 0) {
+ if (InterlockedIncrement(&CriticalSection->LockCount) != 0) {
/*
* We've failed to lock it! Does this thread
CritcalSectionDebugData = RtlpAllocateDebugInfo();
DPRINT("Allocated Debug Data: %p inside Process: %p\n",
CritcalSectionDebugData,
- NtCurrentTeb()->Cid.UniqueProcess);
+ NtCurrentTeb()->ClientId.UniqueProcess);
if (!CritcalSectionDebugData) {
RtlLeaveCriticalSection(PRTL_CRITICAL_SECTION CriticalSection)
{
#ifndef NDEBUG
- HANDLE Thread = (HANDLE)NtCurrentTeb()->Cid.UniqueThread;
+ HANDLE Thread = (HANDLE)NtCurrentTeb()->ClientId.UniqueThread;
/* In win this case isn't checked. However it's a valid check so it should only
be performed in debug builds! */
if (--CriticalSection->RecursionCount) {
/* Someone still owns us, but we are free. This needs to be done atomically. */
- _InterlockedDecrement(&CriticalSection->LockCount);
+ InterlockedDecrement(&CriticalSection->LockCount);
} else {
CriticalSection->OwningThread = 0;
/* Was someone wanting us? This needs to be done atomically. */
- if (-1 != _InterlockedDecrement(&CriticalSection->LockCount)) {
+ if (-1 != InterlockedDecrement(&CriticalSection->LockCount)) {
/* Let him have us */
RtlpUnWaitCriticalSection(CriticalSection);
RtlTryEnterCriticalSection(PRTL_CRITICAL_SECTION CriticalSection)
{
/* Try to take control */
- if (_InterlockedCompareExchange(&CriticalSection->LockCount,
+ if (InterlockedCompareExchange(&CriticalSection->LockCount,
0,
-1) == -1) {
/* It's ours */
- CriticalSection->OwningThread = NtCurrentTeb()->Cid.UniqueThread;
+ CriticalSection->OwningThread = NtCurrentTeb()->ClientId.UniqueThread;
CriticalSection->RecursionCount = 1;
return TRUE;
- } else if (CriticalSection->OwningThread == NtCurrentTeb()->Cid.UniqueThread) {
+ } else if (CriticalSection->OwningThread == NtCurrentTeb()->ClientId.UniqueThread) {
/* It's already ours */
- _InterlockedIncrement(&CriticalSection->LockCount);
+ InterlockedIncrement(&CriticalSection->LockCount);
CriticalSection->RecursionCount++;
return TRUE;
}