KPCR recovery without memory change

This commit is contained in:
Luke Usher 2018-02-10 17:18:13 +00:00
parent f488a05cdc
commit 0bcc81215c
2 changed files with 9 additions and 8 deletions

View File

@ -92,10 +92,7 @@ void EmuKeSetPcr(xboxkrnl::KPCR *Pcr)
// the user data-slot of each Windows thread Cxbx uses for an
// Xbox thread.
//
__asm {
mov eax, Pcr
mov fs : [TIB_ArbitraryDataSlot], eax
}
__writefsdword(TIB_ArbitraryDataSlot, (DWORD)Pcr);
}
__declspec(naked) void EmuFS_CmpEsiFs00()

View File

@ -138,12 +138,16 @@ BOOLEAN KiInsertTreeTimer(
// ******************************************************************
xboxkrnl::KPCR* KeGetPcr()
{
xboxkrnl::KPCR* Pcr;
xboxkrnl::PKPCR Pcr;
// See EmuKeSetPcr()
__asm {
mov eax, fs : [TIB_ArbitraryDataSlot]
mov Pcr, eax
Pcr = (xboxkrnl::PKPCR)__readfsdword(TIB_ArbitraryDataSlot);
if (Pcr == nullptr) {
EmuWarning("KeGetPCR returned nullptr: Was this called from a non-xbox thread?");
// Attempt to salvage the situation by calling InitXboxThread to setup KPCR in place
InitXboxThread(g_CPUXbox);
Pcr = (xboxkrnl::PKPCR)__readfsdword(TIB_ArbitraryDataSlot);
}
return Pcr;