init repo

This commit is contained in:
StarBeats 2025-08-11 15:09:43 +08:00
commit b8029c8a9d
6 changed files with 71 additions and 0 deletions

6
.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
.vscode
.xmake/
build/
vsxmake
vs2022
vs2019

View File

@ -0,0 +1,42 @@
#include <iostream>
#include <windows.h>
#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;
}

9
hook_winapi/xmake.lua Normal file
View File

@ -0,0 +1,9 @@
target("hook_winapi")
set_kind("binary")
add_defines("Hook_DLL_Name=hookdll.dll")
add_includedirs("./")
add_files("*.cpp")

0
hookdll/dllmain.cpp Normal file
View File

7
hookdll/xmake.lua Normal file
View File

@ -0,0 +1,7 @@
target("hookdll")
set_kind("shared")
add_packages("microsoft-detours")
add_includedirs("./")
add_files("*.cpp")

7
xmake.lua Normal file
View File

@ -0,0 +1,7 @@
set_project("win_hook")
add_requires("microsoft-detours")
set_symbols("debug")
includes("**/xmake.lua")