/* Allocate the structure */
CsrThread = RtlAllocateHeap(CsrHeap, HEAP_ZERO_MEMORY, sizeof(CSR_THREAD));
- if (!CsrThread) return(NULL);
+ if (!CsrThread) return NULL;
/* Reference the Thread and Process */
- CsrThread->ReferenceCount++;
- CsrProcess->ReferenceCount++;
+ CsrLockedReferenceThread(CsrThread);
+ CsrLockedReferenceProcess(CsrProcess);
/* Set the Parent Process */
CsrThread->Process = CsrProcess;
/* Get the thread */
FoundThread = CONTAINING_RECORD(NextEntry, CSR_THREAD, HashLinks);
+ /* Move to the next entry */
+ NextEntry = NextEntry->Flink;
+
/* Compare the CID */
- // FIXME: if (*(PULONGLONG)&FoundThread->ClientId == *(PULONGLONG)ClientId)
- if (FoundThread->ClientId.UniqueThread == ClientId->UniqueThread)
+ // if (*(PULONGLONG)&FoundThread->ClientId == *(PULONGLONG)ClientId)
+ if ( FoundThread->ClientId.UniqueProcess == ClientId->UniqueProcess &&
+ FoundThread->ClientId.UniqueThread == ClientId->UniqueThread )
{
/* Match found, return the process */
*Process = FoundThread->Process;
// DPRINT1("Found: %p %p\n", FoundThread, FoundThread->Process);
return FoundThread;
}
-
- /* Next */
- NextEntry = NextEntry->Flink;
}
/* Nothing found */
/* Check for TID Match */
if (FoundThread->ClientId.UniqueThread == Cid->UniqueThread) break;
- /* Next entry */
+ /* Move to the next entry */
NextEntry = NextEntry->Flink;
}
if (!LockCount)
{
/* Call the generic cleanup code */
- CsrThreadRefcountZero(CsrThread);
CsrAcquireProcessLock();
+ CsrThreadRefcountZero(CsrThread);
}
}
}
/* Lock the Owner Process */
- Status = CsrLockProcessByClientId(&ClientId->UniqueProcess, &CsrProcess);
+ Status = CsrLockProcessByClientId(ClientId->UniqueProcess, &CsrProcess);
if (!NT_SUCCESS(Status))
{
DPRINT1("No known process for %lx\n", ClientId->UniqueProcess);
break;
}
- /* Next entry */
+ /* Move to the next entry */
NextEntry = NextEntry->Flink;
}
{
/* Reference the found thread */
Status = STATUS_SUCCESS;
- CurrentThread->ReferenceCount++;
+ CsrLockedReferenceThread(CurrentThread);
*CsrThread = CurrentThread;
}
else