Example #1
0
        private void btnChangeName_Click(object sender, EventArgs e)
        {
            InitProcess();

            try
            {
                if (tbName.Text.Length > 0)
                {
                    if (SelectedVersion.Version == 1)
                    {
                        HotsOffsets_V1 CurrentVersion = SelectedVersion as HotsOffsets_V1;
                        IntPtr         pPlayer        = CurrentVersion.HotsPlayers + (LocalPlayerIndex * HotsPlayer.Size);
                        Memory.WriteCString(pPlayer + NameOffset, tbName.Text);
                    }
                    else if (SelectedVersion.Version >= 2)
                    {
                        HotsOffsets_V2 CurrentVersion = SelectedVersion as HotsOffsets_V2;
                        IntPtr         pPlayer        = CurrentVersion.HotsPlayers + CurrentVersion.f;
                        Memory.WriteCString(pPlayer + 96, this.tbName.Text);
                        Memory.WriteCString(pPlayer + 184, this.tbName.Text);
                    }
                }
            }
            catch
            {
                MessageBox.Show("Name change failed!");
            }
        }
Example #2
0
        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            try
            {
                if (SelectedVersion.Version == 1)
                {
                    HotsOffsets_V1 CurrentVersion = SelectedVersion as HotsOffsets_V1;

                    if (oldMapPtr1 != IntPtr.Zero)
                    {
                        Memory.Write <IntPtr>(CurrentVersion.PatchMapOffset1, oldMapPtr1);
                    }
                    if (oldMapPtr2 != IntPtr.Zero)
                    {
                        Memory.Write <IntPtr>(CurrentVersion.PatchMapOffset2, oldMapPtr2);
                    }
                    if (mapNamePtr != IntPtr.Zero)
                    {
                        Memory.FreeAll(mapNamePtr);
                    }
                }
            }
            catch
            {
            }
        }
Example #3
0
        private void btnApply_Click(object sender, EventArgs e)
        {
            InitProcess();

            try
            {
                if (SelectedVersion.Version == 1)
                {
                    HotsOffsets_V1  CurrentVersion = SelectedVersion as HotsOffsets_V1;
                    FileVersionInfo ver            = Memory.CurrentProcess.MainModule.FileVersionInfo;

                    if (ver.FilePrivatePart != Offsets[cbVersions.SelectedIndex].Build)
                    {
                        MessageBox.Show("Wrong or incompatible build selected! Patch failed.");
                        return;
                    }

                    // Map patch
                    byte[] mapName = Encoding.ASCII.GetBytes(cbMapSelect.SelectedItem + "\0\0\0");

                    if (mapNamePtr == IntPtr.Zero)
                    {
                        mapNamePtr = Memory.Alloc(mapName.Length);
                    }

                    Memory.Write(mapNamePtr, mapName);

                    oldMapPtr1 = Memory.Read <IntPtr>(CurrentVersion.PatchMapOffset1);
                    oldMapPtr2 = Memory.Read <IntPtr>(CurrentVersion.PatchMapOffset2);

                    Memory.Write <IntPtr>(CurrentVersion.PatchMapOffset1, mapNamePtr);
                    Memory.Write <IntPtr>(CurrentVersion.PatchMapOffset2, mapNamePtr + mapName.Length - 3);
                }

                for (int i = 0; i < 10; ++i)
                {
                    Heroes[i] = (int)Enum.Parse(SelectedVersion.HeroIDEnum, (string)HeroComboBoxes[i].SelectedItem);
                }

                AlliedAI = (AIDifficulty)Enum.Parse(typeof(AIDifficulty), (string)cbAllyTeamAI.SelectedItem);
                EnemyAI  = (AIDifficulty)Enum.Parse(typeof(AIDifficulty), (string)cbEnemyTeamAI.SelectedItem);

                timer1.Enabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }