Quellcode-Bibliothek macos.rs
Interaktion und PortierbarkeitRust
/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
/* First we attempt to parse if there's a Fat header there * *Ifwehaveone,thenwehaveauniversalbinarysowearegoingto *searchthearchitecturestofindtheonewewant,extractthecorrect *MachObufferaswellastheoffsetatwhichtheMachObinaryis. *TestingUniversalbinarieswillrequirerunninggtestagainsta *Shippablebuild. * *IfnotwehaveanormalMachOandwedirectlyparsethebufferwe *havereadearlier,andusea0offset.
*/ let (buf, main_offset): ([u8; HEADER_SIZE], usize) = if fat_header.magic == mach::fat::FAT_CIGAM || fat_header.magic == mach::fat::FAT_MAGIC
{ let total = std::mem::size_of::<mach::fat::FatHeader>() as usize
+ (std::mem::size_of::<mach::fat::FatArch>() * fat_header.nfat_arch as usize);
let b = self
.copy_bytes(offset, HEADER_SIZE)?
.try_into()
.expect("copy_bytes didn't copy exactly as many bytes as requested");
(b, offset)
} else { return Err(Error::NotFatArchive);
}
} else {
(
buffer.try_into().map_err(|source| Error::NotEnoughData {
expected: HEADER_SIZE,
source,
})?, 0,
)
};
trace!("get_build_id_bytes: {} {}", section, note);
let macho_head = mach::header::Header64::from_bytes(&buf); letmut address = main_offset + HEADER_SIZE; let end_of_commands = address + (macho_head.sizeofcmds as usize);
while address < end_of_commands { let command = unsafe { self.copy::<mach::load_command::LoadCommandHeader>(address as usize)? };
trace!("get_build_id_bytes: command {:?}", command);
if command.cmd == mach::load_command::LC_SEGMENT_64 { let segment = unsafe { self.copy::<mach::load_command::SegmentCommand64>(address as usize)? };
trace!("get_build_id_bytes: segment {:?}", segment);
let name = segment.name().map_err(|source| Error::Goblin {
action: "get segment name",
source,
})?; if name == section { let sections_addr =
address + std::mem::size_of::<mach::load_command::SegmentCommand64>(); let sections = unsafe { self.copy_array::<mach::load_command::Section64>(
sections_addr as usize,
segment.nsects as usize,
)?
};
trace!("get_build_id_bytes: sections {:?}", sections);
for section in §ions {
trace!("get_build_id_bytes: section {:?}", section); iflet Ok(sname) = Self::string_from_bytes(§ion.sectname) {
trace!("get_build_id_bytes: sname {:?}", sname); if (sname.len() == 0) || (sname != note) { continue;
}
returnself.copy_bytes(
main_offset + section.addr as usize,
section.size as usize,
);
}
}
}
}
address += command.cmdsize as usize;
}
Err(Error::NoteNotAvailable)
}
}
Messung V0.5 in Prozent
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.12Bemerkung:
(Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-10-02)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.