Re-enabled all FS patches, it does not seem to have any effect on compatibilty, but it's better to be safe, we don't want Xbox code playing around with Windows TLS if we can help it.

This commit is contained in:
Luke Usher 2016-04-02 19:41:20 +01:00
parent f7569a4ce9
commit 729123e57a
1 changed files with 17 additions and 15 deletions

View File

@ -259,24 +259,24 @@ void EmuInitFS()
* The entries must be in order of size, to keep the chance of false positives to a minimum.
*/
std::vector<fs_instruction_t> fsInstructions;
//fsInstructions.push_back({ { 0x64, 0x0F, 0xB6, 0x05, 0x24, 0x00, 0x00, 0x00 }, &EmuMzxEaxBytePtrFs24 });// movzx eax, large byte ptr fs:24
//fsInstructions.push_back({ { 0x64, 0x3B, 0x35, 0x00, 0x00, 0x00, 0x00 }, &EmuCmpEsiFs00 }); // cmp esi, large fs:0
//fsInstructions.push_back({ { 0x64, 0x8B, 0x1D, 0x00, 0x00, 0x00, 0x00 }, &EmuMEbxFs00 }); // mov ebx, large fs:0
//fsInstructions.push_back({ { 0x64, 0x8B, 0x0D, 0x00, 0x00, 0x00, 0x00 }, &EmuMEcxFs00 }); // mov ecx, large fs:0
fsInstructions.push_back({ { 0x64, 0x0F, 0xB6, 0x05, 0x24, 0x00, 0x00, 0x00 }, &EmuMzxEaxBytePtrFs24 });// movzx eax, large byte ptr fs:24
fsInstructions.push_back({ { 0x64, 0x3B, 0x35, 0x00, 0x00, 0x00, 0x00 }, &EmuCmpEsiFs00 }); // cmp esi, large fs:0
fsInstructions.push_back({ { 0x64, 0x8B, 0x1D, 0x00, 0x00, 0x00, 0x00 }, &EmuMEbxFs00 }); // mov ebx, large fs:0
fsInstructions.push_back({ { 0x64, 0x8B, 0x0D, 0x00, 0x00, 0x00, 0x00 }, &EmuMEcxFs00 }); // mov ecx, large fs:0
fsInstructions.push_back({ { 0x64, 0x8B, 0x0D, 0x04, 0x00, 0x00, 0x00 }, &EmuMEcxFs04 }); // mov ecx, large fs:4
//fsInstructions.push_back({ { 0x64, 0x8B, 0x3D, 0x00, 0x00, 0x00, 0x00 }, &EmuMEdiFs00 }); // mov edi, large fs:0
fsInstructions.push_back({ { 0x64, 0x8B, 0x3D, 0x00, 0x00, 0x00, 0x00 }, &EmuMEdiFs00 }); // mov edi, large fs:0
fsInstructions.push_back({ { 0x64, 0x8B, 0x3D, 0x04, 0x00, 0x00, 0x00 }, &EmuMEdiFs04 }); // mov edi, large fs:4
//fsInstructions.push_back({ { 0x64, 0x8B, 0x35, 0x00, 0x00, 0x00, 0x00 }, &EmuMEsiFs00 }); // mov esi, large fs:0
//fsInstructions.push_back({ { 0x64, 0x89, 0x1D, 0x00, 0x00, 0x00, 0x00 }, &EmuMFs00Ebx }); // mov large fs:0, ebx
//fsInstructions.push_back({ { 0x64, 0x89, 0x0D, 0x00, 0x00, 0x00, 0x00 }, &EmuMFs00Ecx }); // mov large fs:0, ecx
//fsInstructions.push_back({ { 0x64, 0x89, 0x25, 0x00, 0x00, 0x00, 0x00 }, &EmuMFs00Esp }); // mov large fs:0, esp
//fsInstructions.push_back({ { 0x64, 0x8F, 0x05, 0x00, 0x00, 0x00, 0x00 }, &EmuPopDwordPtrFs00 }); // pop large dword ptr fs:0
//fsInstructions.push_back({ { 0x64, 0xFF, 0x35, 0x00, 0x00, 0x00, 0x00 }, &EmuPushDwordPtrFs00 }); // push large dword ptr fs:0
//fsInstructions.push_back({ { 0x64, 0xA1, 0x00, 0x00, 0x00, 0x00 }, &EmuMEaxFs00 }); // mov eax, large fs:0
fsInstructions.push_back({ { 0x64, 0x8B, 0x35, 0x00, 0x00, 0x00, 0x00 }, &EmuMEsiFs00 }); // mov esi, large fs:0
fsInstructions.push_back({ { 0x64, 0x89, 0x1D, 0x00, 0x00, 0x00, 0x00 }, &EmuMFs00Ebx }); // mov large fs:0, ebx
fsInstructions.push_back({ { 0x64, 0x89, 0x0D, 0x00, 0x00, 0x00, 0x00 }, &EmuMFs00Ecx }); // mov large fs:0, ecx
fsInstructions.push_back({ { 0x64, 0x89, 0x25, 0x00, 0x00, 0x00, 0x00 }, &EmuMFs00Esp }); // mov large fs:0, esp
fsInstructions.push_back({ { 0x64, 0x8F, 0x05, 0x00, 0x00, 0x00, 0x00 }, &EmuPopDwordPtrFs00 }); // pop large dword ptr fs:0
fsInstructions.push_back({ { 0x64, 0xFF, 0x35, 0x00, 0x00, 0x00, 0x00 }, &EmuPushDwordPtrFs00 }); // push large dword ptr fs:0
fsInstructions.push_back({ { 0x64, 0xA1, 0x00, 0x00, 0x00, 0x00 }, &EmuMEaxFs00 }); // mov eax, large fs:0
fsInstructions.push_back({ { 0x64, 0xA1, 0x20, 0x00, 0x00, 0x00 }, &EmuMEaxFs20 }); // mov eax, large fs:20
fsInstructions.push_back({ { 0x64, 0xA1, 0x28, 0x00, 0x00, 0x00 }, &EmuMEaxFs28 }); // mov eax, large fs:28
//fsInstructions.push_back({ { 0x64, 0xA1, 0x58, 0x00, 0x00, 0x00 }, &EmuMEaxFs58 }); // mov eax, large fs:58
//fsInstructions.push_back({ { 0x64, 0xA3, 0x00, 0x00, 0x00, 0x00 }, &EmuMFs00Eax }); // mov large fs:0, eax
fsInstructions.push_back({ { 0x64, 0xA1, 0x58, 0x00, 0x00, 0x00 }, &EmuMEaxFs58 }); // mov eax, large fs:58
fsInstructions.push_back({ { 0x64, 0xA3, 0x00, 0x00, 0x00, 0x00 }, &EmuMFs00Eax }); // mov large fs:0, eax
DbgPrintf("Patching FS Register Accesses\n");
DWORD sizeOfImage = CxbxKrnl_XbeHeader->dwSizeofImage;
@ -290,6 +290,8 @@ void EmuInitFS()
if (memcmp((void*)addr, &fsInstructions[i].data[0], sizeOfData) == 0)
{
DbgPrintf("Patching FS Instruction at 0x%08X", addr);
// Write Call opcode
*(uint08*)addr = 0xE8;
*(uint32*)(addr + 1) = (uint32)fsInstructions[i].functionPtr - addr - 5;
@ -298,7 +300,7 @@ void EmuInitFS()
int remaining_bytes = fsInstructions[i].data.size() - 5;
memset((void*)(addr + 5), 0x90, remaining_bytes);
addr += sizeOfData - 1;
continue;
break;
}
}
}