-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[General] Starting template to compile into a tweak
- Loading branch information
1 parent
6835c5f
commit ea32991
Showing
4 changed files
with
46 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[submodule "ClassDumpRuntime"] | ||
path = ClassDumpRuntime | ||
url = git@github.com:leptos-null/ClassDumpRuntime.git | ||
url = https://github.com/leptos-null/ClassDumpRuntime.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{ Filter = { Bundles = ( "com.apple.springboard" ); }; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,15 @@ | ||
TARGET := iphone:clang:latest:8.0 | ||
INSTALL_TARGET_PROCESSES := SpringBoard | ||
ARCHS := arm64 | ||
|
||
include $(THEOS)/makefiles/common.mk | ||
|
||
TOOL_NAME = classdumpctl | ||
TWEAK_NAME = ClassDumpTweak | ||
|
||
classdumpctl_FILES = Sources/classdumpctl/main.m | ||
classdumpctl_FILES += $(wildcard ClassDumpRuntime/Sources/ClassDumpRuntime/ClassDump/*/*.m) | ||
classdumpctl_FILES += $(wildcard ClassDumpRuntime/Sources/ClassDumpRuntime/ClassDump/*/*/*.m) | ||
ClassDumpTweak_FILES = Tweak.x | ||
ClassDumpTweak_FILES += $(wildcard ClassDumpRuntime/Sources/ClassDumpRuntime/ClassDump/*/*.m) | ||
ClassDumpTweak_FILES += $(wildcard ClassDumpRuntime/Sources/ClassDumpRuntime/ClassDump/*/*/*.m) | ||
|
||
classdumpctl_CFLAGS = -fobjc-arc -I ClassDumpRuntime/Sources/ClassDumpRuntime/include | ||
classdumpctl_CODESIGN_FLAGS = -Sentitlements.plist | ||
classdumpctl_INSTALL_PATH = /usr/local/bin | ||
ClassDumpTweak_CFLAGS = -fobjc-arc -I ClassDumpRuntime/Sources/ClassDumpRuntime/include | ||
|
||
include $(THEOS_MAKE_PATH)/tool.mk | ||
include $(THEOS_MAKE_PATH)/tweak.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#import <Foundation/Foundation.h> | ||
#import <ClassDump/ClassDump.h> | ||
|
||
static CDClassModel *safelyGenerateModelForClass(Class const cls, IMP const blankIMP) { | ||
Method const initializeMthd = class_getClassMethod(cls, @selector(initialize)); | ||
method_setImplementation(initializeMthd, blankIMP); | ||
|
||
return [CDClassModel modelWithClass:cls]; | ||
} | ||
|
||
static void dumpHeader(NSString *requestImage, NSString *outputDir) { | ||
IMP const blankIMP = imp_implementationWithBlock(^{ }); // returns void, takes no parameters | ||
|
||
CDGenerationOptions *const generationOptions = [CDGenerationOptions new]; | ||
generationOptions.stripSynthesized = YES; | ||
|
||
unsigned int classCount = 0; | ||
const char **classNames = objc_copyClassNamesForImage(requestImage.fileSystemRepresentation, &classCount); | ||
for (unsigned int classIndex = 0; classIndex < classCount; classIndex++) { | ||
Class const cls = objc_getClass(classNames[classIndex]); | ||
CDClassModel *model = safelyGenerateModelForClass(cls, blankIMP); | ||
CDSemanticString *semanticString = [model semanticLinesWithOptions:generationOptions]; | ||
NSString *lines = [semanticString string]; | ||
NSString *headerName = [NSStringFromClass(cls) stringByAppendingPathExtension:@"h"]; | ||
|
||
NSString *headerPath = [outputDir stringByAppendingPathComponent:headerName]; | ||
|
||
NSError *writeError = nil; | ||
if (![lines writeToFile:headerPath atomically:NO encoding:NSUTF8StringEncoding error:&writeError]) { | ||
NSLog(@"writeToFileError: %@", writeError); | ||
} | ||
} | ||
} | ||
|
||
%ctor { | ||
dumpHeader(@"TODO", @"TODO"); | ||
} |