From 5067397fc4721dda7ae91a7ed8f1160cc9d6bcf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <101191390+HIllya51@users.noreply.github.com> Date: Mon, 6 May 2024 22:56:24 +0800 Subject: [PATCH] pch --- LunaHook/embed_util.cc | 2 -- LunaHook/embed_util.h | 2 -- LunaHook/engine.h | 1 - LunaHook/engines/python/python.cpp | 2 -- LunaHook/engines/python/python2.cpp | 1 - LunaHook/engines/python/python3.cpp | 2 -- LunaHook/engines/v8/v8.cpp | 4 --- LunaHook/hookfinder.cc | 1 - LunaHook/hookfinder.h | 2 -- LunaHook/main.cc | 3 --- LunaHook/main.h | 1 - LunaHook/stackoffset.hpp | 1 - LunaHook/texthook.cc | 1 - LunaHook/util/ithsys/ithsys.cc | 1 - LunaHook/util/stringfilters.h | 1 - LunaHost/GUI/LunaHost.cpp | 1 - LunaHost/LunaHostCLI.cpp | 1 - LunaHost/LunaHostDll.cpp | 3 --- LunaHost/host.cpp | 3 --- LunaHost/host.h | 1 - LunaHost/textthread.h | 1 - include/CMakeLists.txt | 4 +-- include/hookcode.cpp | 3 +-- include/hookcode.h | 2 -- include/{common.cpp => pch.cpp} | 0 include/pch.h | 41 +++++++++++++++++++++++++++++ include/stringutils.cpp | 2 -- include/texthook.h | 2 +- include/types.h | 1 - include/{common.h => utils.h} | 31 ---------------------- 30 files changed, 45 insertions(+), 76 deletions(-) rename include/{common.cpp => pch.cpp} (100%) create mode 100644 include/pch.h rename include/{common.h => utils.h} (82%) diff --git a/LunaHook/embed_util.cc b/LunaHook/embed_util.cc index a3196b7..b415c70 100644 --- a/LunaHook/embed_util.cc +++ b/LunaHook/embed_util.cc @@ -4,8 +4,6 @@ #include"main.h" #include"detours.h" #include"hijackfuns.h" -#include"winevent.hpp" -#include"defs.h" #include"stringfilters.h" #include"util.h" DynamicShiftJISCodec *dynamiccodec=new DynamicShiftJISCodec(932); diff --git a/LunaHook/embed_util.h b/LunaHook/embed_util.h index f667f10..bb9a63b 100644 --- a/LunaHook/embed_util.h +++ b/LunaHook/embed_util.h @@ -1,7 +1,5 @@ #ifndef __LUNA_EMBED_ENGINE_H #define __LUNA_EMBED_ENGINE_H -#include"types.h" -#include "texthook.h" #include"dyncodec/dynsjiscodec.h" extern EmbedSharedMem *embedsharedmem; diff --git a/LunaHook/engine.h b/LunaHook/engine.h index 401cc85..5f7d5b1 100644 --- a/LunaHook/engine.h +++ b/LunaHook/engine.h @@ -9,7 +9,6 @@ #include"pchooks/pchooks.h" #include "disasm/disasm.h" #include"main.h" -#include"const.h" extern WCHAR* processName, processPath[MAX_PATH],processName_lower[MAX_PATH]; // cached extern uintptr_t processStartAddress, processStopAddress; diff --git a/LunaHook/engines/python/python.cpp b/LunaHook/engines/python/python.cpp index 26727c8..47d1a92 100644 --- a/LunaHook/engines/python/python.cpp +++ b/LunaHook/engines/python/python.cpp @@ -2,8 +2,6 @@ #include"embed_util.h" #include"main.h" #include"stackoffset.hpp" -#include"types.h" -#include"defs.h" #include #include #include diff --git a/LunaHook/engines/python/python2.cpp b/LunaHook/engines/python/python2.cpp index 735ee55..31b3b5c 100644 --- a/LunaHook/engines/python/python2.cpp +++ b/LunaHook/engines/python/python2.cpp @@ -1,4 +1,3 @@ -#include"types.h" #include"python.h" #include"main.h" #include"stackoffset.hpp" diff --git a/LunaHook/engines/python/python3.cpp b/LunaHook/engines/python/python3.cpp index 63fc91c..19d2c0a 100644 --- a/LunaHook/engines/python/python3.cpp +++ b/LunaHook/engines/python/python3.cpp @@ -1,7 +1,5 @@ #include"python.h" -#include"types.h" #include"main.h" -#include"defs.h" namespace { #define PyUnicode_IS_READY(op) 1 #define PyUnicode_Check(op) 1 diff --git a/LunaHook/engines/v8/v8.cpp b/LunaHook/engines/v8/v8.cpp index 80c671d..3385d7c 100644 --- a/LunaHook/engines/v8/v8.cpp +++ b/LunaHook/engines/v8/v8.cpp @@ -1,7 +1,3 @@ - -#include"common.h" -#include"defs.h" -#include"types.h" #include"main.h" #include"v8.h" #include"embed_util.h" diff --git a/LunaHook/hookfinder.cc b/LunaHook/hookfinder.cc index 4adf362..9aafd6d 100644 --- a/LunaHook/hookfinder.cc +++ b/LunaHook/hookfinder.cc @@ -1,5 +1,4 @@ #include "hookfinder.h" -#include "defs.h" #include "main.h" #include "util.h" #include "MinHook.h" diff --git a/LunaHook/hookfinder.h b/LunaHook/hookfinder.h index 17f36f5..845235c 100644 --- a/LunaHook/hookfinder.h +++ b/LunaHook/hookfinder.h @@ -1,6 +1,4 @@ #pragma once -#include "types.h" - void SearchForText(wchar_t* text, UINT codepage); void SearchForHooks(SearchParam sp); diff --git a/LunaHook/main.cc b/LunaHook/main.cc index 47194ae..4f51331 100644 --- a/LunaHook/main.cc +++ b/LunaHook/main.cc @@ -4,12 +4,9 @@ // 8/24/2013 TODO: Clean up this file #include "main.h" -#include "defs.h" -#include "texthook.h" #include "hookfinder.h" #include "util.h" #include "MinHook.h" -#include"hookcode.h" #include"Lang/Lang.h" void Hijack(); void detachall(); diff --git a/LunaHook/main.h b/LunaHook/main.h index 0158cc4..cac137e 100644 --- a/LunaHook/main.h +++ b/LunaHook/main.h @@ -4,7 +4,6 @@ // 8/23/2013 jichi // Branch: ITH/IHF_DLL.h, rev 66 -#include "types.h" void TextOutput(ThreadParam tp, TextOutput_T (*buffer), int len); void ConsoleOutput(LPCSTR text, ...); diff --git a/LunaHook/stackoffset.hpp b/LunaHook/stackoffset.hpp index a2f45c2..13c11e5 100644 --- a/LunaHook/stackoffset.hpp +++ b/LunaHook/stackoffset.hpp @@ -1,4 +1,3 @@ -#include"texthook.h" enum class regs { _flags, diff --git a/LunaHook/texthook.cc b/LunaHook/texthook.cc index d664d42..4194241 100644 --- a/LunaHook/texthook.cc +++ b/LunaHook/texthook.cc @@ -3,7 +3,6 @@ // Branch: LUNA_HOOK_DLL/texthook.cpp, rev 128 // 8/24/2013 TODO: Clean up this file #include"embed_util.h" -#include "texthook.h" #include "main.h" #include "ithsys/ithsys.h" #include "MinHook.h" diff --git a/LunaHook/util/ithsys/ithsys.cc b/LunaHook/util/ithsys/ithsys.cc index f55f208..5e91496 100644 --- a/LunaHook/util/ithsys/ithsys.cc +++ b/LunaHook/util/ithsys/ithsys.cc @@ -7,7 +7,6 @@ // - Move my old create remote thread for ITH2 here #include "ithsys/ithsys.h" -#include "const.h" /** * Return the address of the first matched pattern. diff --git a/LunaHook/util/stringfilters.h b/LunaHook/util/stringfilters.h index 0b4e910..cf1766c 100644 --- a/LunaHook/util/stringfilters.h +++ b/LunaHook/util/stringfilters.h @@ -1,4 +1,3 @@ -#include "texthook.h" #include "cpputil/cppcstring.h" void CharReplacer(char *str, size_t *size, char fr, char to); void CharReplacer(wchar_t *str, size_t *size, wchar_t fr, wchar_t to); diff --git a/LunaHost/GUI/LunaHost.cpp b/LunaHost/GUI/LunaHost.cpp index 198051d..383d116 100644 --- a/LunaHost/GUI/LunaHost.cpp +++ b/LunaHost/GUI/LunaHost.cpp @@ -5,7 +5,6 @@ #include #include #include"host.h" -#include"hookcode.h" #include"textthread.h" #include"LunaHost.h" #include"Lang/Lang.h" diff --git a/LunaHost/LunaHostCLI.cpp b/LunaHost/LunaHostCLI.cpp index 8a48f40..c6cbadf 100644 --- a/LunaHost/LunaHostCLI.cpp +++ b/LunaHost/LunaHostCLI.cpp @@ -1,5 +1,4 @@ #include "host.h" -#include "hookcode.h" #include #include diff --git a/LunaHost/LunaHostDll.cpp b/LunaHost/LunaHostDll.cpp index 7bc4eb0..e171ec7 100644 --- a/LunaHost/LunaHostDll.cpp +++ b/LunaHost/LunaHostDll.cpp @@ -1,7 +1,4 @@ #include "host.h" -#include "hookcode.h" -#include "defs.h" -#include "winevent.hpp" #define C_LUNA_API extern "C" __declspec(dllexport) BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, diff --git a/LunaHost/host.cpp b/LunaHost/host.cpp index f7a47f6..71029af 100644 --- a/LunaHost/host.cpp +++ b/LunaHost/host.cpp @@ -1,7 +1,4 @@ #include "host.h" -#include "defs.h" -#include "hookcode.h" -#include "texthook.h" typedef LONG NTSTATUS; #include"yapi.hpp" #include"Lang/Lang.h" diff --git a/LunaHost/host.h b/LunaHost/host.h index 428b5c3..67d820b 100644 --- a/LunaHost/host.h +++ b/LunaHost/host.h @@ -1,7 +1,6 @@ #pragma once #include "textthread.h" -#include"texthook.h" namespace Host { using ConsoleHandler =std::function; diff --git a/LunaHost/textthread.h b/LunaHost/textthread.h index 25cf075..dcc0b27 100644 --- a/LunaHost/textthread.h +++ b/LunaHost/textthread.h @@ -1,6 +1,5 @@ #pragma once -#include "types.h" class TextThread { diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 1772ed5..959b7e0 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -1,4 +1,4 @@ -add_library(pch hookcode.cpp common.cpp stringutils.cpp) -target_precompile_headers(pch PUBLIC common.h) +add_library(pch hookcode.cpp pch.cpp stringutils.cpp) +target_precompile_headers(pch PUBLIC pch.h) diff --git a/include/hookcode.cpp b/include/hookcode.cpp index e32e26c..6b4a980 100644 --- a/include/hookcode.cpp +++ b/include/hookcode.cpp @@ -1,5 +1,4 @@ -#include "hookcode.h" - + namespace { std::optional ParseRCode(std::wstring RCode) diff --git a/include/hookcode.h b/include/hookcode.h index 2e5a1f3..82d7748 100644 --- a/include/hookcode.h +++ b/include/hookcode.h @@ -1,7 +1,5 @@ #pragma once -#include "types.h" - namespace HookCode { std::optional Parse(std::wstring code); diff --git a/include/common.cpp b/include/pch.cpp similarity index 100% rename from include/common.cpp rename to include/pch.cpp diff --git a/include/pch.h b/include/pch.h new file mode 100644 index 0000000..46e464b --- /dev/null +++ b/include/pch.h @@ -0,0 +1,41 @@ +#pragma once + +#define WIN32_LEAN_AND_MEAN +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#include"stringutils.h" +#include"utils.h" +#include"defs.h" +#include"const.h" +#include"types.h" +#include"hookcode.h" +#include"texthook.h" +#include"winevent.hpp" \ No newline at end of file diff --git a/include/stringutils.cpp b/include/stringutils.cpp index c656548..7506bd6 100644 --- a/include/stringutils.cpp +++ b/include/stringutils.cpp @@ -203,8 +203,6 @@ std::wstring acastw(const std::string x){ xx+=c; return xx; } -#include"const.h" -#include"types.h" std::optional commonparsestring(void* data,size_t length,void* php,DWORD df){ auto hp=(HookParam*)php; if (hp->type & CODEC_UTF16) return std::wstring((wchar_t*)data, length / sizeof(wchar_t)); diff --git a/include/texthook.h b/include/texthook.h index b3871b2..d39291d 100644 --- a/include/texthook.h +++ b/include/texthook.h @@ -7,7 +7,7 @@ // 8/24/2013 TODO: // - Clean up this file // - Reduce global variables. Use namespaces or singleton classes instead. -#include "types.h" + // Artikash 6/17/2019 TODO: These have the wrong values on x64 /** jichi 12/24/2014 diff --git a/include/types.h b/include/types.h index 3049949..1ab8f4f 100644 --- a/include/types.h +++ b/include/types.h @@ -1,6 +1,5 @@ #pragma once -#include "const.h" class WinMutex // Like CMutex but works with scoped_lock { diff --git a/include/common.h b/include/utils.h similarity index 82% rename from include/common.h rename to include/utils.h index a2d7c18..9208811 100644 --- a/include/common.h +++ b/include/utils.h @@ -1,35 +1,5 @@ #pragma once -#define WIN32_LEAN_AND_MEAN -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include"stringutils.h" #ifdef _WIN64 constexpr bool x64 = true; #else @@ -123,4 +93,3 @@ inline std::optional GetModuleFilename(HMODULE module = NULL) if (GetModuleFileNameW(module, buffer.data(), MAX_PATH)) return buffer.data(); return {}; } - \ No newline at end of file