Beispiel #1
0
        public long GetNsoAddress(NsoTypeEnum type)
        {
            long addr = 0;

            for (int i = 0; i < (int)type; i++)
            {
                if (Nsos[i] != null)
                {
                    addr += Nsos[i].EndAddress;
                }
            }

            return((addr + 0xFFF) & ~0xFFF);
        }
Beispiel #2
0
        public MemAddress(string s)
        {
            IsSymbol = s.StartsWith("!");
            if (IsSymbol)
            {
                Symbol = s.Substring(1);
            }
            else
            {
                if (!Regex.IsMatch(s, @"^(rtld|main|sdk)\+(([0-9]{1,})|(0x[0-9a-fA-F]{1,}))$"))
                {
                    throw new PatchConfigException($"Invalid address : {s}");
                }

                var split = s.Split('+');
                NsoType = (NsoTypeEnum)Enum.Parse(typeof(NsoTypeEnum), split[0]);

                Offset = (split[1].StartsWith("0x"))
                    ? uint.Parse(split[1].Substring(2), NumberStyles.HexNumber)
                    : uint.Parse(split[1]);
            }
        }
Beispiel #3
0
 public long GetAddress(ExeFS exefs, List <Tuple <string, uint> > symbols)
 {
     if (IsSymbol)
     {
         foreach (var sym in symbols)
         {
             if (sym.Item1 == Symbol)
             {
                 return(exefs.GetNsoAddress(NsoTypeEnum.sdk) + sym.Item2);
             }
         }
         throw new PatchConfigException($"Could not find symbol : {Symbol}");
     }
     else
     {
         NsoTypeEnum type = NsoType;
         if (type == NsoTypeEnum.sdk)
         {
             type = NsoTypeEnum.subsdk0;
         }
         return(exefs.GetNsoAddress(type) + Offset);
     }
 }
Beispiel #4
0
 public Nso GetNso(NsoTypeEnum type)
 {
     return(Nsos[(int)type]);
 }
Beispiel #5
0
 public void SetNso(Nso nso, NsoTypeEnum type)
 {
     Nsos[(int)type] = nso;
 }