private void _checkTimer_Tick(object sender, EventArgs e) { Dota2Classes.PlayerResources playerResourceObject; try { if (_processMemory.ReadInt32Ptr(_dotaPlayerAddress) == IntPtr.Zero) { return; } var playerResourcePtr = _processMemory.ReadInt32Ptr(_playerResourceAddress); if (playerResourcePtr == IntPtr.Zero) { return; } playerResourceObject = new Dota2Classes.PlayerResources(_processMemory, playerResourcePtr); } catch (ApplicationException) { _checkTimer.Stop(); _searchTimer.Start(); return; } var numHeroes = 0; var container = new StackPanel { Margin = new Thickness(0) }; var playerList = new Dota2Classes.PlayerList(_processMemory, _playersListAddress); var entityList = new Dota2Classes.EntityList(_processMemory, _engineAddress); for (var i = 0; i < 32; i++) { var dotaPlayer = playerList.GetPlayerById(i); if (dotaPlayer == null) { continue; } var playerId = dotaPlayer.PlayerId; var hero = entityList.GetHeroById(dotaPlayer.EntityId); float mana = hero.Mana; float health = hero.Health; int level = hero.Level; int gold = playerResourceObject.GetGold(playerId); if (playerResourceObject.IsValidPlayer(playerId) == false) { continue; } Dota2Classes.Inventory inventory = hero.Inventory; var items = new List <Dota2Classes.Item>(); for (var j = 0; j < 6; j++) { var itemEntityId = inventory.GetItemIdByIndex(j); if (itemEntityId <= 0) { continue; } var item = entityList.GetItemById(itemEntityId); if (item == null) { continue; } items.Add(item); } var semiTransparentControl = new Grid { Margin = new Thickness(0, 5, 0, 0), Height = 60, Width = 130, Background = new SolidColorBrush(Color.FromArgb(100, 0, 0, 0)) }; semiTransparentControl.Children.Add(new Label { Content = string.Format("{0}", level), Margin = new Thickness(0, 0, 0, 0), Foreground = Brushes.White, }); semiTransparentControl.Children.Add(new Label { Content = string.Format("{0}", playerResourceObject.GetPlayerName(playerId)), Margin = new Thickness(25, 0, 0, 0), Foreground = Brushes.White, }); var stackImage = new StackPanel { Margin = new Thickness(0, 30, 0, 0), Orientation = Orientation.Horizontal, }; foreach (Dota2Classes.Items itemType in Enum.GetValues(typeof(Dota2Classes.Items))) { var item = items.Find(x => x.ItemId == itemType); if (item != null) { stackImage.Children.Add(GetItemControl(item)); } } semiTransparentControl.Children.Add(stackImage); semiTransparentControl.Children.Add(new Label { Content = string.Format("{0:0}", mana), Margin = new Thickness(30, 15, 0, 0), Foreground = Brushes.LightBlue }); semiTransparentControl.Children.Add(new Label { Content = string.Format("{0}", health), Margin = new Thickness(0, 15, 0, 0), Foreground = health < 500 ? Brushes.OrangeRed : Brushes.GreenYellow }); semiTransparentControl.Children.Add(new Label { Content = string.Format("{0}", gold), Margin = new Thickness(60, 15, 0, 0), Foreground = Brushes.Gold }); container.Children.Add(semiTransparentControl); numHeroes++; } _playersOverlay.Content = container; _playersOverlay.Height = 100 + numHeroes * 70; _playersOverlay.Width = 120; int index = _processMemory.ReadInt16(_processMemory.ReadInt32Ptr(_dotaPlayerAddress) + 0x19A4); _heroAddress = _processMemory.ReadInt32Ptr(_engineAddress + index * 16); _isVisibleOverlay.Background = _processMemory.ReadBytes(_heroAddress + 0x12E0, 1)[0] == 30 ? Brushes.Red : Brushes.Green; distanceUpDown.Value = _processMemory.ReadInt32(_distanceAddress); fovUpDown.Value = (int?)_processMemory.ReadFloat(_fovAddress); rangeCheckbox.IsChecked = _processMemory.ReadInt32(_rangeAddress) == 816; }
protected override void ReadMemory() { long pGameContext = ProcessMemory.ReadInt64(Offsets.GameContext.GetInstance()); long pGameRenderer = ProcessMemory.ReadInt64(Offsets.GameRenderer.GetInstance()); //read local player if (ProcessMemory.IsValid(pGameRenderer)) { long pRenderView = ProcessMemory.ReadInt64(pGameRenderer + Offsets.GameRenderer.PRenderView); if (ProcessMemory.IsValid(pRenderView)) { _localPlayer.ViewProj = ProcessMemory.ReadMatrix(pRenderView + Offsets.RenderView.PViewProj); } } if (ProcessMemory.IsValid(pGameContext)) { long pPlayerManager = ProcessMemory.ReadInt64(pGameContext + Offsets.GameContext.PPlayerManager); if (ProcessMemory.IsValid(pPlayerManager)) { long pLocalPlayer = ProcessMemory.ReadInt64(pPlayerManager + Offsets.ClientPlayerManager.PLocalPlayer); if (ProcessMemory.IsValid(pLocalPlayer)) { _localPlayer.Name = ProcessMemory.ReadAsciiString(pLocalPlayer + Offsets.ClientPlayer.Name, 10); _localPlayer.TeamId = ProcessMemory.ReadInt32(pLocalPlayer + Offsets.ClientPlayer.TeamId); long pSoldierEntity = ProcessMemory.ReadInt64(pLocalPlayer + Offsets.ClientPlayer.PControlledControllable); if (ProcessMemory.IsValid(pSoldierEntity)) { _localPlayer.Yaw = ProcessMemory.ReadFloat(pSoldierEntity + Offsets.ClientSoldierEntity.Yaw); long pPredictedController = ProcessMemory.ReadInt64(pSoldierEntity + Offsets.ClientSoldierEntity.PPredictedController); if (ProcessMemory.IsValid(pPredictedController)) { _localPlayer.Position = ProcessMemory.ReadVector3(pPredictedController + Offsets.ClientSoldierPrediction.PPosition); } } } } } //read players _players.Clear(); if (ProcessMemory.IsValid(pGameContext)) { long pPlayerManager = ProcessMemory.ReadInt64(pGameContext + Offsets.GameContext.PPlayerManager); if (ProcessMemory.IsValid(pPlayerManager)) { long ppPlayer = ProcessMemory.ReadInt64(pPlayerManager + Offsets.ClientPlayerManager.PClientPlayer); if (ProcessMemory.IsValid(ppPlayer)) { for (int i = 0; i < 64; i++) { long pPlayer = ProcessMemory.ReadInt64(ppPlayer + i * 0x8); if (ProcessMemory.IsValid(pPlayer)) { Player player = new Player(); player.Name = ProcessMemory.ReadAsciiString(pPlayer + Offsets.ClientPlayer.Name, 10); player.TeamId = ProcessMemory.ReadInt32(pPlayer + Offsets.ClientPlayer.TeamId); player.IsSpectator = ProcessMemory.ReadBool(pPlayer + Offsets.ClientPlayer.IsSpectator); long pSoldierEntity = ProcessMemory.ReadInt64(pPlayer + Offsets.ClientPlayer.PControlledControllable); if (ProcessMemory.IsValid(pSoldierEntity)) { player.Yaw = ProcessMemory.ReadFloat(pSoldierEntity + Offsets.ClientSoldierEntity.Yaw); player.IsVisible = ProcessMemory.ReadBool(pSoldierEntity + Offsets.ClientSoldierEntity.IsOccluded); player.PoseType = (Player.Pose)ProcessMemory.ReadInt32(pSoldierEntity + Offsets.ClientSoldierEntity.PoseType); long pHealthComponent = ProcessMemory.ReadInt64(pSoldierEntity + Offsets.ClientSoldierEntity.PHealthComponent); if (ProcessMemory.IsValid(pHealthComponent)) { player.Health = ProcessMemory.ReadFloat(pHealthComponent + Offsets.HealthComponent.Health); player.MaxHealth = ProcessMemory.ReadFloat(pHealthComponent + Offsets.HealthComponent.MaxHealth); } long pPredictedController = ProcessMemory.ReadInt64(pSoldierEntity + Offsets.ClientSoldierEntity.PPredictedController); if (ProcessMemory.IsValid(pPredictedController)) { player.Position = ProcessMemory.ReadVector3(pPredictedController + Offsets.ClientPredictedController.Position); } } _players.Add(player); } } } } } }