Updated thread timings in ethread + null id upon thread termination

This commit is contained in:
ergo720 2022-01-27 20:51:36 +01:00
parent ec6b16c68a
commit 79ac0c3019
3 changed files with 6 additions and 3 deletions

View File

@ -1915,8 +1915,9 @@ KTHREAD, *PKTHREAD, *RESTRICTED_POINTER PRKTHREAD;
// ******************************************************************
typedef struct _ETHREAD
{
struct _KTHREAD Tcb;
uchar_xt UnknownA[0x10]; // 0x110
struct _KTHREAD Tcb;
LARGE_INTEGER CreateTime;
LARGE_INTEGER ExitTime;
ntstatus_xt ExitStatus; // 0x120
uchar_xt UnknownB[0x8]; // 0x124
HANDLE UniqueThread; // 0x12C

View File

@ -288,6 +288,7 @@ XBSYSAPI EXPORTNUM(255) xbox::ntstatus_xt NTAPI xbox::PsCreateSystemThreadEx
RETURN(X_STATUS_INSUFFICIENT_RESOURCES);
}
KeQuerySystemTime(&eThread->CreateTime);
KiUniqueProcess.StackCount++;
RegisterXboxHandle(*ThreadHandle, handle);
RegisterXboxHandle(eThread->UniqueThread, handle);

View File

@ -225,16 +225,17 @@ void EmuKeFreeThread(xbox::ntstatus_xt ExitStatus)
xbox::PETHREAD eThread = xbox::PspGetCurrentThread();
xbox::KeQuerySystemTime(&eThread->ExitTime);
eThread->Tcb.HasTerminated = 1;
// Emulate our exit strategy for GetExitCodeThread
eThread->ExitStatus = ExitStatus;
eThread->Tcb.Header.SignalState = 1;
xbox::HANDLE UniqueThread = eThread->UniqueThread;
if (GetNativeHandle(eThread->UniqueThread)) {
xbox::NtClose(eThread->UniqueThread);
eThread->UniqueThread = NULL;
}
EmuKeFreePcr(UniqueThread);