Skip to content

Commit

Permalink
Merge pull request #141 from p-x9/feature/main-cache-ptr
Browse files Browse the repository at this point in the history
Add `mainCachePtr` property to get pointer of main dyld cache
  • Loading branch information
p-x9 authored Nov 7, 2024
2 parents 40736a8 + 254b257 commit 57956f0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Sources/MachOKit/DyldCacheLoaded.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ public struct DyldCacheLoaded: DyldCacheRepresentable {
_mainCacheHeader ?? header
}

/// Pointer of main cache
public var mainCachePtr: UnsafeRawPointer {
let diff = header.sharedRegionStart - mainCacheHeader.sharedRegionStart
return ptr.advanced(by: -numericCast(diff))
}

/// Initialized with the start pointer of dyld cache loaded on memory.
/// - Parameter ptr: start pointer of dyld cache header
///
Expand Down

0 comments on commit 57956f0

Please sign in to comment.