Skip to content

Commit 94cd973

Browse files
committed
add tool: AppInspector
1 parent eb215f7 commit 94cd973

29 files changed

+1402
-13
lines changed

CMakeLists.txt

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,15 @@ endif()
6969
file(GLOB Main ${CMAKE_SOURCE_DIR}/dylib_dobby_hook/*.m)
7070
file(GLOB MainHeader ${CMAKE_SOURCE_DIR}/dylib_dobby_hook/*.h)
7171

72-
file(GLOB Utils
73-
${CMAKE_SOURCE_DIR}/dylib_dobby_hook/utils/*.m
74-
${CMAKE_SOURCE_DIR}/dylib_dobby_hook/utils/*.c
72+
file(GLOB Common
73+
${CMAKE_SOURCE_DIR}/dylib_dobby_hook/common/*.m
74+
${CMAKE_SOURCE_DIR}/dylib_dobby_hook/common/*.c
7575
)
76-
file(GLOB UtilsHeader ${CMAKE_SOURCE_DIR}/dylib_dobby_hook/utils/*.h)
76+
file(GLOB CommonHeader ${CMAKE_SOURCE_DIR}/dylib_dobby_hook/common/*.h)
77+
78+
file(GLOB Utils ${CMAKE_SOURCE_DIR}/dylib_dobby_hook/${TARGET_OS}/utils/*.m)
79+
file(GLOB UtilsHeader ${CMAKE_SOURCE_DIR}/dylib_dobby_hook/${TARGET_OS}/utils/*.h)
80+
7781

7882
file(GLOB Apps ${CMAKE_SOURCE_DIR}/dylib_dobby_hook/${TARGET_OS}/apps/*.m)
7983
file(GLOB AppsHeader ${CMAKE_SOURCE_DIR}/dylib_dobby_hook/${TARGET_OS}/apps/*.h)
@@ -85,13 +89,15 @@ file(GLOB StaticLibs ${CMAKE_SOURCE_DIR}/libs/${TARGET_OS}/*.a)
8589

8690
include_directories(
8791
${CMAKE_SOURCE_DIR}/dylib_dobby_hook
88-
${CMAKE_SOURCE_DIR}/dylib_dobby_hook/utils
92+
${CMAKE_SOURCE_DIR}/dylib_dobby_hook/Common
93+
${CMAKE_SOURCE_DIR}/dylib_dobby_hook/${TARGET_OS}/utils
8994
${CMAKE_SOURCE_DIR}/dylib_dobby_hook/${TARGET_OS}/apps
9095
${CMAKE_SOURCE_DIR}/dylib_dobby_hook/${TARGET_OS}/helpers
9196
)
9297

9398
add_library(${PROJECT_NAME} SHARED
9499
${Main}
100+
${Common}
95101
${Utils}
96102
${Apps}
97103
${Helpers}
@@ -241,6 +247,7 @@ endif ()
241247
# Explicitly declare header dependencies (for IDE and rebuild tracking)
242248
target_sources(${PROJECT_NAME} PRIVATE
243249
${MainHeader}
250+
${CommonHeader}
244251
${UtilsHeader}
245252
${AppsHeader}
246253
${HelpersHeader}
@@ -250,6 +257,7 @@ target_sources(${PROJECT_NAME} PRIVATE
250257
# install(
251258
# FILES
252259
# ${MainHeader}
260+
# ${CommonHeader}
253261
# ${UtilsHeader}
254262
# ${AppsHeader}
255263
# ${HelpersHeader}

dylib_dobby_hook.xcodeproj/project.pbxproj

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
B5105F5F2E6B298500333727 /* DevHack.m in Sources */ = {isa = PBXBuildFile; fileRef = B5105F5E2E6B298500333727 /* DevHack.m */; };
6666
B513ADD72CB95D0B00F5DC97 /* LocalizationManager.h in Headers */ = {isa = PBXBuildFile; fileRef = B513ADD62CB95D0B00F5DC97 /* LocalizationManager.h */; };
6767
B513ADD92CB95D4100F5DC97 /* LocalizationManager.m in Sources */ = {isa = PBXBuildFile; fileRef = B513ADD82CB95D4100F5DC97 /* LocalizationManager.m */; };
68+
B518593F2E6EF716004240CD /* AppInspector.m in Sources */ = {isa = PBXBuildFile; fileRef = B518593E2E6EF716004240CD /* AppInspector.m */; };
6869
B52BBA842CBFE1CE00F098A9 /* AirBuddyHack.m in Sources */ = {isa = PBXBuildFile; fileRef = B52BBA832CBFE1CE00F098A9 /* AirBuddyHack.m */; };
6970
B5369DCE2CC4C1D200A81211 /* irvueHack.m in Sources */ = {isa = PBXBuildFile; fileRef = B5369DCD2CC4C1D200A81211 /* irvueHack.m */; };
7071
B5369DD02CC4C1DF00A81211 /* VidhubHack.m in Sources */ = {isa = PBXBuildFile; fileRef = B5369DCF2CC4C1DF00A81211 /* VidhubHack.m */; };
@@ -161,6 +162,7 @@
161162
B5105F5E2E6B298500333727 /* DevHack.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DevHack.m; sourceTree = "<group>"; };
162163
B513ADD62CB95D0B00F5DC97 /* LocalizationManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LocalizationManager.h; sourceTree = "<group>"; };
163164
B513ADD82CB95D4100F5DC97 /* LocalizationManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LocalizationManager.m; sourceTree = "<group>"; };
165+
B518593E2E6EF716004240CD /* AppInspector.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppInspector.m; sourceTree = "<group>"; };
164166
B52BBA832CBFE1CE00F098A9 /* AirBuddyHack.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AirBuddyHack.m; sourceTree = "<group>"; };
165167
B5369DCD2CC4C1D200A81211 /* irvueHack.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = irvueHack.m; sourceTree = "<group>"; };
166168
B5369DCF2CC4C1DF00A81211 /* VidhubHack.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VidhubHack.m; sourceTree = "<group>"; };
@@ -289,7 +291,7 @@
289291
38350BF42B53F73A00DD52B3 /* dylib_dobby_hook */ = {
290292
isa = PBXGroup;
291293
children = (
292-
B581601D2BE894A2001DDB9B /* utils */,
294+
B581601D2BE894A2001DDB9B /* common */,
293295
B5105F4C2E6B277500333727 /* ios */,
294296
B5105EE42E6B122700333727 /* mac */,
295297
38350BF52B53F73A00DD52B3 /* dylib_dobby_hook.h */,
@@ -339,6 +341,7 @@
339341
B5105EE42E6B122700333727 /* mac */ = {
340342
isa = PBXGroup;
341343
children = (
344+
B518593C2E6EF5D4004240CD /* utils */,
342345
B5A7D3122C54911C003D4C7F /* helpers */,
343346
B581601C2BE8949B001DDB9B /* apps */,
344347
);
@@ -348,6 +351,7 @@
348351
B5105F4C2E6B277500333727 /* ios */ = {
349352
isa = PBXGroup;
350353
children = (
354+
B518593D2E6EF5DD004240CD /* utils */,
351355
B5105F4E2E6B278A00333727 /* helpers */,
352356
B5105F4D2E6B278600333727 /* apps */,
353357
);
@@ -374,6 +378,21 @@
374378
path = helpers;
375379
sourceTree = "<group>";
376380
};
381+
B518593C2E6EF5D4004240CD /* utils */ = {
382+
isa = PBXGroup;
383+
children = (
384+
B518593E2E6EF716004240CD /* AppInspector.m */,
385+
);
386+
path = utils;
387+
sourceTree = "<group>";
388+
};
389+
B518593D2E6EF5DD004240CD /* utils */ = {
390+
isa = PBXGroup;
391+
children = (
392+
);
393+
path = utils;
394+
sourceTree = "<group>";
395+
};
377396
B581601C2BE8949B001DDB9B /* apps */ = {
378397
isa = PBXGroup;
379398
children = (
@@ -409,7 +428,7 @@
409428
path = apps;
410429
sourceTree = "<group>";
411430
};
412-
B581601D2BE894A2001DDB9B /* utils */ = {
431+
B581601D2BE894A2001DDB9B /* common */ = {
413432
isa = PBXGroup;
414433
children = (
415434
B59D6A2B2E503F010004D71D /* MockUbiquitousKeyValueStore.m */,
@@ -438,7 +457,7 @@
438457
B57584382E0D698A001F7C9E /* MockKeychain.h */,
439458
B575843A2E0D69AA001F7C9E /* MockKeychain.m */,
440459
);
441-
path = utils;
460+
path = common;
442461
sourceTree = "<group>";
443462
};
444463
B5A7D3122C54911C003D4C7F /* helpers */ = {
@@ -661,6 +680,7 @@
661680
B5D0C0BB2C4B553500881398 /* ForkLiftHack.m in Sources */,
662681
B5F06B1D2BEF591E0079E68D /* InfuseHack.m in Sources */,
663682
B5EAA9E22C8C3FC3008C4089 /* URLSessionHook.m in Sources */,
683+
B518593F2E6EF716004240CD /* AppInspector.m in Sources */,
664684
B513ADD92CB95D4100F5DC97 /* LocalizationManager.m in Sources */,
665685
B52BBA842CBFE1CE00F098A9 /* AirBuddyHack.m in Sources */,
666686
08869D0F2E1AF15900B079A0 /* NotchNook.m in Sources */,

dylib_dobby_hook.xcodeproj/xcshareddata/xcschemes/dylib_dobby_hook_mac.xcscheme

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@
5151
value = "${BUILT_PRODUCTS_DIR}/libdylib_dobby_hook.dylib"
5252
isEnabled = "YES">
5353
</EnvironmentVariable>
54+
<EnvironmentVariable
55+
key = "URLSESSION_HOOK_ENABLE"
56+
value = "0"
57+
isEnabled = "YES">
58+
</EnvironmentVariable>
59+
<EnvironmentVariable
60+
key = "APPINSPECTOR_ENABLE"
61+
value = "0"
62+
isEnabled = "YES">
63+
</EnvironmentVariable>
5464
</EnvironmentVariables>
5565
</LaunchAction>
5666
<ProfileAction
Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,11 @@ BOOL canShowAlert(void) {
240240
}
241241
#endif
242242

243-
244243
/// Initialize behavior based on environment variables.
245244
///
246245
/// This function checks for specific environment variables to enable
247246
/// optional runtime features and pass configuration values to components
248-
/// such as URLSessionHook.
247+
/// such as URLSessionHook or AppInspector.
249248
///
250249
/// Supported environment variables:
251250
///
@@ -259,25 +258,45 @@ BOOL canShowAlert(void) {
259258
/// - NSURLSESSION_FILTER:
260259
/// Optional. A string passed to +[URLSessionHook record_NSURL:] for filtering logic.
261260
///
261+
/// - APPINSPECTOR_ENABLE:
262+
/// If set to "1", invokes +[AppInspector showInspector] at startup
263+
/// to display the inspector window.
264+
///
262265
void initEnv(void){
263266
NSDictionary *env = [[NSProcessInfo processInfo] environment];
267+
268+
// URLSessionHook
264269
NSString *enableHook = env[@"URLSESSION_HOOK_ENABLE"];
265270
if ([enableHook isEqualToString:@"1"]) {
266271
Class cls = NSClassFromString(@"URLSessionHook");
267272

268273
NSString *maxBodyLenStr = env[@"NSURLSESSION_MAX_BODY_LEN"];
269274
if (maxBodyLenStr) {
270275
SEL sel = NSSelectorFromString(@"setMaxBodyLength:");
271-
if (cls && [cls respondsToSelector:sel])
276+
if (cls && [cls respondsToSelector:sel]) {
272277
((void (*)(id, SEL, NSUInteger))objc_msgSend)(cls, sel, maxBodyLenStr.integerValue);
278+
}
273279
}
280+
274281
NSString *filterStr = env[@"NSURLSESSION_FILTER"];
275-
if (filterStr && [[filterStr stringByTrimmingCharactersInSet:NSCharacterSet.whitespaceAndNewlineCharacterSet] length] == 0) {
282+
if (filterStr &&
283+
[[filterStr stringByTrimmingCharactersInSet:NSCharacterSet.whitespaceAndNewlineCharacterSet] length] == 0) {
276284
filterStr = nil;
277285
}
278286
SEL sel = NSSelectorFromString(@"record_NSURL:");
279-
if (cls && [cls respondsToSelector:sel])
287+
if (cls && [cls respondsToSelector:sel]) {
280288
((void (*)(id, SEL, id))objc_msgSend)(cls, sel, filterStr);
289+
}
290+
}
291+
292+
// AppInspector
293+
NSString *enableInspector = env[@"APPINSPECTOR_ENABLE"];
294+
if ([enableInspector isEqualToString:@"1"]) {
295+
Class inspectorCls = NSClassFromString(@"AppInspector");
296+
SEL showSel = NSSelectorFromString(@"showInspector");
297+
if (inspectorCls && [inspectorCls respondsToSelector:showSel]) {
298+
((void (*)(id, SEL))objc_msgSend)(inspectorCls, showSel);
299+
}
281300
}
282301
}
283302
+ (void)doHack {

0 commit comments

Comments
 (0)