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] {
84
84
let images = _dyld_image_count ( )
85
85
var types = [ LookupResult] ( )
86
86
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
+
87
95
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 {
89
97
continue
90
98
}
91
99
92
- let header = _dyld_get_image_header ( i) !
93
100
var size : UInt = 0
94
101
let sectStart = UnsafeRawPointer (
95
102
getsectiondata (
96
- UnsafeRawPointer ( header ) . assumingMemoryBound ( to : mach_header_type . self ) ,
103
+ headerType ,
97
104
" __TEXT " ,
98
105
" __swift5_proto " ,
99
106
& size) ) ? . assumingMemoryBound ( to: Int32 . self)
You can’t perform that action at this time.
0 commit comments