Merge pull request #1972 from CookiePLMonster/fix-thread-id

PsCreateSystemThreadEx: Fill dwThreadId immediately after creating the thread
This commit is contained in:
Luke Usher 2020-10-05 07:22:13 +01:00 committed by GitHub
commit a852c3ef9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -285,6 +285,9 @@ XBSYSAPI EXPORTNUM(255) xbox::NTSTATUS NTAPI xbox::PsCreateSystemThreadEx
}*/
*ThreadHandle = (HANDLE)_beginthreadex(NULL, KernelStackSize, PCSTProxy, iPCSTProxyParam, NULL, (unsigned int*)&dwThreadId);
if (ThreadId != NULL)
*ThreadId = (xbox::HANDLE)dwThreadId;
// Note : DO NOT use iPCSTProxyParam anymore, since ownership is transferred to the proxy (which frees it too)
EmuLog(LOG_LEVEL::DEBUG, "Waiting for Xbox proxy thread to start...");
@ -322,9 +325,6 @@ XBSYSAPI EXPORTNUM(255) xbox::NTSTATUS NTAPI xbox::PsCreateSystemThreadEx
EmuLog(LOG_LEVEL::DEBUG, "Created Xbox proxy thread. Handle : 0x%X, ThreadId : [0x%.4X]", *ThreadHandle, dwThreadId);
CxbxKrnlRegisterThread(*ThreadHandle);
if (ThreadId != NULL)
*ThreadId = (xbox::HANDLE)dwThreadId;
}
SwitchToThread();