Ejemplo n.º 1
0
        /// <summary>
        /// Gets a string array of valid layers to pass to SetLayers, or an empty list if that method should not be called
        /// </summary>
        private List <string> GetLayerData()
        {
            var ret = new List <string>();
            var p   = _nyma.GetLayerData();

            if (p == null)
            {
                return(ret);
            }
            var q = p;

            while (true)
            {
                if (*q == 0)
                {
                    if (q > p)
                    {
                        ret.Add(Mershul.PtrToStringUtf8((IntPtr)p));
                    }
                    else
                    {
                        break;
                    }
                    p = q + 1;
                }
                q++;
            }
            return(ret);
        }
Ejemplo n.º 2
0
        private void MakeTrace(IntPtr disasm)
        {
            var disasmStr = Mershul.PtrToStringUtf8(disasm);

            if (!disasmStr.StartsWith("CPU"))             // garbage, ignore
            {
                return;
            }
            disasmStr = disasmStr.Remove(0, 5);                  // remove "CPU  "
            disasmStr = disasmStr.Replace("\n", "");             // remove newlines
            disasmStr = Regex.Replace(disasmStr, @"\{.*\}", ""); // remove any {*} patterns
            disasmStr = disasmStr.PadRight(36);                  // pad

            var regs    = GetCpuFlagsAndRegisters();
            var regsStr = "";

            foreach (var r in regs)
            {
                if (r.Key is not "PC")
                {
                    regsStr += r.Key + $":{r.Value.Value:X16} ";
                }
            }

            regsStr = regsStr.Remove(regsStr.Length - 1, 1);

            Tracer.Put(new(
                           disassembly: disasmStr,
                           registerInfo: regsStr));
        }
Ejemplo n.º 3
0
 public IntPtr GetDataOrThrow()
 {
     if (ErrorMessageStart != 0)
     {
         fixed(byte *p = &ErrorMessageStart)
         throw new InvalidOperationException(Mershul.PtrToStringUtf8((IntPtr)p));
     }
     return(Data);
 }
Ejemplo n.º 4
0
 public MednaSetting(MednaSettingS s)
 {
     Name         = Mershul.PtrToStringUtf8(s.Name);
     Description  = Mershul.PtrToStringUtf8(s.Description);
     SettingsKey  = Mershul.PtrToStringUtf8(s.SettingsKey);
     DefaultValue = Mershul.PtrToStringUtf8(s.DefaultValue);
     Min          = Mershul.PtrToStringUtf8(s.Min);
     Max          = Mershul.PtrToStringUtf8(s.Max);
     Flags        = (SettingFlags)s.Flags;
     Type         = (SettingType)s.Type;
 }
 protected WaterboxMemoryDomain(MemoryArea m, IMonitor monitor)
 {
     Name       = Mershul.PtrToStringUtf8(m.Name);
     EndianType = (m.Flags & MemoryDomainFlags.YugeEndian) != 0 ? Endian.Big : Endian.Little;
     _data      = m.Data;
     Size       = m.Size;
     Writable   = (m.Flags & MemoryDomainFlags.Writable) != 0;
     if ((m.Flags & MemoryDomainFlags.WordSize1) != 0)
     {
         WordSize = 1;
     }
     else if ((m.Flags & MemoryDomainFlags.WordSize2) != 0)
     {
         WordSize = 2;
     }
     else if ((m.Flags & MemoryDomainFlags.WordSize4) != 0)
     {
         WordSize = 4;
     }
     else if ((m.Flags & MemoryDomainFlags.WordSize8) != 0)
     {
         WordSize = 8;
     }
     else
     {
         throw new InvalidOperationException("Unknown word size for memory domain");
     }
     _monitor = monitor;
     if ((m.Flags & MemoryDomainFlags.Swapped) != 0 && EndianType == Endian.Big)
     {
         _addressMangler = WordSize - 1;
     }
     else
     {
         _addressMangler = 0;
     }
     Definition = m;
 }
Ejemplo n.º 6
0
 public EnumValue(MednaSettingS.EnumValueS s)
 {
     Name        = Mershul.PtrToStringUtf8(s.Name);
     Description = Mershul.PtrToStringUtf8(s.Description);
     Value       = Mershul.PtrToStringUtf8(s.Value);
 }