From 90bda7ec53ac515ea52ba2fe46464c3b0bd74554 Mon Sep 17 00:00:00 2001 From: illusion0001 <37698908+illusion0001@users.noreply.github.com> Date: Mon, 1 Jul 2024 12:57:35 -0500 Subject: [PATCH] Flight simulator patches --- Windows-Game-Patches-x64.sln | 14 ++ .../KittyHawk.Patches.vcxproj | 121 ++++++++++++++++++ .../KittyHawk.Patches.vcxproj.filters | 38 ++++++ source/KittyHawk.Patches/dllmain.cpp | 105 +++++++++++++++ 4 files changed, 278 insertions(+) create mode 100644 source/KittyHawk.Patches/KittyHawk.Patches.vcxproj create mode 100644 source/KittyHawk.Patches/KittyHawk.Patches.vcxproj.filters create mode 100644 source/KittyHawk.Patches/dllmain.cpp diff --git a/Windows-Game-Patches-x64.sln b/Windows-Game-Patches-x64.sln index 3e069f8..dc85056 100644 --- a/Windows-Game-Patches-x64.sln +++ b/Windows-Game-Patches-x64.sln @@ -45,6 +45,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SpiderMan.MilesMorales.Patc EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RDR3.Patches", "source\RDR3.Patches\RDR3.Patches.vcxproj", "{B16DFB29-6876-41F5-961F-E67E1C2E9764}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "KittyHawk.Patches", "source\KittyHawk.Patches\KittyHawk.Patches.vcxproj", "{0E5D915F-4905-4496-8024-648E215FC947}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -307,6 +309,18 @@ Global {B16DFB29-6876-41F5-961F-E67E1C2E9764}.Release|x64.Build.0 = Release|x64 {B16DFB29-6876-41F5-961F-E67E1C2E9764}.Release|x86.ActiveCfg = Release|x64 {B16DFB29-6876-41F5-961F-E67E1C2E9764}.Release|x86.Build.0 = Release|x64 + {0E5D915F-4905-4496-8024-648E215FC947}.Debug|Win32.ActiveCfg = Debug|x64 + {0E5D915F-4905-4496-8024-648E215FC947}.Debug|Win32.Build.0 = Debug|x64 + {0E5D915F-4905-4496-8024-648E215FC947}.Debug|x64.ActiveCfg = Debug|x64 + {0E5D915F-4905-4496-8024-648E215FC947}.Debug|x64.Build.0 = Debug|x64 + {0E5D915F-4905-4496-8024-648E215FC947}.Debug|x86.ActiveCfg = Debug|x64 + {0E5D915F-4905-4496-8024-648E215FC947}.Debug|x86.Build.0 = Debug|x64 + {0E5D915F-4905-4496-8024-648E215FC947}.Release|Win32.ActiveCfg = Release|x64 + {0E5D915F-4905-4496-8024-648E215FC947}.Release|Win32.Build.0 = Release|x64 + {0E5D915F-4905-4496-8024-648E215FC947}.Release|x64.ActiveCfg = Release|x64 + {0E5D915F-4905-4496-8024-648E215FC947}.Release|x64.Build.0 = Release|x64 + {0E5D915F-4905-4496-8024-648E215FC947}.Release|x86.ActiveCfg = Release|x64 + {0E5D915F-4905-4496-8024-648E215FC947}.Release|x86.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/source/KittyHawk.Patches/KittyHawk.Patches.vcxproj b/source/KittyHawk.Patches/KittyHawk.Patches.vcxproj new file mode 100644 index 0000000..f443792 --- /dev/null +++ b/source/KittyHawk.Patches/KittyHawk.Patches.vcxproj @@ -0,0 +1,121 @@ + + + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {0E5D915F-4905-4496-8024-648E215FC947} + KittyHawkPatches + 10.0.22621.0 + KittyHawk.Patches + + + + DynamicLibrary + true + ClangCL + Unicode + + + DynamicLibrary + false + ClangCL + true + Unicode + + + + + + + + + + + + + + + \..\include\;$(IncludePath) + .asi + $(SolutionDir)$(Configuration)\$(Platform)\$(ProjectName)\ + $(Configuration)\ + + + \..\include\;$(IncludePath) + .asi + $(SolutionDir)$(Configuration)\$(Platform)\$(ProjectName)\ + $(Configuration)\ + + + + Level3 + true + UNICODE;_UNICODE;_USRDLL + true + NotUsing + pch.h + ..\..\include\;..\..\external\;%(AdditionalIncludeDirectories) + Default + + + NotSet + + + Windows + true + false + + + + + Level3 + true + false + true + UNICODE;_UNICODE;_USRDLL + true + NotUsing + pch.h + ..\..\include\;..\..\external\;%(AdditionalIncludeDirectories) + Default + + + Disabled + NotSet + + + Windows + true + true + true + false + + + call $(MSBuildStartupDirectory)\set_git_ver.cmd + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/source/KittyHawk.Patches/KittyHawk.Patches.vcxproj.filters b/source/KittyHawk.Patches/KittyHawk.Patches.vcxproj.filters new file mode 100644 index 0000000..780a707 --- /dev/null +++ b/source/KittyHawk.Patches/KittyHawk.Patches.vcxproj.filters @@ -0,0 +1,38 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + \ No newline at end of file diff --git a/source/KittyHawk.Patches/dllmain.cpp b/source/KittyHawk.Patches/dllmain.cpp new file mode 100644 index 0000000..fa10ac7 --- /dev/null +++ b/source/KittyHawk.Patches/dllmain.cpp @@ -0,0 +1,105 @@ +#include "stdafx.h" +#include "helper.hpp" +#include "memory.hpp" +#include "git_ver.h" + +HMODULE baseModule{}; + +#define wstr(s) L#s +#define wxstr(s) wstr(s) +#define PROJECT_NAME "KittyHawk.Patches" + +// INI Variables +uint32_t injection_delay{}; + +void ReadConfig(void) +{ + inipp::Ini ini; + // Initialize config + std::wstring config_path = L"" PROJECT_NAME ".ini"; + std::wifstream iniFile(config_path); + if (!iniFile) + { + // no ini, lets generate one. + std::wstring ini_defaults = L"[Settings]\n" + wstr(injection_delay)" = 200\n"; + std::wofstream iniFile(config_path); + iniFile << ini_defaults; + injection_delay = 200; + } + else + { + ini.parse(iniFile); + inipp::get_value(ini.sections[L"Settings"], wstr(injection_delay), injection_delay); + } +} + +bool CreateConsoleHook2(HWND ConsoleWindow) +{ + ShowWindow(ConsoleWindow, 1); + return 1; +} + +void __attribute__((naked)) CreateConsoleHookAsm() +{ + __asm + { + MOV RCX, qword ptr[RBX + 0xa5d0]; + CALL CreateConsoleHook2; + MOV byte ptr[RBX + 0xa4e4], 0x4; + MOV byte ptr[RBX + 0xa6d8], 0x0; + ADD RSP, 0x30; + POP RBX; + RET; + } +} + +#define TYPEDEF_FUNCTION_PTR(ret_type, func_name, ...) \ + typedef ret_type (*func_name##_ptr)(__VA_ARGS__); \ + extern func_name##_ptr func_name; + +#define INIT_FUNCTION_PTR(func_name) \ + func_name##_ptr func_name = nullptr + +void RegisterCustomCmd() +{ +} + +void DoPatches() +{ + WritePatchPattern_Hook(L"c6 83 d8 a6 00 00 00", 14, L"CreateConsoleHook", 0, (void*)&CreateConsoleHookAsm, nullptr); +} + +DWORD __stdcall Main(void*) +{ + baseModule = GetModuleHandle(NULL); + ReadConfig(); + // this isn't particularly reliable + // due to arxan unpacking + // only matters for patch that does its thing during startup + if (injection_delay) + { + Sleep(injection_delay); + } + DoPatches(); + return true; +} + +BOOL APIENTRY DllMain(HMODULE hModule, + DWORD ul_reason_for_call, + LPVOID lpReserved +) +{ + switch (ul_reason_for_call) + { + case DLL_PROCESS_ATTACH: + { + CreateThread(NULL, 0, Main, 0, NULL, 0); + } + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + case DLL_PROCESS_DETACH: + break; + } + return TRUE; +}