Skip to content

Commit

Permalink
fix: make spectating user permanent ptr
Browse files Browse the repository at this point in the history
  • Loading branch information
KotRikD committed Feb 28, 2024
1 parent 358f0e6 commit 05b1731
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
14 changes: 6 additions & 8 deletions packages/tosu/src/entities/TourneyUserProfileData/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import { DataRepo } from '@/entities/DataRepoList';

import { AbstractEntity } from '../AbstractEntity';

// GameBase -> StreamingManager.CurrentlySpectating
const TOURNEY_PROFILE_BASE = '8B 0D ?? ?? ?? ?? 85 C0 74 05 8B 50 30'; // -0x4

export class TourneyUserProfileData extends AbstractEntity {
UserInfoBase: number = 0;

Expand All @@ -26,14 +23,15 @@ export class TourneyUserProfileData extends AbstractEntity {
async updateState() {
wLogger.debug(`[TourneyUserProfileData:updateState] starting`);

const { process } = this.services.getServices(['process']);
const { process, patterns } = this.services.getServices([
'process',
'patterns'
]);

if (!this.UserInfoBase) {
const tourneyProfileBase = process.scanSync(
TOURNEY_PROFILE_BASE,
true
this.UserInfoBase = process.readPointer(
patterns.getPattern('spectatingUserPtr')
);
this.UserInfoBase = process.readPointer(tourneyProfileBase - 0x4);
wLogger.debug('[TUPD] Slot is not equiped');
return;
}
Expand Down
5 changes: 5 additions & 0 deletions packages/tosu/src/objects/instanceManager/osuInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const SCAN_PATTERNS: {
[k in keyof PatternData]: {
pattern: string;
offset?: number;
isTourneyOnly?: boolean;
};
} = {
baseAddr: {
Expand Down Expand Up @@ -76,6 +77,10 @@ const SCAN_PATTERNS: {
gameTimePtr: {
pattern: 'FF 15 ?? ?? ?? ?? A1 ?? ?? ?? ?? 8B 15 ?? ?? ?? ?? 3B',
offset: 0x7
},
spectatingUserPtr: {
pattern: '8B 0D ?? ?? ?? ?? 85 C0 74 05 8B 50 30',
offset: -0x4
}
};

Expand Down
8 changes: 4 additions & 4 deletions packages/tosu/src/objects/memoryPatterns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface PatternData {
userProfilePtr: number;
rawLoginStatusPtr: number;
gameTimePtr: number;
spectatingUserPtr: number;
}

export class MemoryPatterns {
Expand All @@ -36,7 +37,8 @@ export class MemoryPatterns {
getAudioLengthPtr: 0,
userProfilePtr: 0,
rawLoginStatusPtr: 0,
gameTimePtr: 0
gameTimePtr: 0,
spectatingUserPtr: 0
};

if (process.platform !== 'win32') {
Expand Down Expand Up @@ -71,9 +73,7 @@ export class MemoryPatterns {

checkIsBasesValid(): boolean {
Object.entries(this.patterns).map((entry) =>
wLogger.debug(
`${entry[0]}: 0${entry[1].toString(16).toUpperCase()}`
)
wLogger.debug(`${entry[0]}: ${entry[1].toString(16).toUpperCase()}`)
);
return !Object.values(this.patterns).some((base) => base === 0);
}
Expand Down

0 comments on commit 05b1731

Please sign in to comment.