Example #1
0
 public static List <MachObjectFile> ReadMachObjects(byte[] buffer)
 {
     if (UniversalBinaryFile.IsUniversalBinaryFile(buffer))
     {
         UniversalBinaryFile file = new UniversalBinaryFile(buffer);
         return(file.MachObjects);
     }
     else if (MachObjectFile.IsMachObjectFile(buffer, 0))
     {
         List <MachObjectFile> result = new List <MachObjectFile>();
         result.Add(new MachObjectFile(buffer, 0, buffer.Length));
         return(result);
     }
     else
     {
         return(null);
     }
 }
Example #2
0
 public static byte[] PackMachObjects(List <MachObjectFile> files)
 {
     if (files.Count == 1)
     {
         return(files[0].GetBytes());
     }
     else
     {
         UniversalBinaryFile universalBinaryFile = new UniversalBinaryFile();
         universalBinaryFile.Header.NumberOfArchitectures = (uint)files.Count;
         foreach (MachObjectFile machObject in files)
         {
             FatArch fatArch = new FatArch();
             fatArch.CpuType    = machObject.Header.CpuType;
             fatArch.CpuSubType = machObject.Header.CpuSubType;
             universalBinaryFile.Architectures.Add(fatArch, machObject);
         }
         return(universalBinaryFile.GetBytes());
     }
 }