File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
Sources/SnapshotPreviewsCore Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -84,16 +84,23 @@ public func getPreviewTypes() -> [LookupResult] {
8484 let images = _dyld_image_count ( )
8585 var types = [ LookupResult] ( )
8686 for i in 0 ..< images {
87+ let header = _dyld_get_image_header ( i) !
88+ let headerType = UnsafeRawPointer ( header) . assumingMemoryBound ( to: mach_header_type. self)
89+
90+ // Anything in the dylib cache is a system library that we should not include
91+ guard headerType. pointee. flags & MH_DYLIB_IN_CACHE == 0 else {
92+ continue
93+ }
94+
8795 let imageName = String ( cString: _dyld_get_image_name ( i) )
88- guard imageName. starts ( with: Bundle . main . bundleURL . path ) else {
96+ guard ! imageName. contains ( " .simruntime " ) && !imageName . contains ( " .platform " ) && !imageName . starts ( with: " /usr/lib/ " ) && !imageName . starts ( with : " /System/Library/ " ) else {
8997 continue
9098 }
9199
92- let header = _dyld_get_image_header ( i) !
93100 var size : UInt = 0
94101 let sectStart = UnsafeRawPointer (
95102 getsectiondata (
96- UnsafeRawPointer ( header ) . assumingMemoryBound ( to : mach_header_type . self ) ,
103+ headerType ,
97104 " __TEXT " ,
98105 " __swift5_proto " ,
99106 & size) ) ? . assumingMemoryBound ( to: Int32 . self)
You can’t perform that action at this time.
0 commit comments