Obsolete fix removal. Update offsets for console enabling
This commit is contained in:
@@ -83,8 +83,6 @@ static SafetyHookMid FogHook{};
|
||||
// Prototypes
|
||||
static void FOVFixEnabled(bool fix_enabled);
|
||||
static void FPSFixEnabled(bool fix_enabled);
|
||||
static void ResolutionFixEnabled(bool fix_enabled);
|
||||
static void AspectFixEnabled(bool fix_enabled);
|
||||
static void DOFFixEnabled(bool fix_enabled);
|
||||
static void CAFixEnabled(bool fix_enabled);
|
||||
static void VignettingFixEnabled(bool fix_enabled);
|
||||
@@ -115,24 +113,6 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init)
|
||||
}
|
||||
}
|
||||
|
||||
if (Resolutionaddress_1 == nullptr) {
|
||||
constexpr auto ResolutionStringObfuscated = make_obfuscated<0x4A>("C7 44 ?? ?? ?? ?? ?? ?? 0F 11 ?? ?? ?? 48 8D ?? ?? ?? 48 89 ?? ?? ?? 89 ?? ?? ?? C6 ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 8B ?? ?? ?? ?? ?? 66");
|
||||
Resolutionaddress_1 = Memory::AOBScan(gameExecutable, ResolutionStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||
//"MGSDelta-Win64-Shipping.exe" + 4EAC202 - 74 28 - je "MGSDelta-Win64-Shipping.exe" + 4EAC22C
|
||||
//"MGSDelta-Win64-Shipping.exe" + 4EAC204 - 0F57 C9 - xorps xmm1, xmm1
|
||||
//"MGSDelta-Win64-Shipping.exe" + 4EAC207 - C7 44 24 20 00 00 F0 44 - mov[rsp + 20], 44F00000
|
||||
//"MGSDelta-Win64-Shipping.exe" + 4EAC20F - 0F 11 4C 24 28 - movups[rsp + 28], xmm1
|
||||
//"MGSDelta-Win64-Shipping.exe" + 4EAC214 - 48 8D 54 24 20 - lea rdx, [rsp + 20]
|
||||
|
||||
if (!Resolutionaddress_1)
|
||||
logger->warn("Resolution signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
|
||||
else {
|
||||
logger->info("Resolution signature found at address: 0x{:X}.", reinterpret_cast<uintptr_t>(Resolutionaddress_1));
|
||||
Resolutionaddress_1 += 4;
|
||||
Resolutionaddress_2 = Resolutionaddress_1 + 0x3D;
|
||||
}
|
||||
}
|
||||
|
||||
if (FPSaddress == nullptr) {
|
||||
constexpr auto FPSStringObfuscated = make_obfuscated<0x4A>("F3 0F ?? ?? ?? EB ?? 0F ?? ?? 48 8B ?? ?? ?? 48 8B ?? ?? ?? 48 8B ?? ?? ?? 48 8B ?? ?? ?? 0F");
|
||||
FPSaddress = Memory::AOBScan(gameExecutable, FPSStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||
@@ -150,40 +130,6 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init)
|
||||
}
|
||||
}
|
||||
|
||||
if (Aspectaddress == nullptr) {
|
||||
//constexpr auto AspectStringObfuscated = make_obfuscated<0x4A>("C3 CC CC CC CC CC CC CC CC CC 48 89 ?? ?? ?? 57 48 83 ?? ?? 0F ?? ?? 48 ?? ?? 48 ?? ?? 0F ?? ?? F2 0F ?? ?? ?? F2 0F ?? ?? ?? 0F");
|
||||
constexpr auto AspectStringObfuscated = make_obfuscated<0x4A>("F3 0F ?? ?? ?? ?? ?? ?? F3 0F ?? ?? ?? 8B 87 ?? ?? ?? ?? 89 ?? ?? 0F");
|
||||
Aspectaddress = Memory::AOBScan(gameExecutable, AspectStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||
//"MGSDelta-Win64-Shipping.exe" + 3A03453 - 89 41 44 - mov[rcx + 44], eax
|
||||
//"MGSDelta-Win64-Shipping.exe" + 3A03456 - 8B 42 48 - mov eax, [rdx + 48]
|
||||
//"MGSDelta-Win64-Shipping.exe" + 3A03459 - 89 41 48 - mov[rcx + 48], eax
|
||||
//"MGSDelta-Win64-Shipping.exe" + 3A0345C - 48 8D 42 4C - lea rax, [rdx + 4C]
|
||||
//"MGSDelta-Win64-Shipping.exe" + 3A03460 - 48 83 C1 4C - add rcx, 4C
|
||||
|
||||
if (!Aspectaddress)
|
||||
logger->warn("Aspect ratio signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
|
||||
else {
|
||||
logger->info("Aspect ratio signature found at address: 0x{:X}.", reinterpret_cast<uintptr_t>(Aspectaddress));
|
||||
Aspectaddress = Aspectaddress + 0x13;
|
||||
}
|
||||
}
|
||||
|
||||
if (AspectMenuaddress == nullptr) {
|
||||
constexpr auto AspectMenuStringObfuscated = make_obfuscated<0x4A>("66 ?? ?? ?? 66 ?? ?? ?? 0F ?? ?? F2 ?? ?? ?? 0F 11 ?? ?? ?? F2 ?? ?? ?? 0F");
|
||||
AspectMenuaddress = Memory::AOBScan(gameExecutable, AspectMenuStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||
//"MGSDelta-Win64-Shipping.exe" + 50155AF - F2 0F 10 05 39 88 84 07 - movsd xmm0, ["MGSDelta-Win64-Shipping.exe" + C85DDF0]
|
||||
//"MGSDelta-Win64-Shipping.exe" + 50155B7 - 0F 28 DE - movaps xmm3, xmm6
|
||||
//"MGSDelta-Win64-Shipping.exe" + 50155BA - F2 0F 5E 05 36888407 - divsd xmm0, ["MGSDelta-Win64-Shipping.exe" + C85DDF8]
|
||||
//"MGSDelta-Win64-Shipping.exe" + 50155C2 - 66 0F 15 DE - unpckhpd xmm3, xmm6
|
||||
//"MGSDelta-Win64-Shipping.exe" + 50155C6 - 66 0F 5A C8 - cvtpd2ps xmm1, xmm0
|
||||
|
||||
if (!AspectMenuaddress)
|
||||
logger->warn("Aspect ratio ratio signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
|
||||
else {
|
||||
logger->info("Aspect ratio signature found at address: 0x{:X}.", reinterpret_cast<uintptr_t>(AspectMenuaddress));
|
||||
}
|
||||
}
|
||||
|
||||
if (DOFaddress == nullptr) {
|
||||
constexpr auto DOFStringObfuscated = make_obfuscated<0x4A>("7E ?? F6 ?? ?? ?? 74 ?? F6 83");
|
||||
DOFaddress = Memory::AOBScan(gameExecutable, DOFStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||
@@ -262,6 +208,8 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init)
|
||||
GObjectsaddress = Memory::AOBScan(gameExecutable, GObjetcsStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||
constexpr auto GNamesStringObfuscated = make_obfuscated<0x4A>("8B 05 ?? ?? ?? ?? 0F B7 ?? ?? FF ?? 3B ?? 73");
|
||||
GNamesaddress = Memory::AOBScan(gameExecutable, GNamesStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||
constexpr auto GetNameEntryStringStringObfuscated = make_obfuscated<0x4A>("40 ?? 48 83 ?? ?? 80 3D ?? ?? ?? ?? ?? 8B ?? 74 ?? 48 8D ?? ?? ?? ?? ?? EB ?? 48 8D ?? ?? ?? ?? ?? E8 ?? ?? ?? ?? 48");
|
||||
GetNameEntryaddress = Memory::AOBScan(gameExecutable, GetNameEntryStringStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||
constexpr auto AppendStringStringObfuscated = make_obfuscated<0x4A>("48 89 ?? ?? ?? ?? ?? ?? 48 81 ?? ?? ?? ?? ?? 48 8B ?? ?? ?? ?? ?? 48 ?? ?? 48 89 ?? ?? ?? ?? ?? ?? 0F ?? ?? 48 8B");
|
||||
AppendStringaddress = Memory::AOBScan(gameExecutable, AppendStringStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||
constexpr auto ProcessEventStringObfuscated = make_obfuscated<0x4A>("40 ?? 56 57 41 ?? 41 ?? 41 ?? 41 ?? 48 81 ?? ?? ?? ?? ?? 48 8D ?? ?? ?? 48 89 ?? ?? ?? ?? ?? 48 8B ?? ?? ?? ?? ?? 48 33 ?? 48 89 ?? ?? ?? ?? ?? 4D ?? ?? 48");
|
||||
@@ -281,10 +229,20 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init)
|
||||
else {
|
||||
uint32_t gNamesOffset = static_cast<uint32_t>(Memory::GetOffsetFromOpcode(GNamesaddress + 0x2) -
|
||||
reinterpret_cast<uint8_t*>(GetModuleHandleA(gameExecutable.c_str())));
|
||||
gNamesOffset -= 0x8;
|
||||
logger->info("GNames offset is: 0x{:X}.", gNamesOffset);
|
||||
Offsets::GNames = static_cast<UC::uint32>(gNamesOffset); // Update GNames offset
|
||||
}
|
||||
|
||||
if (!GetNameEntryaddress)
|
||||
logger->warn("Get Name Entry signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
|
||||
else {
|
||||
std::optional<uint32_t> gGetNameEntryOffsetOpt = UE::CalculateOffset(gameExecutable, GetNameEntryaddress);
|
||||
uint32_t gGetNameEntryOffset = *gGetNameEntryOffsetOpt;
|
||||
logger->info("Get Name Entry offset is: 0x{:X}.", gGetNameEntryOffset);
|
||||
Offsets::GetNameEntry = static_cast<UC::uint32>(gGetNameEntryOffset);// Update GetNameEntry offset
|
||||
}
|
||||
|
||||
if (!AppendStringaddress)
|
||||
logger->warn("AppendString signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
|
||||
else {
|
||||
@@ -309,8 +267,6 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init)
|
||||
if (g_fix_enabled) {
|
||||
if (FOVaddress) FOVFixEnabled(g_fov_fix_enabled || g_aspect_fix_enabled);
|
||||
if (FPSaddress) FPSFixEnabled(g_FPS_fix_enabled);
|
||||
if (Resolutionaddress_1) ResolutionFixEnabled(g_resolution_fix_enabled);
|
||||
if (Aspectaddress) AspectFixEnabled(g_aspect_fix_enabled);
|
||||
if (DOFaddress) DOFFixEnabled(g_DOF_fix_enabled);
|
||||
if (CAaddress) CAFixEnabled(g_CA_fix_enabled);
|
||||
if (Vignettingaddress) VignettingFixEnabled(g_Vignetting_fix_enabled);
|
||||
@@ -319,15 +275,13 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init)
|
||||
else {
|
||||
if (FOVaddress) FOVFixEnabled(false);
|
||||
if (FPSaddress) FPSFixEnabled(false);
|
||||
if (Resolutionaddress_1) ResolutionFixEnabled(false);
|
||||
if (Aspectaddress) AspectFixEnabled(false);
|
||||
if (DOFaddress) DOFFixEnabled(false);
|
||||
if (CAaddress) CAFixEnabled(false);
|
||||
if (Vignettingaddress) VignettingFixEnabled(false);
|
||||
if (Fogaddress) FogFixEnabled(false);
|
||||
logger->info("All fixes disabled.");
|
||||
}
|
||||
if (!g_Console_Enabled && GObjectsaddress && GNamesaddress && AppendStringaddress && ProcessEventaddress)
|
||||
if (!g_Console_Enabled && GObjectsaddress && GNamesaddress && GetNameEntryaddress && AppendStringaddress && ProcessEventaddress)
|
||||
EnableConsole();
|
||||
}
|
||||
|
||||
@@ -344,18 +298,6 @@ extern "C" __declspec(dllexport) void SetFPSFixEnabled(bool enabled, bool init)
|
||||
if (!init) FPSFixEnabled(g_FPS_fix_enabled);
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) void SetResolutionFixEnabled(bool enabled, bool init)
|
||||
{
|
||||
g_resolution_fix_enabled = enabled;
|
||||
if (!init) ResolutionFixEnabled(g_resolution_fix_enabled);
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) void SetAspectRatioFixEnabled(bool enabled, bool init)
|
||||
{
|
||||
g_aspect_fix_enabled = enabled;
|
||||
if (!init) AspectFixEnabled(g_aspect_fix_enabled);
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) void SetDOFFixEnabled(bool enabled, bool init)
|
||||
{
|
||||
g_DOF_fix_enabled = enabled;
|
||||
@@ -426,27 +368,6 @@ static void FOVFixEnabled(bool fix_enabled) {
|
||||
}
|
||||
}
|
||||
|
||||
static void ResolutionFixEnabled(bool fix_enabled) {
|
||||
if (g_fix_enabled && fix_enabled && Resolutionaddress_1 && Resolutionaddress_2) {
|
||||
Memory::PatchBytes(Resolutionaddress_1, bytesWidth, 4); // patch scree nwidth in memory
|
||||
|
||||
if (!ResolutionHook_2) { // Hook only once
|
||||
ResolutionHook_2 = safetyhook::create_mid(Resolutionaddress_2,
|
||||
[](SafetyHookContext& ctx) {
|
||||
ctx.xmm0.f32[0] = (float)screenHeight;
|
||||
});
|
||||
}
|
||||
else ResolutionHook_2.enable();
|
||||
logger->info("Resolution fix enabled");
|
||||
}
|
||||
if (!fix_enabled) {
|
||||
if (ResolutionHook_2) ResolutionHook_2.disable();
|
||||
Memory::RestoreBytes(Resolutionaddress_1);
|
||||
logger->info("Resolution fix disabled");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void FPSFixEnabled(bool fix_enabled) {
|
||||
if (g_fix_enabled && fix_enabled && FPSaddress) {
|
||||
if (!FPSHook) { // Hook only once
|
||||
@@ -464,47 +385,6 @@ static void FPSFixEnabled(bool fix_enabled) {
|
||||
}
|
||||
}
|
||||
|
||||
static void AspectFixEnabled(bool fix_enabled) {
|
||||
if (g_fix_enabled && fix_enabled && Aspectaddress) {
|
||||
if (!AspectHook) {
|
||||
AspectHook = safetyhook::create_mid(Aspectaddress,
|
||||
[](SafetyHookContext& ctx) {
|
||||
ctx.rax = *reinterpret_cast<uint32_t*>(&aspectRatio);
|
||||
});
|
||||
}
|
||||
else AspectHook.enable();
|
||||
|
||||
if (!AspectMenuHook) {
|
||||
AspectMenuHook = safetyhook::create_mid(AspectMenuaddress,
|
||||
[](SafetyHookContext& ctx) {
|
||||
if (!ctx.rbx) return;
|
||||
|
||||
auto obj = reinterpret_cast<UObject*>(ctx.rbx);
|
||||
constexpr auto PauseBackScreenStringObfuscated = make_obfuscated<0x4A>("WP_PauseBackScreen");
|
||||
auto decrypted = PauseBackScreenStringObfuscated.decrypt();
|
||||
if (!decrypted.empty() && decrypted.back() == '\0') // trim right nul terminated character
|
||||
decrypted.pop_back();
|
||||
|
||||
// This will force screen aspect ratio when pause menu is activated only
|
||||
if (obj->GetName().find(decrypted) != std::string::npos)
|
||||
ctx.xmm0.f64[0] = static_cast<double>(aspectRatio);
|
||||
});
|
||||
}
|
||||
else AspectMenuHook.enable();
|
||||
|
||||
logger->info("Aspect fix enabled");
|
||||
FOVFixEnabled(fix_enabled);
|
||||
}
|
||||
if (!fix_enabled) {
|
||||
if (AspectHook) AspectHook.disable();
|
||||
if (AspectMenuHook) AspectMenuHook.disable();
|
||||
|
||||
logger->info("Aspect ratio fix disabled");
|
||||
if (!g_fov_fix_enabled)
|
||||
FOVFixEnabled(fix_enabled);
|
||||
}
|
||||
}
|
||||
|
||||
// Memory patch fixes
|
||||
static void DOFFixEnabled(bool fix_enabled) {
|
||||
if (g_fix_enabled && fix_enabled && DOFaddress) {
|
||||
@@ -550,7 +430,7 @@ static void FogFixEnabled(bool fix_enabled) {
|
||||
static void EnableConsole()
|
||||
{
|
||||
logger->info("-------------- Console re-enabling --------------");
|
||||
if (!GObjectsaddress || !GNamesaddress || !AppendStringaddress || !ProcessEventaddress) {
|
||||
if (!GObjectsaddress || /*!GNamesaddress ||*/ !AppendStringaddress || !ProcessEventaddress) {
|
||||
logger->warn("Could not re-enable console");
|
||||
logger->info("------------------ User inputs ------------------");
|
||||
return;
|
||||
@@ -560,8 +440,8 @@ static void EnableConsole()
|
||||
auto start = std::chrono::high_resolution_clock::now(); // Measure the time to renable console
|
||||
UEngine* Engine = nullptr;
|
||||
|
||||
for (int i = 0; i < 100; ++i) { // gives 10 seconds to find UE Engine
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
for (int i = 0; i < 10; ++i) { // gives 10 seconds to find UE Engine
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
|
||||
Engine = UEngine::GetEngine();
|
||||
|
||||
if (Engine && Engine->ConsoleClass && Engine->GameViewport)
|
||||
|
||||
Reference in New Issue
Block a user