Skip to content

Instantly share code, notes, and snippets.

@al3xtjames
Created August 23, 2017 12:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save al3xtjames/45b77c71228ad03bf854d9fd991ae066 to your computer and use it in GitHub Desktop.
Save al3xtjames/45b77c71228ad03bf854d9fd991ae066 to your computer and use it in GitHub Desktop.
#include <IOKit/IOKitLib.h>
#include <mach/mach.h>
int GetIOPlatformFeature(void)
{
mach_port_t master_port = 0; // var_1C
io_registry_entry_t path = 0; // rbx
CFTypeRef platform_feature = NULL; // r14
const UInt8 *platform_feature_ptr = NULL; // rbx
if (IOMasterPort(0, &master_port) == 0)
{
path = IORegistryEntryFromPath(master_port, "IOService:/");
if (path)
{
platform_feature = IORegistryEntryCreateCFProperty(path, CFSTR("platform-feature"), kCFAllocatorDefault, 0);
IOObjectRelease(path);
}
if (master_port)
{
mach_port_deallocate(mach_task_self(), master_port);
}
path = 0;
if (platform_feature)
{
if (CFGetTypeID(platform_feature) == CFDataGetTypeID())
{
platform_feature_ptr = CFDataGetBytePtr(platform_feature);
}
CFRelease(platform_feature);
}
}
return *platform_feature_ptr;
}
bool ASI_IsPlatformFeatureEnabled(int feature)
{
int v2 = false;
int v3 = 0;
bool v4 = false;
CFStringRef v5 = NULL;
CFStringRef v6 = NULL;
bool v7 = false;
bool v8 = false;
bool v9 = false;
bool v10 = false;
// skipped the platform override part
v3 = (unsigned int) feature & (unsigned int) GetIOPlatformFeature();
v2 = (v3 == feature);
v4 = (v3 != (unsigned int) feature);
if (feature == 2 && v4)
{
v5 = ASI_CopyComputerModelName(true);
v6 = v5;
if (v5)
{
v7 = CFStringHasPrefix(v5, CFSTR("MacBookAir"));
v8 = CFStringHasPrefix(v6, CFSTR("MacBookPro10"));
CFRelease(v6);
v9 = v7 != 0;
v10 = v8 != 0;
}
else
{
v9 = false;
v10 = false;
}
if (v9 || v10)
{
v2 = true;
}
}
return v2;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment