private void ResetButtonOnClick(object sender, RoutedEventArgs routedEventArgs) { using (TritonHs.AcquireFrame()) { AutoStopSettings.Instance.Reset(); } }
internal static void smethod_2(IBot ibot_1) { try { object obj = object_0; lock (obj) { if (bool_2) { return; } bool_2 = true; } smethod_3(ibot_1, botEvent_4); using (TritonHs.AcquireFrame()) { using (TritonHs.Memory.TemporaryCacheState(false)) { TritonHs.Memory.ClearCache(); ibot_1.Stop(); } } smethod_3(ibot_1, botEvent_5); } finally { object obj = object_0; lock (obj) { bool_2 = false; } } }
private static void smethod_3(IBot ibot_1, BotEvent botEvent_6) { if (botEvent_6 == null) { return; } using (TritonHs.AcquireFrame()) { using (TritonHs.Memory.TemporaryCacheState(false)) { botEvent_6(ibot_1); } } }
internal static void smethod_1(IBot ibot_1) { object obj2; try { obj2 = object_0; lock (obj2) { if (bool_1) { return; } bool_1 = true; } smethod_3(ibot_1, botEvent_2); try { using (TritonHs.AcquireFrame()) { using (TritonHs.Memory.TemporaryCacheState(false)) { TritonHs.Memory.ClearCache(); ibot_1.Tick(); TritonHs.smethod_2(false); } } } catch (Exception exception) { ilog_0.Error("[Tick] Exception during execution:", exception); throw; } smethod_3(ibot_1, botEvent_3); } finally { obj2 = object_0; lock (obj2) { bool_1 = false; } } }
private static void smethod_3(IBot ibot_1, BotEvent botEvent_6) { if (botEvent_6 != null) { try { using (TritonHs.AcquireFrame()) { using (TritonHs.Memory.TemporaryCacheState(false)) { botEvent_6(ibot_1); } } } catch (Exception exception) { ilog_0.Error("[Invoke] Error during execution:", exception); throw; } } }
internal static void smethod_3() { State = StateEnum.None; string[] strArray = string_0; int index = 0; while (true) { if (index >= strArray.Length) { break; } string path = strArray[index]; try { File.Delete(path); } catch { } index++; } ExternalProcessMemory memory = ExternalProcessMemory_0; intptr_1 = memory.GetProcAddress("user32.dll", "GetActiveWindow"); if (intptr_1 == IntPtr.Zero) { throw new Exception("The function 'GetActiveWindow' was not found."); } intptr_0 = memory.GetProcAddress("user32.dll", "GetForegroundWindow"); if (intptr_0 == IntPtr.Zero) { throw new Exception("The function 'GetForegroundWindow' was not found."); } intptr_2 = memory.GetProcAddress("user32.dll", "GetKeyState"); if (intptr_2 == IntPtr.Zero) { throw new Exception("The function 'GetKeyState' was not found."); } intptr_3 = memory.GetProcAddress("user32.dll", "GetCursorPos"); if (intptr_3 == IntPtr.Zero) { throw new Exception("The function 'GetCursorPos' was not found."); } intptr_4 = memory.GetProcAddress("user32.dll", "ScreenToClient"); if (intptr_4 == IntPtr.Zero) { throw new Exception("The function 'ScreenToClient' was not found."); } allocatedMemory_0 = memory.CreateAllocatedMemory(0x1000); List <byte[]> list = smethod_1(); if (list != null) { using (TritonHs.AcquireFrame()) { ExternalProcessMemory_0.WriteBytes(intptr_0, list[0]); ExternalProcessMemory_0.WriteBytes(intptr_1, list[1]); ExternalProcessMemory_0.WriteBytes(intptr_2, list[2]); ExternalProcessMemory_0.WriteBytes(intptr_3, list[3]); ExternalProcessMemory_0.WriteBytes(intptr_4, list[4]); } } bool flag = false; try { int offsetInBytes = 0; IntPtr ptr = IntPtr_0; ManagedFasm asm = memory.Asm; asm.Clear(); asm.AddLine("mov eax, " + ptr.ToString()); asm.AddLine("retn"); byte[] bytes = asm.Assemble(); asm.Clear(); allocatedMemory_0.WriteBytes(0, bytes); IntPtr ptr2 = allocatedMemory_0.Address + IntPtr.Zero; ptr2 = allocatedMemory_0.Address + IntPtr.Zero; int num3 = (ptr2.ToInt32() - intptr_1.ToInt32()) - 5; offsetInBytes = 0 + bytes.Length; byte_0 = new byte[5]; byte_0[0] = 0xe9; byte[] buffer2 = BitConverter.GetBytes((int)((ptr2.ToInt32() - intptr_0.ToInt32()) - 5)); for (int i = 0; i < buffer2.Length; i++) { byte_0[i + 1] = buffer2[i]; } byte_1 = new byte[5]; byte_1[0] = 0xe9; byte[] buffer3 = BitConverter.GetBytes(num3); for (int j = 0; j < buffer3.Length; j++) { byte_1[j + 1] = buffer3[j]; } memory.Patches.Create(intptr_0, byte_0, "ProcessHookManager_GetForegroundWindow"); memory.Patches.Create(intptr_1, byte_1, "ProcessHookManager_GetActiveWindow"); byte[] buffer4 = new byte[0x400]; allocatedMemory_0.WriteBytes(offsetInBytes, buffer4); IntPtr ptr3 = allocatedMemory_0.Address + offsetInBytes; int_0 = offsetInBytes; offsetInBytes += 0x400; byte[] buffer5 = new byte[8]; allocatedMemory_0.WriteBytes(offsetInBytes, buffer5); IntPtr ptr4 = allocatedMemory_0.Address + offsetInBytes; offsetInBytes += 4; IntPtr ptr5 = allocatedMemory_0.Address + offsetInBytes; offsetInBytes += 4; ManagedFasm fasm = memory.Asm; fasm.Clear(); fasm.AddLine("pop eax"); object[] args = new object[] { ptr4 }; fasm.AddLine("mov [{0}], eax", args); fasm.AddLine("pop eax"); object[] objArray2 = new object[] { ptr5 }; fasm.AddLine("mov [{0}], eax", objArray2); fasm.AddLine("imul eax, 4"); object[] objArray3 = new object[] { ptr3 }; fasm.AddLine("add eax, {0}", objArray3); fasm.AddLine("mov eax, [eax]"); object[] objArray4 = new object[] { ptr4 }; fasm.AddLine("pushd [{0}]", objArray4); fasm.AddLine("retn"); byte[] buffer6 = fasm.Assemble(); fasm.Clear(); allocatedMemory_0.WriteBytes(offsetInBytes, buffer6); ptr2 = allocatedMemory_0.Address + offsetInBytes; offsetInBytes += buffer6.Length; byte_2 = new byte[5]; byte_2[0] = 0xe9; byte[] buffer7 = BitConverter.GetBytes((int)((ptr2.ToInt32() - intptr_2.ToInt32()) - 5)); for (int k = 0; k < buffer7.Length; k++) { byte_2[k + 1] = buffer7[k]; } memory.Patches.Create(intptr_2, byte_2, "ProcessHookManager_GetKeyState"); byte[] buffer8 = new byte[12]; buffer8[8] = 1; allocatedMemory_0.WriteBytes(offsetInBytes, buffer8); IntPtr ptr6 = allocatedMemory_0.Address + offsetInBytes; int_1 = offsetInBytes; offsetInBytes += 4; int_2 = offsetInBytes; offsetInBytes += 4; int_3 = offsetInBytes; offsetInBytes += 4; byte[] buffer9 = new byte[8]; allocatedMemory_0.WriteBytes(offsetInBytes, buffer9); IntPtr ptr7 = allocatedMemory_0.Address + offsetInBytes; offsetInBytes += 4; IntPtr ptr8 = allocatedMemory_0.Address + offsetInBytes; offsetInBytes += 4; ManagedFasm fasm2 = memory.Asm; fasm2.Clear(); fasm2.AddLine("pop eax"); object[] objArray5 = new object[] { ptr7 }; fasm2.AddLine("mov [{0}], eax", objArray5); fasm2.AddLine("pop eax"); object[] objArray6 = new object[] { ptr8 }; fasm2.AddLine("mov [{0}], eax", objArray6); fasm2.AddLine("push ecx"); object[] objArray7 = new object[] { ptr6 }; fasm2.AddLine("mov ecx, {0}", objArray7); fasm2.AddLine("mov ecx, [ecx]"); fasm2.AddLine("mov [eax], ecx"); fasm2.AddLine("add eax, 4"); object[] objArray8 = new object[] { ptr6 }; fasm2.AddLine("mov ecx, {0}", objArray8); fasm2.AddLine("add ecx, 4"); fasm2.AddLine("mov ecx, [ecx]"); fasm2.AddLine("mov [eax], ecx"); object[] objArray9 = new object[] { ptr6 }; fasm2.AddLine("mov ecx, {0}", objArray9); fasm2.AddLine("add ecx, 8"); fasm2.AddLine("mov eax, [ecx]"); fasm2.AddLine("pop ecx"); object[] objArray10 = new object[] { ptr7 }; fasm2.AddLine("pushd [{0}]", objArray10); fasm2.AddLine("retn"); byte[] buffer10 = fasm2.Assemble(); fasm2.Clear(); allocatedMemory_0.WriteBytes(offsetInBytes, buffer10); ptr2 = allocatedMemory_0.Address + offsetInBytes; offsetInBytes += buffer10.Length; byte_3 = new byte[5]; byte_3[0] = 0xe9; byte[] buffer11 = BitConverter.GetBytes((int)((ptr2.ToInt32() - intptr_3.ToInt32()) - 5)); for (int m = 0; m < buffer11.Length; m++) { byte_3[m + 1] = buffer11[m]; } memory.Patches.Create(intptr_3, byte_3, "ProcessHookManager_GetCursorPos"); byte[] buffer12 = new byte[12]; buffer12[8] = 1; allocatedMemory_0.WriteBytes(offsetInBytes, buffer12); IntPtr ptr9 = allocatedMemory_0.Address + offsetInBytes; int_4 = offsetInBytes; offsetInBytes += 4; int_5 = offsetInBytes; offsetInBytes += 4; int_6 = offsetInBytes; offsetInBytes += 4; byte[] buffer13 = new byte[12]; allocatedMemory_0.WriteBytes(offsetInBytes, buffer13); IntPtr ptr10 = allocatedMemory_0.Address + offsetInBytes; offsetInBytes += 4; IntPtr ptr11 = allocatedMemory_0.Address + offsetInBytes; offsetInBytes += 4; IntPtr ptr12 = allocatedMemory_0.Address + offsetInBytes; offsetInBytes += 4; ManagedFasm fasm3 = memory.Asm; fasm3.Clear(); fasm3.AddLine("pop eax"); object[] objArray11 = new object[] { ptr10 }; fasm3.AddLine("mov [{0}], eax", objArray11); fasm3.AddLine("pop eax"); object[] objArray12 = new object[] { ptr11 }; fasm3.AddLine("mov [{0}], eax", objArray12); fasm3.AddLine("pop eax"); object[] objArray13 = new object[] { ptr12 }; fasm3.AddLine("mov [{0}], eax", objArray13); fasm3.AddLine("push ecx"); object[] objArray14 = new object[] { ptr9 }; fasm3.AddLine("mov ecx, {0}", objArray14); fasm3.AddLine("mov ecx, [ecx]"); fasm3.AddLine("mov [eax], ecx"); fasm3.AddLine("add eax, 4"); object[] objArray15 = new object[] { ptr9 }; fasm3.AddLine("mov ecx, {0}", objArray15); fasm3.AddLine("add ecx, 4"); fasm3.AddLine("mov ecx, [ecx]"); fasm3.AddLine("mov [eax], ecx"); object[] objArray16 = new object[] { ptr9 }; fasm3.AddLine("mov ecx, {0}", objArray16); fasm3.AddLine("add ecx, 8"); fasm3.AddLine("mov eax, [ecx]"); fasm3.AddLine("pop ecx"); object[] objArray17 = new object[] { ptr10 }; fasm3.AddLine("pushd [{0}]", objArray17); fasm3.AddLine("retn"); byte[] buffer14 = fasm3.Assemble(); fasm3.Clear(); allocatedMemory_0.WriteBytes(offsetInBytes, buffer14); ptr2 = allocatedMemory_0.Address + offsetInBytes; offsetInBytes += buffer14.Length; byte_4 = new byte[5]; byte_4[0] = 0xe9; byte[] buffer15 = BitConverter.GetBytes((int)((ptr2.ToInt32() - intptr_4.ToInt32()) - 5)); for (int n = 0; n < buffer15.Length; n++) { byte_4[n + 1] = buffer15[n]; } memory.Patches.Create(intptr_4, byte_4, "ProcessHookManager_ScreenToClient"); smethod_2(); } catch (Exception) { flag = true; throw; } finally { if (flag && (allocatedMemory_0 != null)) { allocatedMemory_0.Dispose(); allocatedMemory_0 = null; } } }
private static void smethod_2() { List <Class239> source = smethod_0(); if (!source.Any <Class239>((Class240.< > 9__36_0 ?? (Class240.< > 9__36_0 = new Func <Class239, bool>(Class240.< > 9.method_1))))) { Class239 item = new Class239 { int_0 = ExternalProcessMemory_0.Process.Id, list_0 = new List <byte[]>() }; ExternalProcessMemory memory = ExternalProcessMemory_0; using (TritonHs.AcquireFrame()) { item.list_0.Add(memory.Patches["ProcessHookManager_GetForegroundWindow"].OriginalBytes); item.list_0.Add(memory.Patches["ProcessHookManager_GetActiveWindow"].OriginalBytes); item.list_0.Add(memory.Patches["ProcessHookManager_GetKeyState"].OriginalBytes); item.list_0.Add(memory.Patches["ProcessHookManager_GetCursorPos"].OriginalBytes); item.list_0.Add(memory.Patches["ProcessHookManager_ScreenToClient"].OriginalBytes); } source.Add(item); Class239[] classArray = source.ToArray(); int index = 0; while (true) { if (index >= classArray.Length) { break; } Class239 class3 = classArray[index]; try { Process processById = Process.GetProcessById(class3.int_0); try { if (!processById.ProcessName.ToLowerInvariant().Contains("hearthstone")) { source.Remove(class3); } } catch { source.Remove(class3); } } catch (ArgumentException) { source.Remove(class3); } index++; } using (FileStream stream = File.Create(String_0)) { using (BinaryWriter writer = new BinaryWriter(stream)) { writer.Write(source.Count); foreach (Class239 class4 in source) { writer.Write(class4.int_0); writer.Write(class4.list_0.Count); foreach (byte[] buffer in class4.list_0) { writer.Write(buffer.Length); writer.Write(buffer); } } } } } }
public void method_21(object object_0) { try { this.method_22(); string text; if (this.process_0 == null) { MessageBox.Show("can not find process"); return; } else if (!TritonHs.smethod_0(this.process_0, Class12.smethod_4, out text)) { Console.WriteLine(text); MessageBox.Show("TritonHs.smethod_0 == false"); } else { TritonHs.Memory.ProcessExited += Class25.Instance.method_1; TritonHs.Memory.Executor.FrameDropWaitTime = 15000u; TritonHs.Memory.Executor.ExecuteWaitTime = 15000; TritonHs.Memory.DisableCache(); TritonHs.Memory.ClearCache(); int version; int clientChangelist; using (TritonHs.AcquireFrame()) { version = Version.version; clientChangelist = Version.clientChangelist; } if ((long)version != (long)((ulong)Class247.UInt32_1) && (long)clientChangelist != (long)((ulong)Class247.UInt32_2)) { Console.WriteLine("Hearthstone client version ({0}, {1})", version, clientChangelist); //MainWindow.ilog_0.InfoFormat("Hearthstone client version ({0}, {1})", version, clientChangelist); //new Coroutine(new Func<Task>(Class25.Instance.method_2)); smethod_0(); //Configuration.Instance.AddSettings(MainSettings.Instance); //Configuration.Instance.AddSettings(DevSettings.Instance); //Configuration.Instance.SaveAll(); //base.Dispatcher.Invoke(new Action(this.method_23)); //BotManager.PreStart += this.method_11; //BotManager.PostStop += this.method_10; BotManager.Load(); this.method_24(); this.method_25(); //BotManager.OnBotChanged += this.method_6; RoutineManager.Load(); this.method_26(); this.method_27(); //RoutineManager.OnRoutineChanged += this.method_7; //PluginManager.Load(); //foreach (IPlugin plugin in PluginManager.Plugins) //{ // if (MainSettings.Instance.EnabledPlugins.Contains(plugin.Name)) // { // using (TritonHs.AcquireFrame()) // { // PluginManager.Enable(plugin); // } // Thread.Sleep(20); // } // else // { // using (TritonHs.AcquireFrame()) // { // PluginManager.Disable(plugin); // } // Thread.Sleep(20); // } //} //this.listBox_0.Dispatcher.Invoke<IEnumerable>(new Func<IEnumerable>(this.method_28), DispatcherPriority.Normal); this.method_29(); //PluginManager.PluginEnabled += this.method_5; //PluginManager.PluginDisabled += this.method_4; //MainWindow.ilog_0.ErrorFormat("{0}Please read the following guide before using this program:{0}https://github.com/ChuckHearthBuddy/SilverFish/blob/master/ReadMe.md", Environment.NewLine); //base.Dispatcher.Invoke(new Action(this.method_30)); //base.Dispatcher.Invoke(new Action(this.method_31)); //this.stopwatch_0.Restart(); //RoutineManager.OnRoutineChanged += this.method_7; //BotManager.OnBotChanged += this.method_6; TritonHs.IsBotFullyLoaded = true; Hotkeys.Register("BotManager.StartStop", Keys.S, ModifierKeys.Alt | ModifierKeys.Shift, Class25.Instance.method_3); //if (CommandLine.Arguments.Exists("autostart")) { //var bot = new DefaultBot(); //BotManager.CurrentBot = bot; BotManager.Start(); } } else { text = string.Format("This client version ({0}, {1}) is unsupported. Hearthbuddy currently supports client version ({2}, {3}). Please check the forums for more information: https://www.thebuddyforum.com/hearthbuddy-forum/", new object[] { version, clientChangelist, Class247.UInt32_1, Class247.UInt32_2 }); //MainWindow.ilog_0.ErrorFormat(text, Array.Empty<object>()); //System.Windows.MessageBox.Show(text, "Error", MessageBoxButton.OK, MessageBoxImage.Hand); //base.Dispatcher.BeginInvoke(new Action(base.Close), Array.Empty<object>()); } } } catch (Exception exception) { Console.WriteLine(exception); //MainWindow.ilog_0.Error("[OnStartup] A top-level exception has been caught.", exception); } }