First attempt at HLE database verification

This commit is contained in:
PatrickvL 2017-01-15 17:29:13 +01:00
parent dcca5f9ffa
commit 9e50b18fcc
3 changed files with 47 additions and 0 deletions

View File

@ -357,6 +357,8 @@ extern "C" CXBXKRNL_API void CxbxKrnlInit
#endif
}
VerifyHLEData();
{
// Create a fake kernel header for XapiRestrictCodeSelectorLimit
// Thanks advancingdragon / DirtBox

View File

@ -759,3 +759,46 @@ static void EmuXRefFailure()
CxbxKrnlCleanup("XRef-only function body reached. Fatal Error.");
}
void VerifyOOVPA(OOVPA *Oovpa)
{
uint08 dummy_value;
uint32 prev_offset;
GetOovpaEntry(Oovpa, Oovpa->XRefCount, prev_offset, dummy_value);
for (int p = Oovpa->XRefCount; p < Oovpa->Count; p++) {
uint32 curr_offset;
GetOovpaEntry(Oovpa, Oovpa->XRefCount, curr_offset, dummy_value);
if (curr_offset <= prev_offset) {
EmuWarning("Error in OOVPA %s at index %d : offset %d must be larger then previous offset (%d)\n",
p, curr_offset, prev_offset);
}
}
}
void VerifyHLEData()
{
for (uint32 d = 0; d < HLEDataBaseCount; d++) {
const HLEData *mainData = &HLEDataBase[d];
OOVPATable *mainTable = mainData->OovpaTable;
for (uint32 e = 0; e < mainData->OovpaTableSize / sizeof(OOVPATable); e++) {
void * entry_redirect = mainTable[e].lpRedirect;
// does this entry specify a redirection (patch)?
if (entry_redirect != nullptr) {
// check no patch occurs twice in this table
for (uint32 t = e + 1; t < mainData->OovpaTableSize / sizeof(OOVPATable); t++) {
if (entry_redirect == mainTable[t].lpRedirect) {
EmuWarning("Error in OOVPA Table %s at index %d : patch 0x%x (%s) occurs also at index %d (%s)\n",
mainTable->szFuncName,
e, mainTable[e].szFuncName,
t, mainTable[t].szFuncName);
}
}
}
// Check each OOVPA in this table :
OOVPA *mainOovpa = mainTable[e].Oovpa;
VerifyOOVPA(mainOovpa);
// TODO : Find duplicates across all otherr data-table-oovpa's
}
}
}

View File

@ -40,4 +40,6 @@ extern bool bLLE_JIT; // Set this to true for experimental JIT
void EmuHLEIntercept(Xbe::LibraryVersion *LibraryVersion, Xbe::Header *XbeHeader);
void VerifyHLEData();
#endif