diff --git a/230130-hookgamesendto/bin/Readme.txt b/230130-hookgamesendto/bin/Readme.txt new file mode 100644 index 0000000000000000000000000000000000000000..a15c4ec5da92dbb9bf1d0630ec3b8576dd46d5f3 --- /dev/null +++ b/230130-hookgamesendto/bin/Readme.txt @@ -0,0 +1 @@ +编译输出的二进制文件 \ No newline at end of file diff --git a/230130-hookgamesendto/hookdll/Makefile b/230130-hookgamesendto/hookdll/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..deb25ba0747ef7bb4bf53633a1693977cba6db4c --- /dev/null +++ b/230130-hookgamesendto/hookdll/Makefile @@ -0,0 +1,35 @@ +vpath %.cpp ../src +cxx = g++ +cxxflags = -c -O1 -I ../inc +linkflags = -shared -l ws2_32 +cxx32prefix = i686-w64-mingw32- +cxx64prefix = x86_64-w64-mingw32- +objdir = ./obj/ +bindir = ../bin/ +src = hookdll.cpp fksendto.cpp inlinehook.cpp sockqueue.cpp +obj32 = $(patsubst %.cpp, $(objdir)%_32.o, $(src)) +obj64 = $(patsubst %.cpp, $(objdir)%_64.o, $(src)) +target32 = $(bindir)hookdll32.dll +target64 = $(bindir)hookdll64.dll + +all: check $(target32) $(target64) + +$(target32): $(obj32) + $(cxx32prefix)$(cxx) -o $@ $^ $(linkflags) + +$(target64): $(obj64) + $(cxx64prefix)$(cxx) -o $@ $^ $(linkflags) + +$(objdir)%_32.o: %.cpp + $(cxx32prefix)$(cxx) $(cxxflags) -o $@ $< + +$(objdir)%_64.o: %.cpp + $(cxx64prefix)$(cxx) $(cxxflags) -o $@ $< + +.PHONY: check clean + +check: + @ if not exist obj md obj + +clean: + @ if exist obj del obj\*.o diff --git a/230130-hookgamesendto/src/hookdll.cpp b/230130-hookgamesendto/hookdll/hookdll.cpp similarity index 69% rename from 230130-hookgamesendto/src/hookdll.cpp rename to 230130-hookgamesendto/hookdll/hookdll.cpp index cc3aac167ce73537c15752837a8e391edbf7168d..e7a3078afedca5f89e3a760b22d071dda59a0291 100644 --- a/230130-hookgamesendto/src/hookdll.cpp +++ b/230130-hookgamesendto/hookdll/hookdll.cpp @@ -1,11 +1,9 @@ -#include #include -#include #include "inlinehook.h" #include "fksendto.h" #ifdef _MSC_VER -#pragma comment (lib, "ws2_32.lib") // 比较坑啊,在项目设置里加没用 +#pragma comment (lib, "ws2_32.lib") #endif BOOL APIENTRY DllMain(HINSTANCE hinstdll, DWORD reason, LPVOID reserved) diff --git a/230130-hookgamesendto/inc/fksendto.h b/230130-hookgamesendto/inc/fksendto.h index 5bc0ef3646c4c91d754b265ba5f4a2df36497e27..ac82f6297f6fc6594cc481d3b31e8f2bf3dcadf5 100644 --- a/230130-hookgamesendto/inc/fksendto.h +++ b/230130-hookgamesendto/inc/fksendto.h @@ -1,6 +1,5 @@ #pragma once -#include #include "inlinehook.h" void hook_sendto(); diff --git a/230130-hookgamesendto/inc/inject.h b/230130-hookgamesendto/inc/inject.h new file mode 100644 index 0000000000000000000000000000000000000000..d44264722bbbaddcf9aa51bf71ced4aaa1576602 --- /dev/null +++ b/230130-hookgamesendto/inc/inject.h @@ -0,0 +1,5 @@ +#pragma once +#include + +bool inject_dll(DWORD pid, const char *dll_path); +DWORD find_pid_by_name(const char *name); diff --git a/230130-hookgamesendto/injector/Makefile b/230130-hookgamesendto/injector/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..335e553d2054c9c52231037c0f31e4d8efbe3864 --- /dev/null +++ b/230130-hookgamesendto/injector/Makefile @@ -0,0 +1,34 @@ +vpath %.cpp ../src +cxx = g++ +cxxflags = -c -O1 -I ../inc +cxx32prefix = i686-w64-mingw32- +cxx64prefix = x86_64-w64-mingw32- +objdir = ./obj/ +bindir = ../bin/ +src = injector.cpp inject.cpp +obj32 = $(patsubst %.cpp, $(objdir)%_32.o, $(src)) +obj64 = $(patsubst %.cpp, $(objdir)%_64.o, $(src)) +target32 = $(bindir)injector32.exe +target64 = $(bindir)injector64.exe + +all: check $(target32) $(target64) + +$(target32): $(obj32) + $(cxx32prefix)$(cxx) -o $@ $^ + +$(target64): $(obj64) + $(cxx64prefix)$(cxx) -o $@ $^ + +$(objdir)%_32.o: %.cpp + $(cxx32prefix)$(cxx) $(cxxflags) -o $@ $< + +$(objdir)%_64.o: %.cpp + $(cxx64prefix)$(cxx) $(cxxflags) -o $@ $< + +.PHONY: check clean + +check: + @ if not exist obj md obj + +clean: + @ if exist obj del obj\*.o diff --git a/230130-hookgamesendto/injector/injector.cpp b/230130-hookgamesendto/injector/injector.cpp new file mode 100644 index 0000000000000000000000000000000000000000..cbc438cd01e1969dff324814a15c0a95715d163c --- /dev/null +++ b/230130-hookgamesendto/injector/injector.cpp @@ -0,0 +1,102 @@ +#include "inject.h" +#include "platform.h" +#include +#include +#include + +#ifdef _CPU_X64 +#define DLL_NAME "hookdll64.dll" +#endif +#ifdef _CPU_X86 +#define DLL_NAME "hookdll32.dll" +#endif + +void write_help() +{ + printf("Usage: injector32/injector64