public bool Initialize() { Console.WriteLine("Initializing..."); initializeLocalConfig(); var osuProcess = tryGetProcess(); if (osuProcess == null) { Console.WriteLine("\nWaiting for osu!..."); while (osuProcess == null) { osuProcess = tryGetProcess(); Thread.Sleep(1500); } } osuProcess.EnableRaisingEvents = true; osuProcess.Exited += (o, e) => Environment.Exit(0); OsuProcess = new OsuProcess(osuProcess); DependencyContainer.Cache(OsuProcess); return scanMemory(); }
public bool Initialize(Process osuProcess) { osuProcess.EnableRaisingEvents = true; osuProcess.Exited += delegate { Environment.Exit(0); }; OsuProcess = new OsuProcess(osuProcess); DependencyContainer.Cache <OsuProcess>(OsuProcess); return(scanMemory()); }
private bool scanMemory() { bool timeResult = false, modeResult = false, viewportResult = false, bindingManagerResult = false, playerResult = false; try { Console.WriteLine("\nScanning for memory addresses..."); timeResult = OsuProcess.FindPattern(Signatures.Time.Pattern, out UIntPtr timePointer); modeResult = OsuProcess.FindPattern(Signatures.Mode.Pattern, out UIntPtr modePointer); viewportResult = OsuProcess.FindPattern(Signatures.Viewport.Pattern, out UIntPtr viewportPointer); bindingManagerResult = OsuProcess.FindPattern(Signatures.BindingManager.Pattern, out UIntPtr bindingManagerPointer); playerResult = OsuProcess.FindPattern(Signatures.Player.Pattern, out UIntPtr playerPointer); if (timeResult && modeResult && viewportResult && bindingManagerResult && playerResult) { timeAddress = (UIntPtr)OsuProcess.ReadUInt32(timePointer + Signatures.Time.Offset); modeAddress = (UIntPtr)OsuProcess.ReadUInt32(modePointer + Signatures.Mode.Offset); WindowManager = new OsuWindowManager((UIntPtr)OsuProcess.ReadUInt32(viewportPointer + Signatures.Viewport.Offset)); BindingManager = new BindingManager((UIntPtr)OsuProcess.ReadUInt32(bindingManagerPointer + Signatures.BindingManager.Offset)); Player = new OsuPlayer((UIntPtr)OsuProcess.ReadUInt32(playerPointer + Signatures.Player.Offset)); } } catch { } if (timeAddress == UIntPtr.Zero || modeAddress == UIntPtr.Zero || WindowManager == null || BindingManager == null || Player == null) { DebugInfo = $"Time result: {(timeResult ? "success" : "fail")}\n" + $"Mode result: {(modeResult ? "success" : "fail")}\n" + $"Viewport result: {(viewportResult ? "success" : "fail")}\n" + $"BindingManager result: {(bindingManagerResult ? "success" : "fail")}\n" + $"Player result: {(playerResult ? "success" : "fail")}"; return(false); } return(true); }
public HitState GetHitState(int index) { UIntPtr hitObjectListPointer = (UIntPtr)OsuProcess.ReadUInt32(BaseAddress + 0x48); UIntPtr hitObjectListItemsPointer = (UIntPtr)OsuProcess.ReadUInt32(hitObjectListPointer + 0x4); UIntPtr hitObjectPointer = (UIntPtr)OsuProcess.ReadUInt32(hitObjectListItemsPointer + 0x8 + 0x4 * index); HitObjectType type = (HitObjectType)OsuProcess.ReadInt32(hitObjectPointer + 0x18); type &= ~HitObjectType.ComboOffset; type &= ~HitObjectType.NewCombo; var hitState = OsuProcess.ReadBool(hitObjectPointer + 0x84) ? HitState.Hit : HitState.NotHit; switch (type) { case HitObjectType.Slider: UIntPtr startHitCirclePointer = (UIntPtr)OsuProcess.ReadUInt32(hitObjectPointer + 0xCC); return(OsuProcess.ReadBool(startHitCirclePointer + 0x84) ? hitState | HitState.SliderStartHit : hitState); default: return(hitState); } }