From 74cb184c034e8a5d1bf1376b40280d3abf64f7f8 Mon Sep 17 00:00:00 2001 From: Sean Du Date: Sat, 27 Jun 2026 21:01:01 +0800 Subject: [PATCH] Bundle winpthread runtime with build outputs Signed-off-by: Sean Du --- CMakeLists.txt | 8 ++++++++ Makefile | 9 +++++++-- README.md | 4 +++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e4c275f..e3bebf6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,3 +88,11 @@ if(CMAKE_BUILD_TYPE STREQUAL "Release") "-s" ) endif() + +if(MINGW) + add_custom_command(TARGET version POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + /usr/x86_64-w64-mingw32/bin/libwinpthread-1.dll + $/libwinpthread-1.dll + ) +endif() diff --git a/Makefile b/Makefile index 5164373..f4b5af3 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,7 @@ BUILD ?= release CC := x86_64-w64-mingw32-gcc CXX := x86_64-w64-mingw32-g++ WINDRES := x86_64-w64-mingw32-windres +WINPTHREAD_DLL := /usr/x86_64-w64-mingw32/bin/libwinpthread-1.dll INCLUDES := -Isrc -Ideps/minhook/include -Ideps/minhook/src -Ideps/minhook/src/hde INCLUDES += -Ideps/rapidjson/include @@ -58,8 +59,8 @@ OBJS := $(C_OBJS) $(CXX_OBJS) $(RC_OBJS) .PHONY: all release debug clean -all: $(TARGET) $(HELPER_TARGET) -release: $(TARGET) $(HELPER_TARGET) +all: $(TARGET) $(HELPER_TARGET) $(BUILD_DIR)/libwinpthread-1.dll +release: $(TARGET) $(HELPER_TARGET) $(BUILD_DIR)/libwinpthread-1.dll debug: $(MAKE) BUILD=debug @@ -71,6 +72,10 @@ $(HELPER_TARGET): $(HELPER_CXX_OBJS) $(HELPER_RC_OBJS) @mkdir -p $(dir $@) $(CXX) $(HELPER_LDFLAGS) -o $@ $(HELPER_CXX_OBJS) $(HELPER_RC_OBJS) $(HELPER_LDLIBS) +$(BUILD_DIR)/libwinpthread-1.dll: + @mkdir -p $(dir $@) + cp "$(WINPTHREAD_DLL)" "$@" + $(OBJ_DIR)/%.o: %.c @mkdir -p $(dir $@) $(CC) $(CFLAGS) -c $< -o $@ diff --git a/README.md b/README.md index 2bec831..c889a0c 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ make **输出** - `build/version.dll` - `build/cgss-borderless-helper.exe` +- `build/libwinpthread-1.dll` **config.json** ```json @@ -56,7 +57,7 @@ make - `launch_borderless_helper`:是否自动启动 `cgss-borderless-helper.exe`。默认 `true` **使用方法** -1. 将 `build/version.dll` 和 `build/cgss-borderless-helper.exe` 一起复制到 `imascgstage.exe` 同目录 +1. 将 `build/version.dll`、`build/cgss-borderless-helper.exe` 和 `build/libwinpthread-1.dll` 一起复制到 `imascgstage.exe` 同目录 2. 如需覆盖地址,在同目录放置 `config.json` 3. 启动游戏 4. 进入游戏后按 `F11` 切换无边框全屏 @@ -66,6 +67,7 @@ make - `cgss-borderless-helper.exe` 现在只负责外部窗口 borderless 行为,不再修改 Unity 内部 `Screen.SetResolution`。 - 这样更接近 Borderless Gaming 的工作方式,也能减少退出时的干扰。 - `version.dll` 只在 `imascgstage.exe` 主进程中继续启动 hook 和 helper;被其他进程间接加载时会跳过。 +- 不要只单独分发 `version.dll`。当前构建依赖 `libwinpthread-1.dll`,如果目标机器缺少它,Windows 会在进入代理代码前直接拒绝加载,此时通常表现为游戏无法启动,且不会生成任何日志。 **致谢** - 本项目的 `version.dll` 代理注入思路与运行时 IL2CPP hook 方向,受 `gkms-localify-dmm` 项目启发。