Skip to content

Commit 2c0d32f

Browse files
committed
added option to disable anti-cheat and VAC
1 parent 99b484d commit 2c0d32f

10 files changed

Lines changed: 193 additions & 12 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dayz-sp",
3-
"version": "1.0.3",
3+
"version": "1.0.4",
44
"description": "DayZ-SP",
55
"repository": {
66
"type": "git",

src/index.html

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,15 @@ <h2 class="mods-header">
7575
</div>
7676
<div class="options-container">
7777
<h2 class="options-header">Options</h2>
78-
<div class="option-item">
79-
<input type="checkbox" id="quick-join" />
80-
<label for="quick-join" class="option-label">Quick Join</label>
78+
<div class="options-grid">
79+
<div class="option-item">
80+
<input type="checkbox" id="quick-join" />
81+
<label for="quick-join" class="option-label">Quick Join</label>
82+
</div>
83+
<div class="option-item">
84+
<input type="checkbox" id="disable-be" />
85+
<label for="disable-be" class="option-label">Disable BE</label>
86+
</div>
8187
</div>
8288
</div>
8389
<div class="button-row">

src/main.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const fsp = require("fs/promises");
55
const path = require("path");
66
const os = require("os");
77
const https = require("https");
8+
const patcher = require("./scripts/Patcher/patcher");
89

910
const APP_VERSION = app.getVersion();
1011

@@ -296,6 +297,8 @@ ipcMain.handle("dayz:scan-presets", async () => {
296297

297298
let isServerRunning = false;
298299
let isGameRunning = false;
300+
let wasPatched = false;
301+
let lastServerExePath = null;
299302
const SERVER_NAME_ARG = "-serverName=DayZ_SPL";
300303

301304
function killServer() {
@@ -313,6 +316,11 @@ function checkProcesses() {
313316
exec(`wmic process where "name='DayZServer_x64.exe'" get commandline`, (error, stdout) => {
314317
const running = !error && stdout.includes(SERVER_NAME_ARG);
315318
if (running !== isServerRunning) {
319+
if (isServerRunning && !running && wasPatched && lastServerExePath) {
320+
console.log("Server stopped, restoring original executable...");
321+
patcher.restoreFile(lastServerExePath);
322+
wasPatched = false;
323+
}
316324
isServerRunning = running;
317325
broadcastUpdate("dayz:process-status", { running: isServerRunning });
318326
}
@@ -991,6 +999,18 @@ ipcMain.handle("dayz:launch", async (_event, dayzServerPath, map) => {
991999
await saveSettings(settings);
9921000

9931001

1002+
const serverExePath = path.join(dayzServerPath, "DayZServer_x64.exe");
1003+
lastServerExePath = serverExePath;
1004+
if (settings.disableBE) {
1005+
console.log("Disable BE requested, patching server...");
1006+
wasPatched = patcher.patchFile(serverExePath);
1007+
} else {
1008+
1009+
patcher.restoreFile(serverExePath);
1010+
wasPatched = false;
1011+
}
1012+
1013+
9941014
try {
9951015
const serverBatchPath = path.join(dayzServerPath, "!DayzSPL.bat");
9961016
shell.openPath(serverBatchPath);

src/renderer.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const bgLayers = [document.getElementById("bg-1"), document.getElementById("bg-2
77
const mapOptions = document.querySelectorAll(".map-option");
88
const continueBtn = document.querySelector(".continue-button");
99
const quickJoinCheckbox = document.getElementById("quick-join");
10+
const disableBECheckbox = document.getElementById("disable-be");
1011

1112
const updateLink = document.getElementById("update-link");
1213
window.appInfo.checkUpdate().then(result => {
@@ -160,12 +161,18 @@ quickJoinCheckbox?.addEventListener("change", () => {
160161
window.appInfo?.saveSetting?.("quickJoin", quickJoinCheckbox.checked);
161162
});
162163

164+
disableBECheckbox?.addEventListener("change", () => {
165+
window.appInfo?.saveSetting?.("disableBE", disableBECheckbox.checked);
166+
});
167+
163168

164169
(async () => {
165170
const savedMap = await window.appInfo?.getSetting?.("selectedMap") || "chernarus";
166171
const quickJoin = await window.appInfo?.getSetting?.("quickJoin") || false;
172+
const disableBE = await window.appInfo?.getSetting?.("disableBE") || false;
167173

168174
if (quickJoinCheckbox) quickJoinCheckbox.checked = quickJoin;
175+
if (disableBECheckbox) disableBECheckbox.checked = disableBE;
169176

170177
mapOptions.forEach(opt => {
171178
opt.classList.toggle("active", opt.dataset.map === savedMap);

src/scripts/!Dayz.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
start "" DayZ_BE.exe ^
1+
start "" DayZ_x64.exe ^
22
-mod= ^
33
-connect=127.0.0.1 ^
44
-port=2302 ^

src/scripts/!DayzSPL.bat

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@ set PROFILES_FOLDER=Profiles\DayzSPL
1111
set MOD_LIST=
1212

1313
:: Start the server with mods
14-
start "" /b "DayZServer_x64.exe" ^
14+
start "" /b /min "DayZServer_x64.exe" ^
1515
-serverName=%serverName% ^
1616
-config=%CONFIG_FILE% ^
1717
-port=%SERVER_PORT% ^
1818
-profiles=%PROFILES_FOLDER% ^
1919
-freezecheck ^
20-
-noBattlEye ^
2120
-mod=%MOD_LIST%
2221

2322
exit

src/scripts/DayzSPL.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
hostname = "DayzSPL"; // Server name
22
password = ""; // Password to connect to the server
33
passwordAdmin = ""; // Password to become a server admin
4-
BattlEye=0;
4+
55
description = ""; // Description of the server. Gets displayed to users in client server browser.
66

77
enableWhitelist = 0; // Enable/disable whitelist (value 0-1)

src/scripts/Patcher/patcher.js

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
4+
/**
5+
* Patches a DayZ Server executable.
6+
* @param {string} filePath Path to the .exe file
7+
*/
8+
function patchFile(filePath) {
9+
if (!fs.existsSync(filePath)) {
10+
console.error(`Error: File not found at ${filePath}`);
11+
return false;
12+
}
13+
14+
console.log(`Reading ${filePath}...`);
15+
let buffer;
16+
try {
17+
buffer = fs.readFileSync(filePath);
18+
} catch (err) {
19+
console.error(`Error reading file: ${err.message}`);
20+
return false;
21+
}
22+
23+
// Create backup if it doesn't exist or we want to overwrite
24+
const backupPath = filePath + '.bak';
25+
try {
26+
// Only create backup if it doesn't exist, to preserve the "original" clean copy
27+
if (!fs.existsSync(backupPath)) {
28+
fs.writeFileSync(backupPath, buffer);
29+
console.log(`Backup created: ${backupPath}`);
30+
} else {
31+
console.log(`Using existing backup: ${backupPath}`);
32+
}
33+
} catch (err) {
34+
console.error(`Error creating backup: ${err.message}`);
35+
return false;
36+
}
37+
38+
/**
39+
* Scans for a hex pattern and applies a patch if found.
40+
* @param {string} patternStr Hex string pattern (use '?' for wildcards)
41+
* @param {number[]|Buffer} patchBytes Bytes to write
42+
* @param {string} label Descriptive name for the patch
43+
*/
44+
function scanAndPatch(patternStr, patchBytes, label) {
45+
const pattern = patternStr.split(' ').map(x => x === '?' ? null : parseInt(x, 16));
46+
47+
for (let i = 0; i <= buffer.length - pattern.length; i++) {
48+
let match = true;
49+
for (let j = 0; j < pattern.length; j++) {
50+
if (pattern[j] !== null && buffer[i + j] !== pattern[j]) {
51+
match = false;
52+
break;
53+
}
54+
}
55+
if (match) {
56+
const patchBuf = Buffer.isBuffer(patchBytes) ? patchBytes : Buffer.from(patchBytes);
57+
patchBuf.copy(buffer, i);
58+
console.log(`Applied patch: ${label}`);
59+
return true;
60+
}
61+
}
62+
console.log(`Pattern not found for: ${label}`);
63+
return false;
64+
}
65+
66+
let patched = false;
67+
68+
// 1. Patch BattlEye Init
69+
if (scanAndPatch(
70+
"40 53 55 56 57 41 54 48 81 EC ? ? ? ? 45 33 E4 48 8B D9 44 89",
71+
[0xB0, 0x01, 0xC3],
72+
"BattlEye Init"
73+
)) patched = true;
74+
75+
// 2. Patch VAC Check
76+
if (scanAndPatch(
77+
"74 44 0F B7 C8 E8 ? ? ? ? 8B 13 44 0F B7 C0 44 89 4C 24 ? 48",
78+
[0xEB],
79+
"VAC Check"
80+
)) patched = true;
81+
82+
// 3. Patch Title
83+
const newTitle = Buffer.alloc(15, 0);
84+
Buffer.from("Patched version").copy(newTitle);
85+
if (scanAndPatch(
86+
"43 6F 6E 73 6F 6C 65 20 76",
87+
newTitle,
88+
"Server Title"
89+
)) patched = true;
90+
91+
if (patched) {
92+
try {
93+
fs.writeFileSync(filePath, buffer);
94+
console.log("File patched and saved successfully.");
95+
return true;
96+
} catch (err) {
97+
console.error(`Error saving patched file: ${err.message}`);
98+
return false;
99+
}
100+
}
101+
return false;
102+
}
103+
104+
/**
105+
* Restores the original DayZ Server executable from backup.
106+
* @param {string} filePath Path to the .exe file
107+
*/
108+
function restoreFile(filePath) {
109+
const backupPath = filePath + '.bak';
110+
if (fs.existsSync(backupPath)) {
111+
try {
112+
// Check if the current file is actually different (optional, but safer)
113+
if (fs.existsSync(filePath)) {
114+
fs.unlinkSync(filePath);
115+
}
116+
fs.copyFileSync(backupPath, filePath);
117+
// We keep the backup so we can patch again later
118+
console.log(`Restored original file from ${backupPath}`);
119+
return true;
120+
} catch (err) {
121+
console.error(`Error restoring file: ${err.message}`);
122+
return false;
123+
}
124+
} else {
125+
console.log("No backup found to restore.");
126+
return false;
127+
}
128+
}
129+
130+
module.exports = {
131+
patchFile,
132+
restoreFile
133+
};
134+
135+
// CLI Execution
136+
if (require.main === module) {
137+
const target = process.argv[2];
138+
if (target) {
139+
patchFile(path.resolve(target));
140+
} else {
141+
console.log("Usage: node patcher.js <path_to_dayz_server_exe>");
142+
}
143+
}

src/styles.css

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -833,18 +833,24 @@ input[type="checkbox"] {
833833
border-top-right-radius: 8px;
834834
}
835835

836+
.options-grid {
837+
display: grid;
838+
grid-template-columns: 1fr 1fr;
839+
padding: 4px 0 0;
840+
}
841+
836842
.option-item {
837843
display: flex;
838844
align-items: center;
839-
padding: 0 10px;
845+
justify-content: center;
840846
}
841847

842848
.option-label {
843849
font-size: 0.65rem;
844850
color: rgba(237, 234, 225, 0.6);
845851
font-family: 'Consolas', 'Courier New', monospace;
846852
cursor: pointer;
847-
margin-left: 12px;
853+
/* margin-left: 12px; */
848854
}
849855

850856
#loading-spinner {

0 commit comments

Comments
 (0)