internal void HaxCheck(bool forceFail = false) { haxCheckCount++; string calc = CalcScoreChecksum(); //check for other running osu! processes every 30s or so. if (GameBase.Time - lastIpcCheck > 30000) { //todo: check and reenable //GameBase.Scheduler.Add(() => //{ // if (IPC.GetRunningOsu() != null) // flag |= BadFlags.MultipleOsuClients; //}, 500); lastIpcCheck = GameBase.Time; } if (currentScore.EnabledMods != ModManager.ModStatus) { flag |= BadFlags.IncorrectModValue; } if (haxCheckCount % 20 == 0 && GameBase.IsFormOpacityHacked()) { flag |= BadFlags.TransparentWindow; } //Fight the memory editing hacks. if (forceFail || calc != scoreChecksum || Int64.Parse(calc) * 2 != scoreChecksumNumerical || Ruleset.ComboCounter.HitCombo > currentScore.MaxCombo) { if (Status == PlayerStatus.Busy) { return; } flag |= BadFlags.ChecksumFailure; if (Status == PlayerStatus.ExitingSpectator || InputManager.ReplayMode || GameBase.TestMode) { return; } currentScore.InvalidateSubmission(); allowSubmissionHaxCheck = false; if (!haxFound) { GameBase.Scheduler.AddDelayed(crash, RNG.Next(1000, 6000)); GameBase.Scheduler.AddDelayed(delegate { throw new MethodAccessException(); }, RNG.Next(1000, 6000)); GameBase.Scheduler.AddDelayed(delegate { Environment.Exit(-1); }, RNG.Next(10000, 15000)); haxFound = true; } } }
private void HaxCheckPass() { try { if (!GameBase.CheckUniqueId()) { Player.flag |= BadFlags.ChecksumFailure; } } catch { } }
internal static void HaxCheckMouse(Vector2 normalMovement, Vector2 rawMovement) { if (InputManager.ReplayMode || GameBase.TestMode || !GameBase.Instance.IsActive) { return; } float angle = 0; if ((normalMovement == Vector2.Zero && rawMovement != Vector2.Zero) || (normalMovement != Vector2.Zero && rawMovement == Vector2.Zero)) { angle = (float)Math.PI; } else if (normalMovement == Vector2.Zero && rawMovement == Vector2.Zero) { angle = 0; } else { angle = (float)(Math.Abs(Math.Atan2(rawMovement.Y, rawMovement.X)) - Math.Abs(Math.Atan2(normalMovement.Y, normalMovement.X))); angle = Math.Abs(angle); } float decay = (float)Math.Pow(0.99, GameBase.FrameRatio); mouseMovementAngle = decay * mouseMovementAngle + (1 - decay) * angle; if (mouseMovementAngle > Math.PI * 0.75) { if (Player.Playing && !mouseMovementDiscrepancyInMenu) { flag |= BadFlags.RawMouseDiscrepancy; } else { mouseMovementDiscrepancyInMenu = true; } } }
internal void AddSpinnerFlag() { flag |= BadFlags.SpinnerHack; }
internal void AddFlashlightFlag() { flag |= BadFlags.FlashLightImageHack; }
private void InitializeAntiCheat() { flag = BadFlags.Clean; }
private void HaxCheckAudio() { if (!InputManager.ReplayMode && !GameBase.TestMode) { if (audioCheckTime == -1) { if (AudioEngine.Time > 0) { audioCheckTime = AudioEngine.Time; audioCheckTimeComp = GameBase.Time; } } else if (AudioEngine.Time - audioCheckTime >= 1000) { float rate = 1; if (ModManager.CheckActive(Mods.DoubleTime)) { rate = 1.5f; } else if (ModManager.CheckActive(Mods.HalfTime)) { rate = 0.75f; } float diff = (AudioEngine.Time - audioCheckTime) * (1f / rate); if (Math.Abs(diff - (GameBase.Time - audioCheckTimeComp)) > 60) { if (++audioCheckCount > 5) { NotificationManager.ShowMessage( "There was an error during timing calculations. If you continue to get this error, please update your AUDIO/SOUND CARD drivers! Your score will not be submitted for this play."); //BanchoClient.HandleException(new Exception("timing error"), "user is hacking?"); currentScore.InvalidateSubmission(); GameBase.Scheduler.AddDelayed(delegate { flag |= BadFlags.SpeedHackDetected; }, 200); audioCheckCount = -500; } } else { audioCheckCount = 0; } audioCheckTime = -1; } if ((flag & BadFlags.SpeedHackDetected) == 0) { long dateTimeTime = DateTime.Now.Ticks / 10000; if (dateTimeCheckTimeInitial == -1) { if (AudioEngine.Time > 0) { dateTimeCheckTimeInitial = dateTimeTime; dateTimeCheckTimeComp = GameBase.Time; } } else { if (Math.Abs((dateTimeTime - dateTimeCheckTimeInitial) - (GameBase.Time - dateTimeCheckTimeComp)) > 2000) { dateTimeCheckCount++; if (dateTimeCheckCount > 4) { flag |= BadFlags.SpeedHackDetected; } //reset comparison. dateTimeCheckTimeInitial = dateTimeTime; dateTimeCheckTimeComp = GameBase.Time; } } } } }