Exemple #1
0
        private long ParseNrr(out NrrInfo nrrInfo, ServiceCtx context, long nrrAddress, long nrrSize)
        {
            nrrInfo = null;

            if (nrrSize == 0 || nrrAddress + nrrSize <= nrrAddress || (nrrSize & 0xFFF) != 0)
            {
                return(MakeError(ErrorModule.Loader, LoaderErr.BadSize));
            }
            else if ((nrrAddress & 0xFFF) != 0)
            {
                return(MakeError(ErrorModule.Loader, LoaderErr.UnalignedAddress));
            }

            StructReader reader = new StructReader(context.Memory, nrrAddress);
            NrrHeader    header = reader.Read <NrrHeader>();

            if (header.Magic != NrrMagic)
            {
                return(MakeError(ErrorModule.Loader, LoaderErr.InvalidNrr));
            }
            else if (header.NrrSize != nrrSize)
            {
                return(MakeError(ErrorModule.Loader, LoaderErr.BadSize));
            }

            List <byte[]> hashes = new List <byte[]>();

            for (int i = 0; i < header.HashCount; i++)
            {
                hashes.Add(context.Memory.ReadBytes(nrrAddress + header.HashOffset + (i * 0x20), 0x20));
            }

            nrrInfo = new NrrInfo(nrrAddress, header, hashes);

            return(0);
        }
Exemple #2
0
        private long ParseNrr(out NrrInfo NrrInfo, ServiceCtx Context, long NrrAddress, long NrrSize)
        {
            NrrInfo = null;

            if (NrrSize == 0 || NrrAddress + NrrSize <= NrrAddress || (NrrSize & 0xFFF) != 0)
            {
                return(MakeError(ErrorModule.Loader, LoaderErr.BadSize));
            }
            else if ((NrrAddress & 0xFFF) != 0)
            {
                return(MakeError(ErrorModule.Loader, LoaderErr.UnalignedAddress));
            }

            StructReader Reader = new StructReader(Context.Memory, NrrAddress);
            NrrHeader    Header = Reader.Read <NrrHeader>();

            if (Header.Magic != NrrMagic)
            {
                return(MakeError(ErrorModule.Loader, LoaderErr.InvalidNrr));
            }
            else if (Header.NrrSize != NrrSize)
            {
                return(MakeError(ErrorModule.Loader, LoaderErr.BadSize));
            }

            List <byte[]> Hashes = new List <byte[]>();

            for (int i = 0; i < Header.HashCount; i++)
            {
                Hashes.Add(Context.Memory.ReadBytes(NrrAddress + Header.HashOffset + (i * 0x20), 0x20));
            }

            NrrInfo = new NrrInfo(NrrAddress, Header, Hashes);

            return(0);
        }