public SplitOnDefeating(GameState state, SplitRuleDefeating rule) : base(state, rule) { var injector = state.GetInjector <injectors.DefeatInjector>(); lastNpcUID = new(injector.LastNpcUID); lastFightResult = new(injector.LastFightResult); }
public object Var(string id) { MemoryWatcher v = vars.FirstOrDefault((x) => x.Name == id); v?.Update(proc); return(v?.Current); }
public MemoryDefinition(string gameVersion, string gameStorefront) { bKnownVersion = true; pointers = PointerInfoReader.getPointersForVersion(gameVersion, gameStorefront); Debug.WriteLine("Done reading XML pointers..."); if (pointers.Count == 0) // If we're using an unknown version, or atleast one in which we don't have the pointers. { Debug.WriteLine($"Unknown pointers for: {gameVersion}"); bKnownVersion = false; return; } if (pointers.ContainsKey("loading")) { isLoadingInfo = pointers["loading"]; isLoadingState = new MemoryWatcher <int>(isLoadingInfo.ptr); } if (pointers.ContainsKey("mainMenu")) { isMainMenuInfo = pointers["mainMenu"]; isMainMenuState = new MemoryWatcher <int>(isMainMenuInfo.ptr); } if (pointers.ContainsKey("levelSplits")) { levelSplitsInfo = pointers["levelSplits"]; levelSplitsState = new MemoryWatcher <int>(levelSplitsInfo.ptr); } this.AddRange(this.GetType().GetProperties().Where(p => !p.GetIndexParameters().Any()).Select(p => p.GetValue(this, null) as MemoryWatcher).Where(p => p != null)); }
public override void OnSessionStart(GameState state) { base.OnSessionStart(state); if (IsFirstMap) { _splitTime = state.FindOutputFireTime("relay_portal_cancel_room1", 50); } if (this.IsLastMap && state.PlayerEntInfo.EntityPtr != IntPtr.Zero) { this._gladosIndex = state.GetEntIndexByName("glados_body"); Debug.WriteLine("Glados index is " + this._gladosIndex); } if (_elevSplit.BValue) { _elevSplitTime = state.FindOutputFireTime("*elev_start", 15); Debug.WriteLine("Elevator split time is " + _elevSplitTime); } _playerHP = new MemoryWatcher <int>(state.PlayerEntInfo.EntityPtr + _baseEntityHealthOffset); _onceFlag = false; }
public override void OnGameAttached(GameState state) { ProcessModuleWow64Safe server; server = state.GetModule("server.dll"); _playerMoveSpeed = new MemoryWatcher <float>(server.BaseAddress + 0x761310); }
public LoadRemover(GameState state) { var injector = state.GetInjector <injectors.IsLoadingInjector>(); isLoading = new(injector.IsLoading); liveSplitState = state.LiveSplitState; }
/// <summary> /// Initializes <see cref="GameData"/> based on <paramref name="version"/>. /// </summary> /// <param name="version"></param> public GameData(GameVersion version) { switch (version) { case GameVersion.Int: TitleScreen = new MemoryWatcher <bool>(new DeepPointer(0x2A1C58)); LevelComplete = new MemoryWatcher <bool>(new DeepPointer(0x233F54)); Level = new MemoryWatcher <Level>(new DeepPointer(0xC561C)); LevelTime = new MemoryWatcher <uint>(new DeepPointer(0x2D27CF)); PickedPassportFunction = new MemoryWatcher <uint>(new DeepPointer(0x226458)); Health = new MemoryWatcher <short>(new DeepPointer(0x22640C)); break; case GameVersion.JpCracked: TitleScreen = new MemoryWatcher <bool>(new DeepPointer(0x2A1C60)); LevelComplete = new MemoryWatcher <bool>(new DeepPointer(0x233F5C)); Level = new MemoryWatcher <Level>(new DeepPointer(0xC561C)); LevelTime = new MemoryWatcher <uint>(new DeepPointer(0x2D27CF)); PickedPassportFunction = new MemoryWatcher <uint>(new DeepPointer(0x226458)); Health = new MemoryWatcher <short>(new DeepPointer(0x22640C)); break; default: throw new ArgumentOutOfRangeException(nameof(version), version, null); } }
private void AddHooks() { _maingen.Clear(); int loading = _maingen.DataByte(0x00); int gamehead = WriteHead(_maingen, _game); int moviehead = WriteHead(_maingen, _movie); int frontendhead = WriteHead(_maingen, _frontend); int raceeditorhead = WriteHead(_maingen, _raceeditor); int carviewerhead = WriteHead(_maingen, _carviewer); int game = GenWrap(_maingen, loading, gamehead, off: 1); int movie = GenWrap(_maingen, loading, moviehead); int frontend = GenWrap(_maingen, loading, frontendhead, end: 0x02); int raceeditor = GenWrap(_maingen, loading, raceeditorhead); int carviewer = GenWrap(_maingen, loading, carviewerhead); _hook = _maingen.Install(_mc2); InstallJmp(_game, game); InstallJmp(_movie, movie); InstallJmp(_frontend, frontend); InstallJmp(_raceeditor, raceeditor); InstallJmp(_carviewer, carviewer); _loading = new MemoryWatcher <byte>(_hook); _loading.OnChanged += On_Loading; _memory.Add(_loading); _disclaimer = new MemoryWatcher <byte>(_baseaddr + 0x2622B0); _disclaimer.OnChanged += On_Disclaimer; _memory.Add(_disclaimer); }
private void WriteBytes(MemoryWatcher watcher, byte[] bytes) { if (bytes != null) { writeHelper(watcher, () => process.WriteBytes(watcher.Address, bytes), (pointer) => process.WriteBytes(pointer, bytes)); } }
public MainForm() { InitializeComponent(); Icon = MainResource.recycling; ConsoleWritter.Initialize(this); DelaysCounter.Reset(50); MemoryWatcher.Reset(); }
protected void WriteValue <T>(MemoryWatcher watcher, T?value) where T : struct { if (value.HasValue) { writeHelper(watcher, () => process.WriteValue(watcher.Address, value.Value), (pointer) => process.WriteValue(pointer, value.Value)); } }
public UpgradeSplit(string key, TreeView settings, IntPtr maxUpgradeAddress, int upgradeLevel) { _key = key; _enabled = true; _settingsNode = settings.Nodes.Find(key, true)[0]; _upgradeLevel = upgradeLevel; _maxUpgradeLevel = new MemoryWatcher <int>(maxUpgradeAddress); }
public WFSplit(string key, TreeView settings, IntPtr baseAddress, int offsets, byte bitOffset) { _key = key; _bitOffset = bitOffset; _memWatcher = new MemoryWatcher <byte>(baseAddress + offsets); _enabled = true; _splitLevelOneOnLoad = true; _settingsNode = settings.Nodes.Find(key, true)[0]; }
bool TryGetGameProcess() { Process p = Process.GetProcesses().FirstOrDefault(x => x.ProcessName.ToLower() == "amnesia"); if (p == null || p.HasExited) return false; byte[] addrBytes = BitConverter.GetBytes((uint)p.MainModuleWow64Safe().BaseAddress + UNUSED_BYTE_OFFSET); // the following code has a very small chance to crash the game due to not suspending threads while writing memory // commented out stuff is for the cracked version of the game (easier to debug when there's no copy protection) // overwrite unused alignment byte with and initialize as our "is loading" var // this is [419858] as seen below if (!p.WriteBytes(p.MainModuleWow64Safe().BaseAddress + UNUSED_BYTE_OFFSET, 0)) return false; // the following patches are in Amnesia.cLuxMapHandler::CheckMapChange(afTimeStep) // (the game kindly provides us with a .pdb) // overwrite useless code and set loading var to 1 // // patch // 00419984 837D E8 10 CMP DWORD PTR SS:[EBP-18], 10 // 00419988 C645 FC 00 MOV BYTE PTR SS:[EBP-4], 0 // 0041998C 72 0C JB SHORT 0041999A // to // 00419984 C605 58984100 MOV BYTE PTR DS:[419858], 1 // 0041998B 90 NOP // 0041998C EB 0C JMP SHORT 0041999A var payload1 = new List<byte>(new byte[] { 0xC6, 0x05 }); payload1.AddRange(addrBytes); payload1.AddRange(new byte[] { 0x01, 0x90, 0xEB }); if (!p.WriteBytes(p.MainModuleWow64Safe().BaseAddress + 0xC9984, payload1.ToArray())) return false; // overwrite useless code and set loading var to 0 // // patch // 00419AF9 C645 FC 04 MOV BYTE PTR SS:[EBP-4], 4 // 00419AFD E8 DE75F3FF CALL ProgLog // to // 00419AF9 C605 58984100 MOV BYTE PTR DS:[419858], 0 // 00419B00 90 NOP // 00419B01 90 NOP var payload2 = new List<byte>(new byte[] { 0x05 }); payload2.AddRange(addrBytes); payload2.AddRange(new byte[] { 0x00, 0x90, 0x90 }); if (!p.WriteBytes(p.MainModuleWow64Safe().BaseAddress + 0xC9AFA, payload2.ToArray())) return false; _isLoading = new MemoryWatcher<bool>(p.MainModuleWow64Safe().BaseAddress + UNUSED_BYTE_OFFSET); _process = p; return true; }
public EnableSplitTriggers(GameState state) { this.state = state; if (!state.Process.ReadPointer(state.UIMgrPtr + state.Version.OffUIManagerToSavegameScreenPtr, out savegameScreenPtr)) { throw new ApplicationException("Could not read savegame screen ptr"); } currentScreenPtr = new MemoryWatcher <uint>(state.UIMgrPtr + state.Version.OffUIManagerToCurrentScreenPtr); }
public SplitOnReaching(GameState state, SplitRuleReaching rule) : base(state, rule) { sceneId = new MemoryWatcher <int>( state.ResMgrPtr + state.Version.OffResMgrToScene + state.Version.OffSceneToDataset + state.Version.OffDatasetToDatasetStruct + state.Version.OffDatasetStructToSceneId); }
public void UpdateAddress(MemoryWatcher watcher) { var pair = Addresses.FirstOrDefault(p => p.Key == watcher.Name); if (pair.Key != null) { var index = Addresses.IndexOf(pair); Addresses[index] = new KeyValuePair <string, object>(watcher.Name, watcher.Current); } }
public override void OnSessionStart(GameState state) { base.OnSessionStart(state); _onceFlag = false; if (IsFirstMap) { _tinjeGuardHP = new MemoryWatcher <int>(state.GetEntityByName("end") + _baseEntityHealthOffset); } }
public override void OnSessionStart(GameState state) { base.OnSessionStart(state); _onceFlag = false; if (this.IsFirstMap) { _freemanHP = new MemoryWatcher <int>(state.GetEntityByName("bar") + _baseEntityHealthOffset); } }
public Start(GameState state) { this.state = state; if (!state.Process.ReadPointer(state.UIMgrPtr + state.Version.OffUIManagerToSavegameScreenPtr, out savegameScreenPtr)) { throw new ApplicationException("Could not read savegame screen ptr"); } currentScreenPtr = new MemoryWatcher <uint>(state.UIMgrPtr + state.Version.OffUIManagerToCurrentScreenPtr); shouldStart = new MemoryWatcher <int>(savegameScreenPtr + state.Version.OffSavegameScreenToInExitingAnimation); }
public override void OnSessionStart(GameState state) { base.OnSessionStart(state); if (IsLastMap) { IntPtr ptr = state.GetEntityByName("nihilanth"); _nihiDead = new MemoryWatcher <bool>(ptr + _nihiDeadOffset); } _onceFlag = false; }
public override void OnSessionStart(GameState state) { base.OnSessionStart(state); if (IsLastMap && _baseEntityHealthOffset != 0x0) { _gunshipHP = new MemoryWatcher <int>(state.GetEntityByName("helicopter_1") + _baseEntityHealthOffset); } _onceFlag = false; }
public override void OnSessionStart(GameState state) { base.OnSessionStart(state); if (IsFirstMap) { _counterSkin = new MemoryWatcher <int>(state.GetEntityByName("EndWords") + _baseSkinOffset); _camIndex = state.GetEntIndexByName("EndCamera"); Debug.WriteLine("found end cam index at " + _camIndex); } _onceFlag = false; }
public override void OnSessionStart(GameState state) { base.OnSessionStart(state); if (this.IsLastMap && state.PlayerEntInfo.EntityPtr != IntPtr.Zero && _playerSuppressingCrosshairOffset != -1) { _crosshairSuppressed = new MemoryWatcher <bool>(state.PlayerEntInfo.EntityPtr + _playerSuppressingCrosshairOffset); } _onceFlag = false; }
public override void OnSessionStart(GameState state) { base.OnSessionStart(state); if (this.IsLastMap) { _bossHP = new MemoryWatcher <int>(state.GetEntityByName("John_Cena") + _baseEntityHealthOffset); } _onceFlag = false; }
bool TryGetGameProcess() { Process p = Process.GetProcesses().FirstOrDefault(x => x.ProcessName.ToLower() == "amnesia"); if (p == null || p.HasExited) { return(false); } byte[] addrBytes = BitConverter.GetBytes((uint)p.MainModuleWow64Safe().BaseAddress + UNUSED_BYTE_OFFSET); // the following code has a very small chance to crash the game due to not suspending threads while writing memory // commented out stuff is for the cracked version of the game (easier to debug when there's no copy protection) // overwrite unused alignment byte with and initialize as our "is loading" var if (!p.WriteBytes(p.MainModuleWow64Safe().BaseAddress + UNUSED_BYTE_OFFSET, 0)) { return(false); } // the following patches are in Amnesia.cLuxMapHandler::CheckMapChange(afTimeStep) // (the game kindly provides us with a .pdb) // this payload is responsible for setting the loadingvar to 1 // We overwrite useless code that is used for debug/error logging // Search for following bytes in memory: 83 7D E8 10 C6 45 FC 00 72 0C 8B 55 D4 // Use the address where the 83 byte is located var payload1 = new List <byte>(new byte[] { 0xC6, 0x05 }); payload1.AddRange(addrBytes); payload1.AddRange(new byte[] { 0x01, 0x90, 0xEB }); if (!p.WriteBytes(p.MainModuleWow64Safe().BaseAddress + 0xC7884, payload1.ToArray())) { return(false); } // this payload is responsible for setting the loadingvar to 0 // We overwrite useless code that is used for debug/error logging // Search for following bytes in memory: FF 50 6A 02 C6 45 FC 04 E8 6A DC // Use the address where the 45 byte is located var payload2 = new List <byte>(new byte[] { 0x05 }); payload2.AddRange(addrBytes); payload2.AddRange(new byte[] { 0x00, 0x90, 0x90 }); if (!p.WriteBytes(p.MainModuleWow64Safe().BaseAddress + 0xC7A6E, payload2.ToArray())) { return(false); } _isLoading = new MemoryWatcher <bool>(p.MainModuleWow64Safe().BaseAddress + UNUSED_BYTE_OFFSET); _process = p; return(true); }
public new void Add(MemoryWatcher watcher) { if (string.IsNullOrEmpty(watcher.Name)) { throw new ArgumentException("Name property is undefined."); } else if (this.Any(s => s.Name == watcher.Name)) { throw new ArgumentException("A MemoryWatcher with the same name is already in the list."); } base.Add(watcher); }
public Watchers(Process game) { this.RaceState = new MemoryWatcher <byte>(new DeepPointer(game.MainModuleWow64Safe().BaseAddress + 0xBF0FFC)) { FailAction = MemoryWatcher.ReadFailAction.SetZeroOrNull }; this.LoadState = new MemoryWatcher <bool>(new DeepPointer(game.MainModuleWow64Safe().BaseAddress + 0x7CE92C, 0x4, 0x0, 0xD400)) { FailAction = MemoryWatcher.ReadFailAction.SetZeroOrNull }; this.AddRange(this.GetType().GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).Where(p => !p.GetIndexParameters().Any()).Select(p => p.GetValue(this, null) as MemoryWatcher).Where(p => p != null)); }
public override void OnSessionStart(GameState state) { base.OnSessionStart(state); if (this.IsLastMap) { _elevatorPos = new MemoryWatcher <Vector3f>(state.GetEntityByName("a10_a11_elevator_body") + state.GameOffsets.BaseEntityAbsOriginOffset); } _splitTime = 0f; _onceFlag = false; }
public override void OnSessionStart(GameState state) { base.OnSessionStart(state); if (this.IsFirstMap) { _splitTime = state.FindOutputFireTime("teleport_trigger"); } else if (this.IsLastMap) { _heliHP = new MemoryWatcher <int>(state.GetEntityByName("helicopter") + _baseEntityHealthOffset); } _onceFlag = false; }
public override void OnSessionStart(GameState state) { base.OnSessionStart(state); if (IsFirstMap) { this._crashButtonPos = new MemoryWatcher <Vector3f>(state.GetEntityByName("bonzibutton") + state.GameOffsets.BaseEntityAbsOriginOffset); } else if (IsLastMap) { this._colorCorrectEnabled = new MemoryWatcher <byte>(state.GetEntityByName("Color_Correction") + _baseColorCorrectEnabledOffset); } _onceFlag = false; _splitTime = 0f; }