private void Ok_Click(object sender, EventArgs e) { DialogResult = DialogResult.OK; switch (_mode) { default: case Mode.New: var domain = MemoryDomains.FirstOrDefault(d => d.Name == DomainDropDown.SelectedItem.ToString()); var address = AddressBox.ToLong() ?? 0; var notes = NotesBox.Text; var type = Watch.StringToDisplayType(DisplayTypeDropDown.SelectedItem.ToString()); var bigendian = BigEndianCheckBox.Checked; switch (SizeDropDown.SelectedIndex) { case 0: _watchList.Add(Watch.GenerateWatch(domain, address, WatchSize.Byte, type, bigendian, notes)); break; case 1: _watchList.Add(Watch.GenerateWatch(domain, address, WatchSize.Word, type, bigendian, notes)); break; case 2: _watchList.Add(Watch.GenerateWatch(domain, address, WatchSize.DWord, type, bigendian, notes)); break; } break; case Mode.Edit: DoEdit(); break; case Mode.Duplicate: var tempWatchList = new List <Watch>(); tempWatchList.AddRange(_watchList); _watchList.Clear(); foreach (var watch in tempWatchList) { _watchList.Add(Watch.GenerateWatch( watch.Domain, watch.Address, watch.Size, watch.Type, watch.BigEndian, watch.Notes)); } DoEdit(); break; } Close(); }
private void SetAddressBoxProperties() { if (!_loading) { var domain = MemoryDomains.FirstOrDefault(d => d.Name == DomainDropDown.SelectedItem.ToString()); if (domain != null) { AddressBox.SetHexProperties(domain.Size); } } }
public static BlastLayer GetBlastLayer(string filename) { string thisSystem = (AllSpec.VanguardSpec[VSPEC.NAME] as string); var rp = MemoryDomains.GetRomParts(thisSystem, filename); IMemoryDomain Corrupt = new FileInterface("File|" + filename, false, false); (Corrupt as FileInterface).getMemoryDump(); //gotta cache it otherwise it's going to be super slow string[] selectedDomains = (string[])RTCV.NetCore.AllSpec.UISpec["SELECTEDDOMAINS"]; if (selectedDomains.Length == 0) { MessageBox.Show("Error: No domain is selected"); return(null); } string targetDomain = selectedDomains.FirstOrDefault(); MemoryDomainProxy[] mdps = (AllSpec.VanguardSpec[VSPEC.MEMORYDOMAINS_INTERFACES] as MemoryDomainProxy[]); List <IMemoryDomain> originalDomains = new List <IMemoryDomain>(); if (rp.Error != null) { originalDomains.Add(mdps.FirstOrDefault(it => it.Name == targetDomain).MD); if (selectedDomains.Length == 0) { MessageBox.Show($"Warning: More than one domain was selected. The first one ({targetDomain}) was chosen."); } } else { originalDomains.Add(mdps.FirstOrDefault(it => it.Name == rp.PrimaryDomain).MD); if (rp.SecondDomain != null) { originalDomains.Add(mdps.FirstOrDefault(it => it.Name == rp.SecondDomain).MD); } } bool useCustomPrecision = false; if (RtcCore.CurrentPrecision != 1) { var result = MessageBox.Show("Do you want to use Custom Precision for import?", "Use Custom Precision", MessageBoxButtons.YesNo, MessageBoxIcon.Question); useCustomPrecision = (result == DialogResult.Yes); } return(GetBlastLayer(originalDomains.ToArray(), Corrupt, rp.SkipBytes, useCustomPrecision)); }
private void btnActiveTableDumpsReset_Click(object sender, EventArgs e) { ActLoadedFromFile = false; if (!FirstInit) { FirstInit = true; btnActiveTableDumpsReset.Text = "Reset"; btnActiveTableDumpsReset.ForeColor = Color.Black; btnActiveTableAddDump.Font = new Font("Segoe UI Semibold", 8); btnActiveTableGenerate.Enabled = true; btnActiveTableAddDump.Enabled = true; btnActiveTableLoad.Enabled = true; btnActiveTableQuickSave.Enabled = true; cbAutoAddDump.Enabled = true; } MemoryInterface mi = MemoryDomains.GetInterface(cbSelectedMemoryDomain.SelectedItem.ToString()); if (mi == null) { MessageBox.Show("The currently selected domain doesn't exist!\nMake sure you have the correct core loaded and have refreshed the domains."); return; } decimal memoryDomainSize = mi.Size; //Verify they want to continue if the domain size is larger than 32MB if (memoryDomainSize > 0x2000000) { DialogResult result = MessageBox.Show("The domain you have selected is larger than 32MB\n The domain size is " + (memoryDomainSize / (1024 * 1024)) + "MB.\n Are you sure you want to continue?", "Large Domain Detected", MessageBoxButtons.YesNo); if (result == DialogResult.No) { return; } } lbDomainAddressSize.Text = "Domain size: 0x" + mi.Size.ToString("X"); lbFreezeEngineNbDumps.Text = "Memory dumps collected: 0"; lbActiveTableSize.Text = "Active table size: 0x0"; ActiveTableReady = false; ActiveTableGenerated = null; ActiveTableDumps = new List <string>(); foreach (string file in Directory.GetFiles(Path.Combine(CorruptCore.RtcCore.workingDir, "MEMORYDUMPS"))) { File.Delete(file); } currentFilename = null; }
public bool ComputeActiveTableActivity() { if (ActiveTableDumps == null || ActiveTableDumps.Count < 2) { MessageBox.Show("Not enough dumps for generation"); return(false); } List <long> newActiveTableActivity = new List <long>(); MemoryInterface mi = MemoryDomains.GetInterface(cbSelectedMemoryDomain.SelectedItem.ToString()); if (mi == null) { MessageBox.Show("The currently selected domain doesn't exist!\nMake sure you have the correct core loaded and you've refreshed the domains."); return(false); } long domainSize = MemoryDomains.GetInterface(cbSelectedMemoryDomain.SelectedItem.ToString()).Size; for (long i = 0; i < domainSize; i++) { newActiveTableActivity.Add(0); } ActiveTableActivity = newActiveTableActivity.ToArray(); byte[] lastDump = null; for (int i = 0; i < ActiveTableDumps.Count; i++) { if (i == 0) { lastDump = GetDumpFromFile(ActiveTableDumps[i]); continue; } byte[] currentDump = GetDumpFromFile(ActiveTableDumps[i]); for (int j = 0; j < ActiveTableActivity.Length; j++) { if (lastDump[j] != currentDump[j]) { ActiveTableActivity[j]++; } } } return(true); }
public void NewCDL(CodeDataLog cdl) { cdl["MD CART"] = new byte[MemoryDomains["MD CART"].Size]; cdl["68K RAM"] = new byte[MemoryDomains["68K RAM"].Size]; cdl["Z80 RAM"] = new byte[MemoryDomains["Z80 RAM"].Size]; if (MemoryDomains.Has("SRAM")) { cdl["SRAM"] = new byte[MemoryDomains["SRAM"].Size]; } cdl.SubType = "GEN"; cdl.SubVer = 0; }
public object OnMessageReceived(object sender, NetCoreEventArgs e) { //Use setReturnValue to handle returns var message = e.message; var advancedMessage = message as NetCoreAdvancedMessage; switch (e.message.Type) { case NetcoreCommands.REMOTE_OPENHEXEDITOR: { SyncObjectSingleton.FormExecute(() => { if (S.GET <HexEditor>().IsDisposed) { S.SET(new HexEditor()); } S.GET <HexEditor>().Restart(); S.GET <HexEditor>().Show(); }); } break; case NetcoreCommands.EMU_OPEN_HEXEDITOR_ADDRESS: { var temp = advancedMessage.objectValue as object[]; string domain = (string)temp[0]; long address = (long)temp[1]; MemoryInterface mi = MemoryDomains.GetInterface(domain); if (mi == null) { break; } SyncObjectSingleton.FormExecute(() => { if (S.GET <HexEditor>().IsDisposed) { S.SET(new HexEditor()); } S.GET <HexEditor>().Restart(); S.GET <HexEditor>().Show(); S.GET <HexEditor>().SetDomain(mi); S.GET <HexEditor>().GoToAddress(address); }); } break; } return(e.returnMessage); }
void ICodeDataLogger.NewCDL(CodeDataLog cdl) { cdl["ROM"] = new byte[MemoryDomains["ROM"].Size]; //cdl["HRAM"] = new byte[_memoryDomains["HRAM"].Size]; //this is probably useless, but it's here if someone needs it cdl["WRAM"] = new byte[MemoryDomains["WRAM"].Size]; if (MemoryDomains.Has("CartRAM")) { cdl["CartRAM"] = new byte[MemoryDomains["CartRAM"].Size]; } cdl.SubType = "GB"; cdl.SubVer = 0; }
public void NewCDL(ICodeDataLog cdl) { cdl["ROM"] = new byte[MemoryDomains["ROM L"].Size]; cdl["HRAM"] = new byte[MemoryDomains["Zero Page RAM L"].Size]; cdl["WRAM"] = new byte[MemoryDomains["Main RAM L"].Size]; if (MemoryDomains.Has("Cart RAM L")) { cdl["CartRAM"] = new byte[MemoryDomains["Cart RAM L"].Size]; } cdl.SubType = "GB"; cdl.SubVer = 0; }
private void loadVmd(string path, bool refreshvmds) { using (FileStream fs = File.Open(path, FileMode.Open)) { VmdPrototype proto = null; proto = JsonHelper.Deserialize <VmdPrototype>(fs); MemoryDomains.AddVMD(proto); } if (refreshvmds) { RefreshVMDs(); } }
public static BlastUnit GenerateUnit(string domain, long address, int precision, int alignment) { if (domain == null) { return(null); } MemoryInterface mi = MemoryDomains.GetInterface(domain); long safeAddress = address - (address % precision) + alignment; if (safeAddress > mi.Size - precision && mi.Size > precision) { safeAddress = mi.Size - (2 * precision) + alignment; //If we're out of range, hit the last aligned address } return(new BlastUnit(StoreType.ONCE, StoreTime.PREEXECUTE, domain, safeAddress, domain, safeAddress, precision, mi.BigEndian, 0, 0)); }
public void SetWatch(Emu.MemoryDomain domain, IEnumerable <Watch> watches = null, Mode mode = Mode.New) { if (watches != null) { _watchList.AddRange(watches); } _mode = mode; DomainDropDown.Items.Clear(); DomainDropDown.Items.AddRange(MemoryDomains .Select(d => d.ToString()) .ToArray()); DomainDropDown.SelectedItem = domain.ToString(); SetTitle(); }
public static BlastLayer GetBlastLayerFromDiff(byte[] Original, byte[] Corrupt) { BlastLayer bl = new BlastLayer(); string thisSystem = (string)RTCV.NetCore.AllSpec.VanguardSpec[VSPEC.SYSTEM]; string romFilename = (string)RTCV.NetCore.AllSpec.VanguardSpec[VSPEC.OPENROMFILENAME]; var rp = MemoryDomains.GetRomParts(thisSystem, romFilename); if (rp.Error != null) { MessageBox.Show(rp.Error); return(null); } if (Original.Length != Corrupt.Length) { MessageBox.Show("ERROR, ROM SIZE MISMATCH"); return(null); } MemoryInterface mi = MemoryDomains.GetInterface(rp.PrimaryDomain); long maxaddress = mi.Size; for (int i = 0; i < Original.Length; i++) { if (Original[i] != Corrupt[i] && i >= rp.SkipBytes) { if (i - rp.SkipBytes >= maxaddress) { bl.Layer.Add(new BlastUnit(new byte[] { Corrupt[i] }, rp.SecondDomain, (i - rp.SkipBytes) - maxaddress, 1, mi.BigEndian)); } else { bl.Layer.Add(new BlastUnit(new byte[] { Corrupt[i] }, rp.PrimaryDomain, (i - rp.SkipBytes), 1, mi.BigEndian)); } } } if (bl.Layer.Count == 0) { return(null); } return(bl); }
public void NewCDL(ICodeDataLog cdl) { cdl["ROM"] = new byte[MemoryDomains["ROM"].Size]; cdl["Main RAM"] = new byte[MemoryDomains["Main RAM"].Size]; if (MemoryDomains.Has("Save RAM")) { cdl["Save RAM"] = new byte[MemoryDomains["Save RAM"].Size]; } if (MemoryDomains.Has("Cart (Volatile) RAM")) { cdl["Cart (Volatile) RAM"] = new byte[MemoryDomains["Cart (Volatile) RAM"].Size]; } cdl.SubType = "SMS"; cdl.SubVer = 0; }
internal void loadVmd(string path, bool refreshvmds) { using (FileStream fs = File.Open(path, FileMode.Open)) { VmdPrototype proto = null; proto = JsonHelper.Deserialize <VmdPrototype>(fs); string filePath = path.Substring(path.LastIndexOf('\\') + 1); proto.VmdName = filePath.Replace(".vmd", "").Replace(".VMD", ""); MemoryDomains.AddVMD(proto); } if (refreshvmds) { RefreshVMDs(); } }
private void UpdateImage() { try { //if (this.Domain == null) { return; } included in get interface var mi = MemoryDomains.GetInterface(Domain); if (mi == null) { return; } long start = this.offset + this.align; long end = start + ((long)(display.W * display.H) * this.display.curFormat.BytesWide); //long numBytesToGet = this.w * this.h * this.display.curFormat.BytesWide; if (end >= mi.Size) { end = mi.Size - 1; } byte[] byteArr = mi.PeekBytes(start, end, true); //byte[] byteArr = this.GetByteArr(start, start + (long)numBytesToGet); this.rangeStartAddress = start; this.rangeEndAddress = end + 1L; //+1 because vmds are exclusive if (byteArr == null) { this.rangeStartAddress = start; this.rangeEndAddress = end + 1L; return; } SyncObjectSingleton.SyncObjectExecute(PluginForm.pForm, (o, e) => { //this forces that part of code to execute on the main thread this.display.SetBytes(byteArr); this.display.Refresh(); }); } catch (Exception ex) { StopRunning();//failsafe throw ex; } }
public static void CLOSE_GAME(bool loadDefault = false) { try { if (disableRTC) { return; } if (CLOSE_GAME_loop_flag == true) { return; } CLOSE_GAME_loop_flag = true; //RTC_Core.AutoCorrupt = false; StepActions.ClearStepBlastUnits(); MemoryDomains.Clear(); VanguardCore.OpenRomFilename = null; if (loadDefault) { VanguardCore.LoadDefaultRom(); } //RTC_RPC.SendToKillSwitch("UNFREEZE"); CLOSE_GAME_loop_flag = false; } catch (Exception ex) { if (VanguardCore.ShowErrorDialog(ex) == DialogResult.Abort) { throw new RTCV.NetCore.AbortEverythingException(); } } }
private void btnActiveTableAddDump_Click(object sender, EventArgs e) { if (cbSelectedMemoryDomain == null || MemoryDomains.GetInterface(cbSelectedMemoryDomain.SelectedItem.ToString()).Size.ToString() == null) { MessageBox.Show("Select a valid domain before continuing!"); return; } if (ActiveTableDumps == null) { return; } string key = CorruptCore.RtcCore.GetRandomKey(); LocalNetCoreRouter.Route(NetcoreCommands.CORRUPTCORE, NetcoreCommands.REMOTE_DOMAIN_ACTIVETABLE_MAKEDUMP, new object[] { cbSelectedMemoryDomain.SelectedItem.ToString(), key }, true); ActiveTableDumps.Add(key); lbFreezeEngineNbDumps.Text = "Memory dumps collected: " + ActiveTableDumps.Count.ToString(); }
public void Restart() { if ((!IsHandleCreated || IsDisposed) && !Global.Config.DisplayRamWatch) { return; } if (_watches != null && !string.IsNullOrWhiteSpace(_watches.CurrentFileName) && _watches.All(w => w.Domain == null || MemoryDomains.Select(m => m.Name).Contains(w.Domain.Name)) && (Global.Config.RecentWatches.AutoLoad || (IsHandleCreated || !IsDisposed))) { _watches.RefreshDomains(MemoryDomains); _watches.Reload(); UpdateStatusBar(); } else { _watches = new WatchList(MemoryDomains, Emu.SystemId); NewWatchList(true); } }
public void NewCDL(ICodeDataLog cdl) { cdl["RAM"] = new byte[MemoryDomains["RAM"].Size]; if (MemoryDomains.Has("Save RAM")) { cdl["Save RAM"] = new byte[MemoryDomains["Save RAM"].Size]; } if (MemoryDomains.Has("Battery RAM")) { cdl["Battery RAM"] = new byte[MemoryDomains["Battery RAM"].Size]; } if (MemoryDomains.Has("Battery RAM")) { cdl["Battery RAM"] = new byte[MemoryDomains["Battery RAM"].Size]; } cdl.SubType = "VIC20"; cdl.SubVer = 0; }
public void Restart() { if (_currentDomain == null || MemoryDomains.Contains(_currentDomain)) { _currentDomain = MemoryDomains.MainMemory; _bigEndian = _currentDomain.EndianType == MemoryDomain.Endian.Big; _dataSize = 1; } if (_isBotting) { StopBot(); } if (_lastRom != GlobalWin.MainForm.CurrentlyOpenRom) { _lastRom = GlobalWin.MainForm.CurrentlyOpenRom; SetupControlsAndProperties(); } }
private void btnUnloadVMD_Click(object sender, EventArgs e) { if (lbLoadedVmdList.SelectedIndex == -1) { return; } //Clear any active units to prevent bad things due to soon unloaded vmds LocalNetCoreRouter.Route(NetcoreCommands.CORRUPTCORE, NetcoreCommands.REMOTE_CLEARSTEPBLASTUNITS, null, true); foreach (var item in lbLoadedVmdList.SelectedItems) { string VmdName = item.ToString(); //Go through the stash history and rasterize foreach (StashKey sk in S.GET <RTC_StashHistory_Form>().lbStashHistory.Items) { sk.BlastLayer?.RasterizeVMDs(VmdName); } //CurrentStashKey can be separate StockpileManager_UISide.CurrentStashkey?.BlastLayer?.RasterizeVMDs(VmdName); MemoryDomains.RemoveVMD(VmdName); } RefreshVMDs(); }
private void SetBigEndianCheckBox() { if (_watchList != null) { if (_watchList.Count > 1) { // Aggregate state var hasBig = _watchList.Any(x => x.BigEndian); var hasLittle = _watchList.Any(x => x.BigEndian == false); if (hasBig && hasLittle) { BigEndianCheckBox.Checked = true; BigEndianCheckBox.CheckState = CheckState.Indeterminate; } else if (hasBig) { BigEndianCheckBox.Checked = true; } else { BigEndianCheckBox.Checked = false; } } else if (_watchList.Count == 1) { BigEndianCheckBox.Checked = _watchList[0].BigEndian; return; } } var domain = MemoryDomains.FirstOrDefault(d => d.Name == DomainDropDown.SelectedItem.ToString()) ?? MemoryDomains.MainMemory; BigEndianCheckBox.Checked = domain.EndianType == Emu.MemoryDomain.Endian.Big; }
public static void CLOSE_GAME(bool loadDefault = false) { try { if (disableRTC) return; if (CLOSE_GAME_loop_flag) return; CLOSE_GAME_loop_flag = true; //RTC_Core.AutoCorrupt = false; StepActions.ClearStepBlastUnits(); MemoryDomains.Clear(); VanguardCore.OpenRomFilename = null; if (loadDefault) VanguardCore.LoadDefaultRom(); //RTC_RPC.SendToKillSwitch("UNFREEZE"); CLOSE_GAME_loop_flag = false; RtcCore.InvokeGameClosed(); VanguardCore.RTE_API.GAME_CLOSED(); } catch (Exception ex) { if (VanguardCore.ShowErrorDialog(ex) == DialogResult.Abort) throw new AbortEverythingException(); } }
private void loadLegacyVmd(string path) { //Fix int[] to long[] string vmdXML = File.ReadAllText(path); vmdXML = vmdXML.Replace("<int>", "<long>"); vmdXML = vmdXML.Replace("</int>", "</long>"); vmdXML = vmdXML.Replace("ArrayOfInt", "ArrayOfLong"); vmdXML = vmdXML.Replace("addRanges", "AddRanges"); vmdXML = vmdXML.Replace("addSingles", "AddSingles"); vmdXML = vmdXML.Replace("removeRanges", "RemoveRanges"); vmdXML = vmdXML.Replace("removeSingles", "removeSingles"); XmlSerializer xs = new XmlSerializer(typeof(VmdPrototype)); VmdPrototype proto = (VmdPrototype)xs.Deserialize(new StringReader(vmdXML)); var jsonFilename = Path.Combine(Path.GetDirectoryName(path), Path.GetFileNameWithoutExtension(path) + ".vmd"); using (FileStream _fs = File.Open(jsonFilename, FileMode.Create)) { JsonHelper.Serialize(proto, _fs, Newtonsoft.Json.Formatting.Indented); } MemoryDomains.AddVMD(proto); }
private void lbStashHistory_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { Point locate = new Point(((Control)sender).Location.X + e.Location.X, ((Control)sender).Location.Y + e.Location.Y); ContextMenuStrip columnsMenu = new ContextMenuStrip(); ((ToolStripMenuItem)columnsMenu.Items.Add("Open Selected Item in Blast Editor", null, new EventHandler((ob, ev) => { if (S.GET <RTC_NewBlastEditor_Form>() != null) { StashKey sk = StockpileManager_UISide.StashHistory[lbStashHistory.SelectedIndex]; RTC_NewBlastEditor_Form.OpenBlastEditor(sk); } }))).Enabled = lbStashHistory.SelectedIndex != -1; ((ToolStripMenuItem)columnsMenu.Items.Add("Sanitize", null, new EventHandler((ob, ev) => { if (S.GET <RTC_NewBlastEditor_Form>() != null) { StashKey sk = StockpileManager_UISide.StashHistory[lbStashHistory.SelectedIndex]; RTC_NewBlastEditor_Form.OpenBlastEditor(sk, true); S.GET <RTC_NewBlastEditor_Form>().btnSanitizeTool_Click(null, null); } }))).Enabled = lbStashHistory.SelectedIndex != -1; columnsMenu.Items.Add(new ToolStripSeparator()); ((ToolStripMenuItem)columnsMenu.Items.Add("Rename selected item", null, new EventHandler((ob, ev) => { StashKey sk = StockpileManager_UISide.StashHistory[lbStashHistory.SelectedIndex]; S.GET <RTC_StockpileManager_Form>().RenameStashKey(sk); RefreshStashHistory(); }))).Enabled = lbStashHistory.SelectedIndex != -1; ((ToolStripMenuItem)columnsMenu.Items.Add("Generate VMD from Selected Item", null, new EventHandler((ob, ev) => { StashKey sk = StockpileManager_UISide.StashHistory[lbStashHistory.SelectedIndex]; sk.BlastLayer.RasterizeVMDs(); MemoryDomains.GenerateVmdFromStashkey(sk); S.GET <RTC_VmdPool_Form>().RefreshVMDs(); }))).Enabled = lbStashHistory.SelectedIndex != -1; columnsMenu.Items.Add(new ToolStripSeparator()); ((ToolStripMenuItem)columnsMenu.Items.Add("Merge Selected Stashkeys", null, new EventHandler((ob, ev) => { List <StashKey> sks = new List <StashKey>(); foreach (StashKey sk in lbStashHistory.SelectedItems) { sks.Add(sk); } StockpileManager_UISide.MergeStashkeys(sks); RefreshStashHistory(); }))).Enabled = (lbStashHistory.SelectedIndex != -1 && lbStashHistory.SelectedItems.Count > 1); /* * if (!RTC_NetcoreImplementation.isStandaloneUI) * { * columnsMenu.Items.Add(new ToolStripSeparator()); * ((ToolStripMenuItem)columnsMenu.Items.Add("[Multiplayer] Pull State from peer", null, new EventHandler((ob, ev) => * { * S.GET<RTC_Multiplayer_Form>().cbPullStateToGlitchHarvester.Checked = true; * RTC_NetcoreImplementation.Multiplayer.SendCommand(new RTC_Command(CommandType.PULLSTATE), false); * }))).Enabled = RTC_NetcoreImplementation.Multiplayer != null && RTC_NetcoreImplementation.Multiplayer.side != NetworkSide.DISCONNECTED; * }*/ columnsMenu.Show(this, locate); } }
private void dgvStockpile_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { Point locate = new Point((sender as Control).Location.X + e.Location.X, (sender as Control).Location.Y + e.Location.Y); ContextMenuStrip columnsMenu = new ContextMenuStrip(); (columnsMenu.Items.Add("Show Item Name", null, (ob, ev) => { dgvStockpile.Columns["Item"].Visible ^= true; }) as ToolStripMenuItem).Checked = dgvStockpile.Columns["Item"].Visible; (columnsMenu.Items.Add("Show Game Name", null, (ob, ev) => { dgvStockpile.Columns["GameName"].Visible ^= true; }) as ToolStripMenuItem) .Checked = dgvStockpile.Columns["GameName"].Visible; (columnsMenu.Items.Add("Show System Name", null, (ob, ev) => { dgvStockpile.Columns["SystemName"].Visible ^= true; }) as ToolStripMenuItem) .Checked = dgvStockpile.Columns["SystemName"].Visible; (columnsMenu.Items.Add("Show System Core", null, (ob, ev) => { dgvStockpile.Columns["SystemCore"].Visible ^= true; }) as ToolStripMenuItem) .Checked = dgvStockpile.Columns["SystemCore"].Visible; (columnsMenu.Items.Add("Show Note", null, (ob, ev) => { dgvStockpile.Columns["Note"].Visible ^= true; }) as ToolStripMenuItem).Checked = dgvStockpile.Columns["Note"].Visible; columnsMenu.Items.Add(new ToolStripSeparator()); ((ToolStripMenuItem)columnsMenu.Items.Add("Open Selected Item in Blast Editor", null, new EventHandler((ob, ev) => { if (S.GET <RTC_NewBlastEditor_Form>() != null) { var sk = (dgvStockpile.SelectedRows[0].Cells[0].Value as StashKey); RTC_NewBlastEditor_Form.OpenBlastEditor(sk); } }))).Enabled = (dgvStockpile.SelectedRows.Count == 1); ((ToolStripMenuItem)columnsMenu.Items.Add("Manual Inject", null, new EventHandler((ob, ev) => { var sk = (dgvStockpile.SelectedRows[0].Cells[0].Value as StashKey); StashKey newSk = (StashKey)sk.Clone(); S.GET <RTC_GlitchHarvesterBlast_Form>().IsCorruptionApplied = StockpileManager_UISide.ApplyStashkey(newSk, false); }))).Enabled = (dgvStockpile.SelectedRows.Count == 1); columnsMenu.Items.Add(new ToolStripSeparator()); ((ToolStripMenuItem)columnsMenu.Items.Add("Generate VMD from Selected Item", null, new EventHandler((ob, ev) => { var sk = (dgvStockpile.SelectedRows[0].Cells[0].Value as StashKey); MemoryDomains.GenerateVmdFromStashkey(sk); S.GET <RTC_VmdPool_Form>().RefreshVMDs(); }))).Enabled = (dgvStockpile.SelectedRows.Count == 1); ((ToolStripMenuItem)columnsMenu.Items.Add("Merge Selected Stashkeys", null, new EventHandler((ob, ev) => { List <StashKey> sks = new List <StashKey>(); foreach (DataGridViewRow row in dgvStockpile.SelectedRows) { sks.Add((StashKey)row.Cells[0].Value); } StockpileManager_UISide.MergeStashkeys(sks); S.GET <RTC_StashHistory_Form>().RefreshStashHistory(); }))).Enabled = (dgvStockpile.SelectedRows.Count > 1); ((ToolStripMenuItem)columnsMenu.Items.Add("Replace associated ROM", null, new EventHandler((ob, ev) => { List <StashKey> sks = new List <StashKey>(); foreach (DataGridViewRow row in dgvStockpile.SelectedRows) { sks.Add((StashKey)row.Cells[0].Value); } OpenFileDialog ofd = new OpenFileDialog { DefaultExt = "*", Title = "Select Replacement File", Filter = "Any file|*.*", RestoreDirectory = true }; if (ofd.ShowDialog() == DialogResult.OK) { string filename = ofd.FileName.ToString(); string oldFilename = sks.First().RomFilename; foreach (var sk in sks.Where(x => x.RomFilename == oldFilename)) { sk.RomFilename = filename; sk.RomShortFilename = Path.GetFileName(sk.RomFilename); } } }))).Enabled = (dgvStockpile.SelectedRows.Count >= 1); /* * if (!RTC_NetcoreImplementation.isStandaloneUI) * { * ((ToolStripMenuItem)columnsMenu.Items.Add("[Multiplayer] Send Selected Item as a Blast", null, new EventHandler((ob, ev) => { RTC_NetcoreImplementation.Multiplayer?.SendBlastlayer(); }))).Enabled = RTC_NetcoreImplementation.Multiplayer != null && RTC_NetcoreImplementation.Multiplayer.side != NetworkSide.DISCONNECTED; * ((ToolStripMenuItem)columnsMenu.Items.Add("[Multiplayer] Send Selected Item as a Game State", null, new EventHandler((ob, ev) => { RTC_NetcoreImplementation.Multiplayer?.SendStashkey(); }))).Enabled = RTC_NetcoreImplementation.Multiplayer != null && RTC_NetcoreImplementation.Multiplayer.side != NetworkSide.DISCONNECTED; * }*/ columnsMenu.Show(this, locate); } }
private bool GenerateVMD() { if (string.IsNullOrWhiteSpace(cbSelectedMemoryDomain.SelectedItem?.ToString()) || !MemoryDomains.MemoryInterfaces.ContainsKey(cbSelectedMemoryDomain.SelectedItem.ToString())) { cbSelectedMemoryDomain.Items.Clear(); return(false); } if (!string.IsNullOrWhiteSpace(tbVmdName.Text) && MemoryDomains.VmdPool.ContainsKey($"[V]{tbVmdName.Text}")) { MessageBox.Show("There is already a VMD with this name in the VMD Pool"); return(false); } MemoryInterface mi = MemoryDomains.MemoryInterfaces[cbSelectedMemoryDomain.SelectedItem.ToString()]; VirtualMemoryDomain VMD = new VirtualMemoryDomain(); VmdPrototype proto = new VmdPrototype { GenDomain = cbSelectedMemoryDomain.SelectedItem.ToString() }; if (string.IsNullOrWhiteSpace(tbVmdName.Text)) { proto.VmdName = CorruptCore.RtcCore.GetRandomKey(); } else { proto.VmdName = tbVmdName.Text; } proto.BigEndian = mi.BigEndian; proto.WordSize = mi.WordSize; proto.Padding = 0; foreach (string line in tbRangeExpression.Lines) { if (string.IsNullOrWhiteSpace(line)) { continue; } string trimmedLine = line.Trim(); bool remove = false; if (trimmedLine[0] == '-') { remove = true; trimmedLine = trimmedLine.Substring(1); } string[] lineParts = trimmedLine.Split('-'); if (lineParts.Length > 1) { long start = SafeStringToLong(lineParts[0]); long end = SafeStringToLong(lineParts[1]); if (end < start) { continue; } if (end >= currentDomainSize) { end = Convert.ToInt64(currentDomainSize - 1); } if (remove) { proto.RemoveRanges.Add(new long[] { start, end }); } else { proto.AddRanges.Add(new long[] { start, end }); } } else { long address = SafeStringToLong(lineParts[0]); if (address > 0 && address < currentDomainSize) { if (remove) { proto.RemoveSingles.Add(address); } else { proto.AddSingles.Add(address); } } } } if (proto.AddRanges.Count == 0 && proto.AddSingles.Count == 0) { //No add range was specified, use entire domain proto.AddRanges.Add(new long[] { 0, (currentDomainSize > long.MaxValue ? long.MaxValue : Convert.ToInt64(currentDomainSize)) }); } //Precalc the size of the vmd //Ignore the fact that addranges and subtractranges can overlap. Only account for add long size = 0; foreach (var v in proto.AddSingles) { size++; } foreach (var v in proto.AddRanges) { long x = v[1] - v[0]; size += x; } //If the size is still 0 and we have removals, we're gonna use the entire range then sub from it so size is now the size of the domain if (size == 0 && (proto.RemoveSingles.Count > 0 || proto.RemoveRanges.Count > 0) || (proto.RemoveSingles.Count == 0 && proto.RemoveRanges.Count == 0 && size == 0)) { size = currentDomainSize; } foreach (var v in proto.RemoveSingles) { size--; } foreach (var v in proto.RemoveRanges) { long x = v[1] - v[0]; size -= x; } //Verify they want to continue if the domain is larger than 32MB and they didn't manually set ranges if (size > 0x2000000) { DialogResult result = MessageBox.Show("The VMD you're trying to generate is larger than 32MB\n The VMD size is " + ((size / 1024 / 1024) + 1) + " MB (" + size / 1024f / 1024f / 1024f + " GB).\n Are you sure you want to continue?", "VMD Detected", MessageBoxButtons.YesNo); if (result == DialogResult.No) { return(false); } } VMD = proto.Generate(); if (VMD.Size == 0) { MessageBox.Show("The resulting VMD had no pointers so the operation got cancelled."); return(false); } MemoryDomains.AddVMD(VMD); tbVmdName.Text = ""; cbSelectedMemoryDomain.SelectedIndex = -1; cbSelectedMemoryDomain.Items.Clear(); currentDomainSize = 0; tbRangeExpression.Text = ""; lbDomainSizeValue.Text = "######"; lbEndianTypeValue.Text = "######"; lbWordSizeValue.Text = "######"; //send to vmd pool menu S.GET <RTC_VmdPool_Form>().RefreshVMDs(); //Selects back the VMD Pool menu foreach (var item in UICore.mtForm.cbSelectBox.Items) { if (((dynamic)item).value is RTC_VmdPool_Form) { UICore.mtForm.cbSelectBox.SelectedItem = item; break; } } return(true); }
public object OnMessageReceived(object sender, NetCoreEventArgs e) { try { //Use setReturnValue to handle returns var message = e.message; var advancedMessage = message as NetCoreAdvancedMessage; switch (e.message.Type) { case "GETSPECDUMPS": StringBuilder sb = new StringBuilder(); sb.AppendLine("Spec Dump from CorruptCore"); sb.AppendLine(); sb.AppendLine("UISpec"); RTCV.NetCore.AllSpec.UISpec?.GetDump().ForEach(x => sb.AppendLine(x)); sb.AppendLine("CorruptCoreSpec"); RTCV.NetCore.AllSpec.CorruptCoreSpec?.GetDump().ForEach(x => sb.AppendLine(x)); sb.AppendLine("VanguardSpec"); RTCV.NetCore.AllSpec.VanguardSpec?.GetDump().ForEach(x => sb.AppendLine(x)); e.setReturnValue(sb.ToString()); break; //UI sent its spec case REMOTE_PUSHUISPEC: { SyncObjectSingleton.FormExecute(() => { RTCV.NetCore.AllSpec.UISpec = new FullSpec((PartialSpec)advancedMessage.objectValue, !RtcCore.Attached); }); break; } //UI sent a spec update case REMOTE_PUSHUISPECUPDATE: SyncObjectSingleton.FormExecute(() => { RTCV.NetCore.AllSpec.UISpec?.Update((PartialSpec)advancedMessage.objectValue); }); break; //Vanguard sent a copy of its spec case REMOTE_PUSHVANGUARDSPEC: SyncObjectSingleton.FormExecute(() => { if (!RtcCore.Attached) { RTCV.NetCore.AllSpec.VanguardSpec = new FullSpec((PartialSpec)advancedMessage.objectValue, !RtcCore.Attached); } }); break; //Vanguard sent a spec update case REMOTE_PUSHVANGUARDSPECUPDATE: RTCV.NetCore.AllSpec.VanguardSpec?.Update((PartialSpec)advancedMessage.objectValue, false); break; //UI sent a copy of the CorruptCore spec case REMOTE_PUSHCORRUPTCORESPEC: SyncObjectSingleton.FormExecute(() => { //So here's the deal. The UI doesn't actually have the full memory domains (md isn't sent across) so if we take them from it, it results in them going null //Instead, we stick with what we have, then tell the UI to use that. var temp = new FullSpec((PartialSpec)advancedMessage.objectValue, !RtcCore.Attached); //Stick with what we have if it exists to prevent any exceptions if autocorrupt was on or something, then call refresh temp.Update("MEMORYINTERFACES", AllSpec.CorruptCoreSpec?["MEMORYINTERFACES"] ?? new Dictionary <string, MemoryDomainProxy>()); RTCV.NetCore.AllSpec.CorruptCoreSpec = new FullSpec(temp.GetPartialSpec(), !RtcCore.Attached); RTCV.NetCore.AllSpec.CorruptCoreSpec.SpecUpdated += (ob, eas) => { PartialSpec partial = eas.partialSpec; LocalNetCoreRouter.Route(NetcoreCommands.UI, NetcoreCommands.REMOTE_PUSHCORRUPTCORESPECUPDATE, partial, true); }; RTCV.CorruptCore.MemoryDomains.RefreshDomains(); }); e.setReturnValue(true); break; //UI sent an update of the CorruptCore spec case REMOTE_PUSHCORRUPTCORESPECUPDATE: SyncObjectSingleton.FormExecute(() => { RTCV.NetCore.AllSpec.CorruptCoreSpec?.Update((PartialSpec)advancedMessage.objectValue, false); }); break; case REMOTE_EVENT_DOMAINSUPDATED: var domainsChanged = (bool)advancedMessage.objectValue; MemoryDomains.RefreshDomains(domainsChanged); break; case REMOTE_EVENT_RESTRICTFEATURES: { if (!RTCV.NetCore.AllSpec.VanguardSpec?.Get <bool>(VSPEC.SUPPORTS_SAVESTATES) ?? true) { LocalNetCoreRouter.Route(NetcoreCommands.UI, NetcoreCommands.REMOTE_DISABLESAVESTATESUPPORT); } if (!RTCV.NetCore.AllSpec.VanguardSpec?.Get <bool>(VSPEC.SUPPORTS_REALTIME) ?? true) { LocalNetCoreRouter.Route(NetcoreCommands.UI, NetcoreCommands.REMOTE_DISABLEREALTIMESUPPORT); } if (!RTCV.NetCore.AllSpec.VanguardSpec?.Get <bool>(VSPEC.SUPPORTS_KILLSWITCH) ?? true) { LocalNetCoreRouter.Route(NetcoreCommands.UI, NetcoreCommands.REMOTE_DISABLEKILLSWITCHSUPPORT); } if (!RTCV.NetCore.AllSpec.VanguardSpec?.Get <bool>(VSPEC.SUPPORTS_GAMEPROTECTION) ?? true) { LocalNetCoreRouter.Route(NetcoreCommands.UI, NetcoreCommands.REMOTE_DISABLEGAMEPROTECTIONSUPPORT); } break; } case REMOTE_EVENT_SHUTDOWN: { RtcCore.Shutdown(); break; } case REMOTE_OPENHEXEDITOR: { if ((bool?)AllSpec.VanguardSpec[VSPEC.USE_INTEGRATED_HEXEDITOR] ?? false) { LocalNetCoreRouter.Route(NetcoreCommands.VANGUARD, NetcoreCommands.REMOTE_OPENHEXEDITOR, true); } else { //Route it to the plugin if loaded if (RtcCore.PluginHost.LoadedPlugins.Any(x => x.Name == "Hex Editor")) { LocalNetCoreRouter.Route("HEXEDITOR", NetcoreCommands.REMOTE_OPENHEXEDITOR, true); } else { MessageBox.Show("The current Vanguard implementation does not include a\n hex editor & the hex editor plugin isn't loaded. Aborting."); } } } break; case EMU_OPEN_HEXEDITOR_ADDRESS: { if ((bool?)AllSpec.VanguardSpec[VSPEC.USE_INTEGRATED_HEXEDITOR] ?? false) { LocalNetCoreRouter.Route(NetcoreCommands.VANGUARD, NetcoreCommands.EMU_OPEN_HEXEDITOR_ADDRESS, advancedMessage.objectValue, true); } else { //Route it to the plugin if loaded if (RtcCore.PluginHost.LoadedPlugins.Any(x => x.Name == "Hex Editor")) { LocalNetCoreRouter.Route("HEXEDITOR", NetcoreCommands.EMU_OPEN_HEXEDITOR_ADDRESS, advancedMessage.objectValue, true); } else { MessageBox.Show("The current Vanguard implementation does not include a\n hex editor & the hex editor plugin isn't loaded. Aborting."); } } break; } case MANUALBLAST: { RtcCore.GenerateAndBlast(); } break; case GENERATEBLASTLAYER: { var val = advancedMessage.objectValue as object[]; StashKey sk = val[0] as StashKey; bool loadBeforeCorrupt = (bool)val[1]; bool applyBlastLayer = (bool)val[2]; bool backup = (bool)val[3]; BlastLayer bl = null; bool UseSavestates = (bool)AllSpec.VanguardSpec[VSPEC.SUPPORTS_SAVESTATES]; void a() { lock (loadLock) { //Load the game from the main thread if (UseSavestates && loadBeforeCorrupt) { SyncObjectSingleton.FormExecute(() => { StockpileManager_EmuSide.LoadRom_NET(sk); }); } if (UseSavestates && loadBeforeCorrupt) { StockpileManager_EmuSide.LoadState_NET(sk, false); } //We pull the domains here because if the syncsettings changed, there's a chance the domains changed string[] domains = (string[])AllSpec.UISpec["SELECTEDDOMAINS"]; var cpus = Environment.ProcessorCount; if (cpus == 1 || AllSpec.VanguardSpec[VSPEC.SUPPORTS_MULTITHREAD] == null) { bl = RtcCore.GenerateBlastLayer(domains); } else { //if emulator supports multithreaded access of the domains, disregard the emulation thread and just span threads... long reminder = RtcCore.Intensity % (cpus - 1); long splitintensity = (RtcCore.Intensity - reminder) / (cpus - 1); Task <BlastLayer>[] tasks = new Task <BlastLayer> [cpus]; for (int i = 0; i < cpus; i++) { long requestedIntensity = splitintensity; if (i == 0 && reminder != 0) { requestedIntensity = reminder; } tasks[i] = Task.Factory.StartNew(() => RtcCore.GenerateBlastLayer(domains, requestedIntensity)); } Task.WaitAll(tasks); bl = tasks[0] .Result ?? new BlastLayer(); if (tasks.Length > 1) { for (int i = 1; i < tasks.Length; i++) { if (tasks[i] .Result != null) { bl.Layer.AddRange(tasks[i] .Result.Layer); } } } if (bl.Layer.Count == 0) { bl = null; } } if (applyBlastLayer) { bl?.Apply(backup); } } } //If the emulator uses callbacks, we do everything on the main thread and once we're done, we unpause emulation if ((bool?)AllSpec.VanguardSpec[VSPEC.LOADSTATE_USES_CALLBACKS] ?? false) { SyncObjectSingleton.FormExecute(a); e.setReturnValue(LocalNetCoreRouter.Route(NetcoreCommands.VANGUARD, NetcoreCommands.REMOTE_RESUMEEMULATION, true)); } else //We can just do everything on the emulation thread as it'll block { SyncObjectSingleton.EmuThreadExecute(a, true); } if (advancedMessage.requestGuid != null) { e.setReturnValue(bl); } break; } case APPLYBLASTLAYER: { var temp = advancedMessage.objectValue as object[]; BlastLayer bl = (BlastLayer)temp[0]; bool backup = (bool)temp[1]; void a() { bl.Apply(backup, true); } SyncObjectSingleton.EmuThreadExecute(a, true); break; } /* * case STASHKEY: * { * var temp = advancedMessage.objectValue as object[]; * * var sk = temp[0] as StashKey; * var romFilename = temp[1] as String; * var romData = temp[2] as Byte[]; * * if (!File.Exists(CorruptCore.rtcDir + Path.DirectorySeparatorChar + "WORKING" + Path.DirectorySeparatorChar + "SKS" + Path.DirectorySeparatorChar + romFilename)) * File.WriteAllBytes(CorruptCore.rtcDir + Path.DirectorySeparatorChar + "WORKING" + Path.DirectorySeparatorChar + "SKS" + Path.DirectorySeparatorChar + romFilename, romData); * * sk.RomFilename = CorruptCore.rtcDir + Path.DirectorySeparatorChar + "WORKING" + Path.DirectorySeparatorChar + "SKS" + Path.DirectorySeparatorChar + CorruptCore_Extensions.getShortFilenameFromPath(romFilename); * sk.DeployState(); * sk.Run(); * } * break; */ case REMOTE_PUSHRTCSPEC: RTCV.NetCore.AllSpec.CorruptCoreSpec = new FullSpec((PartialSpec)advancedMessage.objectValue, !RtcCore.Attached); e.setReturnValue(true); break; case REMOTE_PUSHRTCSPECUPDATE: RTCV.NetCore.AllSpec.CorruptCoreSpec?.Update((PartialSpec)advancedMessage.objectValue, false); break; case BLASTGENERATOR_BLAST: { List <BlastGeneratorProto> returnList = null; StashKey sk = (StashKey)(advancedMessage.objectValue as object[])[0]; List <BlastGeneratorProto> blastGeneratorProtos = (List <BlastGeneratorProto>)(advancedMessage.objectValue as object[])[1]; bool loadBeforeCorrupt = (bool)(advancedMessage.objectValue as object[])[2]; bool applyAfterCorrupt = (bool)(advancedMessage.objectValue as object[])[3]; bool resumeAfter = (bool)(advancedMessage.objectValue as object[])[4]; void a() { //Load the game from the main thread if (loadBeforeCorrupt) { SyncObjectSingleton.FormExecute(() => { StockpileManager_EmuSide.LoadRom_NET(sk); }); } if (loadBeforeCorrupt) { StockpileManager_EmuSide.LoadState_NET(sk, false); } returnList = BlastTools.GenerateBlastLayersFromBlastGeneratorProtos(blastGeneratorProtos, sk); if (applyAfterCorrupt) { BlastLayer bl = new BlastLayer(); foreach (var p in returnList.Where(x => x != null)) { bl.Layer.AddRange(p.bl.Layer); } bl.Apply(true); } } //If the emulator uses callbacks, we do everything on the main thread and once we're done, we unpause emulation if ((bool?)AllSpec.VanguardSpec[VSPEC.LOADSTATE_USES_CALLBACKS] ?? false) { SyncObjectSingleton.FormExecute(a); if (resumeAfter) { e.setReturnValue(LocalNetCoreRouter.Route(NetcoreCommands.VANGUARD, NetcoreCommands.REMOTE_RESUMEEMULATION, true)); } } else { SyncObjectSingleton.EmuThreadExecute(a, false); } e.setReturnValue(returnList); break; } case REMOTE_LOADSTATE: { lock (loadLock) { StashKey sk = (StashKey)(advancedMessage.objectValue as object[])[0]; bool reloadRom = (bool)(advancedMessage.objectValue as object[])[1]; bool runBlastLayer = (bool)(advancedMessage.objectValue as object[])[2]; bool returnValue = false; //Load the game from the main thread if (reloadRom) { SyncObjectSingleton.FormExecute(() => { StockpileManager_EmuSide.LoadRom_NET(sk); }); } void a() { returnValue = StockpileManager_EmuSide.LoadState_NET(sk, runBlastLayer); } //If the emulator uses callbacks, we do everything on the main thread and once we're done, we unpause emulation if ((bool?)AllSpec.VanguardSpec[VSPEC.LOADSTATE_USES_CALLBACKS] ?? false) { SyncObjectSingleton.FormExecute(a); e.setReturnValue(LocalNetCoreRouter.Route(NetcoreCommands.VANGUARD, NetcoreCommands.REMOTE_RESUMEEMULATION, true)); } else //We're loading on the emulator thread which'll block { SyncObjectSingleton.EmuThreadExecute(a, false); } e.setReturnValue(returnValue); } } break; case REMOTE_SAVESTATE: { StashKey sk = null; void a() { sk = StockpileManager_EmuSide.SaveState_NET(advancedMessage.objectValue as StashKey); //Has to be nullable cast } SyncObjectSingleton.EmuThreadExecute(a, false); e.setReturnValue(sk); } break; case REMOTE_SAVESTATELESS: { StashKey sk = null; void a() { sk = StockpileManager_EmuSide.SaveStateLess_NET(advancedMessage.objectValue as StashKey); //Has to be nullable cast } SyncObjectSingleton.EmuThreadExecute(a, false); e.setReturnValue(sk); } break; case REMOTE_BACKUPKEY_REQUEST: { //We don't store this in the spec as it'd be horrible to push it to the UI and it doesn't care //if (!LocalNetCoreRouter.QueryRoute<bool>(NetcoreCommands.VANGUARD, NetcoreCommands.REMOTE_ISNORMALADVANCE)) //break; StashKey sk = null; //We send an unsynced command back SyncObjectSingleton.FormExecute(() => { sk = StockpileManager_EmuSide.SaveState_NET(); }); if (sk != null) { LocalNetCoreRouter.Route(NetcoreCommands.UI, REMOTE_BACKUPKEY_STASH, sk, false); } break; } case REMOTE_DOMAIN_GETDOMAINS: e.setReturnValue(LocalNetCoreRouter.Route(NetcoreCommands.VANGUARD, NetcoreCommands.REMOTE_DOMAIN_GETDOMAINS, true)); break; case REMOTE_PUSHVMDPROTOS: MemoryDomains.VmdPool.Clear(); foreach (var proto in (advancedMessage.objectValue as VmdPrototype[])) { MemoryDomains.AddVMD(proto); } break; case REMOTE_DOMAIN_VMD_ADD: MemoryDomains.AddVMD_NET((advancedMessage.objectValue as VmdPrototype)); break; case REMOTE_DOMAIN_VMD_REMOVE: { StepActions.ClearStepBlastUnits(); MemoryDomains.RemoveVMD_NET((advancedMessage.objectValue as string)); } break; case REMOTE_DOMAIN_ACTIVETABLE_MAKEDUMP: { void a() { MemoryDomains.GenerateActiveTableDump((string)(advancedMessage.objectValue as object[])[0], (string)(advancedMessage.objectValue as object[])[1]); } SyncObjectSingleton.EmuThreadExecute(a, false); } break; case REMOTE_BLASTTOOLS_GETAPPLIEDBACKUPLAYER: { var bl = (BlastLayer)(advancedMessage.objectValue as object[])[0]; var sk = (StashKey)(advancedMessage.objectValue as object[])[1]; void a() { e.setReturnValue(BlastTools.GetAppliedBackupLayer(bl, sk)); } SyncObjectSingleton.EmuThreadExecute(a, false); break; } case REMOTE_LONGARRAY_FILTERDOMAIN: { lock (loadLock) { var objValues = (advancedMessage.objectValue as object[]); string domain = (string)objValues[0]; string LimiterListHash = (string)objValues[1]; StashKey sk = objValues[2] as StashKey; //Intentionally nullable void a() { if (sk != null) //If a stashkey was passed in, we want to load then profile { StockpileManager_EmuSide.LoadState_NET(sk, false); } MemoryInterface mi = MemoryDomains.MemoryInterfaces[domain]; List <long> allLegalAdresses = new List <long>(); int listItemSize = Filtering.GetPrecisionFromHash(LimiterListHash); for (long i = 0; i < mi.Size; i += listItemSize) { if (Filtering.LimiterPeekBytes(i, i + listItemSize, mi.Name, LimiterListHash, mi)) { for (int j = 0; j < listItemSize; j++) { allLegalAdresses.Add(i + j); } } } e.setReturnValue(allLegalAdresses.ToArray()); } //If the emulator uses callbacks and we're loading a state, we do everything on the main thread and once we're done, we unpause emulation if (sk != null && ((bool?)AllSpec.VanguardSpec[VSPEC.LOADSTATE_USES_CALLBACKS] ?? false)) { SyncObjectSingleton.FormExecute(a); LocalNetCoreRouter.Route(NetcoreCommands.VANGUARD, NetcoreCommands.REMOTE_RESUMEEMULATION, true); } else //We can just do everything on the emulation thread as it'll block { SyncObjectSingleton.EmuThreadExecute(a, true); } } } break; case REMOTE_KEY_GETRAWBLASTLAYER: { void a() { e.setReturnValue(StockpileManager_EmuSide.GetRawBlastlayer()); } SyncObjectSingleton.EmuThreadExecute(a, false); } break; case REMOTE_BL_GETDIFFBLASTLAYER: { string filename = (advancedMessage.objectValue as string); void a() { e.setReturnValue(BlastDiff.GetBlastLayer(filename)); } SyncObjectSingleton.EmuThreadExecute(a, false); } break; case REMOTE_SET_APPLYUNCORRUPTBL: { void a() { if (StockpileManager_EmuSide.UnCorruptBL != null) { StockpileManager_EmuSide.UnCorruptBL.Apply(true); } } SyncObjectSingleton.EmuThreadExecute(a, false); } break; case REMOTE_SET_APPLYCORRUPTBL: { void a() { if (StockpileManager_EmuSide.CorruptBL != null) { StockpileManager_EmuSide.CorruptBL.Apply(false); } } SyncObjectSingleton.EmuThreadExecute(a, false); } break; case REMOTE_CLEARSTEPBLASTUNITS: SyncObjectSingleton.FormExecute(() => { StepActions.ClearStepBlastUnits(); }); break; case REMOTE_LOADPLUGINS: SyncObjectSingleton.FormExecute(() => { string emuPluginDir = ""; try { emuPluginDir = System.IO.Path.Combine(RtcCore.EmuDir, "RTC", "PLUGINS"); } catch (Exception e) { RTCV.Common.Logging.GlobalLogger.Error(e, "Unable to find plugin dir in {dir}", RtcCore.EmuDir + "\\RTC" + "\\PLUGINS"); } RtcCore.LoadPlugins(new[] { RtcCore.pluginDir, emuPluginDir }); }); break; case REMOTE_REMOVEEXCESSINFINITESTEPUNITS: SyncObjectSingleton.FormExecute(() => { StepActions.RemoveExcessInfiniteStepUnits(); }); break; default: new object(); break; } return(e.returnMessage); } catch (Exception ex) { if (CloudDebug.ShowErrorDialog(ex, true) == DialogResult.Abort) { throw new RTCV.NetCore.AbortEverythingException(); } return(e.returnMessage); } }
private void RamWatchNewWatch_Load(object sender, EventArgs e) { if (InitialLocation.X > 0 || InitialLocation.Y > 0) { Location = InitialLocation; } _loading = false; SetAddressBoxProperties(); switch (_mode) { default: case Mode.New: switch (MemoryDomains.First().WordSize) { default: case 1: SizeDropDown.SelectedItem = SizeDropDown.Items[0]; break; case 2: SizeDropDown.SelectedItem = SizeDropDown.Items[1]; break; case 4: SizeDropDown.SelectedItem = SizeDropDown.Items[2]; break; } break; case Mode.Duplicate: case Mode.Edit: switch (_watchList[0].Size) { case WatchSize.Byte: SizeDropDown.SelectedItem = SizeDropDown.Items[0]; break; case WatchSize.Word: SizeDropDown.SelectedItem = SizeDropDown.Items[1]; break; case WatchSize.DWord: SizeDropDown.SelectedItem = SizeDropDown.Items[2]; break; } var index = DisplayTypeDropDown.Items.IndexOf(Watch.DisplayTypeToString(_watchList[0].Type)); DisplayTypeDropDown.SelectedItem = DisplayTypeDropDown.Items[index]; if (_watchList.Count > 1) { NotesBox.Enabled = false; NotesBox.Text = string.Empty; AddressBox.Enabled = false; AddressBox.Text = _watchList.Select(a => a.AddressString).Aggregate((addrStr, nextStr) => addrStr + ("," + nextStr)); BigEndianCheckBox.ThreeState = true; if (_watchList.Select(s => s.Size).Distinct().Count() > 1) { DisplayTypeDropDown.Enabled = false; } } else { NotesBox.Text = _watchList[0].Notes; AddressBox.SetFromLong(_watchList[0].Address); } SetBigEndianCheckBox(); DomainDropDown.Enabled = false; break; } }