File tree Expand file tree Collapse file tree 3 files changed +57
-0
lines changed Expand file tree Collapse file tree 3 files changed +57
-0
lines changed Original file line number Diff line number Diff line change @@ -392,4 +392,14 @@ extension DyldCacheLoaded {
392
392
. advanced ( by: numericCast ( header. swiftOptsOffset) )
393
393
. autoBoundPointee ( )
394
394
}
395
+
396
+ public var dynamicData : DyldCacheDynamicData ? {
397
+ guard mainCacheHeader. dynamicDataOffset > 0 ,
398
+ mainCacheHeader. hasProperty ( \. dynamicDataMaxSize) else {
399
+ return nil
400
+ }
401
+ return ptr
402
+ . advanced ( by: numericCast ( header. dynamicDataOffset) )
403
+ . autoBoundPointee ( )
404
+ }
395
405
}
Original file line number Diff line number Diff line change
1
+ //
2
+ // DyldCacheDynamicData.swift
3
+ // MachOKit
4
+ //
5
+ // Created by p-x9 on 2025/02/28
6
+ //
7
+ //
8
+
9
+ import Foundation
10
+
11
+ public struct DyldCacheDynamicData : LayoutWrapper {
12
+ public typealias Layout = dyld_cache_dynamic_data_header
13
+
14
+ public var layout : Layout
15
+ }
16
+
17
+ extension DyldCacheDynamicData {
18
+ public var magic : String {
19
+ . init( tuple: layout. magic)
20
+ }
21
+ }
22
+
23
+ #if canImport(Darwin)
24
+ extension DyldCacheDynamicData {
25
+ public var path : String {
26
+ let path : UnsafeMutablePointer < CChar > = . allocate( capacity: Int ( MAXPATHLEN) )
27
+ var fsid : UInt64 = numericCast ( layout. fsId)
28
+ return withUnsafeMutablePointer ( to: & fsid) { fsid in
29
+ fsgetpath (
30
+ path,
31
+ Int ( MAXPATHLEN) ,
32
+ UnsafeMutableRawPointer ( fsid) . assumingMemoryBound ( to: fsid_t. self) ,
33
+ layout. fsObjId
34
+ )
35
+ return String ( cString: path)
36
+ }
37
+ }
38
+ }
39
+ #endif
Original file line number Diff line number Diff line change @@ -318,6 +318,14 @@ final class DyldCacheLoadedPrintTests: XCTestCase {
318
318
print ( " Metadata Conformance Hash Table Cache Offset: " , swiftOptimization. metadataConformanceHashTableCacheOffset)
319
319
print ( " Foreign Type Conformance Hash Table Cache Offset: " , swiftOptimization. foreignTypeConformanceHashTableCacheOffset)
320
320
}
321
+
322
+ func testDynamicData( ) throws {
323
+ guard let dynamicData = cache. dynamicData else { return }
324
+ print ( " Magic: " , dynamicData. magic)
325
+ print ( " fsId: " , dynamicData. fsId)
326
+ print ( " fsObjId: " , dynamicData. fsObjId)
327
+ print ( " path: " , dynamicData. path)
328
+ }
321
329
}
322
330
323
331
#endif
You can’t perform that action at this time.
0 commit comments