Skip to content

Instantly share code, notes, and snippets.

@nevan
Created October 8, 2015 20:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nevan/920f51c92747792020b1 to your computer and use it in GitHub Desktop.
Save nevan/920f51c92747792020b1 to your computer and use it in GitHub Desktop.
/*
* 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