//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); } }
//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); }); }
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; }