Created
October 8, 2015 20:02
-
-
Save nevan/920f51c92747792020b1 to your computer and use it in GitHub Desktop.
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
/* | |
* libMobileGestalt header. | |
* Mobile gestalt functions as a QA system. You ask it a question, and it gives you the answer! :) | |
* | |
* Copyright (c) 2013-2014 Cykey (David Murray) | |
* All rights reserved. | |
https://github.com/Cykey/ios-reversed-headers/blob/master/MobileGestalt/MobileGestalt.h | |
*/ | |
#include <CoreFoundation/CoreFoundation.h> | |
CFPropertyListRef MGCopyAnswer(CFStringRef property); | |
static CFStringRef (*$MGCopyAnswer)(CFStringRef); | |
// ------------------------------------------------------------------------------------------------ | |
// ------------------------------------------------------------------------------------------------ | |
// | |
// ViewController.m | |
// CPU test | |
// | |
// Created by Gary on 2015/9/28. | |
// Copyright © 2015年 Gary. All rights reserved. | |
// https://github.com/hirakujira/CPU-Identifier | |
// | |
#import "ViewController.h" | |
#include <sys/sysctl.h> | |
#include <sys/resource.h> | |
#include <sys/vm.h> | |
#include <dlfcn.h> | |
@implementation ViewController | |
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
void *gestalt = dlopen("/usr/lib/libMobileGestalt.dylib", RTLD_GLOBAL | RTLD_LAZY); | |
$MGCopyAnswer = dlsym(gestalt, "MGCopyAnswer"); | |
CFStringRef boardID = (CFStringRef)$MGCopyAnswer(CFSTR("HardwarePlatform")); | |
NSLog(@"Board ID: %@",(__bridge NSString *)boardID); | |
if ([(__bridge NSString *)boardID isEqualToString:@"s8000"]) { | |
NSLog(@"Maker: %@", @"Samsung"); | |
} | |
if ([(__bridge NSString *)boardID isEqualToString:@"s8003"]) { | |
NSLog(@"Maker: %@", @"TSMC"); | |
} | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment