pcsx2 search

This commit is contained in:
Akash Mozumdar 2020-03-01 05:42:34 -07:00
parent b7978ff512
commit 360254d5bf
2 changed files with 12 additions and 3 deletions

View File

@ -20748,6 +20748,13 @@ bool InsertTecmoPSPHook()
*/ */
bool InsertPCSX2Hooks() bool InsertPCSX2Hooks()
{ {
memcpy(spDefault.pattern, Array<BYTE>{ 0x89, 0xc8, 0xc1, 0xe8, 0x0c }, spDefault.length = 5);
*spDefault.boundaryModule = 0;
spDefault.offset = 0;
spDefault.searchTime = 60'000;
spDefault.maxRecords = 500'000;
spDefault.padding = 0x20000000;
ConsoleOutput("Textractor: PCSX2 detected (searching for hooks may work)");
// TODO: Add generic hooks // TODO: Add generic hooks
return InsertTypeMoonPS2Hook() return InsertTypeMoonPS2Hook()
|| InsertMarvelousPS2Hook() || InsertMarvelousPS2Hook()

View File

@ -19,6 +19,7 @@ namespace
struct HookRecord struct HookRecord
{ {
uint64_t address = 0; uint64_t address = 0;
uintptr_t padding = 0;
int offset = 0; int offset = 0;
char text[MAX_STRING_SIZE] = {}; char text[MAX_STRING_SIZE] = {};
}; };
@ -134,9 +135,9 @@ void Send(char** stack, uintptr_t address)
// it is unsafe to call ANY external functions from this, as they may have been hooked (if called the hook would call this function making an infinite loop) // it is unsafe to call ANY external functions from this, as they may have been hooked (if called the hook would call this function making an infinite loop)
// the exceptions are compiler intrinsics like _InterlockedDecrement // the exceptions are compiler intrinsics like _InterlockedDecrement
if (recordsAvailable <= 0) return; if (recordsAvailable <= 0) return;
for (int i = -registers; i < 10; ++i) for (int i = -registers; i < 10; ++i) for (auto padding : { uintptr_t{}, sp.padding })
{ {
char* str = stack[i] + sp.padding; char* str = stack[i] + padding;
if (IsBadReadPtr(str) || IsBadReadPtr(str + MAX_STRING_SIZE)) continue; if (IsBadReadPtr(str) || IsBadReadPtr(str + MAX_STRING_SIZE)) continue;
__try __try
{ {
@ -155,6 +156,7 @@ void Send(char** stack, uintptr_t address)
if (n < sp.maxRecords) if (n < sp.maxRecords)
{ {
records[n].address = address; records[n].address = address;
records[n].padding = padding;
records[n].offset = i * sizeof(char*); records[n].offset = i * sizeof(char*);
for (int j = 0; j < length; ++j) records[n].text[j] = str[j]; for (int j = 0; j < length; ++j) records[n].text[j] = str[j];
records[n].text[length] = 0; records[n].text[length] = 0;
@ -240,7 +242,7 @@ void SearchForHooks(SearchParam spUser)
hp.offset = records[i].offset; hp.offset = records[i].offset;
hp.type = USING_UNICODE | USING_STRING; hp.type = USING_UNICODE | USING_STRING;
hp.address = records[i].address; hp.address = records[i].address;
hp.padding = sp.padding; hp.padding = records[i].padding;
hp.codepage = sp.codepage; hp.codepage = sp.codepage;
if (sp.hookPostProcessor) sp.hookPostProcessor(hp); if (sp.hookPostProcessor) sp.hookPostProcessor(hp);
NotifyHookFound(hp, (wchar_t*)records[i].text); NotifyHookFound(hp, (wchar_t*)records[i].text);