From dfdb317dbd9fc7f1638e698cf1bc692da71514d5 Mon Sep 17 00:00:00 2001 From: k-i-o Date: Thu, 10 Oct 2024 15:41:31 +0200 Subject: [PATCH] fix implementation ddper --- src/interfaces/IBase.ts | 2 +- src/main/index.ts | 2 +- src/main/models/cheats/Aimbot.ts | 6 +- src/main/models/cheats/Balancer.ts | 16 ++--- src/main/models/cheats/Spinbot.ts | 6 +- src/main/models/singletons/Offsets.ts | 88 +++++++++++++++++++++++---- src/main/models/singletons/Server.ts | 14 ++--- src/main/workers.ts | 38 ++++++------ src/renderer/src/App.vue | 9 +-- 9 files changed, 124 insertions(+), 57 deletions(-) diff --git a/src/interfaces/IBase.ts b/src/interfaces/IBase.ts index bba63c8..3915d37 100644 --- a/src/interfaces/IBase.ts +++ b/src/interfaces/IBase.ts @@ -1,5 +1,5 @@ export interface IBase { enabled?: boolean; hotkeys: number[]; - execute(delta: number): void; + execute(profile: string, delta: number): void; } \ No newline at end of file diff --git a/src/main/index.ts b/src/main/index.ts index 5566a01..f2ceb31 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -48,7 +48,7 @@ app.whenReady().then(() => { optimizer.watchWindowShortcuts(window) }); - Offsets.getInstance().loadDefaultOffsets(); + Offsets.getInstance().loadAllDefaultOffsets(); updater(); diff --git a/src/main/models/cheats/Aimbot.ts b/src/main/models/cheats/Aimbot.ts index 59af7c0..0e26b45 100644 --- a/src/main/models/cheats/Aimbot.ts +++ b/src/main/models/cheats/Aimbot.ts @@ -14,7 +14,7 @@ export class Aimbot implements IBase { hotkeys: number[] = []; holdHotkeys: boolean = false; - execute(delta: number): void { + execute(profile: string, delta: number): void { const systemVar = Variables.getInstance().system; const localplayer = Server.getInstance().localPlayer; if (!systemVar.baseClientAddr || !localplayer) return; @@ -24,8 +24,8 @@ export class Aimbot implements IBase { const target = { x: nearest.position.x - localplayer.position.x, y: nearest.position.y - localplayer.position.y }; - writeMemory(Variables.getInstance().system.handle, Variables.getInstance().system.baseClientAddr! + Offsets.getInstance().client.aimX, target.x, FLOAT); - writeMemory(Variables.getInstance().system.handle, Variables.getInstance().system.baseClientAddr! + Offsets.getInstance().client.aimY, target.y, FLOAT); + writeMemory(Variables.getInstance().system.handle, Variables.getInstance().system.baseClientAddr! + Offsets.getInstance().profiles[profile].client.aimX, target.x, FLOAT); + writeMemory(Variables.getInstance().system.handle, Variables.getInstance().system.baseClientAddr! + Offsets.getInstance().profiles[profile].client.aimY, target.y, FLOAT); } diff --git a/src/main/models/cheats/Balancer.ts b/src/main/models/cheats/Balancer.ts index 58a9753..683f48a 100644 --- a/src/main/models/cheats/Balancer.ts +++ b/src/main/models/cheats/Balancer.ts @@ -14,7 +14,7 @@ export class Balancer implements IBase { hotkeys: number[] = []; holdHotkeys: boolean = false; - execute(delta: number): void { + execute(profile: string, delta: number): void { const systemVar = Variables.getInstance().system; const localPlayer = Server.getInstance().localPlayer; if (!systemVar.baseClientAddr || !localPlayer) return; @@ -23,24 +23,24 @@ export class Balancer implements IBase { if(!nearest) return; if(localPlayer.position.x > nearest.position.x){ - writeMemory(Variables.getInstance().system.handle, Variables.getInstance().system.baseClientAddr! + Offsets.getInstance().client.rWalk, 0, INT); - writeMemory(Variables.getInstance().system.handle, Variables.getInstance().system.baseClientAddr! + Offsets.getInstance().client.lWalk, 1, INT); + writeMemory(Variables.getInstance().system.handle, Variables.getInstance().system.baseClientAddr! + Offsets.getInstance().profiles[profile].client.rWalk, 0, INT); + writeMemory(Variables.getInstance().system.handle, Variables.getInstance().system.baseClientAddr! + Offsets.getInstance().profiles[profile].client.lWalk, 1, INT); } if(localPlayer.position.x < nearest.position.x){ - writeMemory(Variables.getInstance().system.handle, Variables.getInstance().system.baseClientAddr! + Offsets.getInstance().client.lWalk, 0, INT); - writeMemory(Variables.getInstance().system.handle, Variables.getInstance().system.baseClientAddr! + Offsets.getInstance().client.rWalk, 1, INT); + writeMemory(Variables.getInstance().system.handle, Variables.getInstance().system.baseClientAddr! + Offsets.getInstance().profiles[profile].client.lWalk, 0, INT); + writeMemory(Variables.getInstance().system.handle, Variables.getInstance().system.baseClientAddr! + Offsets.getInstance().profiles[profile].client.rWalk, 1, INT); } this.needReset = true; } - resetWalk(): void { + resetWalk(profile: string): void { const systemVar = Variables.getInstance().system; if (!systemVar.baseClientAddr) return; - writeMemory(systemVar.handle, systemVar.baseClientAddr! + Offsets.getInstance().client.lWalk, 0, INT); - writeMemory(systemVar.handle, systemVar.baseClientAddr! + Offsets.getInstance().client.rWalk, 0, INT); + writeMemory(systemVar.handle, systemVar.baseClientAddr! + Offsets.getInstance().profiles[profile].client.lWalk, 0, INT); + writeMemory(systemVar.handle, systemVar.baseClientAddr! + Offsets.getInstance().profiles[profile].client.rWalk, 0, INT); this.needReset = false; } diff --git a/src/main/models/cheats/Spinbot.ts b/src/main/models/cheats/Spinbot.ts index c35a00d..19a267b 100644 --- a/src/main/models/cheats/Spinbot.ts +++ b/src/main/models/cheats/Spinbot.ts @@ -15,7 +15,7 @@ export class Spinbot implements IBase { hotkeys: number[] = []; holdHotkeys: boolean = false; - execute(delta: number) { + execute(profile: string, delta: number) { const systemVar = Variables.getInstance().system; if (!systemVar.baseClientAddr) return; @@ -26,7 +26,7 @@ export class Spinbot implements IBase { const x = Math.sin(radians) * this.distance; const y = Math.cos(radians) * this.distance; - writeMemory(systemVar.handle, systemVar.baseClientAddr + Offsets.getInstance().client.aimX, x, FLOAT); - writeMemory(systemVar.handle, systemVar.baseClientAddr + Offsets.getInstance().client.aimY, y, FLOAT); + writeMemory(systemVar.handle, systemVar.baseClientAddr + Offsets.getInstance().profiles[profile].client.aimX, x, FLOAT); + writeMemory(systemVar.handle, systemVar.baseClientAddr + Offsets.getInstance().profiles[profile].client.aimY, y, FLOAT); } } \ No newline at end of file diff --git a/src/main/models/singletons/Offsets.ts b/src/main/models/singletons/Offsets.ts index 205f081..e70f2f6 100644 --- a/src/main/models/singletons/Offsets.ts +++ b/src/main/models/singletons/Offsets.ts @@ -39,7 +39,7 @@ export class Offsets { return Offsets.instance; } - loadDefaultOffsets() { + loadAllDefaultOffsets() { this.profiles["DDNet"] = { exeName: "DDNet.exe", staticServerAddr: BigInt(0x5C1900), @@ -66,7 +66,7 @@ export class Offsets { } this.profiles["DDPer"] = { - exeName: "DDPer.exe", + exeName: "DDPER.exe", staticServerAddr: BigInt(0x33DD18), staticClientAddr: BigInt(0x2F2CB8), client: { @@ -76,18 +76,80 @@ export class Offsets { rWalk: BigInt(0xF8), }, server: { - localPlayerId: BigInt(0x1450), - onlinePlayers: BigInt(0x1454), - gametick: BigInt(0x147C), - playerX: BigInt(0x1480), - playerY: BigInt(0x1484), - velX: BigInt(0x1488), - velY: BigInt(0x148C), - aimAngle: BigInt(0x1490), - frozenTime: BigInt(0x14C0), - frozen: BigInt(0x14CC), - hookingTime: BigInt(0x14A4) + localPlayerId: BigInt(0x1428), + onlinePlayers: BigInt(0x142C), + gametick: BigInt(0x1454), + playerX: BigInt(0x1458), + playerY: BigInt(0x145C), + velX: BigInt(0x1460), + velY: BigInt(0x1464), + aimAngle: BigInt(0x1468), + frozenTime: BigInt(0x1498), + frozen: BigInt(0x14A4), + hookingTime: BigInt(0x147C) } } } + + + loadDefaultOffsets(profile: string) { + + switch(profile) { + case "DDNet": + this.profiles["DDNet"] = { + exeName: "DDNet.exe", + staticServerAddr: BigInt(0x5C1900), + staticClientAddr: BigInt(0x463C20), + client: { + aimX: BigInt(0x10), + aimY: BigInt(0x14), + lWalk: BigInt(0x100), + rWalk: BigInt(0x108), + }, + server: { + localPlayerId: BigInt(0x1450), + onlinePlayers: BigInt(0x1454), + gametick: BigInt(0x147C), + playerX: BigInt(0x1480), + playerY: BigInt(0x1484), + velX: BigInt(0x1488), + velY: BigInt(0x148C), + aimAngle: BigInt(0x1490), + frozenTime: BigInt(0x14C0), + frozen: BigInt(0x14CC), + hookingTime: BigInt(0x14A4) + } + }; + break; + + case "DDPer": + this.profiles["DDPer"] = { + exeName: "DDPER.exe", + staticServerAddr: BigInt(0x33DD18), + staticClientAddr: BigInt(0x2F2CB8), + client: { + aimX: BigInt(0x10), + aimY: BigInt(0x14), + lWalk: BigInt(0xF0), + rWalk: BigInt(0xF8), + }, + server: { + localPlayerId: BigInt(0x1428), + onlinePlayers: BigInt(0x142C), + gametick: BigInt(0x1454), + playerX: BigInt(0x1458), + playerY: BigInt(0x145C), + velX: BigInt(0x1460), + velY: BigInt(0x1464), + aimAngle: BigInt(0x1468), + frozenTime: BigInt(0x1498), + frozen: BigInt(0x14A4), + hookingTime: BigInt(0x147C) + } + } + break; + + } + + } } \ No newline at end of file diff --git a/src/main/models/singletons/Server.ts b/src/main/models/singletons/Server.ts index f05fded..7b82617 100644 --- a/src/main/models/singletons/Server.ts +++ b/src/main/models/singletons/Server.ts @@ -19,7 +19,7 @@ export class Server { return Server.instance; } - update() { + update(profile) { const systemVar = Variables.getInstance().system; if (!systemVar.baseServerAddr) return; @@ -29,19 +29,19 @@ export class Server { return readMemory(systemVar.handle, baseAddr + offset, type); } - this.onlinePlayers = read(Offsets.getInstance().server.onlinePlayers, INT); - const localPlayerId = read(Offsets.getInstance().server.localPlayerId, INT); + this.onlinePlayers = read(Offsets.getInstance().profiles[profile].server.onlinePlayers, INT); + const localPlayerId = read(Offsets.getInstance().profiles[profile].server.localPlayerId, INT); this.players = []; for(let i = 0; i < this.maxPlayers; i++) { let offsetPlayers = BigInt(i * 0xF8); const player: IPlayer = { id: i, - gametick: read(Offsets.getInstance().server.gametick + offsetPlayers, INT), - position: { x: read(Offsets.getInstance().server.playerX + offsetPlayers, INT), y: read(Offsets.getInstance().server.playerY + offsetPlayers, INT) }, - velocity: { x: read(Offsets.getInstance().server.velX + offsetPlayers, INT), y: read(Offsets.getInstance().server.velY + offsetPlayers, INT) }, + gametick: read(Offsets.getInstance().profiles[profile].server.gametick + offsetPlayers, INT), + position: { x: read(Offsets.getInstance().profiles[profile].server.playerX + offsetPlayers, INT), y: read(Offsets.getInstance().profiles[profile].server.playerY + offsetPlayers, INT) }, + velocity: { x: read(Offsets.getInstance().profiles[profile].server.velX + offsetPlayers, INT), y: read(Offsets.getInstance().profiles[profile].server.velY + offsetPlayers, INT) }, // hookingTime: read(Offsets.getInstance().server.hookingTime + offsetPlayers, FLOAT), - frozen: read(Offsets.getInstance().server.frozen + offsetPlayers, BOOL), + frozen: read(Offsets.getInstance().profiles[profile].server.frozen + offsetPlayers, BOOL), playerSize: 64 } diff --git a/src/main/workers.ts b/src/main/workers.ts index 9b9fa9b..bccea68 100644 --- a/src/main/workers.ts +++ b/src/main/workers.ts @@ -7,6 +7,8 @@ import { Variables } from './models/singletons/Variables'; import { IMenuCheatCategory } from '../interfaces/IMenuCheatCategory'; import { compareArrays, convertScanCodeToKeyCode, getHotkeys, handleCheatToggle, rgbToHex } from './utils'; +let lastProfileSelected = "DDNet"; + const getCategories = (): IMenuCheatCategory[] => [ { icon: '', @@ -341,20 +343,20 @@ export function updater() { delta = now - time; time = now; - Server.getInstance().update(); + Server.getInstance().update(lastProfileSelected); if(Variables.getInstance().spinbot.enabled) { - Variables.getInstance().spinbot.execute(delta); + Variables.getInstance().spinbot.execute(lastProfileSelected, delta); } if(Variables.getInstance().aimbot.enabled) { - Variables.getInstance().aimbot.execute(delta); + Variables.getInstance().aimbot.execute(lastProfileSelected, delta); } if(Variables.getInstance().balancer.enabled) { - Variables.getInstance().balancer.execute(delta); + Variables.getInstance().balancer.execute(lastProfileSelected, delta); } else if (Variables.getInstance().balancer.needReset) { - Variables.getInstance().balancer.resetWalk(); + Variables.getInstance().balancer.resetWalk(lastProfileSelected); } }); @@ -364,8 +366,6 @@ function getProfiles() { return Object.keys(Offsets.getInstance().profiles).map(s=> {return {profileName:s}}); } -let lastProfileSelected = "DDNet"; - export function ipcListeners(window: BrowserWindow | null) { const proceed = (needGame: boolean): boolean => { @@ -396,15 +396,15 @@ export function ipcListeners(window: BrowserWindow | null) { return; } - const DDNetClient = Offsets.getInstance().profiles["DDNet"].exeName; + const DDNetClient = Offsets.getInstance().profiles[lastProfileSelected].exeName; try { const proc = openProcess(DDNetClient); Variables.getInstance().system.handle = proc.handle; const base = BigInt(proc.modBaseAddr); - Variables.getInstance().system.baseServerAddr = readMemory(Variables.getInstance().system.handle, base + Offsets.getInstance().profiles["DDNet"].staticServerAddr, PTR); - Variables.getInstance().system.baseClientAddr = readMemory(Variables.getInstance().system.handle, base + Offsets.getInstance().profiles["DDNet"].staticClientAddr, PTR); + Variables.getInstance().system.baseServerAddr = readMemory(Variables.getInstance().system.handle, base + Offsets.getInstance().profiles[lastProfileSelected].staticServerAddr, PTR); + Variables.getInstance().system.baseClientAddr = readMemory(Variables.getInstance().system.handle, base + Offsets.getInstance().profiles[lastProfileSelected].staticClientAddr, PTR); Variables.getInstance().system.gameAttached = true; @@ -431,9 +431,9 @@ export function ipcListeners(window: BrowserWindow | null) { // } // }); - ipcMain.on('resetOffsets', (event) => { - Offsets.getInstance().loadDefaultOffsets(); - event.reply('getCheatsAndOffsetsResponse', { cheats: getCategories(), offsets: getOffsets(lastProfileSelected), profiles: getProfiles() }); + ipcMain.on('resetOffsets', (event, profile) => { + Offsets.getInstance().loadDefaultOffsets(profile); + event.reply('getCheatsAndOffsetsResponse', { cheats: getCategories(), offsets: getOffsets(profile), profiles: getProfiles() }); }); ipcMain.on('newHotkeys', (_, {cheatId, componentId, newValue}) => { @@ -453,13 +453,17 @@ export function ipcListeners(window: BrowserWindow | null) { Variables.getInstance()[cheatId][componentId] = newValue; }); - ipcMain.on('updateOffset', (_, {ids, value}) => { + ipcMain.on('updateOffset', (_, {ids, value, profile}) => { if(ids.length == 1) { - Offsets.getInstance()[ids[0]] = BigInt(value); + if(ids[0] == "exeName") { + Offsets.getInstance().profiles[profile][ids[0]] = value; + } else { + Offsets.getInstance().profiles[profile][ids[0]] = BigInt(value); + } } else if (ids.length == 2) { - Offsets.getInstance()[ids[0]][ids[1]] = BigInt(value); + Offsets.getInstance().profiles[profile][ids[0]][ids[1]] = BigInt(value); } else if (ids.length == 3) { - Offsets.getInstance()[ids[0]][ids[1]][ids[2]] = BigInt(value); + Offsets.getInstance().profiles[profile][ids[0]][ids[1]][ids[2]] = BigInt(value); } }); diff --git a/src/renderer/src/App.vue b/src/renderer/src/App.vue index 3b8eefb..ec7d1bf 100644 --- a/src/renderer/src/App.vue +++ b/src/renderer/src/App.vue @@ -26,6 +26,8 @@ let settings: Ref = ref([]); let activeCategory: Ref = ref(); let activeSetting: Ref<{id:string,icon:string,options:any[]} | undefined> = ref(); +let selectedProfile = "DDNet"; + const send = window.electron.ipcRenderer.send; const on = window.electron.ipcRenderer.on; @@ -135,7 +137,7 @@ on('getCheatsAndOffsetsResponse', (_, {cheats,offsets,profiles,currentProfile}) id: 'reset all', type: 'button', onChange: () => { - send('resetOffsets'); + send('resetOffsets', selectedProfile); } }, { @@ -144,7 +146,7 @@ on('getCheatsAndOffsetsResponse', (_, {cheats,offsets,profiles,currentProfile}) onChange: () => { offsetsOptions.forEach(o => { if(o.ids) { - send('updateOffset', { ids: o.ids, value: o.value }); + send('updateOffset', { ids: o.ids, value: o.value, profile: selectedProfile }); } }); } @@ -155,6 +157,7 @@ on('getCheatsAndOffsetsResponse', (_, {cheats,offsets,profiles,currentProfile}) value: {profileName:currentProfile??'DDNet'}, list: profiles, onChange: ({profileName}) => { + selectedProfile = profileName; send('setNewProfile', profileName); } } @@ -302,8 +305,6 @@ on('getCheatsAndOffsetsResponse', (_, {cheats,offsets,profiles,currentProfile}) const color = `#${value}`; root.style.setProperty('--c-t', color); - console.log(adjustAlpha(lighten(color, 11), 0.9), lighten(color, 11), adjustAlpha(color, 0.9)); - root.style.setProperty('--c-t-variant1', lighten(color, 6)); root.style.setProperty('--c-t-variant2', adjustAlpha(color, 0.8)); root.style.setProperty('--c-t-variant3', adjustAlpha(lighten(color, 11), 0.9));