Beispiel #1
0
        public override void Load(Stream stream)
        {
            KOARBinaryReader br = new KOARBinaryReader(stream);

            // Metadata

            Module             = br.ReadString();
            PrehashedFunctions = new List <string>();

            var count = br.ReadInt();

            for (int i = 0; i < count; i++)
            {
                PrehashedFunctions.Add(br.ReadString());
            }

            br.ReadInt(); // Size of Lua chunk

            // Lua
            // header

            _header                   = new LuaHeader();
            _header.Singature         = br.ReadUInt();
            _header.Version           = (byte)br.ReadInt(1);
            _header.Format            = (byte)br.ReadInt(1);
            _header.Endian            = (LuaHeader.ChunkEndian)br.ReadInt(1);
            _header.SizeOfInt         = (byte)br.ReadInt(1);
            _header.SizeOfSize_T      = (byte)br.ReadInt(1);
            _header.SizeOfInstruction = (byte)br.ReadInt(1);
            _header.SizeOfLuaNumber   = (byte)br.ReadInt(1);
            _header.IntegralFlag      = (byte)br.ReadInt(1);
            _header.Unknown1          = (byte)br.ReadInt(1);
            _header.Unknown2          = (byte)br.ReadInt(1);

            if (_header.Endian == LuaHeader.ChunkEndian.big)
            {
                br.SetLittleEndian(false);
            }

            // value types

            br.Read(224);

            // main function

            Root = LuaFunction.ReadFunction(br);

            // KoreVM footer

            _footer = br.Read(8);

            br.Close();
        }