mirror of
https://github.com/optiscaler/OptiScaler.git
synced 2026-05-04 08:41:43 +00:00
added early quits and search start address to speed up pattern search
This commit is contained in:
@@ -979,98 +979,114 @@ void HookFSR2ExeInputs()
|
||||
{
|
||||
std::wstring_view exeNameV(exeNameW.c_str());
|
||||
|
||||
// Create
|
||||
LOG_DEBUG("Checking createPattern");
|
||||
std::string_view createPattern("40 55 57 41 54 41 56 48 8D AC 24 ? ? ? ? 48 81 EC ? ? ? ? 48 8B 05 ? ? ? ? 48 33 C4 48 89 85 ? ? ? ? 4C 8B F2 41 B8 ? ? ? ? 33 D2 48 8B F9 E8");
|
||||
o_ffxFsr2ContextCreate_Pattern_Dx12 = (PFN_ffxFsr2ContextCreate)scanner::GetAddress(exeNameV, createPattern, 0);
|
||||
|
||||
// Witchfire
|
||||
// Game uses FSR1 as FSR2
|
||||
//if (o_ffxFsr2ContextCreate_Pattern_Dx12 == nullptr)
|
||||
//{
|
||||
// LOG_DEBUG("Checking createPatternWF");
|
||||
// std::string_view createPatternWF("40 55 57 41 54 41 56 48 8D AC 24 ? ? ? ? 48 81 EC ? ? ? ? 48 8B 05 ? ? ? ? 48 33 C4 48 89 85 ? ? ? ? 4C 8B F2 41 B8 ? ? ? ? 33 D2 48 8B F9");
|
||||
// o_ffxFsr2ContextCreate_Pattern_Dx12 = (PFN_ffxFsr2ContextCreate)scanner::GetAddress(exeNameV, createPatternWF, 0);
|
||||
//}
|
||||
|
||||
// AW2
|
||||
// Custom implementation
|
||||
//if (o_ffxFsr2ContextCreate_Pattern_Dx12 == nullptr)
|
||||
//{
|
||||
// std::string_view createPatternAW2("40 55 57 41 54 41 56 48 8D AC 24 ? ? ? ? 48 81 EC ? ? ? ? 4C 8B F2 41 B8 ? ? ? ? 33 D2 48 8B F9");
|
||||
// o_ffxFsr2ContextCreate_Pattern_Dx12 = (PFN_ffxFsr2ContextCreate)scanner::GetAddress(exeNameV, createPatternAW2, 0);
|
||||
//}
|
||||
|
||||
if (o_ffxFsr2ContextCreate_Pattern_Dx12 != nullptr)
|
||||
DetourAttach(&(PVOID&)o_ffxFsr2ContextCreate_Pattern_Dx12, ffxFsr2ContextCreate_Pattern_Dx12);
|
||||
|
||||
LOG_DEBUG("ffxFsr2ContextCreate_Pattern_Dx12: {:X}", (size_t)o_ffxFsr2ContextCreate_Pattern_Dx12);
|
||||
|
||||
// DRG
|
||||
// Not receiving calls
|
||||
// Assumed FSR2.0
|
||||
LOG_DEBUG("Checking dispatchPattern20");
|
||||
std::string_view dispatchPattern20("40 55 56 41 57 48 8D AC 24 ? ? ? ? B8 ? ? ? ? E8 ? ? ? ? 48 2B E0 80 B9 ? ? ? ? 00 4C 8B FA 48 8B 02 48 8B F1");
|
||||
o_ffxFsr20ContextDispatch_Pattern_Dx12 = (PFN_ffxFsr2ContextDispatch)scanner::GetAddress(exeNameV, dispatchPattern20, 0);
|
||||
|
||||
if (o_ffxFsr20ContextDispatch_Pattern_Dx12 != nullptr)
|
||||
DetourAttach(&(PVOID&)o_ffxFsr20ContextDispatch_Pattern_Dx12, ffxFsr20ContextDispatch_Pattern_Dx12);
|
||||
|
||||
LOG_DEBUG("ffxFsr20ContextDispatch_Patern_Dx12: {:X}", (size_t)o_ffxFsr20ContextDispatch_Pattern_Dx12);
|
||||
|
||||
// Lies of P
|
||||
// Dispatch 2.X
|
||||
LOG_DEBUG("Checking dispatchPattern");
|
||||
std::string_view dispatchPattern("40 55 53 57 48 8D AC 24 ? ? ? ? B8 ? ? ? ? E8 ? ? ? ? 48 2B E0 80 B9 ? ? ? ? 00 48 8B DA 48 8B 02 48 8B F9");
|
||||
o_ffxFsr2ContextDispatch_Pattern_Dx12 = (PFN_ffxFsr2ContextDispatch)scanner::GetAddress(exeNameV, dispatchPattern, 0);
|
||||
|
||||
// Alone in the Dark - Game is using FSR1
|
||||
// Deliver Us Mars
|
||||
if (o_ffxFsr2ContextDispatch_Pattern_Dx12 == nullptr)
|
||||
do
|
||||
{
|
||||
LOG_DEBUG("Checking dispatchPatternAITD");
|
||||
std::string_view dispatchPatternAITD("40 55 57 41 56 48 8D AC 24 ? ? ? ? B8 ? ? ? ? E8 ? ? ? ? 48 2B E0 80 B9 ? ? ? ? ? 4C 8B F2 48 8B 02 48 8B F9");
|
||||
o_ffxFsr2ContextDispatch_Pattern_Dx12 = (PFN_ffxFsr2ContextDispatch)scanner::GetAddress(exeNameV, dispatchPatternAITD, 0);
|
||||
}
|
||||
// Create
|
||||
LOG_DEBUG("Checking createPattern");
|
||||
std::string_view createPattern("40 55 57 41 54 41 56 48 8D AC 24 ? ? ? ? 48 81 EC ? ? ? ? 48 8B 05 ? ? ? ? 48 33 C4 48 89 85 ? ? ? ? 4C 8B F2 41 B8 ? ? ? ? 33 D2 48 8B F9 E8");
|
||||
o_ffxFsr2ContextCreate_Pattern_Dx12 = (PFN_ffxFsr2ContextCreate)scanner::GetAddress(exeNameV, createPattern, 0);
|
||||
|
||||
// Witchfire
|
||||
// Game uses FSR1 as FSR2
|
||||
//if (o_ffxFsr2ContextDispatch_Pattern_Dx12 == nullptr)
|
||||
//{
|
||||
// LOG_DEBUG("Checking dispatchPatternWF");
|
||||
// std::string_view dispatchPatternWF("40 55 56 57 48 8D AC 24 ? ? ? ? B8 ? ? ? ? E8 ? ? ? ? 48 2B E0 48 8B 05 ? ? ? ? 48 33 C4 48 89 85 ? ? ? ? F7 01 ? ? ? ? 48 8B F2 48 8B F9");
|
||||
// o_ffxFsr2ContextDispatch_Pattern_Dx12 = (PFN_ffxFsr2ContextDispatch)scanner::GetAddress(exeNameV, dispatchPatternWF, 0);
|
||||
//}
|
||||
// Witchfire
|
||||
// Game uses FSR1 as FSR2
|
||||
//if (o_ffxFsr2ContextCreate_Pattern_Dx12 == nullptr)
|
||||
//{
|
||||
// LOG_DEBUG("Checking createPatternWF");
|
||||
// std::string_view createPatternWF("40 55 57 41 54 41 56 48 8D AC 24 ? ? ? ? 48 81 EC ? ? ? ? 48 8B 05 ? ? ? ? 48 33 C4 48 89 85 ? ? ? ? 4C 8B F2 41 B8 ? ? ? ? 33 D2 48 8B F9");
|
||||
// o_ffxFsr2ContextCreate_Pattern_Dx12 = (PFN_ffxFsr2ContextCreate)scanner::GetAddress(exeNameV, createPatternWF, 0);
|
||||
//}
|
||||
|
||||
// Banishers
|
||||
// Custom implementation
|
||||
//if (o_ffxFsr2ContextDispatch_Pattern_Dx12 == nullptr)
|
||||
//{
|
||||
// std::string_view dispatchPatternBanish("40 55 56 57 48 8D AC 24 ? ? ? ? B8 ? ? ? ? E8 ? ? ? ? 48 2B E0 48 8B 05 ? ? ? ? 48 33 C4 48 89 85 ? ? ? ? F7 01 ? ? ? ? 48 8B F2 48 8B F9");
|
||||
// o_ffxFsr2ContextDispatch_Pattern_Dx12 = (PFN_ffxFsr2ContextDispatch)scanner::GetAddress(exeNameV, dispatchPatternBanish, 0);
|
||||
//}
|
||||
// AW2
|
||||
// Custom implementation
|
||||
//if (o_ffxFsr2ContextCreate_Pattern_Dx12 == nullptr)
|
||||
//{
|
||||
// std::string_view createPatternAW2("40 55 57 41 54 41 56 48 8D AC 24 ? ? ? ? 48 81 EC ? ? ? ? 4C 8B F2 41 B8 ? ? ? ? 33 D2 48 8B F9");
|
||||
// o_ffxFsr2ContextCreate_Pattern_Dx12 = (PFN_ffxFsr2ContextCreate)scanner::GetAddress(exeNameV, createPatternAW2, 0);
|
||||
//}
|
||||
|
||||
// AW2
|
||||
// Custom implementation
|
||||
//{
|
||||
// std::string_view dispatchPatternAW2("40 55 56 41 56 48 8D AC 24 ? ? ? ? B8 ? ? ? ? E8 ? ? ? ? 48 2B E0 F7 01 ? ? ? ? 4C 8B F2 48 8B F1");
|
||||
// o_ffxFsr2ContextDispatch_Pattern_Dx12 = (PFN_ffxFsr2ContextDispatch)scanner::GetAddress(exeNameV, dispatchPatternAW2, 0);
|
||||
//}
|
||||
if (o_ffxFsr2ContextCreate_Pattern_Dx12 != nullptr)
|
||||
DetourAttach(&(PVOID&)o_ffxFsr2ContextCreate_Pattern_Dx12, ffxFsr2ContextCreate_Pattern_Dx12);
|
||||
|
||||
if (o_ffxFsr2ContextDispatch_Pattern_Dx12 != nullptr)
|
||||
DetourAttach(&(PVOID&)o_ffxFsr2ContextDispatch_Pattern_Dx12, ffxFsr2ContextDispatch_Pattern_Dx12);
|
||||
LOG_DEBUG("ffxFsr2ContextCreate_Pattern_Dx12: {:X}", (size_t)o_ffxFsr2ContextCreate_Pattern_Dx12);
|
||||
|
||||
LOG_DEBUG("ffxFsr2ContextDispatch_Pattern_Dx12: {:X}", (size_t)o_ffxFsr2ContextDispatch_Pattern_Dx12);
|
||||
|
||||
// Destroy
|
||||
LOG_DEBUG("Checking destroyPattern");
|
||||
std::string_view destroyPattern("40 53 48 83 EC 20 48 8B D9 48 85 C9 75 ? B8 00 00 00 80 48 83 C4 20 5B C3");
|
||||
o_ffxFsr2ContextDestroy_Pattern_Dx12 = (PFN_ffxFsr2ContextDestroy)scanner::GetAddress(exeNameV, destroyPattern, 0);
|
||||
if (o_ffxFsr2ContextCreate_Dx12 == nullptr && o_ffxFsr2ContextCreate_Pattern_Dx12)
|
||||
{
|
||||
LOG_DEBUG("No CreateContext found, stopping pattern matching");
|
||||
break;
|
||||
}
|
||||
|
||||
if (o_ffxFsr2ContextDestroy_Pattern_Dx12 != nullptr)
|
||||
DetourAttach(&(PVOID&)o_ffxFsr2ContextDestroy_Pattern_Dx12, ffxFsr2ContextDestroy_Pattern_Dx12);
|
||||
// Destroy
|
||||
LOG_DEBUG("Checking destroyPattern");
|
||||
std::string_view destroyPattern("40 53 48 83 EC 20 48 8B D9 48 85 C9 75 ? B8 00 00 00 80 48 83 C4 20 5B C3");
|
||||
o_ffxFsr2ContextDestroy_Pattern_Dx12 = (PFN_ffxFsr2ContextDestroy)scanner::GetAddress(exeNameV, destroyPattern, 0, (size_t)o_ffxFsr2ContextCreate_Pattern_Dx12);
|
||||
|
||||
LOG_DEBUG("ffxFsr2ContextDestroy_Pattern_Dx12: {:X}", (size_t)o_ffxFsr2ContextDestroy_Pattern_Dx12);
|
||||
if (o_ffxFsr2ContextDestroy_Pattern_Dx12 != nullptr)
|
||||
DetourAttach(&(PVOID&)o_ffxFsr2ContextDestroy_Pattern_Dx12, ffxFsr2ContextDestroy_Pattern_Dx12);
|
||||
|
||||
LOG_DEBUG("ffxFsr2ContextDestroy_Pattern_Dx12: {:X}", (size_t)o_ffxFsr2ContextDestroy_Pattern_Dx12);
|
||||
|
||||
if (o_ffxFsr2ContextDestroy_Dx12 == nullptr && o_ffxFsr2ContextDestroy_Pattern_Dx12)
|
||||
{
|
||||
LOG_DEBUG("No ContextDestroy found, stopping pattern matching");
|
||||
break;
|
||||
}
|
||||
|
||||
// DRG
|
||||
// Not receiving calls
|
||||
// Assumed FSR2.0
|
||||
LOG_DEBUG("Checking dispatchPattern20");
|
||||
std::string_view dispatchPattern20("40 55 56 41 57 48 8D AC 24 ? ? ? ? B8 ? ? ? ? E8 ? ? ? ? 48 2B E0 80 B9 ? ? ? ? 00 4C 8B FA 48 8B 02 48 8B F1");
|
||||
o_ffxFsr20ContextDispatch_Pattern_Dx12 = (PFN_ffxFsr2ContextDispatch)scanner::GetAddress(exeNameV, dispatchPattern20, 0, (size_t)o_ffxFsr2ContextCreate_Pattern_Dx12);
|
||||
|
||||
if (o_ffxFsr20ContextDispatch_Pattern_Dx12 != nullptr)
|
||||
DetourAttach(&(PVOID&)o_ffxFsr20ContextDispatch_Pattern_Dx12, ffxFsr20ContextDispatch_Pattern_Dx12);
|
||||
|
||||
LOG_DEBUG("ffxFsr20ContextDispatch_Patern_Dx12: {:X}", (size_t)o_ffxFsr20ContextDispatch_Pattern_Dx12);
|
||||
|
||||
// Lies of P
|
||||
// Dispatch 2.X
|
||||
LOG_DEBUG("Checking dispatchPattern");
|
||||
std::string_view dispatchPattern("40 55 53 57 48 8D AC 24 ? ? ? ? B8 ? ? ? ? E8 ? ? ? ? 48 2B E0 80 B9 ? ? ? ? 00 48 8B DA 48 8B 02 48 8B F9");
|
||||
o_ffxFsr2ContextDispatch_Pattern_Dx12 = (PFN_ffxFsr2ContextDispatch)scanner::GetAddress(exeNameV, dispatchPattern, 0, (size_t)o_ffxFsr2ContextCreate_Pattern_Dx12);
|
||||
|
||||
// Alone in the Dark - Game is using FSR1
|
||||
// Deliver Us Mars
|
||||
if (o_ffxFsr2ContextDispatch_Pattern_Dx12 == nullptr)
|
||||
{
|
||||
LOG_DEBUG("Checking dispatchPatternAITD");
|
||||
std::string_view dispatchPatternAITD("40 55 57 41 56 48 8D AC 24 ? ? ? ? B8 ? ? ? ? E8 ? ? ? ? 48 2B E0 80 B9 ? ? ? ? ? 4C 8B F2 48 8B 02 48 8B F9");
|
||||
o_ffxFsr2ContextDispatch_Pattern_Dx12 = (PFN_ffxFsr2ContextDispatch)scanner::GetAddress(exeNameV, dispatchPatternAITD, 0, (size_t)o_ffxFsr2ContextCreate_Pattern_Dx12);
|
||||
}
|
||||
|
||||
// Witchfire
|
||||
// Game uses FSR1 as FSR2
|
||||
//if (o_ffxFsr2ContextDispatch_Pattern_Dx12 == nullptr)
|
||||
//{
|
||||
// LOG_DEBUG("Checking dispatchPatternWF");
|
||||
// std::string_view dispatchPatternWF("40 55 56 57 48 8D AC 24 ? ? ? ? B8 ? ? ? ? E8 ? ? ? ? 48 2B E0 48 8B 05 ? ? ? ? 48 33 C4 48 89 85 ? ? ? ? F7 01 ? ? ? ? 48 8B F2 48 8B F9");
|
||||
// o_ffxFsr2ContextDispatch_Pattern_Dx12 = (PFN_ffxFsr2ContextDispatch)scanner::GetAddress(exeNameV, dispatchPatternWF, 0);
|
||||
//}
|
||||
|
||||
// Banishers
|
||||
// Custom implementation
|
||||
//if (o_ffxFsr2ContextDispatch_Pattern_Dx12 == nullptr)
|
||||
//{
|
||||
// std::string_view dispatchPatternBanish("40 55 56 57 48 8D AC 24 ? ? ? ? B8 ? ? ? ? E8 ? ? ? ? 48 2B E0 48 8B 05 ? ? ? ? 48 33 C4 48 89 85 ? ? ? ? F7 01 ? ? ? ? 48 8B F2 48 8B F9");
|
||||
// o_ffxFsr2ContextDispatch_Pattern_Dx12 = (PFN_ffxFsr2ContextDispatch)scanner::GetAddress(exeNameV, dispatchPatternBanish, 0);
|
||||
//}
|
||||
|
||||
// AW2
|
||||
// Custom implementation
|
||||
//{
|
||||
// std::string_view dispatchPatternAW2("40 55 56 41 56 48 8D AC 24 ? ? ? ? B8 ? ? ? ? E8 ? ? ? ? 48 2B E0 F7 01 ? ? ? ? 4C 8B F2 48 8B F1");
|
||||
// o_ffxFsr2ContextDispatch_Pattern_Dx12 = (PFN_ffxFsr2ContextDispatch)scanner::GetAddress(exeNameV, dispatchPatternAW2, 0);
|
||||
//}
|
||||
|
||||
if (o_ffxFsr2ContextDispatch_Pattern_Dx12 != nullptr)
|
||||
DetourAttach(&(PVOID&)o_ffxFsr2ContextDispatch_Pattern_Dx12, ffxFsr2ContextDispatch_Pattern_Dx12);
|
||||
|
||||
LOG_DEBUG("ffxFsr2ContextDispatch_Pattern_Dx12: {:X}", (size_t)o_ffxFsr2ContextDispatch_Pattern_Dx12);
|
||||
} while (false);
|
||||
}
|
||||
|
||||
State::Instance().fsrHooks = o_ffxFsr2ContextCreate_Dx12 != nullptr || o_ffxFsr2ContextCreate_Pattern_Dx12 != nullptr;
|
||||
|
||||
@@ -51,7 +51,7 @@ uintptr_t scanner::GetAddress(const std::wstring_view moduleName, const std::str
|
||||
uintptr_t address;
|
||||
|
||||
if (startAddress != 0)
|
||||
address = FindPattern(startAddress, GetModule(moduleName.data()).second - GetModule(moduleName.data()).first, pattern.data());
|
||||
address = FindPattern(startAddress, GetModule(moduleName.data()).second - startAddress, pattern.data());
|
||||
else
|
||||
address = FindPattern(GetModule(moduleName.data()).first, GetModule(moduleName.data()).second - GetModule(moduleName.data()).first, pattern.data());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user