summaryrefslogtreecommitdiff
path: root/MobileCydia.mm
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2011-03-05 11:55:25 -0800
committerJay Freeman (saurik) <saurik@saurik.com>2011-03-07 02:41:39 -0800
commitc31d7cdc8a13123ba06b93bcab517b046f2cd0b2 (patch)
treeb1d50b26eab3622cbd7724752de5578bea8baa75 /MobileCydia.mm
parentbe45a862ee5609d427a51b20d04599ce902fb52c (diff)
Expose CYIOGetValue() to JavaScript.
Diffstat (limited to 'MobileCydia.mm')
-rw-r--r--MobileCydia.mm22
1 files changed, 17 insertions, 5 deletions
diff --git a/MobileCydia.mm b/MobileCydia.mm
index ce12ef6..79caf4f 100644
--- a/MobileCydia.mm
+++ b/MobileCydia.mm
@@ -928,7 +928,7 @@ bool isSectionVisible(NSString *section) {
return hidden == nil || ![hidden boolValue];
}
-static id CYIOGetValue(const char *path, NSString *property) {
+static NSObject *CYIOGetValue(const char *path, NSString *property) {
io_registry_entry_t entry(IORegistryEntryFromPath(kIOMasterPortDefault, path));
if (entry == MACH_PORT_NULL)
return nil;
@@ -941,7 +941,7 @@ static id CYIOGetValue(const char *path, NSString *property) {
return [(id) value autorelease];
}
-static NSString *CYHex(NSData *data, bool reverse) {
+static NSString *CYHex(NSData *data, bool reverse = false) {
if (data == nil)
return nil;
@@ -3955,6 +3955,8 @@ static _H<NSMutableSet> Diversions_;
return @"getKernelString";
else if (selector == @selector(getInstalledPackages))
return @"getInstalledPackages";
+ else if (selector == @selector(getIORegistryEntry::))
+ return @"getIORegistryEntry";
else if (selector == @selector(getLocaleIdentifier))
return @"getLocaleIdentifier";
else if (selector == @selector(getPreferredLanguages))
@@ -4057,6 +4059,16 @@ static _H<NSMutableSet> Diversions_;
return [NSString stringWithCString:value];
}
+- (NSObject *) getIORegistryEntry:(NSString *)path :(NSString *)entry {
+ NSObject *value(CYIOGetValue([path UTF8String], entry));
+
+ if (value != nil)
+ if ([value isKindOfClass:[NSData class]])
+ value = CYHex((NSData *) value);
+
+ return value;
+}
+
- (id) getSessionValue:(NSString *)key {
@synchronized (SessionData_) {
return [SessionData_ objectForKey:key];
@@ -9824,9 +9836,9 @@ int main(int argc, char *argv[]) { _pooled
else
Machine_ = machine;
- SerialNumber_ = CYIOGetValue("IOService:/", @"IOPlatformSerialNumber");
- ChipID_ = [CYHex(CYIOGetValue("IODeviceTree:/chosen", @"unique-chip-id"), true) uppercaseString];
- BBSNum_ = CYHex(CYIOGetValue("IOService:/AppleARMPE/baseband", @"snum"), false);
+ SerialNumber_ = (NSString *) CYIOGetValue("IOService:/", @"IOPlatformSerialNumber");
+ ChipID_ = [CYHex((NSData *) CYIOGetValue("IODeviceTree:/chosen", @"unique-chip-id"), true) uppercaseString];
+ BBSNum_ = CYHex((NSData *) CYIOGetValue("IOService:/AppleARMPE/baseband", @"snum"), false);
UniqueID_ = [[UIDevice currentDevice] uniqueIdentifier];