Skip to content

Commit 8f7081b

Browse files
committed
minor changes
1 parent 811c64b commit 8f7081b

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

classdump/classdump.h

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
@interface classdump : NSObject
3131
@property (readwrite, assign) BOOL verbose;
3232
+ (id)sharedInstance;
33+
- (NSInteger)performClassDumpOnFile:(NSString *)file withEntitlements:(BOOL)dumpEnt toFolder:(NSString *)outputPath;
3334
- (NSInteger)performClassDumpOnFile:(NSString *)file toFolder:(NSString *)outputPath;
3435
- (CDClassDump *)classDumpInstanceFromFile:(NSString *)file;
3536
- (NSDictionary *)getFileEntitlements:(NSString *)file;

classdump/classdump.m

+13
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ - (NSDictionary *)getFileEntitlements:(NSString *)file {
7373
}
7474

7575
- (NSInteger)performClassDumpOnFile:(NSString *)file toFolder:(NSString *)outputPath {
76+
return [self performClassDumpOnFile:file withEntitlements:YES toFolder:outputPath];
77+
}
78+
79+
- (NSInteger)performClassDumpOnFile:(NSString *)file withEntitlements:(BOOL)dumpEnt toFolder:(NSString *)outputPath {
7680

7781
CDClassDump *classDump = [self classDumpInstanceFromFile:file];
7882
if (!classDump){
@@ -88,6 +92,15 @@ - (NSInteger)performClassDumpOnFile:(NSString *)file toFolder:(NSString *)output
8892
classDump.typeController.delegate = multiFileVisitor;
8993
multiFileVisitor.outputPath = outputPath;
9094
[classDump recursivelyVisit:multiFileVisitor];
95+
if (dumpEnt) {
96+
NSString *newName = [[[[[file executablePathForFilename] lastPathComponent] stringByDeletingPathExtension] stringByAppendingString:@"-Entitlements"] stringByAppendingPathExtension:@"plist"];
97+
NSString *entPath = [outputPath stringByAppendingPathComponent:newName];
98+
NSDictionary *ent = [[classDump.machOFiles firstObject] entitlementsDictionary];
99+
if (ent){
100+
DLog(@"writing entitlements to path: %@", entPath);
101+
[ent writeToFile:entPath atomically:true];
102+
}
103+
}
91104
return 0;
92105
}
93106

classdumpios/Classes/class-dump.m

+13-6
Original file line numberDiff line numberDiff line change
@@ -356,12 +356,6 @@ int main(int argc, char *argv[])
356356
fprintf(stderr, "Error: %s\n", [[error localizedFailureReason] UTF8String]);
357357
exit(1);
358358
} else {
359-
if (dumpEnt) {
360-
NSString *ent = [[classDump.machOFiles firstObject] entitlements];
361-
DLog(@"%@", ent);
362-
exit(0);
363-
//NSString *ent = [classDump.machOFiles]
364-
}
365359
[classDump processObjectiveCData];
366360
[classDump registerTypes];
367361

@@ -376,6 +370,15 @@ int main(int argc, char *argv[])
376370
classDump.typeController.delegate = multiFileVisitor;
377371
multiFileVisitor.outputPath = outputPath;
378372
[classDump recursivelyVisit:multiFileVisitor];
373+
if (dumpEnt) {
374+
NSString *newName = [[[[executablePath lastPathComponent] stringByDeletingPathExtension] stringByAppendingString:@"-Entitlements"] stringByAppendingPathExtension:@"plist"];
375+
NSString *entPath = [outputPath stringByAppendingPathComponent:newName];
376+
NSDictionary *ent = [[classDump.machOFiles firstObject] entitlementsDictionary];
377+
if (ent){
378+
InfoLog(@"writing entitlements to path: %@", entPath);
379+
[ent writeToFile:entPath atomically:true];
380+
}
381+
}
379382
} else {
380383
if (suppressAllHeaderOutput){
381384
exit(0);
@@ -385,6 +388,10 @@ int main(int argc, char *argv[])
385388
if ([hiddenSections containsObject:@"structures"]) visitor.shouldShowStructureSection = NO;
386389
if ([hiddenSections containsObject:@"protocols"]) visitor.shouldShowProtocolSection = NO;
387390
[classDump recursivelyVisit:visitor];
391+
if (dumpEnt) {
392+
NSString *ent = [[classDump.machOFiles firstObject] entitlements];
393+
DLog(@"%@", ent);
394+
}
388395
}
389396
}
390397
}

0 commit comments

Comments
 (0)