protected override void PackageData(WritingContext SW) { // Write the segment load command SW.WriteFixedASCII(SegmentName, 16); SW.WriteUInt(VirtualAddress, AddressSize); SW.WriteUInt(VirtualSize, AddressSize); // Offset to first segment //@TODO: These file offsets and file lengths aren't correct (compared to the original MachO's) OffsetFieldU32or64 FileOffset = SW.WriteDeferredOffsetFrom(0, AddressSize); LengthFieldU32or64 FileLength = SW.WriteDeferredLength(0, AddressSize); SW.Write(MaxProt); SW.Write(InitProt); SW.Write(Sections.Count); SW.Write(Flags); // Enqueue a job to commit the file offset to the first section SW.CurrentPhase.PendingWrites.Enqueue(delegate(WritingContext Context) { FileLength.Rebase(Context.Position); FileOffset.Commit(Context); }); // Write the sections belonging to the segment foreach (MachSection Section in Sections) { Section.Write(SW); } // Enqueue a job to commit the length of data in all the sections SW.CurrentPhase.PendingWrites.Enqueue(delegate(WritingContext Context) { FileLength.Commit(Context); }); }
public override void WriteData(WritingContext SW) { base.WriteData(SW); SW.Write(CertificateIndex); // index in the mobile provision certificate list (always 0 for now) SW.Write(FieldName.Length); // field name length SW.WriteFixedASCII(FieldName, FieldName.Length); // field name to match int Count = 4 - FieldName.Length % 4; // may need to pad to alignment of 4 bytes if (Count > 0 && Count < 4) SW.WriteZeros(Count); SW.Write(MatchOp.MatchOp); // must equal SW.Write(MatchOp.CertificateName.Length); // length of certficate name SW.WriteFixedASCII(MatchOp.CertificateName, MatchOp.CertificateName.Length);// certificate name to match Count = 4 - MatchOp.CertificateName.Length % 4; // may need to pad to alignment of 4 bytes if (Count > 0 && Count < 4) SW.WriteZeros(Count); }
public void Write(WritingContext SW) { SW.WriteFixedASCII(SectionName, 16); SW.WriteFixedASCII(SegmentName, 16); SW.WriteUInt(Addr, AddressSize); SW.WriteUInt(Size, AddressSize); SW.WriteAbsoluteOffsetAndDelayedData(SectionData, 1 << (byte)LogAlignment, AddressSize); SW.Write(LogAlignment); SW.Write(RelocationOffset); SW.Write(NumRelocations); SW.Write((UInt32)Flags); SW.Write(Reserved1); SW.Write(Reserved2); if (AddressSize == Bits.Num._64) SW.Write(Reserved3); }
public override void WriteData(WritingContext SW) { base.WriteData(SW); SW.Write(BundleIdentifier.Length); // bundle identifier length SW.WriteFixedASCII(BundleIdentifier, BundleIdentifier.Length); // bundle identifier string int Count = 4 - BundleIdentifier.Length % 4; // may need to pad to alignment of 4 bytes if (Count > 0 && Count < 4) SW.WriteZeros(Count); }