Skip to content

Commit

Permalink
feat: add lazer placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
xxCherry authored and cyperdark committed Oct 19, 2024
1 parent ef41556 commit a701b52
Show file tree
Hide file tree
Showing 6 changed files with 194 additions and 7 deletions.
7 changes: 4 additions & 3 deletions packages/tosu/src/instances/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,10 @@ export abstract class AbstractInstance {
);
}

if (!this.checkIsBasesValid()) {
return false;
}
// TODO: fix this when PatternData will be separated between different instances
// if (!this.checkIsBasesValid()) {
// return false;
// }

return true;
} catch (error) {
Expand Down
31 changes: 31 additions & 0 deletions packages/tosu/src/instances/lazerInstance.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { LazerMemory } from '@/memory/lazer';
import { Gameplay } from '@/states/gameplay';
import { Global } from '@/states/global';

import { AbstractInstance } from '.';

export class LazerInstance extends AbstractInstance {
memory: LazerMemory;

constructor(pid: number) {
super(pid);

this.memory = new LazerMemory(this.process, this);
}

start(): void | Promise<void> {
super.start();

this.initiateDataLoops();
this.watchProcessHealth();
}

injectGameOverlay(): void {
throw new Error('Method not implemented.');
}

regularDataLoop(): void {}
preciseDataLoop(global: Global, gameplay: Gameplay): void {
throw new Error('Method not implemented.' + global + gameplay);
}
}
5 changes: 3 additions & 2 deletions packages/tosu/src/instances/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { argumetsParser, wLogger } from '@tosu/common';
import { Process } from 'tsprocess/dist/process';

import { AbstractInstance } from '@/instances';
import { OsuInstance } from '@/instances/osuInstance';

import { LazerInstance } from './lazerInstance';

export class InstanceManager {
osuInstances: {
Expand Down Expand Up @@ -47,7 +48,7 @@ export class InstanceManager {
continue;
}

const osuInstance = new OsuInstance(processId);
const osuInstance = new LazerInstance(processId);
const cmdLine = osuInstance.process.getProcessCommandLine();

const args = argumetsParser(cmdLine);
Expand Down
3 changes: 2 additions & 1 deletion packages/tosu/src/memory/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import { KeyOverlay } from '@/states/gameplay';
import { OsuMods } from '@/utils/osuMods.types';
import { BindingsList, ConfigList } from '@/utils/settings.types';

// TODO: fix this when PatternData will be separated for each
export type ScanPatterns = {
[k in keyof PatternData]: {
[k in keyof any]: {
pattern: string;
offset?: number;
isTourneyOnly?: boolean;
Expand Down
153 changes: 153 additions & 0 deletions packages/tosu/src/memory/lazer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
import { KeyOverlay } from '@/states/gameplay';
import { OsuMods } from '@/utils/osuMods.types';
import { BindingsList, ConfigList } from '@/utils/settings.types';

import { AbstractMemory, ScanPatterns } from '.';

export class LazerMemory extends AbstractMemory {
private scanPatterns: ScanPatterns = {
spectatorClient: {
pattern:
'3F 00 00 80 3F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 3F 00 00 80 3F 00 00 80 3F 00 00 80 3F 00 00 80 3F 00 00 80 3F 00 00 80 3F 00 00 80 3F 00 00 80 3F 00 00 80 3F 00 00 80 3F 00 00 80 3F 00 00 80 3F 00 00 80 3F 00 00 80 3F 00 00 80 3F 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ?? 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00',
offset: -0x16f
}
};

getScanPatterns(): ScanPatterns {
return this.scanPatterns;
}

audioVelocityBase(): number[] | null {
throw new Error('Lazer:audioVelocityBase not implemented.');
}

user():
| Error
| {
name: string;
accuracy: number;
rankedScore: number;
id: number;
level: number;
playCount: number;
playMode: number;
rank: number;
countryCode: number;
performancePoints: number;
rawBanchoStatus: number;
backgroundColour: number;
rawLoginStatus: number;
} {
throw new Error('Lazer:user not implemented.');
}

settingsPointers(): { config: number; binding: number } | Error {
throw new Error('Lazer:settingsPointers not implemented.');
}

configOffsets(address: number, list: ConfigList): number[] | Error {
throw new Error(
'Lazer:configOffsets not implemented.' + address + list
);
}

bindingsOffsets(address: number, list: BindingsList): number[] | Error {
throw new Error(
'Lazer:bindingsOffsets not implemented.' + address + list
);
}

configValue(
address: number,
position: number,
list: ConfigList
): { key: string; value: any } | null | Error {
throw new Error(
'Lazer:configValue not implemented.' + address + position + list
);
}

bindingValue(
address: number,
position: number
): { key: number; value: number } | Error {
throw new Error(
'Lazer:bindingValue not implemented.' + address + position
);
}

resultScreen():
| {
onlineId: number;
playerName: string;
mods: OsuMods;
mode: number;
maxCombo: number;
score: number;
hit100: number;
hit300: number;
hit50: number;
hitGeki: number;
hitKatu: number;
hitMiss: number;
date: string;
}
| string
| Error {
throw new Error('Lazer:resultScreen not implemented.');
}

gameplay():
| {
address: number;
retries: number;
playerName: string;
mods: OsuMods;
mode: number;
score: number;
playerHPSmooth: number;
playerHP: number;
accuracy: number;
hit100: number;
hit300: number;
hit50: number;
hitGeki: number;
hitKatu: number;
hitMiss: number;
combo: number;
maxCombo: number;
}
| string
| Error {
throw new Error('Lazer:gameplay not implemented.');
}

keyOverlay(mode: number): KeyOverlay | string | Error {
throw new Error('Lazer:keyOverlay not implemented.' + mode);
}

hitErors(): number[] | string | Error {
throw new Error('Lazer:hitErrors not implemented.');
}

global():
| {
isWatchingReplay: number;
isReplayUiHidden: boolean;
showInterface: boolean;
chatStatus: number;
status: number;
gameTime: number;
menuMods: number;
skinFolder: string;
memorySongsFolder: string;
}
| string
| Error {
throw new Error('Lazer:global not implemented.');
}

globalPrecise(): { time: number } | Error {
throw new Error('Lazer:globalPrecise not implemented.');
}
}
2 changes: 1 addition & 1 deletion packages/tsprocess/lib/memory/memory_windows.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ std::vector<MemoryRegion> memory::query_regions(void *process) {

MEMORY_BASIC_INFORMATION info;
for (uint8_t *address = 0; VirtualQueryEx(process, address, &info, sizeof(info)) != 0; address += info.RegionSize) {
if ((info.State & MEM_COMMIT) == 0 || (info.Protect & (PAGE_EXECUTE_READWRITE)) == 0) {
if ((info.State & MEM_COMMIT) == 0 || (info.Protect & (PAGE_READWRITE | PAGE_EXECUTE_READWRITE)) == 0) {
continue;
}

Expand Down

0 comments on commit a701b52

Please sign in to comment.