Просмотр исходного кода

Initialize WebKitLegacy when exploring all classes

Tanner Bennett лет назад: 6
Родитель
Сommit
6bf746d4aa
1 измененных файлов с 22 добавлено и 0 удалено
  1. 22 0
      Classes/GlobalStateExplorers/RuntimeBrowser/FLEXRuntimeKeyPath.m

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

@@ -7,6 +7,7 @@
 //
 //
 
 
 #import "FLEXRuntimeKeyPath.h"
 #import "FLEXRuntimeKeyPath.h"
+#include <dlfcn.h>
 
 
 @interface FLEXRuntimeKeyPath () {
 @interface FLEXRuntimeKeyPath () {
     NSString *flex_description;
     NSString *flex_description;
@@ -46,10 +47,31 @@
         keyPathString = [keyPathString substringToIndex:keyPathString.length];
         keyPathString = [keyPathString substringToIndex:keyPathString.length];
     }
     }
     keyPath->flex_description = keyPathString;
     keyPath->flex_description = keyPathString;
+    
+    if (bundle.isAny && cls.isAny && method.isAny) {
+        [self initializeWebKitLegacy];
+    }
 
 
     return keyPath;
     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 {
 - (NSString *)description {
     return flex_description;
     return flex_description;
 }
 }