-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
321f735
commit 90bda7e
Showing
4 changed files
with
278 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup Label="ProjectConfigurations"> | ||
<ProjectConfiguration Include="Debug|x64"> | ||
<Configuration>Debug</Configuration> | ||
<Platform>x64</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Release|x64"> | ||
<Configuration>Release</Configuration> | ||
<Platform>x64</Platform> | ||
</ProjectConfiguration> | ||
</ItemGroup> | ||
<PropertyGroup Label="Globals"> | ||
<VCProjectVersion>16.0</VCProjectVersion> | ||
<Keyword>Win32Proj</Keyword> | ||
<ProjectGuid>{0E5D915F-4905-4496-8024-648E215FC947}</ProjectGuid> | ||
<RootNamespace>KittyHawkPatches</RootNamespace> | ||
<WindowsTargetPlatformVersion>10.0.22621.0</WindowsTargetPlatformVersion> | ||
<ProjectName>KittyHawk.Patches</ProjectName> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> | ||
<ConfigurationType>DynamicLibrary</ConfigurationType> | ||
<UseDebugLibraries>true</UseDebugLibraries> | ||
<PlatformToolset>ClangCL</PlatformToolset> | ||
<CharacterSet>Unicode</CharacterSet> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> | ||
<ConfigurationType>DynamicLibrary</ConfigurationType> | ||
<UseDebugLibraries>false</UseDebugLibraries> | ||
<PlatformToolset>ClangCL</PlatformToolset> | ||
<WholeProgramOptimization>true</WholeProgramOptimization> | ||
<CharacterSet>Unicode</CharacterSet> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | ||
<ImportGroup Label="ExtensionSettings"> | ||
</ImportGroup> | ||
<ImportGroup Label="Shared"> | ||
</ImportGroup> | ||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<PropertyGroup Label="UserMacros" /> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
<IncludePath>\..\include\;$(IncludePath)</IncludePath> | ||
<TargetExt>.asi</TargetExt> | ||
<OutDir>$(SolutionDir)$(Configuration)\$(Platform)\$(ProjectName)\</OutDir> | ||
<IntDir>$(Configuration)\</IntDir> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
<IncludePath>\..\include\;$(IncludePath)</IncludePath> | ||
<TargetExt>.asi</TargetExt> | ||
<OutDir>$(SolutionDir)$(Configuration)\$(Platform)\$(ProjectName)\</OutDir> | ||
<IntDir>$(Configuration)\</IntDir> | ||
</PropertyGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
<ClCompile> | ||
<WarningLevel>Level3</WarningLevel> | ||
<SDLCheck>true</SDLCheck> | ||
<PreprocessorDefinitions>UNICODE;_UNICODE;_USRDLL</PreprocessorDefinitions> | ||
<ConformanceMode>true</ConformanceMode> | ||
<PrecompiledHeader>NotUsing</PrecompiledHeader> | ||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile> | ||
<AdditionalIncludeDirectories>..\..\include\;..\..\external\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||
<LanguageStandard_C>Default</LanguageStandard_C> | ||
<UndefinePreprocessorDefinitions> | ||
</UndefinePreprocessorDefinitions> | ||
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Windows</SubSystem> | ||
<GenerateDebugInformation>true</GenerateDebugInformation> | ||
<EnableUAC>false</EnableUAC> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
<ClCompile> | ||
<WarningLevel>Level3</WarningLevel> | ||
<FunctionLevelLinking>true</FunctionLevelLinking> | ||
<IntrinsicFunctions>false</IntrinsicFunctions> | ||
<SDLCheck>true</SDLCheck> | ||
<PreprocessorDefinitions>UNICODE;_UNICODE;_USRDLL</PreprocessorDefinitions> | ||
<ConformanceMode>true</ConformanceMode> | ||
<PrecompiledHeader>NotUsing</PrecompiledHeader> | ||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile> | ||
<AdditionalIncludeDirectories>..\..\include\;..\..\external\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||
<LanguageStandard_C>Default</LanguageStandard_C> | ||
<UndefinePreprocessorDefinitions> | ||
</UndefinePreprocessorDefinitions> | ||
<Optimization>Disabled</Optimization> | ||
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Windows</SubSystem> | ||
<EnableCOMDATFolding>true</EnableCOMDATFolding> | ||
<OptimizeReferences>true</OptimizeReferences> | ||
<GenerateDebugInformation>true</GenerateDebugInformation> | ||
<EnableUAC>false</EnableUAC> | ||
</Link> | ||
<PreBuildEvent> | ||
<Command>call $(MSBuildStartupDirectory)\set_git_ver.cmd</Command> | ||
</PreBuildEvent> | ||
</ItemDefinitionGroup> | ||
<ItemGroup> | ||
<ClCompile Include="..\Shared\helper.cpp" /> | ||
<ClCompile Include="..\Shared\memory.cpp" /> | ||
<ClCompile Include="..\Shared\stdafx.cpp" /> | ||
<ClCompile Include="dllmain.cpp" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClInclude Include="..\..\include\helper.hpp" /> | ||
<ClInclude Include="..\..\include\memory.hpp" /> | ||
<ClInclude Include="..\..\include\stdafx.h" /> | ||
</ItemGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | ||
<ImportGroup Label="ExtensionTargets"> | ||
</ImportGroup> | ||
</Project> |
38 changes: 38 additions & 0 deletions
38
source/KittyHawk.Patches/KittyHawk.Patches.vcxproj.filters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup> | ||
<Filter Include="Source Files"> | ||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> | ||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions> | ||
</Filter> | ||
<Filter Include="Header Files"> | ||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> | ||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions> | ||
</Filter> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClCompile Include="dllmain.cpp"> | ||
<Filter>Source Files</Filter> | ||
</ClCompile> | ||
<ClCompile Include="..\Shared\stdafx.cpp"> | ||
<Filter>Source Files</Filter> | ||
</ClCompile> | ||
<ClCompile Include="..\Shared\helper.cpp"> | ||
<Filter>Source Files</Filter> | ||
</ClCompile> | ||
<ClCompile Include="..\Shared\memory.cpp"> | ||
<Filter>Source Files</Filter> | ||
</ClCompile> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClInclude Include="..\..\include\helper.hpp"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="..\..\include\stdafx.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="..\..\include\memory.hpp"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<wchar_t> 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; | ||
} |