@@ -210,6 +210,56 @@ private extension ALTApplication {
210210 cachedEntitlementsString = string
211211 return string
212212 }
213+
214+ @objc
215+ public func dumpMachOInfo( ) -> String {
216+ let executableURL = bundle. executableURL ?? fileURL. appendingPathComponent ( fileURL. deletingPathExtension ( ) . lastPathComponent)
217+ guard let parser = try ? MachOParser ( url: executableURL) else {
218+ return " [AltSign] MachOParser failed to load \( executableURL. lastPathComponent) "
219+ }
220+
221+ var info = " --- Mach-O Binary Info: \( executableURL. lastPathComponent) --- \n "
222+ info += " Path: \( fileURL. path) \n "
223+ info += " Architectures: \( parser. architectures ( ) . joined ( separator: " , " ) ) \n "
224+ if let platform = parser. platformType ( ) {
225+ info += " Platform: \( platform) \n "
226+ }
227+ if let minOS = parser. minimumOSVersion ( ) {
228+ info += " Min OS Version: \( minOS) \n "
229+ }
230+ info += " Encrypted (DRM): \( parser. isEncrypted ( ) ? " Yes " : " No " ) \n "
231+ if let teamID = parser. teamID ( ) {
232+ info += " Team ID: \( teamID) \n "
233+ }
234+
235+ let certs = parser. certificates ( )
236+ if !certs. isEmpty {
237+ info += " Certificates ( \( certs. count) ): \n "
238+ for (index, cert) in certs. enumerated ( ) {
239+ let subject = SecCertificateCopySubjectSummary ( cert) as String ? ?? " Unknown Subject "
240+ info += " [ \( index) ] \( subject) \n "
241+ }
242+ }
243+
244+ let libs = parser. linkedLibraries ( )
245+ if !libs. isEmpty {
246+ info += " Linked Libraries ( \( libs. count) ): \n "
247+ for lib in libs {
248+ info += " - \( lib) \n "
249+ }
250+ }
251+
252+ let segs = parser. segments ( )
253+ if !segs. isEmpty {
254+ info += " Segments ( \( segs. count) ): \n "
255+ for seg in segs {
256+ info += " - \( seg. name) (offset: \( seg. offset) , size: \( seg. size) ) \n "
257+ }
258+ }
259+
260+ info += " ---------------------------------------- "
261+ return info
262+ }
213263}
214264
215265
0 commit comments