Explorar o código

Initialize WebKitLegacy when exploring all classes

Tanner Bennett %!s(int64=6) %!d(string=hai) anos
pai
achega
6bf746d4aa

+ 22 - 0
Classes/GlobalStateExplorers/RuntimeBrowser/FLEXRuntimeKeyPath.m

@@ -7,6 +7,7 @@
 //
 
 #import "FLEXRuntimeKeyPath.h"
+#include <dlfcn.h>
 
 @interface FLEXRuntimeKeyPath () {
     NSString *flex_description;
@@ -46,10 +47,31 @@
         keyPathString = [keyPathString substringToIndex:keyPathString.length];
     }
     keyPath->flex_description = keyPathString;
+    
+    if (bundle.isAny && cls.isAny && method.isAny) {
+        [self initializeWebKitLegacy];
+    }
 
     return keyPath;
 }
 
++ (void)initializeWebKitLegacy {
+    static dispatch_once_t onceToken;
+    dispatch_once(&onceToken, ^{
+        void *handle = dlopen(
+            "/System/Library/PrivateFrameworks/WebKitLegacy.framework/WebKitLegacy",
+            RTLD_LAZY
+        );
+        void (*WebKitInitialize)() = dlsym(handle, "WebKitInitialize");
+        if (WebKitInitialize) {
+            NSAssert(NSThread.isMainThread,
+                @"WebKitInitialize can only be called on the main thread"
+            );
+            WebKitInitialize();
+        }
+    });
+}
+
 - (NSString *)description {
     return flex_description;
 }