Ejemplo n.º 1
0
        public void WriteInst(BuildInstruction inst)
        {
            switch (inst.Type)
            {
            case BuildType.FromPatcher:
                this.deflateWriter.Write((0x08 << 0x1c) | (inst.Length & 0x0fffffff));
                break;

            case BuildType.FillBytes:
                this.deflateWriter.Write((0x0c << 0x1c)
                                         | ((inst.Length & 0x000fffff) << 0x08)
                                         | (inst.FillByte & 0xff));
                break;

            case BuildType.FromOldFile:
                int flag = (inst.Length >> 0x1c);
                if (flag == 0x08 || flag == 0x0c)
                {
                    throw new Exception("errrrrrrrrr");
                }
                this.deflateWriter.Write(inst.Length);
                this.deflateWriter.Write(inst.OldFilePosition);
                break;

            case BuildType.Ending:
                this.deflateWriter.Write(0);
                break;
            }
        }
Ejemplo n.º 2
0
        public BuildInstruction ReadInst()
        {
            BuildInstruction inst = new BuildInstruction();

            inst.Length          = 0;
            inst.FillByte        = 0;
            inst.OldFilePosition = 0;

            uint command = reader.ReadUInt32();

            if (command == 0)
            {
                inst.Type = BuildType.Ending;
            }
            else
            {
                switch (command >> 0x1c)
                {
                case 0x08:
                    inst.Type   = BuildType.FromPatcher;
                    inst.Length = (int)command & 0x0fffffff;
                    break;

                case 0x0c:
                    inst.Type     = BuildType.FillBytes;
                    inst.Length   = (int)(command & 0x0fffff00) >> 8;
                    inst.FillByte = (byte)(command & 0xff);
                    break;

                default:
                    inst.Type            = BuildType.FromOldFile;
                    inst.Length          = (int)command;
                    inst.OldFilePosition = reader.ReadInt32();
                    break;
                }
            }
            return(inst);
        }