@@ -30,6 +30,13 @@ private func symbol<T>(_ handle: UnsafeMutableRawPointer, _ name: String) -> T {
3030 return unsafeBitCast ( result, to: T . self)
3131}
3232
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+
3340enum Sym {
3441 static let pidFromHint : @convention ( c) ( AnyObject ) -> pid_t =
3542 symbol ( symbolicationHandle, " pidFromHint " )
@@ -97,6 +104,16 @@ typealias CSSymbolicatorRef = CSTypeRef
97104typealias CSSymbolRef = CSTypeRef
98105typealias CSSymbolOwnerRef = CSTypeRef
99106
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+
100117func pidFromHint( _ hint: String ) -> pid_t ? {
101118 let result = Sym . pidFromHint ( hint as NSString )
102119 return result == 0 ? nil : result
@@ -231,4 +248,8 @@ func machErrStr(_ kr: kern_return_t) -> String {
231248 return " \( errStr) (0x \( errHex) ) "
232249}
233250
251+ func getVMUProcInfoClass( ) -> VMUProcInfo . Type ? {
252+ return objcClass ( " VMUProcInfo " )
253+ }
254+
234255#endif
0 commit comments