Beispiel #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;
                }
            }
        }
Beispiel #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);
            }
        }
Beispiel #3
0
        public override void CreateChildren()
        {
            using (WindowsApi.ProcessMemory mem = new WindowsApi.ProcessMemory(_gameContext.ProcessId))
            {
                // Get ESI of each selected unit
                UInt32 selectedUnitList = mem.ReadUInt32((IntPtr)_gameContext.UnitListAddress);
                UInt16 a2 = mem.ReadUInt16((IntPtr) unchecked (selectedUnitList + 0x28));
                UInt32 tmpAddress;
                tmpAddress = mem.ReadUInt32((IntPtr) unchecked (selectedUnitList + 0x58 + 4 * a2));
                tmpAddress = mem.ReadUInt32((IntPtr) unchecked (tmpAddress + 0x34));

                UInt32 listHead = mem.ReadUInt32((IntPtr) unchecked (tmpAddress + 0x1F0));
                // UInt32 listEnd = mem.ReadUInt32((IntPtr)unchecked(tmpAddress + 0x1F4));
                UInt32 listLength = mem.ReadUInt32((IntPtr) unchecked (tmpAddress + 0x1F8));

                UInt32 nextNode = listHead;
                // UInt32 nextNodeNot = ~listHead;
                for (int selectedUnitIndex = 0; selectedUnitIndex < listLength; selectedUnitIndex++)
                {
                    _newChildrenArgs.ThisUnitAddress = mem.ReadUInt32((IntPtr) unchecked (nextNode + 8));
                    // nextNodeNot             = mem.ReadUInt32((IntPtr)unchecked(NextNode + 4));
                    nextNode = mem.ReadUInt32((IntPtr) unchecked (nextNode + 0));

                    base.CreateChild(TrainerNodeType.OneSelectedUnit, NodeIndex);
                }
            }
        }
Beispiel #4
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)));
        }
Beispiel #5
0
        public override void CreateChildren()
        {
            using (WindowsApi.ProcessMemory mem = new WindowsApi.ProcessMemory(_gameContext.ProcessId))
            {
                Int32 list = mem.ReadInt32((IntPtr) unchecked (_newChildrenArgs.ThisUnitAddress + _gameContext.ItemsListOffset));
                if (list != 0)
                {
                    for (Int32 itemIndex = 0; itemIndex < 6; itemIndex++)
                    {
                        UInt32 currentItem = 0;

                        // We assume ItemIndex never go out of bounds to the List
                        Int32 tmpValue1 = mem.ReadInt32((IntPtr) unchecked (list + 0xC * itemIndex + 0x70));
                        if (tmpValue1 > 0)
                        {
                            UInt32 RawItem = War3Common.ReadFromGameMemory(
                                mem, _gameContext, _newChildrenArgs,
                                tmpValue1);
                            if (RawItem != 0)
                            {
                                UInt32 tmpValue2 = mem.ReadUInt32((IntPtr) unchecked (RawItem + 0x20));
                                if (tmpValue2 == 0)
                                {
                                    currentItem = mem.ReadUInt32((IntPtr) unchecked (RawItem + 0x54));
                                }
                            }
                            if (currentItem != 0)
                            {
                                _newChildrenArgs.CurrentItemPackAddress = currentItem;
                                base.CreateChild(TrainerNodeType.OneItem, NodeIndex);
                            }
                        }
                    } // foreach items
                }     // Item list exists
            }         // mem
        }             // CreateChildren()
Beispiel #6
0
        public override void CreateChildren()
        {
            using (WindowsApi.ProcessMemory mem = new WindowsApi.ProcessMemory(_gameContext.ProcessId))
            {
                _newChildrenArgs.AttackAttributesAddress = mem.ReadUInt32((IntPtr) unchecked (_newChildrenArgs.ThisUnitAddress + _gameContext.AttackAttributesOffset));
                _newChildrenArgs.HeroAttributesAddress   = mem.ReadUInt32((IntPtr) unchecked (_newChildrenArgs.ThisUnitAddress + _gameContext.HeroAttributesOffset));

                if (_newChildrenArgs.AttackAttributesAddress > 0)
                {
                    base.CreateChild(TrainerNodeType.AttackAttributes, NodeIndex);
                    // base.CreateChild(TrainerNodeType.UnitAbility, NodeIndex);
                    base.CreateChild(TrainerNodeType.AllItems, NodeIndex);
                }

                if (_newChildrenArgs.HeroAttributesAddress > 0)
                {
                    base.CreateChild(TrainerNodeType.HeroAttributes, NodeIndex);
                }

                // Unit self propety(s)
                CreateAddress(new NewAddressListEventArgs(_nodeIndex,
                                                          "单位名称",
                                                          unchecked (_newChildrenArgs.ThisUnitAddress + 0x30),
                                                          AddressListValueType.Char4));

                UInt32 tmpAddress1, tmpAddress2;
                Int32  tmpValue1, tmpValue2;
                tmpValue1   = mem.ReadInt32((IntPtr) unchecked (_newChildrenArgs.ThisUnitAddress + 0x98 + 0x8));
                tmpAddress1 = War3Common.ReadFromGameMemory(
                    mem, _gameContext, _newChildrenArgs,
                    tmpValue1);
                tmpAddress1 = unchecked (tmpAddress1 + 0x84);
                CreateAddress(new NewAddressListEventArgs(_nodeIndex,
                                                          "HP - 目前",
                                                          unchecked (tmpAddress1 - 0xC),
                                                          AddressListValueType.Float));
                CreateAddress(new NewAddressListEventArgs(_nodeIndex,
                                                          "HP - 最大",
                                                          tmpAddress1,
                                                          AddressListValueType.Float));
                CreateAddress(new NewAddressListEventArgs(_nodeIndex,
                                                          "HP - 回复率",
                                                          unchecked (_newChildrenArgs.ThisUnitAddress + 0xB0),
                                                          AddressListValueType.Float));

                tmpValue1   = mem.ReadInt32((IntPtr) unchecked (_newChildrenArgs.ThisUnitAddress + 0x98 + 0x28));
                tmpAddress1 = War3Common.ReadFromGameMemory(
                    mem, _gameContext, _newChildrenArgs,
                    tmpValue1);
                tmpAddress1 = unchecked (tmpAddress1 + 0x84);
                CreateAddress(new NewAddressListEventArgs(_nodeIndex,
                                                          "MP - 目前",
                                                          unchecked (tmpAddress1 - 0xC),
                                                          AddressListValueType.Float));
                CreateAddress(new NewAddressListEventArgs(_nodeIndex,
                                                          "MP - 最大",
                                                          tmpAddress1,
                                                          AddressListValueType.Float));
                CreateAddress(new NewAddressListEventArgs(_nodeIndex,
                                                          "MP - 回复率",
                                                          unchecked (_newChildrenArgs.ThisUnitAddress + 0xD4),
                                                          AddressListValueType.Float));

                CreateAddress(new NewAddressListEventArgs(_nodeIndex,
                                                          "盔甲 - 数量",
                                                          unchecked (_newChildrenArgs.ThisUnitAddress + 0xE0),
                                                          AddressListValueType.Float));
                CreateAddress(new NewAddressListEventArgs(_nodeIndex,
                                                          "盔甲 - 种类",
                                                          unchecked (_newChildrenArgs.ThisUnitAddress + 0xE4),
                                                          AddressListValueType.Integer));

                // Move speed
                tmpAddress1 = unchecked (_newChildrenArgs.ThisUnitAddress + _gameContext.MoveSpeedOffset - 0x24);
                do
                {
                    tmpValue1   = mem.ReadInt32((IntPtr) unchecked (tmpAddress1 + 0x24));
                    tmpAddress1 = War3Common.ReadGameValue2(
                        mem, _gameContext, _newChildrenArgs,
                        tmpValue1);
                    tmpAddress2 = mem.ReadUInt32((IntPtr) unchecked (tmpAddress1 + 0));
                    tmpValue1   = mem.ReadInt32((IntPtr) unchecked (tmpAddress1 + 0x24));
                    tmpValue2   = mem.ReadInt32((IntPtr) unchecked (tmpAddress1 + 0x28));

                    // Note: If new game version released, set breakpoint here
                    //       and check tmpAddress2. Set this value as War3AddressMoveSpeed
                    tmpAddress2 = mem.ReadUInt32((IntPtr) unchecked (tmpAddress2 + 0x2D4));
                    if (_gameContext.MoveSpeedAddress == tmpAddress2)
                    {
                        CreateAddress(new NewAddressListEventArgs(_nodeIndex,
                                                                  "移动速度",
                                                                  unchecked (tmpAddress1 + 0x70), // +70 or +78 are both OK
                                                                  AddressListValueType.Float));
                    }
                } while (tmpValue1 > 0 && tmpValue2 > 0);

                // Coordinate
                tmpValue1   = mem.ReadInt32((IntPtr) unchecked (_newChildrenArgs.ThisUnitAddress + 0x164 + 8));
                tmpAddress1 = War3Common.ReadGameValue1(
                    mem, _gameContext, _newChildrenArgs,
                    tmpValue1);
                CreateAddress(new NewAddressListEventArgs(_nodeIndex,
                                                          "坐标 - X",
                                                          tmpAddress1,
                                                          AddressListValueType.Float));
                CreateAddress(new NewAddressListEventArgs(_nodeIndex,
                                                          "坐标 - Y",
                                                          unchecked (tmpAddress1 + 4),
                                                          AddressListValueType.Float));
            }
        }