OLD | NEW |
(Empty) | |
| 1 // -*- mode: ObjC -*- |
| 2 |
| 3 // This file is part of class-dump, a utility for examining the Objective-C seg
ment of Mach-O files. |
| 4 // Copyright (C) 1997-1998, 2000-2001, 2004-2010 Steve Nygard. |
| 5 |
| 6 #import "CDLCDylib.h" |
| 7 |
| 8 #import "CDFatFile.h" |
| 9 #import "CDMachOFile.h" |
| 10 |
| 11 static NSString *CDDylibVersionString(unsigned long version) |
| 12 { |
| 13 return [NSString stringWithFormat:@"%d.%d.%d", version >> 16, (version >> 8)
& 0xff, version & 0xff]; |
| 14 } |
| 15 |
| 16 @implementation CDLCDylib |
| 17 |
| 18 - (id)initWithDataCursor:(CDDataCursor *)cursor machOFile:(CDMachOFile *)aMachOF
ile; |
| 19 { |
| 20 NSUInteger length; |
| 21 |
| 22 if ([super initWithDataCursor:cursor machOFile:aMachOFile] == nil) |
| 23 return nil; |
| 24 |
| 25 dylibCommand.cmd = [cursor readInt32]; |
| 26 dylibCommand.cmdsize = [cursor readInt32]; |
| 27 |
| 28 dylibCommand.dylib.name.offset = [cursor readInt32]; |
| 29 dylibCommand.dylib.timestamp = [cursor readInt32]; |
| 30 dylibCommand.dylib.current_version = [cursor readInt32]; |
| 31 dylibCommand.dylib.compatibility_version = [cursor readInt32]; |
| 32 |
| 33 length = dylibCommand.cmdsize - sizeof(dylibCommand); |
| 34 //NSLog(@"expected length: %u", length); |
| 35 |
| 36 path = [[cursor readStringOfLength:length encoding:NSASCIIStringEncoding] re
tain]; |
| 37 //NSLog(@"path: %@", path); |
| 38 |
| 39 return self; |
| 40 } |
| 41 |
| 42 - (void)dealloc; |
| 43 { |
| 44 [path release]; |
| 45 |
| 46 [super dealloc]; |
| 47 } |
| 48 |
| 49 - (uint32_t)cmd; |
| 50 { |
| 51 return dylibCommand.cmd; |
| 52 } |
| 53 |
| 54 - (uint32_t)cmdsize; |
| 55 { |
| 56 return dylibCommand.cmdsize; |
| 57 } |
| 58 |
| 59 - (NSString *)path; |
| 60 { |
| 61 return path; |
| 62 } |
| 63 |
| 64 - (uint32_t)timestamp; |
| 65 { |
| 66 return dylibCommand.dylib.timestamp; |
| 67 } |
| 68 |
| 69 - (uint32_t)currentVersion; |
| 70 { |
| 71 return dylibCommand.dylib.current_version; |
| 72 } |
| 73 |
| 74 - (uint32_t)compatibilityVersion; |
| 75 { |
| 76 return dylibCommand.dylib.compatibility_version; |
| 77 } |
| 78 |
| 79 - (NSString *)formattedCurrentVersion; |
| 80 { |
| 81 return CDDylibVersionString([self currentVersion]); |
| 82 } |
| 83 |
| 84 - (NSString *)formattedCompatibilityVersion; |
| 85 { |
| 86 return CDDylibVersionString([self compatibilityVersion]); |
| 87 } |
| 88 |
| 89 #if 0 |
| 90 - (NSString *)extraDescription; |
| 91 { |
| 92 return [NSString stringWithFormat:@"%@ (compatibility version %@, current ve
rsion %@, timestamp %d [%@])", |
| 93 [self path], CDDylibVersionString([self compatibilityVersio
n]), CDDylibVersionString([self currentVersion]), |
| 94 [self timestamp], [NSDate dateWithTimeIntervalSince1970:[se
lf timestamp]]]; |
| 95 } |
| 96 #endif |
| 97 |
| 98 @end |
OLD | NEW |