diff --git a/.gitmodules b/.gitmodules index abcf5d8..a5666ac 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,12 +1,6 @@ [submodule "libs/libvalinet"] path = libs/libvalinet url = https://github.com/valinet/libvalinet -[submodule "libs/funchook"] - path = libs/funchook - url = https://github.com/kubo/funchook -[submodule "libs/Detours"] - path = libs/Detours - url = https://github.com/microsoft/Detours [submodule "libs/sws"] path = libs/sws url = https://github.com/valinet/sws diff --git a/BuildDependenciesDebug.bat b/BuildDependenciesDebug.bat index 6b5bfe6..2d0ba9d 100644 --- a/BuildDependenciesDebug.bat +++ b/BuildDependenciesDebug.bat @@ -1,6 +1,3 @@ -rmdir /s /q libs\funchook\build -rmdir /s /q libs\funchook\build-x64 -rmdir /s /q libs\funchook\build-arm64 rmdir /s /q libs\zlib\build-x64 rmdir /s /q libs\zlib\build-arm64 @@ -10,12 +7,8 @@ if "%VSINSTALLDIR:~-1%"=="\" ( set "EP_VSINSTALLDIR=%VSINSTALLDIR%" ) -cmake libs/funchook -Blibs/funchook/build-x64 -G "Visual Studio 17 2022" -A x64 -D"CMAKE_GENERATOR_INSTANCE:PATH=%EP_VSINSTALLDIR%" -D"CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$:Debug>" -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DFUNCHOOK_CPU=x86 -DFUNCHOOK_BUILD_TESTS=OFF -cmake libs/funchook -Blibs/funchook/build-arm64 -G "Visual Studio 17 2022" -A ARM64 -D"CMAKE_GENERATOR_INSTANCE:PATH=%EP_VSINSTALLDIR%" -D"CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$:Debug>" -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DFUNCHOOK_CPU=arm64 -DFUNCHOOK_DISASM=capstone -DFUNCHOOK_BUILD_TESTS=OFF cmake libs/zlib -Blibs/zlib/build-x64 -G "Visual Studio 17 2022" -A x64 -D"CMAKE_GENERATOR_INSTANCE:PATH=%EP_VSINSTALLDIR%" -D"CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$:Debug>" -DCMAKE_POLICY_DEFAULT_CMP0091=NEW cmake libs/zlib -Blibs/zlib/build-arm64 -G "Visual Studio 17 2022" -A ARM64 -D"CMAKE_GENERATOR_INSTANCE:PATH=%EP_VSINSTALLDIR%" -D"CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$:Debug>" -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -cmake --build libs/funchook/build-x64 --config Debug -cmake --build libs/funchook/build-arm64 --config Debug cmake --build libs/zlib/build-x64 --config Debug cmake --build libs/zlib/build-arm64 --config Debug diff --git a/BuildDependenciesRelease.bat b/BuildDependenciesRelease.bat index bf8b0d2..e0739c4 100644 --- a/BuildDependenciesRelease.bat +++ b/BuildDependenciesRelease.bat @@ -1,6 +1,3 @@ -rmdir /s /q libs\funchook\build -rmdir /s /q libs\funchook\build-x64 -rmdir /s /q libs\funchook\build-arm64 rmdir /s /q libs\zlib\build-x64 rmdir /s /q libs\zlib\build-arm64 @@ -10,12 +7,8 @@ if "%VSINSTALLDIR:~-1%"=="\" ( set "EP_VSINSTALLDIR=%VSINSTALLDIR%" ) -cmake libs/funchook -Blibs/funchook/build-x64 -G "Visual Studio 17 2022" -A x64 -D"CMAKE_GENERATOR_INSTANCE:PATH=%EP_VSINSTALLDIR%" -D"CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$:Debug>" -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DFUNCHOOK_CPU=x86 -DFUNCHOOK_BUILD_TESTS=OFF -cmake libs/funchook -Blibs/funchook/build-arm64 -G "Visual Studio 17 2022" -A ARM64 -D"CMAKE_GENERATOR_INSTANCE:PATH=%EP_VSINSTALLDIR%" -D"CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$:Debug>" -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DFUNCHOOK_CPU=arm64 -DFUNCHOOK_DISASM=capstone -DFUNCHOOK_BUILD_TESTS=OFF cmake libs/zlib -Blibs/zlib/build-x64 -G "Visual Studio 17 2022" -A x64 -D"CMAKE_GENERATOR_INSTANCE:PATH=%EP_VSINSTALLDIR%" -D"CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$:Debug>" -DCMAKE_POLICY_DEFAULT_CMP0091=NEW cmake libs/zlib -Blibs/zlib/build-arm64 -G "Visual Studio 17 2022" -A ARM64 -D"CMAKE_GENERATOR_INSTANCE:PATH=%EP_VSINSTALLDIR%" -D"CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$:Debug>" -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -cmake --build libs/funchook/build-x64 --config Release -cmake --build libs/funchook/build-arm64 --config Release cmake --build libs/zlib/build-x64 --config Release cmake --build libs/zlib/build-arm64 --config Release diff --git a/ExplorerPatcher/ExplorerPatcher.vcxproj b/ExplorerPatcher/ExplorerPatcher.vcxproj index 10eb1e3..2209a22 100644 --- a/ExplorerPatcher/ExplorerPatcher.vcxproj +++ b/ExplorerPatcher/ExplorerPatcher.vcxproj @@ -132,9 +132,11 @@ true %(PreprocessorDefinitions) true - inc;$(SolutionDir)libs\funchook\include;$(SolutionDir)libs\libvalinet;%(AdditionalIncludeDirectories) + inc;$(SolutionDir)libs\libvalinet;%(AdditionalIncludeDirectories) stdcpp20 false + false + true Console @@ -171,18 +173,12 @@ WITH_MAIN_PATCHER;%(PreprocessorDefinitions) Cdecl - - $(SolutionDir)libs\funchook\build-$(Platform)\$(Configuration)\;%(AdditionalLibraryDirectories) - WITH_MAIN_PATCHER;%(PreprocessorDefinitions) Cdecl - - $(SolutionDir)libs\funchook\build-$(Platform)\$(Configuration)\;$(SolutionDir)libs\funchook\build-arm64\_deps\capstone-build\Release\;%(AdditionalLibraryDirectories) - @@ -316,12 +312,14 @@ - + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + + \ No newline at end of file diff --git a/ExplorerPatcher/ExplorerPatcher.vcxproj.filters b/ExplorerPatcher/ExplorerPatcher.vcxproj.filters index c4be604..4da58ee 100644 --- a/ExplorerPatcher/ExplorerPatcher.vcxproj.filters +++ b/ExplorerPatcher/ExplorerPatcher.vcxproj.filters @@ -129,6 +129,33 @@ Header Files\internal + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + @@ -142,9 +169,6 @@ Source Files - - Source Files - Source Files @@ -163,9 +187,6 @@ Source Files - - Source Files - Source Files\internal @@ -196,9 +217,6 @@ Source Files\sws - - Source Files - Source Files @@ -211,8 +229,32 @@ Source Files + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + \ No newline at end of file diff --git a/ExplorerPatcher/hooking.h b/ExplorerPatcher/hooking.h index 15d391f..41b7720 100644 --- a/ExplorerPatcher/hooking.h +++ b/ExplorerPatcher/hooking.h @@ -1,80 +1,45 @@ #ifndef _H_HOOKING_H_ #define _H_HOOKING_H_ -#define STRAT_REPLACE_ANY_TYPE_OF_JUMP_WITH_NOP 0 -#define STRAT_REPLACE_ANY_TYPE_OF_JUMP_WITH_ALWAYS_JUMP 1 -#define HOOK_WITH_FUNCHOOK 0 -#define HOOK_WITH_DETOURS 1 -#define HOW_TO_HOOK HOOK_WITH_FUNCHOOK - -#if HOW_TO_HOOK == HOOK_WITH_FUNCHOOK - -#include -#pragma comment(lib, "funchook.lib") -#pragma comment(lib, "Psapi.lib") // required by funchook -#if defined(_M_IX86) || defined(_M_X64) -#pragma comment(lib, "distorm.lib") -#else -#pragma comment(lib, "capstone.lib") -#endif - -#elif HOW_TO_HOOK == HOOK_WITH_DETOURS - #ifdef __cplusplus extern "C" { #endif -#include -#pragma comment(lib, "detours.lib") +#include -#ifdef __cplusplus -inline -#endif -void* funchook_create(void) +typedef struct funchook funchook_t; + +inline funchook_t* funchook_create(void) { - return 1; + return (funchook_t*)1; } -#ifdef __cplusplus -inline -#endif -int funchook_uninstall( - void* _this, +inline int funchook_uninstall( + funchook_t* _this, int flags ) { return 0; } -#ifdef __cplusplus -inline -#endif -int funchook_destroy(void* _this) +inline int funchook_destroy(funchook_t* _this) { return 0; } -#ifdef __cplusplus -inline -#endif -int funchook_prepare( - void* funchook, +inline int funchook_prepare( + funchook_t* funchook, void** target_func, void* hook_func ) { - DetourTransactionBegin(); - DetourUpdateThread(GetCurrentThread()); - DetourAttach(target_func, hook_func); - return DetourTransactionCommit(); + HRESULT hr = SlimDetoursInlineHook(TRUE, target_func, hook_func); + return SUCCEEDED(hr) ? 0 : hr; } -#ifdef __cplusplus -inline -#endif -int funchook_install( - void* funchook, +inline int funchook_install( + funchook_t* funchook, int flags ) { @@ -94,20 +59,8 @@ extern "C" { #endif -#if HOW_TO_HOOK == HOOK_WITH_FUNCHOOK -#ifdef __cplusplus -inline -#endif -funchook_t* funchook; -#elif HOW_TO_HOOK == HOOK_WITH_DETOURS -#ifdef __cplusplus -inline -#endif -void* funchook; -#endif +DECLSPEC_SELECTANY funchook_t* funchook = NULL; #ifdef __cplusplus } // extern "C" #endif - -#endif \ No newline at end of file diff --git a/ExplorerPatcher/packages.config b/ExplorerPatcher/packages.config index 14c6321..91ac6c0 100644 --- a/ExplorerPatcher/packages.config +++ b/ExplorerPatcher/packages.config @@ -1,4 +1,5 @@  - + + \ No newline at end of file diff --git a/ep_gui/ep_gui.vcxproj b/ep_gui/ep_gui.vcxproj index 0a1acd4..e02990f 100644 --- a/ep_gui/ep_gui.vcxproj +++ b/ep_gui/ep_gui.vcxproj @@ -92,7 +92,7 @@ true true stdcpp20 - $(SolutionDir)libs\libvalinet;$(SolutionDir)libs\funchook\include;$(SolutionDir)\ep_weather_host;$(SolutionDir)\ep_weather_host\$(Platform)\$(Configuration);%(AdditionalIncludeDirectories) + $(SolutionDir)libs\libvalinet;$(SolutionDir)\ep_weather_host;$(SolutionDir)\ep_weather_host\$(Platform)\$(Configuration);%(AdditionalIncludeDirectories) pch.h @@ -118,16 +118,6 @@ true - - - $(SolutionDir)libs\funchook\build-x64\$(Configuration)\;%(AdditionalLibraryDirectories) - - - - - $(SolutionDir)libs\funchook\build-arm64\$(Configuration)\;$(SolutionDir)libs\funchook\build-arm64\_deps\capstone-build\Release\;%(AdditionalLibraryDirectories) - - diff --git a/ep_weather_host/ep_weather_host.vcxproj b/ep_weather_host/ep_weather_host.vcxproj index 12a5932..06f4c1b 100644 --- a/ep_weather_host/ep_weather_host.vcxproj +++ b/ep_weather_host/ep_weather_host.vcxproj @@ -319,12 +319,12 @@ - + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + \ No newline at end of file diff --git a/ep_weather_host/packages.config b/ep_weather_host/packages.config index 3722370..bc97770 100644 --- a/ep_weather_host/packages.config +++ b/ep_weather_host/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/libs/Detours b/libs/Detours deleted file mode 160000 index 45a76a3..0000000 --- a/libs/Detours +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 45a76a359989aa0ce037440449976a777fd01e63 diff --git a/libs/funchook b/libs/funchook deleted file mode 160000 index 2aca28e..0000000 --- a/libs/funchook +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2aca28efeb2a3b00c696e1c3e05b44581e118580