added helpful info for hook searching in native and ppsspp memory

This commit is contained in:
Akash Mozumdar 2019-06-09 00:50:26 -04:00
parent 5e27de842b
commit 907c43db4a
5 changed files with 75 additions and 5 deletions

View File

@ -16806,6 +16806,37 @@ bool InsertVanillawareGCHook()
return addr; return addr;
} }
/** Artikash 6/7/2019
* PPSSPP JIT code has pointers, but they are all added to an offset before being used.
Find that offset and report it to user so they can search for hooks properly.
To find the offset, find a page of mapped memory with size 0x1f00000, read and write permissions, take its address and subtract 0x8000000.
The above is useful for emulating PSP hardware, so unlikely to change between versions.
*/
bool FindPPSSPP()
{
bool found = false;
SYSTEM_INFO systemInfo;
GetNativeSystemInfo(&systemInfo);
for (BYTE* probe = NULL; probe < systemInfo.lpMaximumApplicationAddress;)
{
MEMORY_BASIC_INFORMATION info;
if (!VirtualQuery(probe, &info, sizeof(info)))
{
probe += systemInfo.dwPageSize;
}
else
{
if (info.RegionSize == 0x1f00000 && info.Protect == PAGE_READWRITE && info.Type == MEM_MAPPED)
{
found = true;
ConsoleOutput("Textractor: PPSSPP memory found: use pattern 79 0F C7 85 and pattern offset 0 and string offset %p to search for hooks", probe - 0x8000000);
}
probe += info.RegionSize;
}
}
return found;
}
/** jichi 7/12/2014 PPSSPP /** jichi 7/12/2014 PPSSPP
* Tested with PPSSPP 0.9.8. * Tested with PPSSPP 0.9.8.
*/ */

View File

@ -43,6 +43,7 @@ bool InsertTypeMoonPS2Hook(); // http://typemoon.com
void SpecialPSPHook(DWORD esp_base, HookParam *hp, DWORD *data, DWORD *split, DWORD *len); // General PSP extern hook void SpecialPSPHook(DWORD esp_base, HookParam *hp, DWORD *data, DWORD *split, DWORD *len); // General PSP extern hook
bool FindPPSSPP();
bool InsertPPSSPPHooks(); // PPSSPPWindows bool InsertPPSSPPHooks(); // PPSSPPWindows
bool InsertPPSSPPHLEHooks(); bool InsertPPSSPPHLEHooks();

View File

@ -53,6 +53,6 @@ namespace Engine
DetermineEngineType(); DetermineEngineType();
hijacked = true; hijacked = true;
ConsoleOutput("Textractor: finished hijacking %S located from 0x%p to 0x%p", processName, processStartAddress, processStopAddress); ConsoleOutput("Textractor: finished hijacking process located from 0x%p to 0x%p", processStartAddress, processStopAddress);
} }
} }

View File

@ -36,10 +36,13 @@ bool DeterminePCEngine()
return true; return true;
} }
if (Util::CheckFile(L"PPSSPP*.exe")) { // jichi 7/12/2014 PPSSPPWindows.exe, PPSSPPEX.exe PPSSPPSP.exe //if (Util::CheckFile(L"PPSSPP*.exe")) { // jichi 7/12/2014 PPSSPPWindows.exe, PPSSPPEX.exe PPSSPPSP.exe
//InsertPPSSPPHooks(); // Artikash 8/4/2018: removed for now as doesn't work for non ancient ppsspp versions // //InsertPPSSPPHooks(); // Artikash 8/4/2018: removed for now as doesn't work for non ancient ppsspp versions
return true; // FindPPSSPP();
} // return true;
//}
if (Util::CheckFile(L"PPSSPP*.exe") && FindPPSSPP()) return true;
if (Util::CheckFile(L"pcsx2*.exe")) { // jichi 7/19/2014 PCSX2.exe or PCSX2WX.exe if (Util::CheckFile(L"pcsx2*.exe")) { // jichi 7/19/2014 PCSX2.exe or PCSX2WX.exe
InsertPCSX2Hooks(); InsertPCSX2Hooks();

View File

@ -1,9 +1,42 @@
#include "match.h" #include "match.h"
#include "main.h" #include "main.h"
#include "native/pchooks.h" #include "native/pchooks.h"
#include "engine.h"
#include "util.h"
namespace Engine namespace Engine
{ {
/** Artikash 6/7/2019
* PPSSPP JIT code has pointers, but they are all added to an offset before being used.
Find that offset and report it to user so they can search for hooks properly.
To find the offset, find a page of mapped memory with size 0x1f00000, read and write permissions, take its address and subtract 0x8000000.
The above is useful for emulating PSP hardware, so unlikely to change between versions.
*/
bool FindPPSSPP()
{
bool found = false;
SYSTEM_INFO systemInfo;
GetNativeSystemInfo(&systemInfo);
for (BYTE* probe = NULL; probe < systemInfo.lpMaximumApplicationAddress;)
{
MEMORY_BASIC_INFORMATION info;
if (!VirtualQuery(probe, &info, sizeof(info)))
{
probe += systemInfo.dwPageSize;
}
else
{
if (info.RegionSize == 0x1f00000 && info.Protect == PAGE_READWRITE && info.Type == MEM_MAPPED)
{
found = true;
ConsoleOutput("Textractor: PPSSPP memory found: use pattern 79 10 41 C7 and pattern offset 0 and string offset %p to search for hooks", probe - 0x8000000);
}
probe += info.RegionSize;
}
}
return found;
}
bool UnsafeDetermineEngineType() bool UnsafeDetermineEngineType()
{ {
for (std::wstring DXVersion : { L"d3dx9", L"d3dx10" }) for (std::wstring DXVersion : { L"d3dx9", L"d3dx10" })
@ -11,6 +44,8 @@ namespace Engine
else for (int i = 0; i < 50; ++i) else for (int i = 0; i < 50; ++i)
if (HMODULE module = GetModuleHandleW((DXVersion + L"_" + std::to_wstring(i)).c_str())) PcHooks::hookD3DXFunctions(module); if (HMODULE module = GetModuleHandleW((DXVersion + L"_" + std::to_wstring(i)).c_str())) PcHooks::hookD3DXFunctions(module);
if (Util::CheckFile(L"PPSSPP*.exe") && FindPPSSPP()) return true;
PcHooks::hookGDIFunctions(); PcHooks::hookGDIFunctions();
PcHooks::hookGDIPlusFunctions(); PcHooks::hookGDIPlusFunctions();
return false; return false;