Beispiel #1
0
        //This will apply a patch to all patch results
        public static bool PatchRecursive(Patch patch)
        {
            LogFile.WriteToLog("Starting recursive memory patch for " + patch.title);
            byte[] patchBytes   = HelperFunctions.StringToByteArray(patch.patch);
            byte[] patternBytes = HelperFunctions.StringToByteArray(patch.pattern);
            IntPtr p            = Memory.OpenProcess(0x001F0FFF, true, MainForm.HaloOnline.Id);
            IntPtr PatchReturnAddress;

            PatchReturnAddress = MagicPatches.ScanForPattern(MainForm.HaloOnline, patternBytes, patch.match, patch.offset);

            if (PatchReturnAddress == null || PatchReturnAddress.ToInt32() <= 0)
            {
                return(false);
            }
            else
            {
                bool patched = false;
                while (PatchReturnAddress.ToInt32() > 0 && PatchLoopRun)
                {
                    Memory.WriteProtectedMemory(p, PatchReturnAddress, patchBytes, patchBytes.Length);
                    LogFile.WriteToLog("Recursive Memory Patch (" + patch.title + ") found and patched at " + PatchReturnAddress.ToString("X"));
                    patched = true;
                    IntPtr startOffset = PatchReturnAddress + 0x1;
                    PatchReturnAddress = MagicPatches.ScanForPattern(MainForm.HaloOnline, patternBytes, patch.match, patch.offset, startOffset);
                }
                return(patched);
            }
        }
 private void TestPatchWrite()
 {
     if (listPatternResults.Items.Count > 0)
     {
         MagicPatches.Patch tmpPatch = new MagicPatches.Patch
         {
             title              = txtPatchTitle.Text,
             author             = txtPatchAuthor.Text,
             description        = txtPatchDescription.Text,
             pattern            = txtPatternBytesSearch.Text,
             match              = txtPatternMatch.Text,
             offset             = Convert.ToInt32(txtPatternOffset.Text),
             patch              = txtBytesToPatch.Text,
             recursivePatch     = chkPatchReplaceAll.Checked,
             patchOnStartup     = chkRunOnStartup.Checked,
             patchBeforeStartup = chkPatchBeforeStartup.Checked
         };
         if (tmpPatch.recursivePatch)
         {
             if (MagicPatches.PatchRecursive(tmpPatch))
             {
                 GoogleAnalyticsApi.TrackEvent("PatchEditor.cs", "TestPatchWrite", "Patch Successful");
                 MessageBox.Show("Patch Successful");
             }
             else
             {
                 GoogleAnalyticsApi.TrackEvent("PatchEditor.cs", "TestPatchWrite", "Patch Failed.");
                 MessageBox.Show("Patch Failed.");
             }
         }
         else
         {
             this.Invoke((MethodInvoker) delegate()
             {
                 if (listPatternResults.SelectedItems.Count > 0)
                 {
                     string item         = listPatternResults.SelectedItems[0].ToString();
                     CurrentPatchAddress = (IntPtr)Convert.ToInt32(item, 16);
                     MagicPatches.PatchSingleAddress(tmpPatch, CurrentPatchAddress);
                 }
                 else
                 {
                     MessageBox.Show("If you're not running a full run, you need to select an address in the patch test results.");
                 }
                 btnPatternScanStop.Enabled = false;
                 btnTestPatchWrite.Enabled  = true;
                 btnTestPatchWrite.Text     = "Test Patch";
             });
         }
     }
     else
     {
         MessageBox.Show("You need to run a pattern scan test before you can test writing.");
     }
 }
Beispiel #3
0
        private void btnShowHud_Click(object sender, EventArgs e)
        {
            GoogleAnalyticsApi.TrackEvent("MainForm.cs", "btnShowHud_Click", "");
            btnShowHud.Text    = "Scanning";
            btnShowHud.Enabled = false;

            MagicPatches.RunPatch("Hud Show");

            btnShowHud.Text    = "Show Hud";
            btnShowHud.Enabled = true;
        }
Beispiel #4
0
        //This will apply a patch to only the first value found
        public static bool PatchFirst(Patch patch)
        {
            byte[] patchBytes   = HelperFunctions.StringToByteArray(patch.patch);
            byte[] patternBytes = HelperFunctions.StringToByteArray(patch.pattern);
            IntPtr p            = Memory.OpenProcess(0x001F0FFF, true, MainForm.HaloOnline.Id);
            IntPtr PatchReturnAddress;

            PatchReturnAddress = MagicPatches.ScanForPattern(MainForm.HaloOnline, patternBytes, patch.match, patch.offset);

            if (PatchReturnAddress == null || PatchReturnAddress.ToInt32() <= 0)
            {
                return(false);
            }
            else
            {
                Memory.WriteProtectedMemory(p, PatchReturnAddress, patchBytes, patchBytes.Length);
                LogFile.WriteToLog("Memory Patch (" + patch.title + ") found and patched at " + PatchReturnAddress.ToString("X"));
                return(true);
            }
        }
        private void PatchScanTest()
        {
            IntPtr PatchReturnAddress;

            byte[] searchBytePattern = HelperFunctions.StringToByteArray(txtPatternBytesSearch.Text);
            string match             = txtPatternMatch.Text;
            int    offset            = Convert.ToInt32(txtPatternOffset.Text);

            PatchReturnAddress = MagicPatches.ScanForPattern(MainForm.HaloOnline, searchBytePattern, match, offset);

            if (PatchReturnAddress == null || PatchReturnAddress.ToInt32() <= 0)
            {
                GoogleAnalyticsApi.TrackEvent("PatchEditor.cs", "PatchScanTest", "No results, bad patch?");
                MessageBox.Show("No results, bad patch?");
            }
            else
            {
                GoogleAnalyticsApi.TrackEvent("PatchEditor.cs", "PatchScanTest", "Found Results!");
                while (PatchReturnAddress.ToInt32() > 0)
                {
                    this.Invoke((MethodInvoker) delegate()
                    {
                        listPatternResults.Items.Add(PatchReturnAddress.ToString("X"));
                    });
                    IntPtr startOffset = PatchReturnAddress + 0x1;
                    PatchReturnAddress = MagicPatches.ScanForPattern(MainForm.HaloOnline, searchBytePattern, match, offset, startOffset);
                }
            }
            this.Invoke((MethodInvoker) delegate()
            {
                lblPatternResultCount.Text = listPatternResults.Items.Count.ToString() + " Results";
                btnPatchScanTest.Enabled   = true;
                btnPatchScanTest.Text      = "Test Pattern";
                SetProgressBarValue(0, 0, 100);
            });
        }
Beispiel #6
0
        private void LaunchHaloOnline()
        {
            var darkLoadedProcesses = Process.GetProcesses().Where(pr => pr.ProcessName.Contains("darkloaded"));

            foreach (var process in darkLoadedProcesses)
            {
                process.Kill();
                process.WaitForExit();
            }
            if (!HaloIsRunning)
            {
                try
                {
                    byte[] HaloExeBytes = File.ReadAllBytes(Application.StartupPath + @"\" + HaloOnlineEXE + ".exe");

                    string tmpExe     = Path.Combine(Application.StartupPath, "darkloaded.exe");
                    string gameShield = Path.Combine(Application.StartupPath, "gameShieldDll.dll");

                    MagicPatches.ExePatches(HaloExeBytes);

                    File.WriteAllBytes(tmpExe, HaloExeBytes);
                    Thread.Sleep(100);
                    if (File.Exists(gameShield))
                    {
                        if (File.Exists(gameShield + ".nope"))
                        {
                            File.Delete(gameShield + ".nope");
                        }
                        File.Move(gameShield, gameShield + ".nope");
                    }
                    HaloOnline = new System.Diagnostics.Process();
                    HaloOnline.StartInfo.FileName         = tmpExe;
                    HaloOnline.StartInfo.WorkingDirectory = Application.StartupPath;
                    HaloOnline.StartInfo.Arguments        = txtHaloLaunchArguments.Text + " " + txt4gameArguments.Text + " -launcher";

                    HaloOnline.Start();

                    Thread.Sleep(3000);
                    Memory.SuspendProcess(HaloOnline.Id);
                    MagicPatches.RunStartupPatches();
                    Memory.ResumeProcess(HaloOnline.Id);
                    this.Invoke(new MethodInvoker(delegate
                    {
                        splash.Hide();
                    }));
                }
                catch (Exception e)
                {
                    this.Invoke(new MethodInvoker(delegate
                    {
                        splash.Hide();
                    }));
                    GoogleAnalyticsApi.TrackEvent("MainForm.cs", "LaunchHaloOnline", e.Message);
                    MessageBox.Show("Failed to start Halo Online!\n\n" + e.Message, "Something bad happened.");
                }
            }
            else
            {
                this.Invoke(new MethodInvoker(delegate
                {
                    splash.Hide();
                }));
                GoogleAnalyticsApi.TrackEvent("MainForm.cs", "LaunchHaloOnline", "Halo Already Running");
                MessageBox.Show("Halo Online is already running!", "DarkLoader uh...");
            }
            this.Invoke(new MethodInvoker(delegate
            {
                btnLaunchHaloOnline.Enabled = true;
                btnLaunchHaloOnline.Text    = "Launch Halo Online";
            }));
        }
Beispiel #7
0
        private void ForceLoadMap()
        {
            //Do Magic
            try
            {
                IntPtr p = Memory.OpenProcess(0x001F0FFF, true, HaloOnline.Id);

                if (pAddr == null || pAddr.ToInt32() == 0)
                {
                    pAddr = MagicPatches.ScanForPattern(HaloOnline, new byte[] { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x6D, 0x61, 0x70, 0x73, 0x5C, 0x6D, 0x61, 0x69, 0x6E, 0x6D, 0x65, 0x6E, 0x75 }, "xxxxxxxxxxxxxxxxxxxxx", 0);

                    if (pAddr == null || pAddr.ToInt32() <= 0)
                    {
                        MessageBox.Show("DarkLoader failed to find the map loading code...\nThis could mean two things:\n\n1. You tried loading a map already and closed + opened HaloLoader on the same EXE (You have to keep it running!)\n2. This version of Halo Online is not supported.");
                        return;
                    }
                    //pAddr = 4BB300C
                    PtrMapName  = pAddr + 0xD;         //0x4BB3019
                    PtrMapReset = pAddr - 0x2C;        //0x4BB2FE0
                    PtrMapTime  = pAddr + 0x435;       //0x4BB3441
                    PtrMapType  = pAddr - 0x1C;        //0x4BB2FF0
                    PtrGameType = PtrMapReset + 0x33C; //0x4BB331C
                }
                //Pattern Scan Finds (4BB300C)
                //Map Title = Mainmenu (04BB3019)

                int lpNumberOfBytesWritten = 0;


                //Patch Multiplayer Loading

                /*
                 *   eldorado.Scaleform::Event::TryAcquireCancel+155147 - 8B CE                 - mov ecx,esi
                 *   eldorado.Scaleform::Event::TryAcquireCancel+155149 - 66 89 43 02           - mov [ebx+02],ax
                 *   eldorado.Scaleform::Event::TryAcquireCancel+15514D - E8 9E150000           - call eldorado.Scaleform::Event::TryAcquireCancel+1566F0
                 *   eldorado.Scaleform::Event::TryAcquireCancel+155152 - 8B 47 10              - mov eax,[edi+10]
                 *
                 * */

                if (MpPatchAddr == null || MpPatchAddr.ToInt32() <= 0)
                {
                    //New builds of Halo Online

                    MpPatchAddr = MagicPatches.ScanForPattern(HaloOnline, new byte[] { 0x8B, 0xCE, 0x66, 0x89, 0x43, 0x02, 0xE8, 0x9E, 0x15, 0x00, 0x00, 0x8B, 0x47, 0x10 }, "xxxxx??????xxx", 7);

                    if (MpPatchAddr == null || MpPatchAddr.ToInt32() <= 0)
                    {
                        //Original Halo Online - Eldewrito!
                        MpPatchAddr = MagicPatches.ScanForPattern(HaloOnline, new byte[] { 0x17, 0x56, 0x66, 0x89, 0x47, 0x02, 0xE8, 0x4C, 0xFB, 0xFF, 0xFF, 0x57, 0x53, 0x56 }, "xxxxx??????xxx", 7);
                    }

                    PtrMpPatch = MpPatchAddr - 0x1;
                }

                //Pointer finds 0xF605FE - actual is 0xF605FD

                if (PtrMpPatch.ToInt32() <= 0)
                {
                    GoogleAnalyticsApi.TrackEvent("MainForm.cs", "ForceLoadMap", "Failed to find PtrMpPatch!");
                    MessageBox.Show("Failed to find pointer... Go file a bug report.");
                    return;
                }
                this.btnDarkLoad.Invoke(new MethodInvoker(delegate { btnDarkLoad.Text = "Patching"; }));
                byte[] nop = { 0x90, 0x90, 0x90, 0x90, 0x90 };
                Memory.WriteProcessMemory(p, PtrMpPatch, nop, 5, out lpNumberOfBytesWritten);

                byte[] mapReset = { 0x1 };
                // sets map type
                byte[] mapType = { 0, 0, 0, 0 };
                // sets gametype
                byte[] gameType = { 0, 0, 0, 0 };
                // Infinite play time
                byte[] mapTime = { 0x0 };
                // Grab map name from selected listbox
                byte[] mapName = new byte[36];
                this.comboGameModes.Invoke(new MethodInvoker(delegate
                {
                    BitConverter.GetBytes(Convert.ToInt32(comboGameModes.SelectedIndex)).CopyTo(mapType, 0);
                    BitConverter.GetBytes(Convert.ToInt32(comboGameTypes.SelectedIndex)).CopyTo(gameType, 0);
                    Encoding.ASCII.GetBytes(listMapNames.SelectedItem.ToString()).CopyTo(mapName, 0);
                }));
                Memory.WriteProcessMemory(p, PtrGameType, gameType, 4, out lpNumberOfBytesWritten);
                Memory.WriteProcessMemory(p, PtrMapType, mapType, 4, out lpNumberOfBytesWritten);
                Memory.WriteProcessMemory(p, PtrMapName, mapName, mapName.Length, out lpNumberOfBytesWritten);
                Memory.WriteProcessMemory(p, PtrMapTime, mapTime, 1, out lpNumberOfBytesWritten);
                Memory.WriteProcessMemory(p, PtrMapReset, mapReset, 1, out lpNumberOfBytesWritten);
            }
            catch (Exception ex)
            {
                GoogleAnalyticsApi.TrackEvent("MainForm.cs", "ForceLoadMap", ex.Message);
                MessageBox.Show("Something went wrong...\n" + ex.Message, "DarkLoader Error");
            }
            this.btnDarkLoad.Invoke(new MethodInvoker(delegate
            {
                btnDarkLoad.Text    = "DarkLoad";
                btnDarkLoad.Enabled = true;
            }));
            forceLoading = false;
        }