Skip to content

Commit d6bbfb5

Browse files
committed
docs: README.md 改为中文,英文移至 README.en.md
1 parent 565b122 commit d6bbfb5

3 files changed

Lines changed: 217 additions & 217 deletions

File tree

README.en.md

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
# ChuModLoader
2+
3+
Mod loading framework for CHUNITHM. Proxies `version.dll` to load mod DLLs from `mods/` at runtime.
4+
5+
> **[中文说明](README_cn.md)**
6+
7+
> **v2.0.0** — Loader rewritten from C++ to Rust. Mod C ABI unchanged; existing mod DLLs work without modification. C++ mods remain fully supported via `chumod.h` — the header is maintained alongside the Rust codebase and will continue to receive updates. Legacy C++ loader code at tag [`v1.0.0-cpp`](https://github.com/Applesaber/ChuModLoader/tree/v1.0.0-cpp).
8+
9+
## Features
10+
11+
- `version.dll` proxy, forwards all 17 exports to the real system DLL
12+
- Auto-scans `mods/*.dll` on startup, no config needed
13+
- Optional Mod API (`chumod_init`) with memory read/write, AOB scan, inline hook, inter-mod IPC; plain DLLs work too
14+
- `mods.ini` to disable individual mods
15+
- Inline hooking via [retour](https://crates.io/crates/retour)
16+
- Written in Rust, mods can be written in Rust, C/C++, or any language that produces a Win32 DLL
17+
18+
## Installation
19+
20+
1. Build or download `version.dll`
21+
2. Place it in the game directory (next to `chusanApp.exe`)
22+
3. Drop mod DLLs into `mods/`
23+
4. Launch the game normally
24+
25+
`mods/` directory and `mods.ini` are created automatically on first run.
26+
27+
## Configuration
28+
29+
`mods.ini` is auto-generated in the game directory. To disable a mod:
30+
31+
```ini
32+
[mods]
33+
mod_name.dll=0
34+
```
35+
36+
Mods not listed (or set to `1`) are loaded by default.
37+
38+
### Per-Mod Configuration (v2)
39+
40+
Each mod gets its own config file at `mods/config/<mod_name>.ini`, created automatically on first access. Mods read/write settings via the Config API:
41+
42+
```c
43+
// read with defaults (file created automatically if missing)
44+
int fov = api->config_get_int("fov", 75);
45+
float bloom = api->config_get_float("bloom_intensity", 1.0f);
46+
int unlock = api->config_get_bool("unlock_fps", 0);
47+
48+
// write (persisted to INI immediately)
49+
api->config_set_int("fov", 90);
50+
api->config_set_bool("unlock_fps", 1);
51+
```
52+
53+
```ini
54+
; mods/config/my_mod.ini
55+
[config]
56+
fov=90
57+
bloom_intensity=1.0
58+
unlock_fps=true
59+
```
60+
61+
## For Mod Developers
62+
63+
See [Mod Development Guide](docs/mod-development.md) and [API Reference](docs/api-reference.md).
64+
65+
### Quick Start (Rust)
66+
67+
```rust
68+
use std::ffi::{c_char, c_void};
69+
70+
#[repr(C)]
71+
pub struct ChuModInfo {
72+
pub api_version: u32,
73+
pub loader_version: *const c_char,
74+
pub game_module: *const c_char,
75+
pub game_base: usize,
76+
pub game_size: u32,
77+
pub text_base: usize,
78+
pub text_size: u32,
79+
}
80+
81+
#[repr(C)]
82+
pub struct ChuModAPI {
83+
pub struct_size: u32,
84+
pub log: Option<unsafe extern "C" fn(*const c_char, ...)>,
85+
// ... other fields
86+
}
87+
88+
#[no_mangle]
89+
pub extern "C" fn chumod_name() -> *const c_char {
90+
b"My Rust Mod\0".as_ptr() as *const c_char
91+
}
92+
93+
#[no_mangle]
94+
pub unsafe extern "C" fn chumod_init(
95+
info: *const ChuModInfo,
96+
_api: *const ChuModAPI,
97+
) -> i32 {
98+
// your init code
99+
0
100+
}
101+
102+
#[no_mangle]
103+
pub extern "C" fn chumod_shutdown() {}
104+
```
105+
106+
### Quick Start (C/C++)
107+
108+
```c
109+
#include "chumod.h"
110+
111+
CHUMOD_API const char* chumod_name() { return "My Mod"; }
112+
113+
CHUMOD_API int chumod_init(const ChuModInfo* info, const ChuModAPI* api) {
114+
api->log("game base = 0x%08X, .text = 0x%08X +0x%X",
115+
info->game_base, info->text_base, info->text_size);
116+
return 0;
117+
}
118+
119+
CHUMOD_API void chumod_shutdown() { }
120+
```
121+
122+
All exports are optional. Plain DLL with `DllMain` only also works.
123+
124+
## Building
125+
126+
Requires Rust toolchain with `i686-pc-windows-msvc` target:
127+
128+
```bash
129+
rustup toolchain install nightly --target i686-pc-windows-msvc
130+
cargo +nightly build --release
131+
```
132+
133+
Output: `target/i686-pc-windows-msvc/release/version.dll`
134+
135+
> **C++ build**: The loader was previously built with CMake 3.15+ and MSVC (`cmake -B build -A Win32 && cmake --build build --config Release`).
136+
137+
## How It Works
138+
139+
Exploits Windows DLL search order (application directory before System32):
140+
141+
1. Loads the real `version.dll` from System32, forwards exports via naked JMP
142+
2. Background thread waits 2s, scans `mods/*.dll`, calls `LoadLibrary` on each
143+
3. Parses PE headers for `.text` section info, calls `chumod_init` on API-exporting mods
144+
4. On exit, calls `chumod_shutdown` in reverse order, then `FreeLibrary`
145+
146+
## Logging
147+
148+
Output to `chusan_loader.log` and console if available. Format: `[HH:MM:SS.mmm] [loader] message`
149+
150+
## Project Structure
151+
152+
```
153+
ChuModLoader/
154+
├── include/chumod.h # Mod API header (for C/C++ mods)
155+
├── src/
156+
│ ├── lib.rs # version.dll proxy entry (DllMain + forward_dll)
157+
│ ├── loader.rs # mod scanning & loading
158+
│ └── api_impl.rs # API implementation (retour hooks, memory, IPC)
159+
├── docs/
160+
│ ├── mod-development.md
161+
│ └── api-reference.md
162+
├── Cargo.toml
163+
└── build.rs
164+
```
165+
166+
## License
167+
168+
MIT

README.md

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,51 @@
11
# ChuModLoader
22

3-
Mod loading framework for CHUNITHM. Proxies `version.dll` to load mod DLLs from `mods/` at runtime.
3+
CHUNITHM 的 mod 加载框架。通过代理 `version.dll`,在游戏启动时自动从 `mods/` 目录加载 mod DLL。
44

5-
> **[中文说明](README_cn.md)**
5+
> **[English](README.md)**
66
7-
> **v2.0.0** — Loader rewritten from C++ to Rust. Mod C ABI unchanged; existing mod DLLs work without modification. C++ mods remain fully supported via `chumod.h` — the header is maintained alongside the Rust codebase and will continue to receive updates. Legacy C++ loader code at tag [`v1.0.0-cpp`](https://github.com/Applesaber/ChuModLoader/tree/v1.0.0-cpp).
7+
> **v2.0.0** — Loader C++ 迁移到 Rust 重写。Mod C ABI 接口不变,已有 mod DLL 无需修改。C++ mod 开发仍然完整支持 — `chumod.h` 头文件随 Rust 代码同步维护,持续更新。旧版 C++ 代码保留在 tag [`v1.0.0-cpp`](https://github.com/Applesaber/ChuModLoader/tree/v1.0.0-cpp)
88
9-
## Features
9+
## 功能
1010

11-
- `version.dll` proxy, forwards all 17 exports to the real system DLL
12-
- Auto-scans `mods/*.dll` on startup, no config needed
13-
- Optional Mod API (`chumod_init`) with memory read/write, AOB scan, inline hook, inter-mod IPC; plain DLLs work too
14-
- `mods.ini` to disable individual mods
15-
- Inline hooking via [retour](https://crates.io/crates/retour)
16-
- Written in Rust, mods can be written in Rust, C/C++, or any language that produces a Win32 DLL
11+
- `version.dll` 代理劫持,转发全部 17 个导出函数
12+
- 启动时自动扫描 `mods/*.dll`,无需配置
13+
- 可选的 Mod API`chumod_init`),提供内存读写、AOB 扫描、inline hookmod 间通信;不实现也能加载
14+
- `mods.ini` 按 mod 禁用
15+
- 基于 [retour](https://crates.io/crates/retour) 的 inline hook
16+
- Rust 编写,mod 可用 RustC/C++ 或任何能编译 Win32 DLL 的语言
1717

18-
## Installation
18+
## 安装
1919

20-
1. Build or download `version.dll`
21-
2. Place it in the game directory (next to `chusanApp.exe`)
22-
3. Drop mod DLLs into `mods/`
23-
4. Launch the game normally
20+
1. 构建或下载 `version.dll`
21+
2. 放到游戏目录(和 `chusanApp.exe` 同级)
22+
3. mod DLL 丢进 `mods/`
23+
4. 正常启动游戏
2424

25-
`mods/` directory and `mods.ini` are created automatically on first run.
25+
`mods/` 目录和 `mods.ini` 首次运行时自动创建。
2626

27-
## Configuration
27+
## 配置
2828

29-
`mods.ini` is auto-generated in the game directory. To disable a mod:
29+
`mods.ini` 自动生成在游戏目录,禁用 mod 时编辑:
3030

3131
```ini
3232
[mods]
3333
mod_name.dll=0
3434
```
3535

36-
Mods not listed (or set to `1`) are loaded by default.
36+
未列出(或设为 `1`)的 mod 默认加载。
3737

38-
### Per-Mod Configuration (v2)
38+
### Mod 独立配置 (v2)
3939

40-
Each mod gets its own config file at `mods/config/<mod_name>.ini`, created automatically on first access. Mods read/write settings via the Config API:
40+
每个 mod `mods/config/<mod名>.ini` 有独立配置文件,首次访问时自动创建。通过 Config API 读写:
4141

4242
```c
43-
// read with defaults (file created automatically if missing)
43+
// 读取,不存在时返回默认值(文件自动创建)
4444
int fov = api->config_get_int("fov", 75);
4545
float bloom = api->config_get_float("bloom_intensity", 1.0f);
4646
int unlock = api->config_get_bool("unlock_fps", 0);
4747

48-
// write (persisted to INI immediately)
48+
// 写入(立即持久化到 INI
4949
api->config_set_int("fov", 90);
5050
api->config_set_bool("unlock_fps", 1);
5151
```
@@ -58,11 +58,11 @@ bloom_intensity=1.0
5858
unlock_fps=true
5959
```
6060

61-
## For Mod Developers
61+
## Mod 开发
6262

63-
See [Mod Development Guide](docs/mod-development.md) and [API Reference](docs/api-reference.md).
63+
详见 [Mod 开发指南](docs/mod-development_cn.md) [API 参考](docs/api-reference_cn.md)
6464

65-
### Quick Start (Rust)
65+
### 快速上手(Rust
6666

6767
```rust
6868
use std::ffi::{c_char, c_void};
@@ -82,7 +82,7 @@ pub struct ChuModInfo {
8282
pub struct ChuModAPI {
8383
pub struct_size: u32,
8484
pub log: Option<unsafe extern "C" fn(*const c_char, ...)>,
85-
// ... other fields
85+
// ... 其他字段
8686
}
8787

8888
#[no_mangle]
@@ -95,15 +95,15 @@ pub unsafe extern "C" fn chumod_init(
9595
info: *const ChuModInfo,
9696
_api: *const ChuModAPI,
9797
) -> i32 {
98-
// your init code
98+
// 初始化代码
9999
0
100100
}
101101

102102
#[no_mangle]
103103
pub extern "C" fn chumod_shutdown() {}
104104
```
105105

106-
### Quick Start (C/C++)
106+
### 快速上手(C/C++
107107

108108
```c
109109
#include "chumod.h"
@@ -119,46 +119,46 @@ CHUMOD_API int chumod_init(const ChuModInfo* info, const ChuModAPI* api) {
119119
CHUMOD_API void chumod_shutdown() { }
120120
```
121121
122-
All exports are optional. Plain DLL with `DllMain` only also works.
122+
所有导出函数可选。只用 `DllMain` 的普通 DLL 也能加载。
123123
124-
## Building
124+
## 构建
125125
126-
Requires Rust toolchain with `i686-pc-windows-msvc` target:
126+
需要 Rust 工具链和 `i686-pc-windows-msvc` target
127127
128128
```bash
129129
rustup toolchain install nightly --target i686-pc-windows-msvc
130130
cargo +nightly build --release
131131
```
132132

133-
Output: `target/i686-pc-windows-msvc/release/version.dll`
133+
输出:`target/i686-pc-windows-msvc/release/version.dll`
134134

135-
> **C++ build**: The loader was previously built with CMake 3.15+ and MSVC (`cmake -B build -A Win32 && cmake --build build --config Release`).
135+
> **C++ 构建**:之前使用 CMake 3.15+ MSVC 构建(`cmake -B build -A Win32 && cmake --build build --config Release`)。
136136
137-
## How It Works
137+
## 工作原理
138138

139-
Exploits Windows DLL search order (application directory before System32):
139+
利用 Windows DLL 搜索顺序(程序目录优先于 System32)实现劫持:
140140

141-
1. Loads the real `version.dll` from System32, forwards exports via naked JMP
142-
2. Background thread waits 2s, scans `mods/*.dll`, calls `LoadLibrary` on each
143-
3. Parses PE headers for `.text` section info, calls `chumod_init` on API-exporting mods
144-
4. On exit, calls `chumod_shutdown` in reverse order, then `FreeLibrary`
141+
1. 加载 System32 的真 `version.dll`naked JMP 转发导出函数
142+
2. 后台线程等 2 秒,扫描 `mods/*.dll`,逐个 `LoadLibrary`
143+
3. 解析 PE 头拿 `.text` 段信息,对导出了 ChuMod API 的 mod 调用 `chumod_init`
144+
4. 退出时逆序调用 `chumod_shutdown`,再 `FreeLibrary`
145145

146-
## Logging
146+
## 日志
147147

148-
Output to `chusan_loader.log` and console if available. Format: `[HH:MM:SS.mmm] [loader] message`
148+
输出到 `chusan_loader.log`,有控制台时同步输出。格式:`[HH:MM:SS.mmm] [loader] message`
149149

150-
## Project Structure
150+
## 项目结构
151151

152152
```
153153
ChuModLoader/
154-
├── include/chumod.h # Mod API header (for C/C++ mods)
154+
├── include/chumod.h # Mod API 头文件(C/C++ mod 使用)
155155
├── src/
156-
│ ├── lib.rs # version.dll proxy entry (DllMain + forward_dll)
157-
│ ├── loader.rs # mod scanning & loading
158-
│ └── api_impl.rs # API implementation (retour hooks, memory, IPC)
156+
│ ├── lib.rs # version.dll 代理入口(DllMain + forward_dll
157+
│ ├── loader.rs # mod 扫描加载
158+
│ └── api_impl.rs # API 实现(retour hook、内存、IPC
159159
├── docs/
160-
│ ├── mod-development.md
161-
│ └── api-reference.md
160+
│ ├── mod-development_cn.md # 开发指南
161+
│ └── api-reference_cn.md # API 参考
162162
├── Cargo.toml
163163
└── build.rs
164164
```

0 commit comments

Comments
 (0)