コード例 #1
0
        private void TargetUser(PlayerUpdate_t tag)
        {
            checkFamine.CheckedChanged         -= CheckFamine_CheckedChanged;
            checkStripWeapons.CheckedChanged   -= CheckStripWeapons_CheckedChanged;
            checkRemoveResource.CheckedChanged -= CheckRemoveResource_CheckedChanged;
            checkInfinite.CheckedChanged       -= CheckInfinite_CheckedChanged;
            checkInvincible.CheckedChanged     -= CheckInvincible_CheckedChanged;

            targettedUser = tag;

            lblTargetted.Text   = "Targetting User #" + tag.iPlayerNum;
            groupMacros.Enabled = true;

            CControl.GetMacroState_t state = control.GetMacroState(target.Handle, ptrBaseAddress, tag.iPlayerNum);
            checkFamine.Checked         = state.bStarve == 1;
            checkStripWeapons.Checked   = state.bNoWeapons == 1;
            checkRemoveResource.Checked = state.bNoResources == 1;
            checkInfinite.Checked       = state.bInfiniteResources == 1;
            checkInvincible.Checked     = state.bInvincibleTroops == 1;

            checkFamine.CheckedChanged         += CheckFamine_CheckedChanged;
            checkStripWeapons.CheckedChanged   += CheckStripWeapons_CheckedChanged;
            checkRemoveResource.CheckedChanged += CheckRemoveResource_CheckedChanged;
            checkInfinite.CheckedChanged       += CheckInfinite_CheckedChanged;
            checkInvincible.CheckedChanged     += CheckInvincible_CheckedChanged;
        }
コード例 #2
0
        public CPlayerUpdate(int _num, PlayerUpdate_t[] _plys, PlayerUpdate_t _local)
        {
            iLocalPlayerNum = _num;

            this.players = _plys;
            this.local   = _local;
        }
コード例 #3
0
        private bool GetPlayer(int iPlayerID, out PlayerUpdate_t ply)
        {
            for (int i = 0; i < players.Length; i++)
            {
                if (players[i].iPlayerNum == iPlayerID)
                {
                    ply = players[i];
                    return(true);
                }
            }

            ply = new PlayerUpdate_t();
            return(false);
        }
コード例 #4
0
ファイル: CControl.cs プロジェクト: Ald0s/Stronghold2-Trainer
        // Retrieves a current state of all player slots.
        public void GetUpdate(IntPtr ptrHandle, IntPtr ptrBaseAddress)
        {
            // Create an Update_t in foreign process.
            Update_t update    = new Update_t();
            IntPtr   ptrUpdate = ippc.WriteStruct(ptrHandle, update);

            // Pass pointer to Update_t to GetUpdate C++.
            IntPtr ptrGetUpdate = ippc.GetRemoteProcAddress(ptrHandle, ptrBaseAddress, "GetUpdate");

            if (ptrGetUpdate == IntPtr.Zero)
            {
                Console.WriteLine("Failed to get update. GetUpdate exported function not found!");
                return;
            }

            IntPtr ptrThread = ippc.Run(ptrHandle, ptrGetUpdate, ptrUpdate);
            uint   uiResult  = ippc.GetThreadReturnValue(ptrThread);

            // Read Update_t from foreign process.
            update = (Update_t)ippc.ReadStruct(ptrHandle, ptrUpdate, update);

            PlayerUpdate_t ply          = new PlayerUpdate_t();
            object         local_struct = ippc.ReadStruct(ptrHandle, update.ptrLocalPlayer, ply);

            uint[]           uiPlayers = ippc.ReadUIntArray(ptrHandle, update.ptrSlots, PLAYER_NUM);
            PlayerUpdate_t[] players   = new PlayerUpdate_t[PLAYER_NUM];
            for (int i = 0; i < PLAYER_NUM; i++)
            {
                players[i] = (PlayerUpdate_t)ippc.ReadStruct(ptrHandle, new IntPtr(uiPlayers[i]), ply);
            }

            CPlayerUpdate result = new CPlayerUpdate(update.iLocalPlayerNum, players, (PlayerUpdate_t)local_struct);

            UpdateFound(result);

            // Process & Destory memory.
            ippc.FreeMemory(ptrHandle, update.ptrSlots);
            ippc.FreeMemory(ptrHandle, ptrUpdate);
        }
コード例 #5
0
        private void Control_UpdateFound(CPlayerUpdate update)
        {
            if (this.InvokeRequired)
            {
                Control_UpdateFound_Delegate call = new Control_UpdateFound_Delegate(Control_UpdateFound);
                this.Invoke(call, new object[] { update });
            }
            else
            {
                lsPlayers.Items.Clear();

                bool added = false;
                for (int i = 0; i < update.GetPlayerList().Length; i++)
                {
                    PlayerUpdate_t ply = (PlayerUpdate_t)update.GetPlayerList()[i];

                    ListViewItem it = new ListViewItem();
                    it.Tag  = ply;
                    it.Text = ply.iPlayerNum.ToString();
                    it.SubItems.Add(ply.fGold.ToString());
                    it.SubItems.Add(update.GetTotalResources(ply.iPlayerNum).ToString());
                    it.SubItems.Add(update.GetTotalFood(ply.iPlayerNum).ToString());
                    it.SubItems.Add(update.GetTotalWeapons(ply.iPlayerNum).ToString());

                    if (ply.iPlayerNum == update.iLocalPlayerNum)
                    {
                        if (added)
                        {
                            continue;
                        }

                        added   = true;
                        it.Text = it.Text + " (You)";
                    }

                    lsPlayers.Items.Add(it);
                }
            }
        }