示例#1
0
        private void lbLoadedVmdList_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lbLoadedVmdList.SelectedIndex == -1)
            {
                return;
            }

            string          VmdName = lbLoadedVmdList.SelectedItem.ToString();
            MemoryInterface mi      = RTC_MemoryDomains.VmdPool[VmdName];

            lbRealDomainValue.Text = (mi as VirtualMemoryDomain).PointerDomains[0];
            lbVmdSizeValue.Text    = mi.Size.ToString();
        }
示例#2
0
 public static string getRealDomain(string domain, long address)
 {
     if (domain.Contains("[V]"))
     {
         MemoryInterface mi  = VmdPool[domain];
         var             vmd = (mi as VirtualMemoryDomain);
         return(vmd.getRealDomain(address));
     }
     else
     {
         return(domain);
     }
 }
示例#3
0
        private void cbSelectedEngine_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(cbSelectedMemoryDomain.SelectedItem?.ToString()) || !RTC_MemoryDomains.MemoryInterfaces.ContainsKey(cbSelectedMemoryDomain.SelectedItem.ToString()))
            {
                cbSelectedMemoryDomain.Items.Clear();
                return;
            }

            MemoryInterface mi = RTC_MemoryDomains.MemoryInterfaces[cbSelectedMemoryDomain.SelectedItem.ToString()];

            lbDomainSizeValue.Text = mi.Size.ToString();
            lbWordSizeValue.Text   = $"{mi.WordSize*8} bits";
            lbEndianTypeValue.Text = (mi.BigEndian ? "Big" : "Little");

            currentDomainSize = Convert.ToInt64(mi.Size);
        }
示例#4
0
        public static MemoryDomainProxy getProxy(string _domain, long _address)
        {
            if (MemoryInterfaces.Count == 0)
            {
                RefreshDomains();
            }

            if (MemoryInterfaces.ContainsKey(_domain))
            {
                MemoryInterface mi = MemoryInterfaces[_domain];
                return((MemoryDomainProxy)mi);
            }
            else if (VmdPool.ContainsKey(_domain))
            {
                MemoryInterface mi  = VmdPool[_domain];
                var             vmd = (mi as VirtualMemoryDomain);
                return(getProxy(vmd.getRealDomain(_address), vmd.getRealAddress(_address)));
            }
            else
            {
                return(null);
            }
        }
示例#5
0
        private bool GenerateVMD()
        {
            if (string.IsNullOrWhiteSpace(cbSelectedMemoryDomain.SelectedItem?.ToString()) || !RTC_MemoryDomains.MemoryInterfaces.ContainsKey(cbSelectedMemoryDomain.SelectedItem.ToString()))
            {
                cbSelectedMemoryDomain.Items.Clear();
                return(false);
            }

            if (!string.IsNullOrWhiteSpace(tbVmdName.Text) && RTC_MemoryDomains.VmdPool.ContainsKey($"[V]{tbVmdName.Text}"))
            {
                MessageBox.Show("There is already a VMD with this name in the VMD Pool");
                return(false);
            }

            MemoryInterface     mi    = RTC_MemoryDomains.MemoryInterfaces[cbSelectedMemoryDomain.SelectedItem.ToString()];
            VirtualMemoryDomain VMD   = new VirtualMemoryDomain();
            VmdPrototype        proto = new VmdPrototype();

            proto.GenDomain = cbSelectedMemoryDomain.SelectedItem.ToString();

            if (string.IsNullOrWhiteSpace(tbVmdName.Text))
            {
                proto.VmdName = RTC_Core.GetRandomKey();
            }
            else
            {
                proto.VmdName = tbVmdName.Text;
            }


            proto.BigEndian = mi.BigEndian;
            proto.WordSize  = mi.WordSize;


            if (cbUsePointerSpacer.Checked && nmPointerSpacer.Value > 1)
            {
                proto.PointerSpacer = Convert.ToInt32(nmPointerSpacer.Value);
            }
            else
            {
                proto.PointerSpacer = 1;
            }


            foreach (string line in tbCustomAddresses.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)
                {
                    int start = SafeStringToInt(lineParts[0]);
                    int end   = SafeStringToInt(lineParts[1]);

                    if (end >= currentDomainSize)
                    {
                        end = Convert.ToInt32(currentDomainSize - 1);
                    }

                    if (remove)
                    {
                        proto.removeRanges.Add(new int[] { start, end });
                    }
                    else
                    {
                        proto.addRanges.Add(new int[] { start, end });
                    }
                }
                else
                {
                    int address = SafeStringToInt(lineParts[0]);

                    if (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 int[] { 0, (currentDomainSize > int.MaxValue ? int.MaxValue : Convert.ToInt32(currentDomainSize)) });
            }


            VMD = proto.Generate();


            if (VMD.PointerAddresses.Count == 0)
            {
                MessageBox.Show("The resulting VMD had no pointers so the operation got cancelled.");
                return(false);
            }

            RTC_MemoryDomains.AddVMD(VMD);

            tbVmdName.Text = "";
            cbSelectedMemoryDomain.SelectedIndex = -1;
            cbSelectedMemoryDomain.Items.Clear();

            currentDomainSize = 0;

            nmPointerSpacer.Value      = 2;
            cbUsePointerSpacer.Checked = false;

            tbCustomAddresses.Text = "";

            lbDomainSizeValue.Text = "######";
            lbEndianTypeValue.Text = "######";
            lbWordSizeValue.Text   = "######";

            //send to vmd pool menu
            RTC_Core.vmdPoolForm.RefreshVMDs();
            RTC_Core.ecForm.cbMemoryDomainTool.SelectedIndex = 1;

            GC.Collect();
            GC.WaitForPendingFinalizers();

            return(true);
        }