Skip to content

Commit

Permalink
preliminary 830 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Truthlight committed Jun 4, 2022
1 parent 98e3b9c commit 347c43e
Show file tree
Hide file tree
Showing 11 changed files with 12,167 additions and 2,579 deletions.
5,117 changes: 2,560 additions & 2,557 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions src/core/domain/disableSpectate.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const flagsBufferSize = 4;
const flagsBuffer = new Buffer(flagsBufferSize);

function disableSpectate(Game, Memory, Offsets, Module) {
return (CameraStruct) => {
Expand All @@ -12,6 +14,12 @@ function disableSpectate(Game, Memory, Offsets, Module) {
} else if (Game.client === 'ctl') {
Memory.writeData(Module + Offsets[Game.client].SpectatePointer, Offsets[Game.client].DisableSpectate, Offsets[Game.client].DisableSpectate.byteLength);
Memory.writeData(Pointer + Offsets[Game.client].EnableCorrectKeyboardControls, Offsets[Game.client].DisableSpectateOnCam, Offsets[Game.client].DisableSpectateOnCam.byteLength);
} else if (Offsets[Game.client].base.version[Game.build].PlayerPointer) {
Memory.readData(SpectatePointer, flagsBuffer, 4);
const flags = flagsBuffer.readUInt32LE() & ~Offsets[Game.client].SpectateFlags;
flagsBuffer.fill();
flagsBuffer.writeUInt32LE(flags);
Memory.writeData(SpectatePointer, flagsBuffer, 4);
} else {
Memory.writeData(SpectatePointer, Offsets[Game.client].DisableSpectate, Offsets[Game.client].DisableSpectate.byteLength);
}
Expand Down
1 change: 0 additions & 1 deletion src/core/domain/enableKeyboardControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ function EnableKeyboardControls(Game, EnableSpectate, EnableViewMatrixUpdate, Ge
Pointer,
ViewMatrixInstructionsPointer,
} = CameraStruct;

if (!(Game.client === 'vanilla') && !(Game.client === 'alpha')) {
EnableSpectate(CameraStruct, Pointer);
EnableViewMatrixUpdate(ViewMatrixInstructionsPointer);
Expand Down
14 changes: 13 additions & 1 deletion src/core/domain/enableSpectate.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
const flagsBufferSize = 4;
const flagsBuffer = new Buffer(flagsBufferSize);

function enableSpectateMode(Game, Memory, Offsets, Module, GetCameraData, SetPosition) {
return (CameraStruct) => {
const {
InstructionPointer,
SpectatePointer,
Pointer,
CameraValuesPointer,
} = CameraStruct;
if (Game.client === 'vanilla' || Game.client === 'alpha') {
const fixPositionPattern = Offsets[Game.client].camera.position[Game.build].fix;
Expand All @@ -17,7 +20,16 @@ function enableSpectateMode(Game, Memory, Offsets, Module, GetCameraData, SetPos
} else {
const { position } = GetCameraData(Pointer);
SetPosition(CameraStruct, position.x, position.y, position.z);
Memory.writeData(SpectatePointer, Offsets[Game.client].EnableSpectate, Offsets[Game.client].EnableSpectate.byteLength);

if (Offsets[Game.client].base.version[Game.build].PlayerPointer) {
Memory.readData(SpectatePointer, flagsBuffer, 4);
const flags = flagsBuffer.readUInt32LE() | Offsets[Game.client].SpectateFlags;
flagsBuffer.fill();
flagsBuffer.writeUInt32LE(flags);
Memory.writeData(SpectatePointer, flagsBuffer, 4);
} else {
Memory.writeData(SpectatePointer, Offsets[Game.client].EnableSpectate, Offsets[Game.client].EnableSpectate.byteLength);
}
}
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/domain/environment/getNormalizedTimeOfDay.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ function GetNormalizedTimeOfDay(Game) {
return (hour, minutes) => {
if (Game.client === 'mop' ||
Game.client === 'draenor' ||
Game.client === 'legion') return (((3600 * hour) + (60 * minutes)) / 86400) * 1440;
Game.client === 'legion' || Game.client === 'bfa') return (((3600 * hour) + (60 * minutes)) / 86400) * 1440;
return ((3600 * hour) + (60 * minutes)) / 86400;
};
}
Expand Down
36 changes: 26 additions & 10 deletions src/core/domain/getCameraData.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,25 @@ const cameraBuffer = new Buffer(cameraBufferSize);
const cameraRotBufferSize = 0xC;
const cameraRotBuffer = new Buffer(cameraRotBufferSize);

const nearFarClipSize = 0x14;
const nearFarClipBuffer = new Buffer(nearFarClipSize);

function GetCameraData(Offsets, Game, Memory) {
return (Pointer) => {
const camera = getCameraStruct();
const rotationPtr = Offsets[Game.client].CameraRot;
Memory.readData(Pointer, cameraBuffer, cameraBufferSize);
Memory.readData(Pointer + rotationPtr, cameraRotBuffer, cameraRotBufferSize);

camera.position.x = cameraBuffer.readFloatLE(0x8);
camera.position.y = cameraBuffer.readFloatLE(0xC);
camera.position.z = cameraBuffer.readFloatLE(0x10);
const cameraPositionOffset = Offsets[Game.client].CameraPositionOffset;
camera.position.x = cameraBuffer.readFloatLE(cameraPositionOffset);
camera.position.y = cameraBuffer.readFloatLE(cameraPositionOffset + 4);
camera.position.z = cameraBuffer.readFloatLE(cameraPositionOffset + 8);

camera.viewMatrix[0][0] = cameraBuffer.readFloatLE(0x14);
camera.viewMatrix[0][1] = cameraBuffer.readFloatLE(0x18);
camera.viewMatrix[0][2] = cameraBuffer.readFloatLE(0x1C);
const cameraViewMatrixOffset = Offsets[Game.client].CameraViewMatrixOffset;
camera.viewMatrix[0][0] = cameraBuffer.readFloatLE(cameraViewMatrixOffset);
camera.viewMatrix[0][1] = cameraBuffer.readFloatLE(cameraViewMatrixOffset + 4);
camera.viewMatrix[0][2] = cameraBuffer.readFloatLE(cameraViewMatrixOffset + 8);

/**
* First row of the View Matrix is the forward vector
Expand All @@ -37,10 +42,21 @@ function GetCameraData(Offsets, Game, Memory) {
camera.pitch = cameraRotBuffer.readFloatLE(4);
camera.roll = cameraRotBuffer.readFloatLE(8);

camera.Fov = cameraBuffer.readFloatLE(0x38);
camera.NearClip = cameraBuffer.readFloatLE(0x3C);
camera.FarClip = cameraBuffer.readFloatLE(0x40);
camera.Aspect = cameraBuffer.readFloatLE(0x44);
const cameraFovOffset = Offsets[Game.client].CameraFovOffset;
camera.Fov = cameraBuffer.readFloatLE(cameraFovOffset);

const worldScenePointer = Offsets[Game.client].base.version[Game.build].WorldScenePointer;
if (worldScenePointer) { // bfa+
const oWorldSceneNearFarClip = Offsets[Game.client].base.version[Game.build].WorldSceneNearFarClipOffset;
Memory.readData(worldScenePointer + oWorldSceneNearFarClip, nearFarClipBuffer, nearFarClipSize);
camera.NearClip = nearFarClipBuffer.readFloatLE(0);
camera.FarClip = nearFarClipBuffer.readFloatLE(4);
camera.Aspect = nearFarClipBuffer.readFloatLE(16);
} else {
camera.NearClip = cameraBuffer.readFloatLE(0x3C);
camera.FarClip = cameraBuffer.readFloatLE(0x40);
camera.Aspect = cameraBuffer.readFloatLE(0x44);
}
return clonedeep(camera);
};
}
Expand Down
17 changes: 13 additions & 4 deletions src/core/domain/getCameraPtr.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,23 @@ function GetCameraPtr(Game, memory, Module, offsets) {
CameraValuesPointer: null,
};
} else if (offsets[Game.client].base) {
const SpectatePointerFinder = offsets[Game.client].base.version[Game.build].SpectatePointer;
const SpectatePointer = Array.isArray(SpectatePointerFinder) ? memory.readMultiLevelPtr(SpectatePointerFinder) : SpectatePointerFinder;
let SpectatePointer;
if (offsets[Game.client].base.version[Game.build].PlayerPointer) {
// Might not be player pointer... we should confirm the type of the object we're accessing.
const PlayerPointerFinder = offsets[Game.client].base.version[Game.build].PlayerPointer;
const PlayerPointer = Array.isArray(PlayerPointerFinder) ? memory.readMultiLevelPtr(PlayerPointerFinder) : PlayerPointerFinder;
SpectatePointer = PlayerPointer + offsets[Game.client].base.version[Game.build].PlayerFlagsOffset;
// ^ this is a pointer to PlayerFlags.
} else {
const SpectatePointerFinder = offsets[Game.client].base.version[Game.build].SpectatePointer;
SpectatePointer = Array.isArray(SpectatePointerFinder) ? memory.readMultiLevelPtr(SpectatePointerFinder) : SpectatePointerFinder;
}
const Pointer = memory.readMultiLevelPtr(offsets[Game.client].base.version[Game.build].CameraPointer);
const CameraValuesPointer = Module + offsets[Game.client].base.version[Game.build].CameraValuesPointer;

console.log('# Camera SpectatePointer found at', `0x${SpectatePointer.toString(16)}
- Camera spectate values at: 0x${CameraValuesPointer.toString(16)}
- Camera values at: 0x${Pointer.toString(16)}`);
- Camera spectate values at: 0x${CameraValuesPointer.toString(16)}
- Camera values at: 0x${Pointer.toString(16)}`);
return {
Pointer,
InstructionPointer: null,
Expand Down
5 changes: 3 additions & 2 deletions src/core/domain/setPosition.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
const cameraPosition = new Buffer(0xC);

function setPosition(Game, Memory) {
function setPosition(Game, Memory, Offsets) {
return (CameraStruct, x, y, z) => {
cameraPosition.writeFloatLE(x, 0x0);
cameraPosition.writeFloatLE(y, 0x4);
cameraPosition.writeFloatLE(z, 0x8);
const { Pointer, CameraValuesPointer } = CameraStruct;

if (Game.client === 'vanilla' || Game.client === 'alpha') {
Memory.writeData(Pointer + 0x8, cameraPosition, 0xC);
} else {
Memory.writeData(CameraValuesPointer + 0xC, cameraPosition, 0xC);
Memory.writeData(CameraValuesPointer + Offsets[Game.client].CameraValuesPositionOffset, cameraPosition, 0xC);
}
};
}
Expand Down
76 changes: 74 additions & 2 deletions src/core/logic/patterns.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

export const getVersion = (Memory) => {

const build = Memory.findStrPattern(' (build ');
const build = Memory.findStrPattern('Build (build ');
const buildStr = new Buffer(0xE);
if (build.length === 0) return;
const versionPtr = build[0];
Memory.readData(versionPtr, buildStr, buildStr.byteLength);
Memory.readData(versionPtr + 7, buildStr, buildStr.byteLength);
const buildFound = buildStr.toString('ascii').match(/\d/g).join('');
console.log('# WoW Build Found', buildFound);
if (buildFound === '3368') return { client: 'alpha', build: '0.5.3' };
Expand All @@ -21,9 +21,13 @@ export const getVersion = (Memory) => {
if (buildFound === '20779') return { client: 'draenor', build: '6.2.3' };
if (buildFound === '24742') return { client: 'legion', build: '7.2.5' };
if (buildFound === '26972') return { client: 'legion', build: '7.3.5' };
if (buildFound === '34963') return { client: 'bfa', build: '8.3.0' };
};

export const alpha = {
CameraPositionOffset: 0x08,
CameraViewMatrixOffset: 0x14,
CameraFovOffset: 0x38,
camera: {
position: {
['0.5.3']: {
Expand Down Expand Up @@ -192,6 +196,9 @@ export const alpha = {
};

export const vanilla = {
CameraPositionOffset: 0x08,
CameraViewMatrixOffset: 0x14,
CameraFovOffset: 0x38,
CameraRot: 0xF0,
enableCameraFacing: 0x90,
camera: {
Expand Down Expand Up @@ -259,6 +266,10 @@ export const vanilla = {
};

export const tbc = {
CameraPositionOffset: 0x08,
CameraViewMatrixOffset: 0x14,
CameraValuesPositionOffset: 0xC,
CameraFovOffset: 0x38,
CameraRot: 0x104,
SpectatePointer: [0x00A29D28, 0x128, 0x7FC, 0x7F8, 0x720, 0x6FC],
CameraPointer: [0x86ECCC, 0x732c, 0],
Expand Down Expand Up @@ -289,6 +300,10 @@ export const tbc = {
};

export const wlk = {
CameraPositionOffset: 0x08,
CameraViewMatrixOffset: 0x14,
CameraValuesPositionOffset: 0xC,
CameraFovOffset: 0x38,
SpectatePointer: [0x006DB754, 0x38, 0x98, 0x240],
CameraPointer: [0x77436C, 0x7e20, 0],
EnableSpectate: new Buffer([0x00, 0x00, 0x7F, 0x43]),
Expand Down Expand Up @@ -319,6 +334,10 @@ export const wlk = {
};

export const ctl = {
CameraPositionOffset: 0x08,
CameraViewMatrixOffset: 0x14,
CameraValuesPositionOffset: 0xC,
CameraFovOffset: 0x38,
SpectatePointer: 0x163BEC,
CameraRot: 0x104,
CameraPointer: [0xAD7A10, 0x80D0, 0],
Expand Down Expand Up @@ -353,6 +372,10 @@ export const ctl = {

const OFFSET_FIX = 0x4F0;
export const mop = {
CameraPositionOffset: 0x08,
CameraViewMatrixOffset: 0x14,
CameraValuesPositionOffset: 0xC,
CameraFovOffset: 0x38,
SpectatePointer: [0xCFEFAC + OFFSET_FIX, 0x1504, 0x8],
CameraRot: 0x10C,
CameraPointer: [0xD64E5C, 0x8208, 0],
Expand Down Expand Up @@ -382,6 +405,10 @@ export const mop = {
};

export const draenor = {
CameraPositionOffset: 0x08,
CameraViewMatrixOffset: 0x14,
CameraValuesPositionOffset: 0xC,
CameraFovOffset: 0x38,
SpectatePointer: [0x00E379B0, 0xD4, 0x50, 0x350],
CameraRot: 0x128,
CameraPointer: [0xEAF270, 0x7610, 0],
Expand Down Expand Up @@ -411,6 +438,10 @@ export const draenor = {
};

export const legion = {
CameraPositionOffset: 0x08,
CameraValuesPositionOffset: 0xC,
CameraViewMatrixOffset: 0x14,
CameraFovOffset: 0x38,
EnableSpectate: new Buffer([0x00, 0x00, 0x48, 0x00]),
DisableSpectate: new Buffer([0, 0, 0, 0]),
Collision: 0x90,
Expand Down Expand Up @@ -459,3 +490,44 @@ export const legion = {
}
},
};

export const bfa = {
CameraPositionOffset: 0x10,
CameraValuesPositionOffset: 0x10,
CameraViewMatrixOffset: 0x1C,
CameraFovOffset: 0x40,
SpectateFlags: 0x480000,
CameraRot: 0x13C,
Collision: 0x98,
Speed: 0x8C,
base: {
version: {
['8.3.0']: {
WorldScenePointer: 0x28CDB40,
WorldSceneNearFarClipOffset: 0x4B4,
PlayerPointer: [0x296A490 + 0x10, 0x08, 0],
PlayerFlagsOffset: 0x1AB8,
CameraPointer: [0x2A6BAA8, 0x3438, 0],
CameraValuesPointer: 0x2ABB1F0,
}
}
},
cameraViewMatrix: {
version: {
['8.3.0']: {
pattern: new Buffer([0x48, 0x8B, 0xD0, 0x48, 0x8B, 0xCF, 0xE8, 0x72, 0x34, 0xFF, 0xFF, 0x33]),
fix: new Buffer([0x48, 0x8B, 0xD0, 0x48, 0x8B, 0xCF, 0x90, 0x90, 0x90, 0x90, 0x90, 0x33]),
}
}
},
environment: {
version: {
['8.3.0']: {
timeOfDay: 0,
timeOfDaySpeed: 0,
renderFlags: 0x0,
renderFlagsDefault: 0x0
}
}
},
};
2 changes: 1 addition & 1 deletion src/core/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module.exports = (process, Module, Memory, window, Offsets) => {
const DisableViewMatrixUpdate = createDisableViewMatrixUpdate(Game, Memory, Offsets);
const GetCametaPtr = createGetCametaPtr(Game, Memory, Module, Offsets);
const GetCameraData = createGetCameraData(Offsets, Game, Memory);
const SetPosition = createSetPosition(Game, Memory);
const SetPosition = createSetPosition(Game, Memory, Offsets);
const EnableSpectate = createEnableSpectate(Game, Memory, Offsets, Module, GetCameraData, SetPosition);
const DisableSpectate = createDisableSpectate(Game, Memory, Offsets, Module);
const SetCollision = createSetCollision(Game, Memory, Offsets);
Expand Down
Loading

0 comments on commit 347c43e

Please sign in to comment.