From b8029c8a9d2e4c1e1341da311ec01dda091afa44 Mon Sep 17 00:00:00 2001 From: StarBeats <977663818@qq.com> Date: Mon, 11 Aug 2025 15:09:43 +0800 Subject: [PATCH] init repo --- .gitignore | 6 ++++++ hook_winapi/hook_winapi.cpp | 42 +++++++++++++++++++++++++++++++++++++ hook_winapi/xmake.lua | 9 ++++++++ hookdll/dllmain.cpp | 0 hookdll/xmake.lua | 7 +++++++ xmake.lua | 7 +++++++ 6 files changed, 71 insertions(+) create mode 100644 .gitignore create mode 100644 hook_winapi/hook_winapi.cpp create mode 100644 hook_winapi/xmake.lua create mode 100644 hookdll/dllmain.cpp create mode 100644 hookdll/xmake.lua create mode 100644 xmake.lua diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..44b1d75 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +.vscode +.xmake/ +build/ +vsxmake +vs2022 +vs2019 diff --git a/hook_winapi/hook_winapi.cpp b/hook_winapi/hook_winapi.cpp new file mode 100644 index 0000000..25e6eba --- /dev/null +++ b/hook_winapi/hook_winapi.cpp @@ -0,0 +1,42 @@ +#include +#include + +#ifndef Hook_DLL_Name +#define Hook_DLL_Name +#endif + +wstring GetDllFullPath(wstring& dllname) +{ + wchar_t buffer[MAX_PATH]; + + DWORD length = GetCurrentDirectoryW(MAX_PATH, buffer); + + if (length != 0) + { + return wstring(buffer) + L"\\" + dllname; + } + + return wstring(L""); +} + + +int maint() +{ + auto cmdLine = GetCommandLineW(); + + int argc; + auto argv = CommandLineToArgvW(cmdLine, &argc); + + if (argc != 2) + { + return 1; + } + + wstring dllName = Hook_DLL_Name; + wstring dllPath = GetDllFullPath(dllName); + wstring processName = wstring(argv[1]); + + HookWindowsApi(dllPath, processName); + + return 0; +} \ No newline at end of file diff --git a/hook_winapi/xmake.lua b/hook_winapi/xmake.lua new file mode 100644 index 0000000..db2043e --- /dev/null +++ b/hook_winapi/xmake.lua @@ -0,0 +1,9 @@ + + + +target("hook_winapi") + set_kind("binary") + + add_defines("Hook_DLL_Name=hookdll.dll") + add_includedirs("./") + add_files("*.cpp") diff --git a/hookdll/dllmain.cpp b/hookdll/dllmain.cpp new file mode 100644 index 0000000..e69de29 diff --git a/hookdll/xmake.lua b/hookdll/xmake.lua new file mode 100644 index 0000000..0856a8b --- /dev/null +++ b/hookdll/xmake.lua @@ -0,0 +1,7 @@ +target("hookdll") + set_kind("shared") + + add_packages("microsoft-detours") + + add_includedirs("./") + add_files("*.cpp") diff --git a/xmake.lua b/xmake.lua new file mode 100644 index 0000000..95be0ba --- /dev/null +++ b/xmake.lua @@ -0,0 +1,7 @@ +set_project("win_hook") + +add_requires("microsoft-detours") + +set_symbols("debug") + +includes("**/xmake.lua")