Skip to content

Commit

Permalink
Add UUID in Mach-O file description
Browse files Browse the repository at this point in the history
  • Loading branch information
Cédric Luthi authored and Cédric Luthi committed Jul 30, 2010
1 parent f93f65f commit 509591f
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 18 deletions.
1 change: 1 addition & 0 deletions CDClassDumpVisitor.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ - (void)visitObjectiveCProcessor:(CDObjectiveCProcessor *)aProcessor;
[resultString appendString:@"#pragma mark -\n\n"];
[resultString appendString:@"/*\n"];
[resultString appendFormat:@" * File: %@\n", [machOFile filename]];
[resultString appendFormat:@" * UUID: %@\n", [machOFile uuidString]];

archInfo = NXGetArchInfoFromCpuType([machOFile cputypePlusArchBits], [machOFile cpusubtype]);
//archInfo = [machOFile archInfo];
Expand Down
2 changes: 2 additions & 0 deletions CDLCUUID.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
- (uint32_t)cmd;
- (uint32_t)cmdsize;

- (NSString *)uuidString;

- (void)appendToString:(NSMutableString *)resultString verbose:(BOOL)isVerbose;

@end
25 changes: 7 additions & 18 deletions CDLCUUID.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,28 +60,17 @@ - (uint32_t)cmdsize;
return uuidCommand.cmdsize;
}

- (void)appendToString:(NSMutableString *)resultString verbose:(BOOL)isVerbose;
- (NSString *)uuidString;
{
unsigned int index;
CFUUIDBytes uuidBytes;
UInt8 *bytePtr = (UInt8 *)&uuidBytes;
UInt8 byte;
return [NSMakeCollectable(CFUUIDCreateString(kCFAllocatorDefault, uuid)) autorelease];
}

- (void)appendToString:(NSMutableString *)resultString verbose:(BOOL)isVerbose;
{
[super appendToString:resultString verbose:isVerbose];

uuidBytes = CFUUIDGetUUIDBytes(uuid);
[resultString appendString:@" uuid"];
for (index = 0; index < 8; index++) {
byte = bytePtr[index];
[resultString appendFormat:@" 0x%02x", byte];
}

[resultString appendString:@"\n"];
[resultString appendString:@" "];
for (index = 0; index < 8; index++) {
byte = bytePtr[8 + index];
[resultString appendFormat:@" 0x%02x", byte];
}
[resultString appendString:@" uuid "];
[resultString appendString:[self uuidString]];
[resultString appendString:@"\n"];
}

Expand Down
1 change: 1 addition & 0 deletions CDMachOFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
- (NSString *)loadCommandString:(BOOL)isVerbose;
- (NSString *)headerString:(BOOL)isVerbose;

- (NSString *)uuidString;
- (NSString *)archName;

- (NSString *)description;
Expand Down
10 changes: 10 additions & 0 deletions CDMachOFile.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#import "CDLCSegment.h"
#import "CDLCSegment64.h"
#import "CDLCSymbolTable.h"
#import "CDLCUUID.h"
#import "CDObjectiveCProcessor.h"
#import "CDSection.h"
#import "CDSymbol.h"
Expand Down Expand Up @@ -493,6 +494,15 @@ - (NSString *)headerString:(BOOL)isVerbose;
return resultString;
}

- (NSString *)uuidString;
{
for (CDLoadCommand *loadCommand in loadCommands)
if ([loadCommand isKindOfClass:[CDLCUUID class]])
return [(CDLCUUID*)loadCommand uuidString];

return @"N/A";
}

// Must not return nil.
- (NSString *)archName;
{
Expand Down

0 comments on commit 509591f

Please sign in to comment.