Example #1
0
        // Game memory init
        public static void GetGameMemory(
            GameContext gameContext,
            ref NewChildrenEventArgs gameAddress)
        {
            using (WindowsApi.ProcessMemory mem = new WindowsApi.ProcessMemory(gameContext.ProcessId))
            {
                gameAddress.ThisGameAddress = mem.ReadUInt32((IntPtr)gameContext.ThisGameAddress);
                if (gameAddress.ThisGameAddress != 0)
                {
                    gameAddress.ThisGameMemoryAddress = mem.ReadUInt32((IntPtr) unchecked (gameAddress.ThisGameAddress + 0xC));
                    if (gameAddress.ThisGameMemoryAddress == 0xFFFFFFFF)
                    {
                        gameAddress.ThisGameMemoryAddress = 0;
                    }
                }

                if (gameAddress.ThisGameAddress == 0 ||
                    gameAddress.ThisGameMemoryAddress == 0)
                {
                    gameAddress.ThisGameMemoryAddress   = 0;
                    gameAddress.ThisUnitAddress         = 0;
                    gameAddress.AttackAttributesAddress = 0;
                    gameAddress.HeroAttributesAddress   = 0;
                }
            }
        }
Example #2
0
        // Game memory extract algorithm 2
        // Used in MoveSpeed
        public static UInt32 ReadGameValue2(
            WindowsApi.ProcessMemory mem, GameContext gameContext, NewChildrenEventArgs gameAddress,
            Int32 index)
        {
            if (gameAddress.ThisGameMemoryAddress == 0)
            {
                return(0);
            }

            UInt32 tmpValue = ReadFromGameMemory(
                mem, gameContext, gameAddress,
                index);

            if (0 == mem.ReadUInt32((IntPtr) unchecked (tmpValue + 0x20)))
            {
                return(mem.ReadUInt32((IntPtr) unchecked (tmpValue + 0x54)));
            }
            else
            {
                System.Windows.Forms.MessageBox.Show(
                    "Bug detected in ReadGameValue2().",
                    "Bug check");
                // Copy sub_6F468A20() again, set breakpoint at 6F0776F6
                return(0);
            }
        }
Example #3
0
        private void NewChildrenEventReaction(object sender, NewChildrenEventArgs e)
        {
            lock (_allTrainers)
            {
                TrainerNode newNode;
                int         newNodeIndex = _allTrainers.Count;

                // Factory pattern
                switch (e.NodeType)
                {
                case TrainerNodeType.Root:
                    newNode = new RootNode(newNodeIndex, _gameContext, e);
                    break;

                case TrainerNodeType.Introduction:
                    newNode = new IntroductionNode(newNodeIndex, _gameContext, e);
                    break;

                case TrainerNodeType.Cash:
                    newNode = new CashNode(newNodeIndex, _gameContext, e);
                    break;

                case TrainerNodeType.AllSelectedUnits:
                    newNode = new AllSelectedUnitsNode(newNodeIndex, _gameContext, e);
                    break;

                case TrainerNodeType.OneSelectedUnit:
                    newNode = new OneSelectedUnitNode(newNodeIndex, _gameContext, e);
                    break;

                case TrainerNodeType.AttackAttributes:
                    newNode = new AttackAttributesNode(newNodeIndex, _gameContext, e);
                    break;

                case TrainerNodeType.HeroAttributes:
                    newNode = new HeroAttributesNode(newNodeIndex, _gameContext, e);
                    break;

                // case TrainerNodeType.UnitAbility:
                //    newNode = new UnitAbilityNode(newNodeIndex, _gameContext, e);
                //    break;
                case TrainerNodeType.AllItems:
                    newNode = new AllItemsNode(newNodeIndex, _gameContext, e);
                    break;

                case TrainerNodeType.OneItem:
                    newNode = new OneItemNode(newNodeIndex, _gameContext, e);
                    break;

                default:
                    throw new System.ArgumentException("e.NodeType");
                }
                newNode.NewChildren += NewChildrenEventReaction;
                newNode.NewAddress  += NewAddressEventReaction;
                _allTrainers.Add(newNode);
            }
        }
Example #4
0
 public TrainerNode(
     int nodeIndex,
     GameContext gameContext,
     NewChildrenEventArgs args)
 {
     _nodeIndex       = nodeIndex;
     _parentIndex     = args.ParentNodeIndex;
     _gameContext     = gameContext;
     _newChildrenArgs = args;
 }
Example #5
0
 protected void CreateChild(
     TrainerNodeType childType,
     int parentIndex)
 {
     if (NewChildren != null)
     {
         NewChildrenEventArgs args = _newChildrenArgs.Clone();
         args.NodeType        = childType;
         args.ParentNodeIndex = parentIndex;
         NewChildren(this, args);
     }
 }
Example #6
0
        // Game memory extract algorithm 1
        // Used in Intelligence
        public static UInt32 ReadGameValue1(
            WindowsApi.ProcessMemory mem, GameContext gameContext, NewChildrenEventArgs gameAddress,
            Int32 index)
        {
            if (gameAddress.ThisGameMemoryAddress == 0)
            {
                return(0);
            }

            return(unchecked (0x78 + ReadFromGameMemory(
                                  mem, gameContext, gameAddress,
                                  index)));
        }
Example #7
0
        public static UInt32 ReadFromGameMemory(
            WindowsApi.ProcessMemory mem, GameContext gameContext, NewChildrenEventArgs gameAddress,
            Int32 index)
        {
            System.Diagnostics.Debug.Assert(index >= 0);

            if (gameAddress.ThisGameMemoryAddress == 0)
            {
                return(0);
            }

            return(mem.ReadUInt32((IntPtr) unchecked (gameAddress.ThisGameMemoryAddress + index * 8 + 4)));
        }
Example #8
0
        public NewChildrenEventArgs Clone()
        {
            NewChildrenEventArgs retObject = new NewChildrenEventArgs();

            retObject.NodeType                = this.NodeType;
            retObject.ParentNodeIndex         = this.ParentNodeIndex;
            retObject.ThisGameAddress         = this.ThisGameAddress;
            retObject.ThisGameMemoryAddress   = this.ThisGameMemoryAddress;
            retObject.ThisUnitAddress         = this.ThisUnitAddress;
            retObject.AttackAttributesAddress = this.AttackAttributesAddress;
            retObject.HeroAttributesAddress   = this.HeroAttributesAddress;
            retObject.CurrentItemPackAddress  = this.CurrentItemPackAddress;

            return(retObject);
        }
Example #9
0
        /************************************************************************/
        /* Debug                                                                */
        /************************************************************************/
        private void menuDebug1_Click(object sender, EventArgs e)
        {
            string strIndex = Microsoft.VisualBasic.Interaction.InputBox(
                "nIndex = 0x?",
                "War3Common.ReadFromGameMemory(nIndex)",
                "0", -1, -1);

            if (String.IsNullOrEmpty(strIndex))
            {
                return;
            }

            Int32 nIndex;

            if (!Int32.TryParse(
                    strIndex,
                    System.Globalization.NumberStyles.HexNumber,
                    System.Globalization.NumberFormatInfo.InvariantInfo,
                    out nIndex))
            {
                nIndex = 0;
            }

            try
            {
                UInt32 result = 0;
                using (WindowsApi.ProcessMemory mem = new WindowsApi.ProcessMemory(_currentGameContext.ProcessId))
                {
                    NewChildrenEventArgs args = new NewChildrenEventArgs();
                    War3Common.GetGameMemory(
                        _currentGameContext, ref args);
                    result = War3Common.ReadFromGameMemory(
                        mem, _currentGameContext, args,
                        nIndex);
                }
                MessageBox.Show(
                    "0x" + result.ToString("X"),
                    "War3Common.ReadFromGameMemory(0x" + strIndex + ")");
            }
            catch (WindowsApi.BadProcessIdException ex)
            {
                ReportProcessIdFailure(ex.ProcessId);
            }
        }
Example #10
0
        // ctor()
        public GameTrainer(GameContext gameContext)
        {
            this._gameContext = gameContext;

            // Get trainers in 1st layer
            NewChildrenEventArgs args = new NewChildrenEventArgs();

            args.NodeType = TrainerNodeType.Root;
            NewChildrenEventReaction(this, args);

            // Get all other trainers
            int index = 0;
            int count = 1;

            while (index < count)
            {
                lock (_allTrainers)
                {
                    _allTrainers[index].CreateChildren();
                    index++;
                    count = _allTrainers.Count;
                }
            }
        }
Example #11
0
 public AllItemsNode(int nodeIndex, GameContext gameContext, NewChildrenEventArgs args)
     : base(nodeIndex, gameContext, args)
 {
 }
Example #12
0
 public HeroAttributesNode(int nodeIndex, GameContext gameContext, NewChildrenEventArgs args)
     : base(nodeIndex, gameContext, args)
 {
 }
Example #13
0
 public OneSelectedUnitNode(int nodeIndex, GameContext gameContext, NewChildrenEventArgs args)
     : base(nodeIndex, gameContext, args)
 {
 }
Example #14
0
 public IntroductionNode(int nodeIndex, GameContext gameContext, NewChildrenEventArgs args)
     : base(nodeIndex, gameContext, args)
 {
 }