@@ -30,6 +30,13 @@ private func symbol<T>(_ handle: UnsafeMutableRawPointer, _ name: String) -> T {
30
30
return unsafeBitCast ( result, to: T . self)
31
31
}
32
32
33
+ private func objcClass< T> ( _ name: String ) -> T ? {
34
+ guard let result = objc_getClass ( name) as? AnyClass else {
35
+ return nil
36
+ }
37
+ return unsafeBitCast ( result, to: T . self)
38
+ }
39
+
33
40
enum Sym {
34
41
static let pidFromHint : @convention ( c) ( AnyObject ) -> pid_t =
35
42
symbol ( symbolicationHandle, " pidFromHint " )
@@ -97,6 +104,16 @@ typealias CSSymbolicatorRef = CSTypeRef
97
104
typealias CSSymbolRef = CSTypeRef
98
105
typealias CSSymbolOwnerRef = CSTypeRef
99
106
107
+ // Declare just enough of VMUProcInfo for our purposes. It does not actually
108
+ // conform to this protocol, but ObjC protocol method dispatch is based entirely
109
+ // around msgSend and the presence of the method on the class, not conformance.
110
+ @objc protocol VMUProcInfo {
111
+ @objc ( initWithTask: )
112
+ init ( task: task_read_t )
113
+
114
+ var shouldAnalyzeWithCorpse : Bool { get }
115
+ }
116
+
100
117
func pidFromHint( _ hint: String ) -> pid_t ? {
101
118
let result = Sym . pidFromHint ( hint as NSString )
102
119
return result == 0 ? nil : result
@@ -231,4 +248,8 @@ func machErrStr(_ kr: kern_return_t) -> String {
231
248
return " \( errStr) (0x \( errHex) ) "
232
249
}
233
250
251
+ func getVMUProcInfoClass( ) -> VMUProcInfo . Type ? {
252
+ return objcClass ( " VMUProcInfo " )
253
+ }
254
+
234
255
#endif
0 commit comments