//private static void CorruptTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) //{ // lock (CorruptLock) // { // if (!VanguardCore.vanguardConnected || AllSpec.CorruptCoreSpec == null || (p?.HasExited ?? true)) // { // AutoCorruptTimer.Start(); // return; // } // try // { // if (!DontChangeMemoryProtection) // { // foreach (var m in MemoryDomains.MemoryInterfaces?.Values ?? Enumerable.Empty<MemoryDomainProxy>()) // { // if (m.MD is ProcessMemoryDomain pmd) // { // pmd.SetMemoryProtection(ProcessExtensions.MemoryProtection.ExecuteReadWrite); // if (p?.HasExited ?? false) // { // Console.WriteLine($"Bad! {pmd.Name}"); // } // } // } // } // try // { // RtcClock.StepCorrupt(true, true); // if (p?.HasExited ?? false) // { // Console.WriteLine($"Bad2!"); // } // } // catch (Exception ex) // { // Console.WriteLine($"STEP_CORRUPT Error!\n{ex.Message}\n{ex.StackTrace}"); // } // } // finally // { // if (!DontChangeMemoryProtection) // { // foreach (var m in MemoryDomains.MemoryInterfaces?.Values ?? Enumerable.Empty<MemoryDomainProxy>()) // { // if (m.MD is ProcessMemoryDomain pmd) // { // pmd.ResetMemoryProtection(); // pmd.FlushInstructionCache(); // } // if (p?.HasExited ?? false) // { // Console.WriteLine($"Bad3!"); // } // } // } // } // } // if (p.HasExited) // { // Console.WriteLine($"Bad4!"); // } // AutoCorruptTimer.Start(); //} //private static void AutoHookTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) //{ // try // { // if (p?.HasExited == false) // return; // SyncObjectSingleton.FormExecute(() => S.GET<StubForm>().lbTargetStatus.Text = "Waiting..."); // var procToFind = S.GET<StubForm>().tbClientAddr.Text; // if (string.IsNullOrWhiteSpace(procToFind)) // return; // SyncObjectSingleton.FormExecute(() => S.GET<StubForm>().lbTargetStatus.Text = "Hooking..."); // var _p = Process.GetProcesses().First(x => x.ProcessName == procToFind); // if (_p != null) // { // Thread.Sleep(2000); //Give the process 2 seconds // SyncObjectSingleton.FormExecute(() => // { // LoadTarget(_p); // if (!VanguardCore.vanguardConnected) // VanguardCore.Start(); // S.GET<StubForm>().EnableTargetInterface(); // }); // } // } // catch (Exception ex) // { // Console.WriteLine($"AutoHook failed.\n{ex.Message}\n{ex.StackTrace}"); // } // AutoHookTimer.Start(); //} //internal static bool LoadTarget(Process _p = null) //{ // lock (CorruptLock) // { // if (_p == null) // { // using (var f = new HookProcessForm()) // { // if (f.ShowDialog() != DialogResult.OK) // return false; // if (f.RequestedProcess == null || (f.RequestedProcess?.HasExited ?? true)) // { // return false; // } // if (IsProcessBlacklisted(f.RequestedProcess)) // { // MessageBox.Show("Blacklisted process"); // return false; // } // p = f.RequestedProcess; // } // } // else // p = _p; // /* // if (UseExceptionHandler) // { // ProcessExtensions.IsWow64Process(p.Handle, out bool is32BitProcess); //This method is stupid and returns the inverse // string path = is32BitProcess // ? Path.Combine(currentDir, "ExceptionHandler_x86.dll") // : Path.Combine(currentDir, "ExceptionHandler_x64.dll"); // if (File.Exists(path)) // { // try // { // using (var i = new Injector(InjectionMethod.CreateThread, p.Id, path)) // { // if ((ulong) i.InjectDll() != 0) // { // Console.WriteLine("Injected exception helper successfully"); // } // } // } // catch (Exception e) // { // Console.WriteLine($"Injection failed! {e}"); // } // } // }*/ // Action<object, EventArgs> action = (ob, ea) => // { // if (VanguardCore.vanguardConnected) // UpdateDomains(); // }; // Action<object, EventArgs> postAction = (ob, ea) => // { // if (p == null) // { // MessageBox.Show("Failed to load target"); // S.GET<StubForm>().DisableTargetInterface(); // return; // } // S.GET<StubForm>().lbTarget.Text = p.ProcessName; // S.GET<StubForm>().lbTargetStatus.Text = "Hooked!"; // //Refresh the UI // //RefreshUIPostLoad(); // }; // S.GET<StubForm>().RunProgressBar($"Loading target...", 0, action, postAction); // } // return true; //} //internal static bool CloseTarget(bool updateDomains = true) //{ // p = null; // if (updateDomains) // UpdateDomains(); // return true; //} public static void UpdateDomains() { if (!VanguardCore.vanguardConnected) { return; } try { PartialSpec gameDone = new PartialSpec("VanguardSpec"); gameDone[VSPEC.SYSTEM] = "Linux"; gameDone[VSPEC.GAMENAME] = "IGNORE"; gameDone[VSPEC.SYSTEMPREFIX] = "Linux"; gameDone[VSPEC.SYSTEMCORE] = "Linux"; gameDone[VSPEC.OPENROMFILENAME] = "IGNORE"; gameDone[VSPEC.MEMORYDOMAINS_BLACKLISTEDDOMAINS] = Array.Empty <string>(); gameDone[VSPEC.MEMORYDOMAINS_INTERFACES] = GetInterfaces(); gameDone[VSPEC.CORE_DISKBASED] = false; AllSpec.VanguardSpec.Update(gameDone); //This is local. If the domains changed it propgates over netcore LocalNetCoreRouter.Route(RTCV.NetCore.Endpoints.CorruptCore, RTCV.NetCore.Commands.Remote.EventDomainsUpdated, true, true); //Asks RTC to restrict any features unsupported by the stub LocalNetCoreRouter.Route(RTCV.NetCore.Endpoints.CorruptCore, RTCV.NetCore.Commands.Remote.EventRestrictFeatures, true, true); } catch (Exception ex) { if (VanguardCore.ShowErrorDialog(ex) == DialogResult.Abort) { throw new RTCV.NetCore.AbortEverythingException(); } } }
private void CbSelectedGame_SelectedIndexChanged(object sender, EventArgs e) { if (CemuWatch.DontSelectGame) { return; } string selected = cbSelectedGame.SelectedItem.ToString(); if (selected == "Autodetect") { CemuWatch.Start(); return; } if (!CemuWatch.SelectGame(selected)) { cbSelectedGame.SelectedIndex = 0; return; } if (!VanguardCore.vanguardStarted) { VanguardCore.Start(); } else if (VanguardCore.vanguardConnected) { CemuWatch.UpdateDomains(); } }
public static void UpdateDomains() { try { PartialSpec gameDone = new PartialSpec("VanguardSpec"); gameDone[VSPEC.SYSTEM] = "FileSystem"; gameDone[VSPEC.GAMENAME] = FileWatch.currentSession.targetShortName; gameDone[VSPEC.SYSTEMPREFIX] = "FileStub"; gameDone[VSPEC.SYSTEMCORE] = "FileStub"; //gameDone[VSPEC.SYNCSETTINGS] = BIZHAWK_GETSET_SYNCSETTINGS; gameDone[VSPEC.OPENROMFILENAME] = currentSession.targetFullName; gameDone[VSPEC.MEMORYDOMAINS_BLACKLISTEDDOMAINS] = Array.Empty <string>(); gameDone[VSPEC.MEMORYDOMAINS_INTERFACES] = GetInterfaces(); gameDone[VSPEC.CORE_DISKBASED] = false; AllSpec.VanguardSpec.Update(gameDone); //This is local. If the domains changed it propgates over netcore LocalNetCoreRouter.Route(RTCV.NetCore.Endpoints.CorruptCore, RTCV.NetCore.Commands.Remote.EventDomainsUpdated, true, true); //Asks RTC to restrict any features unsupported by the stub LocalNetCoreRouter.Route(RTCV.NetCore.Endpoints.CorruptCore, RTCV.NetCore.Commands.Remote.EventRestrictFeatures, true, true); } catch (Exception ex) { if (VanguardCore.ShowErrorDialog(ex) == DialogResult.Abort) { throw new RTCV.NetCore.AbortEverythingException(); } } }
public static void UpdateDomains() { try { PartialSpec gameDone = new PartialSpec("VanguardSpec"); gameDone[VSPEC.SYSTEM] = "FileSystem"; gameDone[VSPEC.GAMENAME] = FileWatch.currentFileInfo.targetShortName; gameDone[VSPEC.SYSTEMPREFIX] = "FileStub"; gameDone[VSPEC.SYSTEMCORE] = "FileStub"; //gameDone[VSPEC.SYNCSETTINGS] = BIZHAWK_GETSET_SYNCSETTINGS; gameDone[VSPEC.OPENROMFILENAME] = currentFileInfo.targetFullName; gameDone[VSPEC.MEMORYDOMAINS_BLACKLISTEDDOMAINS] = new string[0]; gameDone[VSPEC.MEMORYDOMAINS_INTERFACES] = GetInterfaces(); gameDone[VSPEC.CORE_DISKBASED] = false; AllSpec.VanguardSpec.Update(gameDone); //This is local. If the domains changed it propgates over netcore LocalNetCoreRouter.Route(NetcoreCommands.CORRUPTCORE, NetcoreCommands.REMOTE_EVENT_DOMAINSUPDATED, true, true); //Asks RTC to restrict any features unsupported by the stub LocalNetCoreRouter.Route(NetcoreCommands.CORRUPTCORE, NetcoreCommands.REMOTE_EVENT_RESTRICTFEATURES, true, true); } catch (Exception ex) { if (VanguardCore.ShowErrorDialog(ex) == DialogResult.Abort) { throw new RTCV.NetCore.AbortEverythingException(); } } }
public void btnLoadTargets_Click(object sender, EventArgs e) { FileTarget[] overrideTargets = null; if (selectedTemplate != null) { lbTargets.Items.Clear(); overrideTargets = selectedTemplate.GetTargets(); //if (targets != null) // lbTargets.Items.AddRange(targets); //overrideTargets. } if (overrideTargets == null) { MessageBox.Show("Error loading target"); } if (!FileWatch.LoadTargets(overrideTargets)) { return; } if (!VanguardCore.vanguardConnected) { VanguardCore.Start(); } EnableTargetInterface(); }
private void BtnLoadTarget_Click(object sender, EventArgs e) { //only use backups for uncorrupt, reset on every reload foreach (string file in Directory.GetFiles(Path.Combine(FileWatch.currentDir, "FILEBACKUPS"))) { try { File.Delete(file); } catch { MessageBox.Show($"Could not delete file {file}"); } } if (!FileWatch.LoadTarget()) { return; } if (!VanguardCore.vanguardConnected) { VanguardCore.Start(); } EnableTargetInterface(); }
private void BtnBrowseTarget_Click(object sender, EventArgs e) { if (!UnityWatch.LoadTarget()) { return; } if (!VanguardCore.vanguardConnected) { VanguardCore.Start(); } EnableInterface(); }
public static MemoryDomainProxy[] GetInterfaces() { try { Console.WriteLine($" getInterfaces()"); if (currentFileInfo.targetInterface == null) { Console.WriteLine($"rpxInterface was null!"); return(new MemoryDomainProxy[] { }); } List <MemoryDomainProxy> interfaces = new List <MemoryDomainProxy>(); switch (currentFileInfo.selectedTargetType) { //Checking if the FileInterface/MultiFileInterface is split in sub FileInterfaces case TargetType.MULTIPLE_FILE_MULTIDOMAIN: case TargetType.MULTIPLE_FILE_MULTIDOMAIN_FULLPATH: foreach (var fi in (currentFileInfo.targetInterface as MultipleFileInterface).FileInterfaces) { interfaces.Add(new MemoryDomainProxy(fi)); } break; case TargetType.SINGLE_FILE: case TargetType.MULTIPLE_FILE_SINGLEDOMAIN: default: interfaces.Add(new MemoryDomainProxy(currentFileInfo.targetInterface)); break; } foreach (MemoryDomainProxy mdp in interfaces) { mdp.BigEndian = currentFileInfo.bigEndian; } return(interfaces.ToArray()); } catch (Exception ex) { if (VanguardCore.ShowErrorDialog(ex, true) == DialogResult.Abort) { throw new RTCV.NetCore.AbortEverythingException(); } return(new MemoryDomainProxy[] { }); } }
static Program() { //this needs to be done before the warnings/errors show up Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //RTC_Hijack : Hijack unhandled errors Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); Application.ThreadException += (o, e) => VanguardCore.ApplicationThreadException(GlobalWin.MainForm, e); AppDomain.CurrentDomain.UnhandledException += (o, e) => VanguardCore.CurrentDomainOnUnhandledException(GlobalWin.MainForm, e); //------------------------- if (OSTC.IsUnixHost) { // for Unix, skip everything else and just wire up the event handler AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; return; }
private static void AutoHookTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { try { if (p?.HasExited == false) { return; } SyncObjectSingleton.FormExecute(() => S.GET <StubForm>().lbTargetStatus.Text = "Waiting..."); var procToFind = S.GET <StubForm>().tbAutoAttach.Text; if (string.IsNullOrWhiteSpace(procToFind)) { return; } SyncObjectSingleton.FormExecute(() => S.GET <StubForm>().lbTargetStatus.Text = "Hooking..."); var _p = Process.GetProcesses().First(x => x.ProcessName == procToFind); if (_p != null) { Thread.Sleep(2000); //Give the process 2 seconds SyncObjectSingleton.FormExecute(() => { LoadTarget(_p); if (!VanguardCore.vanguardConnected) { VanguardCore.Start(); } S.GET <StubForm>().EnableTargetInterface(); }); } } catch (Exception ex) { Console.WriteLine($"AutoHook failed.\n{ex.Message}\n{ex.StackTrace}"); } AutoHookTimer.Start(); }
public static MemoryDomainProxy[] GetInterfaces() { try { Console.WriteLine($" getInterfaces()"); if (currentFileInfo.targetInterface == null) { Console.WriteLine($"rpxInterface was null!"); return(new MemoryDomainProxy[] { }); } List <MemoryDomainProxy> interfaces = new List <MemoryDomainProxy>(); foreach (var fi in (currentFileInfo.targetInterface as MultipleFileInterface).FileInterfaces) { interfaces.Add(new MemoryDomainProxy(fi)); } foreach (MemoryDomainProxy mdp in interfaces) { mdp.BigEndian = currentFileInfo.bigEndian; } return(interfaces.ToArray()); } catch (Exception ex) { if (VanguardCore.ShowErrorDialog(ex, true) == DialogResult.Abort) { throw new RTCV.NetCore.AbortEverythingException(); } return(new MemoryDomainProxy[] { }); } }
public static MemoryDomainProxy[] GetInterfaces() { try { Console.WriteLine($"getInterfaces()"); try { if (ProcessExtensions.GetProcessSafe(p) == null) { Console.WriteLine($"p was null!"); return(Array.Empty <MemoryDomainProxy>()); } } catch (Exception e) { Console.WriteLine($"GetInterfaces threw an exception!\n{e.Message}\n{e.StackTrace}"); return(Array.Empty <MemoryDomainProxy>()); } List <MemoryDomainProxy> interfaces = new List <MemoryDomainProxy>(); var _p = ProcessExtensions.GetProcessSafe(p); if (IsProcessBlacklisted(_p)) { return(Array.Empty <MemoryDomainProxy>()); } ProcessExtensions.GetSystemInfo(out var info); IntPtr minAddr = info.minimumApplicationAddress; IntPtr maxAddr = info.maximumApplicationAddress; long minAddr_l = (long)info.minimumApplicationAddress; long maxAddr_l = (long)info.maximumApplicationAddress; while (minAddr_l < maxAddr_l) { _p = ProcessExtensions.GetProcessSafe(p); if (_p == null) { return(Array.Empty <MemoryDomainProxy>()); } if (ProcessExtensions.VirtualQueryEx(_p, minAddr, out var mbi) == false) { break; } if (mbi.State == (uint)ProcessExtensions.MemoryType.MEM_COMMIT && mbi.Protect != ProcessExtensions.MemoryProtection.NoAccess && //Hard blacklist mbi.Protect != ProcessExtensions.MemoryProtection.ZeroAccess && //Hard blacklist (mbi.Protect | ProtectMode) == ProtectMode) { var name = ProcessExtensions.GetMappedFileNameW(_p.Handle, mbi.BaseAddress); if (string.IsNullOrWhiteSpace(name) || !IsPathBlacklisted(name)) { if (string.IsNullOrWhiteSpace(name)) { name = "UNKNOWN"; } var filters = S.GET <StubForm>().tbFilterText.Text.Split('\n').Select(x => x.Trim()).ToArray(); if (!UseFiltering || filters.Any(x => name.ToUpper().Contains(x.ToUpper()))) { Console.WriteLine($"Adding mbi {name.Split('\\').Last()} {mbi.Protect} | {ProtectMode}"); ProcessMemoryDomain pmd = new ProcessMemoryDomain(_p, mbi.BaseAddress, (long)mbi.RegionSize); interfaces.Add(new MemoryDomainProxy(pmd)); } } } minAddr_l += (long)mbi.RegionSize; minAddr = (IntPtr)minAddr_l; } Console.WriteLine("Done adding domains"); Thread.Sleep(1000); return(interfaces.ToArray()); } catch (Exception ex) { if (VanguardCore.ShowErrorDialog(ex, true) == DialogResult.Abort) { throw new RTCV.NetCore.AbortEverythingException(); } return(Array.Empty <MemoryDomainProxy>()); } }
private void btnStartClient_Click(object sender, EventArgs e) { Hook.Start(); VanguardCore.Start(); }
private void btnStartClient_Click(object sender, EventArgs e) { Hook.Start(); VanguardCore.Start(); btnRefreshDomains.Visible = true; }