Skip to content

Commit aa9f61b

Browse files
committed
v2.0
1 parent 8dd1634 commit aa9f61b

34 files changed

Lines changed: 14774 additions & 23 deletions

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ qrc_*.cpp
2727
ui_*.h
2828
*.qmlc
2929
*.jsc
30-
Makefile*
3130
*build-*
3231
*.qm
3332
*.prl

README.md

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
# civrip
2+
**100% open source**
3+
24
GUI to create virtual network for civilization 6 and old school games in multiplayer mode.
35

46
简单GUI为文明6及老游戏联机提供虚拟组网。
57

68
[中文Readme](README_zh_CN.md)
79

10+
![main](./assets/main_en.png)
11+
812
## Motivation
913
Civilization 6 and other old school games only support LAN for multiplayer (if you cannot connect to Civilization 6 official server). The most common way is to create a virtual network to simulate a LAN.
1014

@@ -13,7 +17,9 @@ Possible solution:
1317
- [n2n](https://github.com/ntop/n2n): Similar to Zerotier, but it needs a coordinator server to connect different users and forwarding traffic (if P2P is disabled). It allows the user to force TCP connection instead of UDP.
1418
- VPN: Also work for most cases, but it is too heavy and not allowed in some network environment.
1519

16-
Civilization 6 has another problem that it only scan the default NIC for local rooms, but most solutions based on virtual NIC. We need [WinIPBroadcast](https://github.com/dechamps/WinIPBroadcast) to send IP broadcast packets to all interfaces.
20+
~~Civilization 6 has another problem that it only scan the default NIC for local rooms, but most solutions based on virtual NIC. We need [WinIPBroadcast](https://github.com/dechamps/WinIPBroadcast) to send IP broadcast packets to all interfaces.~~
21+
22+
Update: Inspired by @xaxys (https://github.com/xaxys/injciv6/tree/master), we now have a newer solution through function hook.
1723

1824
I developed this tool to automate the process for Civilization 6 multiplayer mode (and old school games), based on n2n to overcome network issues.
1925

@@ -42,6 +48,29 @@ The server will have two community, `civsix` and `free`.
4248
## Client
4349
Download the latest release on the [release page](https://github.com/MXWXZ/civrip/releases).
4450

51+
### v2.0
52+
53+
1. Execute `civrip.exe`
54+
2. Click `Install TAP` if status is `UNINST`.
55+
3. Click `Restart TAP` if status is `STOPPED` or `UNKNOWN`.
56+
4. Fill in `Server IP` with port, e.g., `1.2.3.4:7654`.
57+
5. Fill in `Community` configured by server, e.g., `civsix`.
58+
6. Fill in `Encrypt Key`, this can be arbitrary, e.g., `114514`.
59+
7. Do not check any network setting and click `Connect`.
60+
61+
If you are game server:
62+
1. Make sure server status is `CONNECT`.
63+
2. Find the LAN IP in the output (e.g., 10.0.0.100).
64+
3. Disable the firewall, create the game room and tell your IP to the others!
65+
66+
If you are joining others server:
67+
1. Make sure server status is `CONNECT`.
68+
2. Fill in `Game IP` with the LAN IP of the game server.
69+
3. Click `Ping` to make sure you can touch the server.
70+
4. Start the game. Click `Inject` when you are at the game menu.
71+
72+
### v1.0
73+
4574
1. Execute `civrip.exe`
4675
2. Click `Install WinIPB` or `Install TAP` if status is `UNINST`.
4776
3. Click `Restart WinIPB` or `Restart TAP` if status is `STOPPED` or `UNKNOWN`.
@@ -51,7 +80,32 @@ Download the latest release on the [release page](https://github.com/MXWXZ/civri
5180
7. Do not check any network setting and click `Connect`.
5281
8. If server status is `CONNECT`, go and play your game! Otherwise, please check the output by yourself.
5382

54-
### Troubleshooting
83+
## Troubleshooting
84+
85+
### v2.0 FAQ
86+
87+
> I am the game server, but I cannot find the LAN IP.
88+
89+
Please check EDGE connection below.
90+
91+
> I am joining others game, but I cannot ping the server.
92+
93+
Please make sure you have the LAN IP, check EDGE connection below and disable the firewall on the game server.
94+
95+
> I see errors after clicking the `Inject`.
96+
97+
Please start the game first and wait for the main menu. There will be two logs about `Injector` (for DX11 and DX12). It is expected to have one error log and one success log. It is OK when any of them reports success.
98+
99+
> I want to change the Game IP. Do I need to restart the game?
100+
101+
No. Click eject, modify the Game IP and inject again is OK.
102+
103+
> I am using 32-bit system. How to run?
104+
105+
Unfortunately, we do not support 32 bit officially. You can compile the project by yourself (see below).
106+
107+
### EDGE connection
108+
55109
These only work if your server status is `CONNECT`, otherwise please solve the server connection problem first.
56110

57111
If you cannot find the room or cannot connect to the room, please follow the steps below. Please check the game to see if you solve the problem after complete each step:
@@ -68,5 +122,24 @@ If you cannot find the room or cannot connect to the room, please follow the ste
68122

69123
If you can connect, but the connection is not stable, please check `Disable P2P` (and `Force TCP` if possible).
70124

125+
## Compile
126+
127+
It is possible that the injector and the main program are marked as virus by anti-virus softwares. This software and third-party dependencies are 100% open-source. You can compile the program by yourself.
128+
129+
Environment:
130+
- QT6
131+
- Visual Studio (C++ Desktop support is the minimum)
132+
133+
Compile:
134+
1. `cd detours/src` and run `nmake` (Please use VS x64 compile chains).
135+
2. Open `hook/hook.sln` and compile for `x64 | Release`.
136+
3. Open `civrip.pro` and compile for `Release`.
137+
138+
Third party:
139+
- WinIPBroadcast: https://github.com/dechamps/WinIPBroadcast
140+
- Tap Windows: https://community.openvpn.net/openvpn/wiki/GettingTapWindows
141+
- n2n: http://github.com/ntop/n2n
142+
- Injector: https://github.com/nefarius/Injector
143+
71144
## License
72145
GNU General Public License v3.0

README_zh_CN.md

Lines changed: 76 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
# civrip
2+
**100%开源**
3+
24
简单GUI为文明6及老游戏联机提供虚拟组网。
35

46
**本软件完全免费且开源,严禁任何形式的倒卖、二次封装售卖。**
57

68
**软件基于GPL3.0协议,二次修改前请遵循协议要求。**
79

10+
![main](./assets/main_cn.png)
11+
12+
813
## 为什么有这个项目?
914
文明6以及其他老游戏只支持局域网多人游戏(文明6官方服务器国内什么情况懂得都懂),常见的解决方法是创建一个虚拟局域网。
1015

@@ -13,7 +18,9 @@
1318
- [n2n](https://github.com/ntop/n2n): 类似Zerotier,不过需要自建一个协调服务器,当P2P不可用时中转流量。优点是可以指定加密类型和协议,对于国内网络环境比较友好。
1419
- VPN: 也是一种解决方法,不过对于臭打游戏的而言算是杀鸡用牛刀了,效果也不一定好。
1520

16-
文明6更是重量级,由于只搜索默认网卡的网段,但大部分上述方案都使用了虚拟网卡,因此还需要 [WinIPBroadcast](https://github.com/dechamps/WinIPBroadcast) 将数据包转发到所有网卡才能搜到房间。
21+
~~文明6更是重量级,由于只搜索默认网卡的网段,但大部分上述方案都使用了虚拟网卡,因此还需要 [WinIPBroadcast](https://github.com/dechamps/WinIPBroadcast) 将数据包转发到所有网卡才能搜到房间。~~
22+
23+
更新:感谢 @xaxys (https://github.com/xaxys/injciv6/tree/master) 提供的思路,现在可以采用hook函数的方式解决。
1724

1825
由于配置上述方案对于玩家而言太过复杂,群友的网络环境千奇百怪,因此我写了这个基于n2n的小工具来自动化大部分流程,基本上是基于文明6联机而优化的,其他老游戏应该也能使用。
1926

@@ -42,6 +49,30 @@ free
4249
## 客户端
4350
[release page](https://github.com/MXWXZ/civrip/releases)下载最新客户端。
4451

52+
53+
### v2.0
54+
55+
1. 双击打开 `civrip.exe`
56+
2. 如果客户端状态是 `未安装`,请点击 `安装 TAP`
57+
3. 如果客户端状态是 `已停止``未知`,请点击 `重启 TAP`
58+
4. 填写 `服务器 IP`,包括端口号。例如 `1.2.3.4:7654`
59+
5. 填写 `频道`,需要是服务器所定义的。例如 `civsix`
60+
6. 填写 `加密密钥`,可任意填写。例如 `114514`
61+
7. 不要选中任何重量级网络设置,点击 `连接`
62+
63+
如果你是房主:
64+
1. 确保服务器状态是 `已连接`
65+
2. 在日志里找到内网IP(例如 10.0.0.100)。
66+
3. 关闭防火墙,创建游戏房间并将IP告知其他人!
67+
68+
如果你要加入其他人的游戏:
69+
1. 确保服务器状态是 `已连接`
70+
2.`游戏IP` 中填写房主的内网IP。
71+
3. 点击 `Ping` 检测连接情况。
72+
4. 启动游戏,在主菜单界面点击 `注入`
73+
74+
### v1.0
75+
4576
1. 双击打开 `civrip.exe`
4677
2. 如果客户端状态是 `未安装`,请点击 `安装 WinIPB` 或者 `安装 TAP`
4778
3. 如果客户端状态是 `已停止``未知`,请点击 `重启 WinIPB` 或者 `重启 TAP`
@@ -51,7 +82,31 @@ free
5182
7. 不要选中任何重量级网络设置,点击 `连接`
5283
8. 如果服务器状态是 `已连接`,打开游戏开玩!否则你需要根据日志输出自行解决连接问题。
5384

54-
### 疑难杂症
85+
## 疑难杂症
86+
87+
### v2.0 FAQ
88+
89+
> 我是房主,但在日志里找不到内网IP。
90+
91+
请参见下方协调服务器连接问题。
92+
93+
> 我要加入其他人的游戏,但我Ping不通房主。
94+
95+
请先确保自己获取了内网IP,并参考下方解决协调服务器连接问题,最后让房主确保关闭防火墙。
96+
97+
> 我点击 `注入` 后有报错。
98+
99+
请先启动游戏,等待主菜单出现后注入。日志中会有两个 `Injector` 相关日志(分别对应DX11和DX12)。其中一个日志报错一个日志成功是正常现象,确保任意一个日志成功即可。
100+
101+
> 我要修改游戏IP,需要重启游戏么?
102+
103+
不需要,点击弹出,修改IP,重新注入即可。
104+
105+
> 我是32位系统,如何运行?
106+
107+
很不幸,目前我们并不对32位系统提供技术支持。你可以自行编译程序,理论上没有问题(见下方)。
108+
109+
### 协调服务器连接问题
55110
请注意,下面的方法仅限于服务器状态是 `已连接`,但是搜不到房间或进不去房间,如果你连服务器都无法连接则需要根据日志自行解决(通常是服务器配置问题,例如防火墙阻断)。
56111

57112
如果搜不到房或者无法连接进房,请尝试下面的步骤。注意请每做一步试一下问题是否解决,能否进入游戏:
@@ -68,5 +123,24 @@ free
68123

69124
如果可以连接,但是连接不稳定或很卡,请勾选 `禁用 P2P`(还是卡请同时勾选 `强制 TCP`)。
70125

126+
## 编译
127+
128+
由于程序存在线程注入高危操作,可能会被杀毒软件报毒。本程序及所有第三方软件均为100%开源,你可以自行编译程序。
129+
130+
环境:
131+
- QT6
132+
- Visual Studio (至少需要C++ Desktop组件)
133+
134+
编译
135+
1. `cd detours/src`,运行 `nmake` (请使用 VS x64 编译工具链)。
136+
2. 打开 `hook/hook.sln` 并编译 `x64 | Release`
137+
3. 打开 `civrip.pro` 并编译 `Release`
138+
139+
第三方软件:
140+
- WinIPBroadcast: https://github.com/dechamps/WinIPBroadcast
141+
- Tap Windows: https://community.openvpn.net/openvpn/wiki/GettingTapWindows
142+
- n2n: http://github.com/ntop/n2n
143+
- Injector: https://github.com/nefarius/Injector
144+
71145
## License
72146
GNU General Public License v3.0

assets/main_cn.png

240 KB
Loading

assets/main_en.png

242 KB
Loading

civrip.cpp

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,3 +460,90 @@ void CivRIP::closeEvent(QCloseEvent *event) {
460460
event->accept();
461461
}
462462
}
463+
464+
void CivRIP::on_pushButton_7_clicked() {
465+
QProcess process;
466+
process.startCommand("ping -w 2000 -n 2 " + ui->key_2->text());
467+
process.waitForFinished(-1);
468+
ui->output->append(process.readAll());
469+
}
470+
471+
void CivRIP::on_inject_clicked() {
472+
auto srvMgr = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
473+
if (!srvMgr) {
474+
ui->output->append(QString("OpenSCManager failed: %1").arg(GetLastError()));
475+
ChangeWinIPB(STATUS_WINIPB_UNKNOWN);
476+
return;
477+
}
478+
479+
auto srvDDK = OpenService(srvMgr, _T("WinIPBroadcast"), SERVICE_ALL_ACCESS);
480+
if (srvDDK) {
481+
SERVICE_STATUS_PROCESS ssStatus;
482+
if (!QueryService(srvMgr, srvDDK, &ssStatus)) {
483+
ChangeWinIPB(STATUS_WINIPB_UNKNOWN);
484+
return;
485+
}
486+
487+
ControlService(srvDDK, SERVICE_CONTROL_STOP,
488+
(LPSERVICE_STATUS)&ssStatus); // ignore stop error
489+
while (ssStatus.dwCurrentState != SERVICE_STOPPED) {
490+
auto dwWaitTime = ssStatus.dwWaitHint / 10;
491+
if (dwWaitTime < 1000)
492+
dwWaitTime = 1000;
493+
else if (dwWaitTime > 10000)
494+
dwWaitTime = 10000;
495+
Sleep(dwWaitTime);
496+
497+
if (!QueryService(srvMgr, srvDDK, &ssStatus)) {
498+
ChangeWinIPB(STATUS_WINIPB_UNKNOWN);
499+
return;
500+
}
501+
if (ssStatus.dwCurrentState == SERVICE_STOPPED)
502+
break;
503+
}
504+
ui->output->append(QString("WinIPBroadcast Stopped"));
505+
ChangeWinIPB(STATUS_WINIPB_STOPPED);
506+
repaint();
507+
} else {
508+
ChangeWinIPB(STATUS_WINIPB_UNINSTALLED);
509+
}
510+
511+
if (srvMgr)
512+
CloseServiceHandle(srvMgr);
513+
if (srvDDK)
514+
CloseServiceHandle(srvDDK);
515+
516+
QFile file("address.txt");
517+
file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate);
518+
QTextStream out(&file);
519+
out << ui->key_2->text();
520+
file.close();
521+
522+
if (ui->inject->text() == tr("Inject")) {
523+
QProcess process;
524+
process.startCommand("Injector.exe -n CivilizationVI.exe -i hook.dll");
525+
process.waitForFinished(-1);
526+
ui->output->append(process.readAllStandardOutput());
527+
ui->output->append(process.readAllStandardError());
528+
529+
process.startCommand("Injector.exe -n CivilizationVI_DX12.exe -i hook.dll");
530+
process.waitForFinished(-1);
531+
ui->output->append(process.readAllStandardOutput());
532+
ui->output->append(process.readAllStandardError());
533+
534+
ui->inject->setText(tr("Eject"));
535+
} else {
536+
QProcess process;
537+
process.startCommand("Injector.exe -n CivilizationVI.exe -e hook.dll");
538+
process.waitForFinished(-1);
539+
ui->output->append(process.readAllStandardOutput());
540+
ui->output->append(process.readAllStandardError());
541+
542+
process.startCommand("Injector.exe -n CivilizationVI_DX12.exe -e hook.dll");
543+
process.waitForFinished(-1);
544+
ui->output->append(process.readAllStandardOutput());
545+
ui->output->append(process.readAllStandardError());
546+
547+
ui->inject->setText(tr("Inject"));
548+
}
549+
}

civrip.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef CIVRIP_H
22
#define CIVRIP_H
33

4-
#define VERSION "1.0.0"
4+
#define VERSION "2.0.0"
55

66
#include <QMainWindow>
77
#include <QProcess>
@@ -69,7 +69,11 @@ private slots:
6969

7070
void closeEvent(QCloseEvent *event) override;
7171

72-
private:
72+
void on_pushButton_7_clicked();
73+
74+
void on_inject_clicked();
75+
76+
private:
7377
QProcess edge;
7478
QTranslator *translator;
7579
Ui::CivRIP *ui;

0 commit comments

Comments
 (0)