-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dummy patch dll to start things rolling.
- Loading branch information
Showing
6 changed files
with
94 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,3 +26,7 @@ out/ | |
*.lai | ||
*.la | ||
*.a | ||
*.lib | ||
|
||
# Library generated exports | ||
*.exp |
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 @@ | ||
add_subdirectory(Client_I0) |
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,19 @@ | ||
LINK_DIRECTORIES(../patch_tools) | ||
set (CMAKE_CXX_STANDARD 17) | ||
if (MSVC_VERSION GREATER_EQUAL "1900") | ||
include(CheckCXXCompilerFlag) | ||
CHECK_CXX_COMPILER_FLAG("/std:c++latest" _cpp_latest_flag_supported) | ||
if (_cpp_latest_flag_supported) | ||
add_compile_options("/std:c++latest") | ||
endif() | ||
endif() | ||
set(SOURCES | ||
utils/dll_patcher.cpp | ||
patch_all_the_things.cpp | ||
dll_core.cpp | ||
) | ||
add_library(cohdll SHARED ${SOURCES}) | ||
# we link to the imp lib for the exe | ||
target_link_libraries(cohdll CityOfPatches) | ||
# enforce the dll prefix. | ||
SET_TARGET_PROPERTIES(cohdll PROPERTIES PREFIX "lib") |
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,35 @@ | ||
#include "patch_all_the_things.h" | ||
|
||
#include <stdio.h> | ||
#include <windows.h> | ||
|
||
HMODULE coh_instance; | ||
extern "C" { | ||
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { | ||
|
||
switch (fdwReason) | ||
{ | ||
case DLL_PROCESS_ATTACH: | ||
printf ("CoH Patch dll loaded\n"); | ||
coh_instance = GetModuleHandle(nullptr); | ||
patch_all_the_things(); | ||
break; | ||
|
||
case DLL_PROCESS_DETACH: | ||
printf ("Unload working...\n"); | ||
break; | ||
|
||
case DLL_THREAD_ATTACH: | ||
printf ("Thread attach ???\n"); | ||
break; | ||
|
||
case DLL_THREAD_DETACH: | ||
printf ("Thread detach ??\n"); | ||
break; | ||
} | ||
return TRUE; | ||
} | ||
__declspec(dllexport) int test() { | ||
return 0; | ||
} | ||
} |
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,7 @@ | ||
#include "patch_all_the_things.h" | ||
#include "utils/dll_patcher.h" | ||
// extern patch_named_module() | ||
void patch_all_the_things() | ||
{ | ||
//patch_named_module() | ||
} |
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,28 @@ | ||
#include "dll_patcher.h" | ||
|
||
#include <stdio.h> | ||
#include <stdint.h> | ||
#include <windows.h> | ||
#include <cassert> | ||
void break_me() | ||
{ | ||
assert(false); | ||
} | ||
|
||
extern HMODULE coh_instance; | ||
void patchit(const char *tgt,void *proc) | ||
{ | ||
uint8_t *addr = (uint8_t *)GetProcAddress(coh_instance,tgt); | ||
DWORD offset = ((DWORD)proc - (DWORD)addr - 5); | ||
if(addr) | ||
{ | ||
*addr = 0xE9; // write JMP | ||
*(DWORD *)(addr+1) = (DWORD)offset; // write target offset | ||
printf("Patched %s\n",tgt); | ||
} | ||
else | ||
{ | ||
printf("Couldn't patch %s\n",tgt); | ||
abort(); | ||
} | ||
} |