Ejemplo n.º 1
0
        static object ReadFile(BinaryReader reader, string filename)
        {
            var magic = reader.ReadUInt32();

            reader.BaseStream.Position = 0;
            switch (magic)
            {
            case MH_MAGIC:
            case MH_MAGIC_64:
                var mf = new MachOFile(filename);
                mf.Read(reader);
                return(mf);

            case FAT_MAGIC:             // little-endian fat binary
            case FAT_CIGAM:             // big-endian fat binary
            {
                var f = new FatFile(filename);
                f.Read(reader);
                return(f);
            }

            default:
                if (StaticLibrary.IsStaticLibrary(reader))
                {
                    var sl = new StaticLibrary();
                    sl.Read(filename, reader, reader.BaseStream.Length);
                    return(sl);
                }
                throw new Exception(string.Format("File format not recognized: {0} (magic: 0x{1})", filename, magic.ToString("X")));
            }
        }
Ejemplo n.º 2
0
        internal void ReadEntry(BinaryReader reader)
        {
            reader.BaseStream.Position = offset;

            if (MachOFile.IsMachOLibrary(this, reader))
            {
                entry = new MachOFile(this);
                entry.Read(reader);
            }
            else if (StaticLibrary.IsStaticLibrary(reader))
            {
                static_library = new StaticLibrary();
                static_library.Read(parent?.Filename, reader, size);
            }
            else
            {
                throw ErrorHelper.CreateError(1603, Errors.MX1603, offset, parent.Filename);
            }
        }
Ejemplo n.º 3
0
        internal void ReadEntry(BinaryReader reader)
        {
            reader.BaseStream.Position = offset;

            if (MachOFile.IsMachOLibrary(this, reader))
            {
                entry = new MachOFile(this);
                entry.Read(reader);
            }
            else if (StaticLibrary.IsStaticLibrary(reader))
            {
                static_library = new StaticLibrary();
                static_library.Read(reader);
            }
            else
            {
                throw ErrorHelper.CreateError(1603, "Unknown format for fat entry at position {0} in {1}.", offset, parent.Filename);
            }
        }
Ejemplo n.º 4
0
        internal void ReadEntry(BinaryReader reader)
        {
            reader.BaseStream.Position = offset;

            if (MachOFile.IsMachOLibrary (this, reader)) {
                entry = new MachOFile (this);
                entry.Read (reader);
            } else if (StaticLibrary.IsStaticLibrary (reader)) {
                static_library = new StaticLibrary ();
                static_library.Read (reader);
            } else {
                throw ErrorHelper.CreateError (1603, "Unknown format for fat entry at position {0} in {1}.", offset, parent.Filename);
            }
        }
Ejemplo n.º 5
0
 static object ReadFile(BinaryReader reader, string filename)
 {
     var magic = reader.ReadUInt32 ();
     reader.BaseStream.Position = 0;
     switch (magic) {
     case MH_MAGIC:
     case MH_MAGIC_64:
         var mf = new MachOFile (filename);
         mf.Read (reader);
         return mf;
     case FAT_MAGIC: // little-endian fat binary
     case FAT_CIGAM: // big-endian fat binary
         {
             var f = new FatFile (filename);
             f.Read (reader);
             return f;
         }
     default:
         if (StaticLibrary.IsStaticLibrary (reader)) {
             var sl = new StaticLibrary ();
             sl.Read (reader);
             return sl;
         }
         throw new Exception (string.Format ("File format not recognized: {0} (magic: 0x{1})", filename, magic.ToString ("X")));
     }
 }