From 4bb59bf5789c31ce98a61f39d1e1c9aa88e663f2 Mon Sep 17 00:00:00 2001 From: Emmanuel AYME Date: Wed, 6 Aug 2025 09:46:07 +0200 Subject: [PATCH] Added Five Nights at Freddy's: Secret of the Mimic. Minor WuchangFF addon reviews. --- FNAF_SOTM/FNAF_SOTM.vcxproj | 156 ++++++++++++++++++++++ FNAF_SOTM/dllmain.cpp | 249 ++++++++++++++++++++++++++++++++++++ Reshade Plugins Addons.sln | 10 ++ WuchangFF/dllmain.cpp | 13 +- 4 files changed, 422 insertions(+), 6 deletions(-) create mode 100644 FNAF_SOTM/FNAF_SOTM.vcxproj create mode 100644 FNAF_SOTM/dllmain.cpp diff --git a/FNAF_SOTM/FNAF_SOTM.vcxproj b/FNAF_SOTM/FNAF_SOTM.vcxproj new file mode 100644 index 0000000..faebb98 --- /dev/null +++ b/FNAF_SOTM/FNAF_SOTM.vcxproj @@ -0,0 +1,156 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {6DF09C78-135D-4702-903A-B0FCB156A584} + Five Nights at Freddy's: Secret of the Mimic + 10.0 + FNAF_SOTM + + + + DynamicLibrary + true + v143 + Unicode + + + DynamicLibrary + false + v143 + true + Unicode + + + DynamicLibrary + true + v143 + Unicode + + + DynamicLibrary + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + .addon + + + .addon + + + .addon + + + .addon + + + + Level3 + true + WIN32;_DEBUG;TLOU2_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + $(SolutionDir)external\reshade\include;$(SolutionDir)external\reshade\deps\imgui + MultiThreadedDLL + + + Windows + true + false + + + + + Level3 + true + true + true + WIN32;NDEBUG;TLOU2_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + $(SolutionDir)external\reshade\include;$(SolutionDir)external\reshade\deps\imgui + MultiThreadedDLL + + + Windows + true + false + + + + + Level3 + true + _DEBUG;TLOU2_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + $(SolutionDir)external\reshade\include;$(SolutionDir)external\reshade\deps\imgui + MultiThreadedDLL + + + Windows + true + false + + + + + Level3 + true + true + true + NDEBUG;TLOU2_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + $(SolutionDir)external\reshade\include;$(SolutionDir)external\reshade\deps\imgui + MultiThreadedDLL + + + Windows + true + false + + + + + + + + + \ No newline at end of file diff --git a/FNAF_SOTM/dllmain.cpp b/FNAF_SOTM/dllmain.cpp new file mode 100644 index 0000000..e50a1df --- /dev/null +++ b/FNAF_SOTM/dllmain.cpp @@ -0,0 +1,249 @@ +#define IMGUI_DISABLE_INCLUDE_IMCONFIG_H +#define IMGUI_HAS_DOCK 1 + +#include +#include +#include +#include + +// Core game dll functions declarations +typedef void (*SetBoolFn)(bool, bool); +typedef void (*SetIntFn)(int); +typedef float (*GetFloatFn)(); + +static HMODULE fixLib = nullptr; +static SetBoolFn SetFixEnabled = nullptr; +static SetBoolFn SetFOVFixEnabled = nullptr; +static SetBoolFn SetHORPlusFixEnabled = nullptr; +static SetBoolFn SetDOFFixEnabled = nullptr; +static SetBoolFn SetFPSFixEnabled = nullptr; +static SetIntFn SetFOV = nullptr; +static GetFloatFn GetFOVIn = nullptr; +static GetFloatFn GetFOVOut = nullptr; + +// Plugin variables for checkboxes and sliders +static bool fov_fix_enabled = false; +static bool hor_plus_fix_enabled = false; +static bool DOF_fix_enabled = false; +static bool FPS_fix_enabled = false; +static bool fix_enabled = false; +static int worldFOVvalue = 0; +static bool popup_Informations = false; + +// Plugin settings +const char* SETTINGS_FILE = "PluginSettings.ini"; +const char* GENERAL_FIX_SETTING = "GeneralFIX="; +const char* WORLD_FOV_FIX_SETTING = "WorldFOVFIX="; +const char* HOR_PLUS_FIX_SETTING = "HORPLUSFIX="; +const char* DOF_FIX_SETTING = "DOFFIX="; +const char* FPS_FIX_SETTING = "DOFFIX="; +const char* WORLD_FOV_SETTING = "WorldFOV="; +const char* FIX_VERSION = "1.0.1"; +const char* FIX_INFORMATIONS = "This fix allows to:\n - Control in game FOV.\n - Force HOR+.\n - Disable depth of field.\n - Unlock FPS cap."; +const char* DONATION_URL = "https://buymeacoffee.com/k4sh44"; + +// Load and unload game core dll functions /!\ necessary +static void LoadFixDLL() +{ + if (fixLib) return; + fixLib = LoadLibraryA("FNAF_SOTMCore.dll"); + + if (!fixLib) { + MessageBoxA(nullptr, "Impossible to load game core dll", "Erreur", MB_OK); + return; + } + SetFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetFixEnabled"); + SetFOVFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetFOVFixEnabled"); + SetHORPlusFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetHORPlusFixEnabled"); + SetDOFFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetDOFFixEnabled"); + SetFPSFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetFPSFixEnabled"); + SetFOV = (SetIntFn)GetProcAddress(fixLib, "SetFOV"); + GetFOVIn = (GetFloatFn)GetProcAddress(fixLib, "GetFOVIn"); + GetFOVOut = (GetFloatFn)GetProcAddress(fixLib, "GetFOVOut");; + + // Apply initial values loaded from ini file + if (SetFOV) SetFOV(worldFOVvalue); + if (SetFOVFixEnabled) SetFOVFixEnabled(fov_fix_enabled, true); + if (SetHORPlusFixEnabled) SetHORPlusFixEnabled(hor_plus_fix_enabled, true); + if (SetDOFFixEnabled) SetDOFFixEnabled(DOF_fix_enabled, true); + if (SetFPSFixEnabled) SetFPSFixEnabled(FPS_fix_enabled, true); + if (SetFixEnabled) SetFixEnabled(fix_enabled, true); +} + +// Addon functions +static void SaveSettings() +{ + std::ofstream file(SETTINGS_FILE); + if (file.is_open()) + { + file << GENERAL_FIX_SETTING << (fix_enabled ? "1" : "0") << "\n"; + file << WORLD_FOV_FIX_SETTING << (fov_fix_enabled ? "1" : "0") << "\n"; + file << HOR_PLUS_FIX_SETTING << (hor_plus_fix_enabled ? "1" : "0") << "\n"; + file << DOF_FIX_SETTING << (DOF_fix_enabled ? "1" : "0") << "\n"; + file << FPS_FIX_SETTING << (FPS_fix_enabled ? "1" : "0") << "\n"; + file << WORLD_FOV_SETTING << worldFOVvalue << "\n"; + file.close(); + } +} + +static void LoadSettings() +{ + std::ifstream file(SETTINGS_FILE); + if (file.is_open()) + { + std::string line; + while (std::getline(file, line)) + { + if (line.find(GENERAL_FIX_SETTING) == 0) + { + std::string val = line.substr(strlen(GENERAL_FIX_SETTING)); + fix_enabled = (val == "1" || val == "true"); + } + else if (line.find(WORLD_FOV_FIX_SETTING) == 0) + { + std::string val = line.substr(strlen(WORLD_FOV_FIX_SETTING)); + fov_fix_enabled = (val == "1" || val == "true"); + } + else if (line.find(HOR_PLUS_FIX_SETTING) == 0) + { + std::string val = line.substr(strlen(HOR_PLUS_FIX_SETTING)); + hor_plus_fix_enabled = (val == "1" || val == "true"); + } + else if (line.find(DOF_FIX_SETTING) == 0) + { + std::string val = line.substr(strlen(DOF_FIX_SETTING)); + DOF_fix_enabled = (val == "1" || val == "true"); + } + else if (line.find(FPS_FIX_SETTING) == 0) + { + std::string val = line.substr(strlen(FPS_FIX_SETTING)); + FPS_fix_enabled = (val == "1" || val == "true"); + } + else if (line.find(WORLD_FOV_SETTING) == 0) + worldFOVvalue = std::stoi(line.substr(strlen(WORLD_FOV_SETTING))); + } + file.close(); + } +} + +static void displayFixInformations() { + // Fix version + ImGui::Begin("Informations", &popup_Informations); // + ImGui::SetCursorPos(ImVec2(10, 36)); + ImGui::Text("Version : %s", FIX_VERSION); + ImGui::SetCursorPos(ImVec2(10, 76)); + ImGui::Text(FIX_INFORMATIONS); + ImGui::End(); +} + +// Initialize ImGui widgets for Reshade +static void on_overlay_draw(reshade::api::effect_runtime* runtime) +{ + ImGui::SetNextWindowPos(ImVec2(100, 200), ImGuiCond_Once); + ImGui::SetNextWindowSize(ImVec2(350, 150), ImGuiCond_Once); + + // Donation ? + ImGui::SetCursorPos(ImVec2(10, 36)); + ImGui::Text("Like my work ?"); + ImGui::SetCursorPos(ImVec2(130, 33)); + if (ImGui::Button("consider donation")) + { + ShellExecuteA(NULL, "open", DONATION_URL, NULL, NULL, SW_SHOWNORMAL); + } + + // Fix informations + ImGui::SetCursorPos(ImVec2(270, 33)); + if (ImGui::Button("Fix informations")) + popup_Informations = true; + + if (popup_Informations) + displayFixInformations(); + + // Generic fix + ImGui::SetCursorPos(ImVec2(10, 60)); + ImGui::BeginChild("AllFixesHeader", ImVec2(220, 0), false); // true = border + if (ImGui::CollapsingHeader("Enable fixes", ImGuiTreeNodeFlags_DefaultOpen)) { + ImGui::SetCursorPos(ImVec2(5, 30)); + if (ImGui::Checkbox("Fix enabled", &fix_enabled)) { + if (SetFixEnabled) SetFixEnabled(fix_enabled, false); + SaveSettings(); + } + } + ImGui::EndChild(); + + // FOV adjustment + ImGui::SetCursorPos(ImVec2(10, 120)); + ImGui::BeginChild("FOVHeader", ImVec2(220, 0), false); + if (ImGui::CollapsingHeader("In game additional FOV", ImGuiTreeNodeFlags_DefaultOpen)) { + ImGui::SetCursorPos(ImVec2(5, 30)); + ImGui::SetNextItemWidth(150.0f); + if (ImGui::SliderInt("", &worldFOVvalue, -20, 50)) {} + if (ImGui::IsItemDeactivatedAfterEdit()) { + if (SetFOV) SetFOV(worldFOVvalue); + SaveSettings(); + } + } + ImGui::EndChild(); + + // Individual fixes + ImGui::SetCursorPos(ImVec2(240, 60)); + ImGui::BeginChild("IndividualFixesHeader", ImVec2(250, 0), false); + if (ImGui::CollapsingHeader("Individual fixes", ImGuiTreeNodeFlags_DefaultOpen)) { + ImGui::SetCursorPos(ImVec2(5, 30)); + if (ImGui::Checkbox("Enable FOV Fix", &fov_fix_enabled)) { + if (SetFOVFixEnabled) SetFOVFixEnabled(fov_fix_enabled, false); + SaveSettings(); + } + + ImGui::SetCursorPos(ImVec2(5, 55)); + if (ImGui::Checkbox("Enable HOR+", &hor_plus_fix_enabled)) { + if (SetHORPlusFixEnabled) SetHORPlusFixEnabled(hor_plus_fix_enabled, false); + SaveSettings(); + } + + ImGui::SetCursorPos(ImVec2(5, 80)); + if (ImGui::Checkbox("Depth of field Fix", &DOF_fix_enabled)) { + if (SetDOFFixEnabled) SetDOFFixEnabled(DOF_fix_enabled, false); + SaveSettings(); + } + + ImGui::SetCursorPos(ImVec2(5, 105)); + if (ImGui::Checkbox("FPS cap Fix", &FPS_fix_enabled)) { + if (SetFPSFixEnabled) SetFPSFixEnabled(FPS_fix_enabled, false); + SaveSettings(); + } + } + ImGui::EndChild(); + + // Fix status + ImGui::SetCursorPos(ImVec2(10, 200)); + ImGui::BeginChild("INFOSHeader", ImVec2(480, 80), true); + if (ImGui::CollapsingHeader("Fix informations", ImGuiTreeNodeFlags_DefaultOpen)) { + ImGui::SetCursorPos(ImVec2(5, 30)); + ImGui::Text("FOV In: %.2f, Out : %.2f", GetFOVIn(), GetFOVOut()); + } + ImGui::EndChild(); +} + +// Main dll intrance +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD ul_reason_for_call, LPVOID) +{ + switch (ul_reason_for_call) + { + case DLL_PROCESS_ATTACH: + if (!reshade::register_addon(hinstDLL)) + return FALSE; + + LoadSettings(); + reshade::register_overlay("Spirit Of The North", &on_overlay_draw); + reshade::register_event( + [](reshade::api::effect_runtime* runtime) { + LoadFixDLL(); + }); + break; + case DLL_PROCESS_DETACH: + reshade::unregister_addon(hinstDLL); + break; + } + return TRUE; +} \ No newline at end of file diff --git a/Reshade Plugins Addons.sln b/Reshade Plugins Addons.sln index ab28e17..ba4d280 100644 --- a/Reshade Plugins Addons.sln +++ b/Reshade Plugins Addons.sln @@ -33,6 +33,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Starfield", "Starfield\Star EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Wuchang Fallen Feathers", "WuchangFF\Wuchang.vcxproj", "{6BFB12DD-7B5D-4BD7-B763-3374B9F85D10}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FNAF_SOTM", "FNAF_SOTM\FNAF_SOTM.vcxproj", "{6DF09C78-135D-4702-903A-B0FCB156A584}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -153,6 +155,14 @@ Global {6BFB12DD-7B5D-4BD7-B763-3374B9F85D10}.Release|x64.Build.0 = Release|x64 {6BFB12DD-7B5D-4BD7-B763-3374B9F85D10}.Release|x86.ActiveCfg = Release|Win32 {6BFB12DD-7B5D-4BD7-B763-3374B9F85D10}.Release|x86.Build.0 = Release|Win32 + {6DF09C78-135D-4702-903A-B0FCB156A584}.Debug|x64.ActiveCfg = Debug|x64 + {6DF09C78-135D-4702-903A-B0FCB156A584}.Debug|x64.Build.0 = Debug|x64 + {6DF09C78-135D-4702-903A-B0FCB156A584}.Debug|x86.ActiveCfg = Debug|Win32 + {6DF09C78-135D-4702-903A-B0FCB156A584}.Debug|x86.Build.0 = Debug|Win32 + {6DF09C78-135D-4702-903A-B0FCB156A584}.Release|x64.ActiveCfg = Release|x64 + {6DF09C78-135D-4702-903A-B0FCB156A584}.Release|x64.Build.0 = Release|x64 + {6DF09C78-135D-4702-903A-B0FCB156A584}.Release|x86.ActiveCfg = Release|Win32 + {6DF09C78-135D-4702-903A-B0FCB156A584}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/WuchangFF/dllmain.cpp b/WuchangFF/dllmain.cpp index 55ee522..12ab74c 100644 --- a/WuchangFF/dllmain.cpp +++ b/WuchangFF/dllmain.cpp @@ -48,6 +48,7 @@ const char* DONATION_URL = "https://buymeacoffee.com/k4sh44"; // Load and unload game core dll functions /!\ necessary static void LoadFixDLL() { + MessageBoxA(nullptr, "LoadFixDll", "Logger Error", MB_ICONERROR | MB_OK); std::thread([]() { std::this_thread::sleep_for(std::chrono::milliseconds(8000)); // Game process is not ready at launch and memory is not yet initialized if (GetModuleHandleA("WuchangFFCore.dll") == nullptr) { @@ -233,14 +234,14 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD ul_reason_for_call, LPVOID) LoadSettings(); reshade::register_overlay("Wuchang Fallen Feathers", &on_overlay_draw); - //reshade::register_event( - // [](reshade::api::effect_runtime* runtime) { - // LoadFixDLL(); - // }); - reshade::register_event( - [](reshade::api::command_queue *queue) { + reshade::register_event( + [](reshade::api::effect_runtime* runtime) { LoadFixDLL(); }); + //reshade::register_event( + // [](reshade::api::command_queue *queue) { + // LoadFixDLL(); + // }); break; case DLL_PROCESS_DETACH: reshade::unregister_addon(hinstDLL);