Skip to content

Commit

Permalink
fix implementation ddper
Browse files Browse the repository at this point in the history
  • Loading branch information
k-i-o committed Oct 10, 2024
1 parent f6a0326 commit dfdb317
Show file tree
Hide file tree
Showing 9 changed files with 124 additions and 57 deletions.
2 changes: 1 addition & 1 deletion src/interfaces/IBase.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export interface IBase {
enabled?: boolean;
hotkeys: number[];
execute(delta: number): void;
execute(profile: string, delta: number): void;
}
2 changes: 1 addition & 1 deletion src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ app.whenReady().then(() => {
optimizer.watchWindowShortcuts(window)
});

Offsets.getInstance().loadDefaultOffsets();
Offsets.getInstance().loadAllDefaultOffsets();

updater();

Expand Down
6 changes: 3 additions & 3 deletions src/main/models/cheats/Aimbot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);

}

Expand Down
16 changes: 8 additions & 8 deletions src/main/models/cheats/Balancer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/models/cheats/Spinbot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
}
}
88 changes: 75 additions & 13 deletions src/main/models/singletons/Offsets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class Offsets {
return Offsets.instance;
}

loadDefaultOffsets() {
loadAllDefaultOffsets() {
this.profiles["DDNet"] = {
exeName: "DDNet.exe",
staticServerAddr: BigInt(0x5C1900),
Expand All @@ -66,7 +66,7 @@ export class Offsets {
}

this.profiles["DDPer"] = {
exeName: "DDPer.exe",
exeName: "DDPER.exe",
staticServerAddr: BigInt(0x33DD18),
staticClientAddr: BigInt(0x2F2CB8),
client: {
Expand All @@ -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;

}

}
}
14 changes: 7 additions & 7 deletions src/main/models/singletons/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class Server {
return Server.instance;
}

update() {
update(profile) {
const systemVar = Variables.getInstance().system;
if (!systemVar.baseServerAddr) return;

Expand All @@ -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
}

Expand Down
38 changes: 21 additions & 17 deletions src/main/workers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-currency"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M12 12m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0" /><path d="M4 4l3 3" /><path d="M20 4l-3 3" /><path d="M4 20l3 -3" /><path d="M20 20l-3 -3" /></svg>',
Expand Down Expand Up @@ -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);
}

});
Expand All @@ -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 => {
Expand Down Expand Up @@ -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;

Expand All @@ -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}) => {
Expand All @@ -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);
}
});

Expand Down
9 changes: 5 additions & 4 deletions src/renderer/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ let settings: Ref<ISetting[]> = ref([]);
let activeCategory: Ref<IMenuCheatCategory | undefined> = 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;
Expand Down Expand Up @@ -135,7 +137,7 @@ on('getCheatsAndOffsetsResponse', (_, {cheats,offsets,profiles,currentProfile})
id: 'reset all',
type: 'button',
onChange: () => {
send('resetOffsets');
send('resetOffsets', selectedProfile);
}
},
{
Expand All @@ -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 });
}
});
}
Expand All @@ -155,6 +157,7 @@ on('getCheatsAndOffsetsResponse', (_, {cheats,offsets,profiles,currentProfile})
value: {profileName:currentProfile??'DDNet'},
list: profiles,
onChange: ({profileName}) => {
selectedProfile = profileName;
send('setNewProfile', profileName);
}
}
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit dfdb317

Please sign in to comment.