Improve Scan Support

Now it has multi sections array support up to 2 (can be change by
increasing LINKSCANSEC_MAX

In fact, we can finally support other than DSound in v2 database now!
🎉
This commit is contained in:
RadWolfie 2017-09-05 08:40:23 -05:00 committed by Luke Usher
parent d145edd1be
commit c34a5e9d60
3 changed files with 93 additions and 14 deletions

View File

@ -40,19 +40,44 @@
#include <windows.h> #include <windows.h>
#include "CxbxKrnl.h" // For xbaddr #include "CxbxKrnl.h" // For xbaddr
#include "HLEDataBase.h" // For PairScanLibSec
extern "C" const char *szHLELastCompileTime = __TIMESTAMP__; extern "C" const char *szHLELastCompileTime = __TIMESTAMP__;
const char *Lib_D3D8 = "D3D8"; const char *Lib_D3D8 = "D3D8";
const char *Sec_D3D = "D3D";
const char *Lib_D3D8LTCG = "D3D8LTCG"; const char *Lib_D3D8LTCG = "D3D8LTCG";
const char *Lib_D3DX8 = "D3DX8"; const char *Lib_D3DX8 = "D3DX8";
const char *Sec_D3DX = "D3DX";
const char *Lib_DSOUND = "DSOUND"; const char *Lib_DSOUND = "DSOUND";
const char *Sec_DSOUND = Lib_DSOUND;
const char *Lib_XACTENG = "XACTENG"; const char *Lib_XACTENG = "XACTENG";
const char *Lib_XAPILIB = "XAPILIB"; const char *Lib_XAPILIB = "XAPILIB";
const char *Sec_XPP = "XPP";
const char *Lib_XGRAPHC = "XGRAPHC"; const char *Lib_XGRAPHC = "XGRAPHC";
const char *Sec_XGRPH = "XGRPH";
const char *Lib_XNETS = "XNETS"; const char *Lib_XNETS = "XNETS";
const char *Lib_XONLINE = "XONLINE"; // TODO : Typo for XONLINES? const char *Lib_XONLINE = "XONLINE"; // TODO : Typo for XONLINES?
const char *Sec_XONLINE = Lib_XONLINE;
const char *Lib_XONLINES = "XONLINES"; const char *Lib_XONLINES = "XONLINES";
const char *Sec_XNET = "XNET";
const PairScanLibSec PairScanLibSection[] = {
{ Lib_D3D8, { Sec_D3D } },
{ Lib_D3D8LTCG, { Sec_D3D } },
{ Lib_D3DX8, { Sec_D3DX } },
{ Lib_DSOUND, { Sec_DSOUND } },
//{ Lib_DSOUNDH, Sec_DSOUND },
//Lib_XACTENG = Sec_????
//{ Lib_XACTENLT, Sec_XACTENG },
{ Lib_XAPILIB, { Sec_XPP } },
{ Lib_XGRAPHC, { Sec_XGRPH } },
{ Lib_XONLINE, { Sec_XONLINE } },
{ Lib_XONLINES, { Sec_XONLINE, Sec_XNET } }, //and Sec_XNET too.
{ Lib_XNETS, { Sec_XNET } },
};
const uint32 StrScanLibSectionCount = sizeof(PairScanLibSection) / sizeof(PairScanLibSec);
#include "Emu.h" #include "Emu.h"
#include "EmuXTL.h" #include "EmuXTL.h"
@ -188,7 +213,41 @@ const HLEData HLEDataBase[] =
}; };
const HLEDataV2 HLEDataBaseV2[] = { const HLEDataV2 HLEDataBaseV2[] = {
{ Lib_DSOUND, DSound_OOVPAV2, DSound_OOVPA_SIZEV2 } //
//{ Lib_D3D8,{ Sec_D3D }, D3D8_OOVPAV2, D3D8_OOVPA_SIZEV2 },
// Cannot support LTCG in HLE
//{ Lib_D3D8LTCG,{ Sec_D3D }, _OOVPAV2, _OOVPA_SIZEV2 },
// Jarupxx mention this is not a requirement?
//{ Lib_D3DX8,{ Sec_D3DX }, _OOVPAV2, _OOVPA_SIZEV2 },
//
{ Lib_DSOUND,{ Sec_DSOUND }, DSound_OOVPAV2, DSound_OOVPA_SIZEV2 },
// DSOUNDH is just meant to define hot fix, there is no seperate section
//{ Lib_DSOUNDH,{ Sec_DSOUND }, DSound_OOVPAV2, DSound_OOVPA_SIZEV2 },
// I have not seen which header section it supposed to go with...
//{ Lib_XACTENG, { Sec_???? }, XACTENG_OOVPAV2, XACTENG_OOVPA_SIZEV2 },
//
//{ Lib_XACTENLT,{ Sec_XACTENG }, XACTENG_OOVPAV2, XACTENG_OOVPA_SIZEV2 },
//
//{ Lib_XAPILIB,{ Sec_XPP }, XAPILIB_OOVPAV2, XAPILIB_OOVPA_SIZEV2 },
//
//{ Lib_XGRAPHC,{ Sec_XGRPH }, XGRAPHC_OOVPAV2, XGRAPHC_OOVPA_SIZEV2 },
//
//{ Lib_XONLINE,{ Sec_XONLINE }, XONLINES_OOVPAV2, XONLINES_OOVPA_SIZEV2 },
// Fun fact, XONLINES are split into 2 header sections.
//{ Lib_XONLINES,{ Sec_XONLINE, Sec_XNET }, XONLINES_OOVPAV2, XONLINES_OOVPA_SIZEV2 },
// XNETS only has XNET, might be true.
//{ Lib_XNETS,{ Sec_XNET }, XONLINES_OOVPAV2, XONLINES_OOVPA_SIZEV2 },
}; };
// ****************************************************************** // ******************************************************************

View File

@ -97,6 +97,7 @@
// ****************************************************************** // ******************************************************************
extern "C" const char *szHLELastCompileTime; extern "C" const char *szHLELastCompileTime;
//TODO: Need to remove these externs as v2 is no longer require it.
extern const char *Lib_D3D8; extern const char *Lib_D3D8;
extern const char *Lib_D3D8LTCG; extern const char *Lib_D3D8LTCG;
extern const char *Lib_D3DX8; extern const char *Lib_D3DX8;
@ -105,7 +106,7 @@ extern const char *Lib_XACTENG;
extern const char *Lib_XAPILIB; extern const char *Lib_XAPILIB;
extern const char *Lib_XGRAPHC; extern const char *Lib_XGRAPHC;
extern const char *Lib_XNETS; extern const char *Lib_XNETS;
extern const char *Lib_XONLINE; // TODO : Typo for XONLINES? extern const char *Lib_XONLINE; //Is not a typo issue
extern const char *Lib_XONLINES; extern const char *Lib_XONLINES;
// ****************************************************************** // ******************************************************************
@ -121,9 +122,17 @@ extern const struct HLEData
} }
HLEDataBase[]; HLEDataBase[];
#define PAIRSCANSEC_MAX 2
extern const struct PairScanLibSec {
const char *library;
const char *section[PAIRSCANSEC_MAX];
}
PairScanLibSection[];
extern const struct HLEDataV2 extern const struct HLEDataV2
{ {
const char *Library; const PairScanLibSec LibSec;
OOVPATable *OovpaTable; OOVPATable *OovpaTable;
uint32 OovpaTableSize; uint32 OovpaTableSize;

View File

@ -593,18 +593,29 @@ void EmuHLEIntercept(Xbe::Header *pXbeHeader)
//HLE Database v2 //HLE Database v2
if (notFoundHLEDB) { if (notFoundHLEDB) {
//Initialize library scan against HLE database we want to search for address of patches and xreferences.
for (uint32 d2 = 0; d2 < HLEDataBaseCountV2; d2++) {
if (strcmp(LibraryName.c_str(), HLEDataBaseV2[d2].LibSec.library) == 0) {
bool bPrintOn = g_bPrintfOn;
for (uint32 v = 0; v < pXbeHeader->dwSections; v++) { for (uint32 v = 0; v < pXbeHeader->dwSections; v++) {
SectionName.assign((char*)pSectionHeaders[v].dwSectionNameAddr, (char*)pSectionHeaders[v].dwSectionNameAddr + 8); SectionName.assign((char*)pSectionHeaders[v].dwSectionNameAddr, (char*)pSectionHeaders[v].dwSectionNameAddr + 8);
if (strcmp(SectionName.c_str(), Lib_DSOUND) == 0) {
//Initialize a matching specific section is currently pair with library in order to scan specific section only.
//By doing this method will reduce false detection dramatically. If it had happened before.
for (uint32 d3 = 0; d3 < PAIRSCANSEC_MAX; d3++) {
if (HLEDataBaseV2[d2].LibSec.section[d3] != NULL && strcmp(SectionName.c_str(), HLEDataBaseV2[d2].LibSec.section[d3]) == 0) {
pSectionScan = pSectionHeaders + v; pSectionScan = pSectionHeaders + v;
if (g_bPrintfOn) printf("Found\n");
g_bPrintfOn = false;
EmuInstallPatchesV2(HLEDataBaseV2[d2].OovpaTable, HLEDataBaseV2[d2].OovpaTableSize, pSectionScan, OrigBuildVersion);
notFoundHLEDB = false;
break; break;
} }
} }
for (uint32 d2 = 0; d2 < HLEDataBaseCountV2; d2++) { }
if (strcmp(LibraryName.c_str(), HLEDataBaseV2[d2].Library) == 0 && pSectionScan != nullptr) { g_bPrintfOn = bPrintOn;
if (g_bPrintfOn) printf("Found\n");
EmuInstallPatchesV2(HLEDataBaseV2[d2].OovpaTable, HLEDataBaseV2[d2].OovpaTableSize, pSectionScan, OrigBuildVersion);
notFoundHLEDB = false;
break; break;
} }
} }