{"action":"created","issue":{"url":"https://api.github.com/repos/darlinghq/darling/issues/310","repository_url":"https://api.github.com/repos/darlinghq/darling","labels_url":"https://api.github.com/repos/darlinghq/darling/issues/310/labels{/name}","comments_url":"https://api.github.com/repos/darlinghq/darling/issues/310/comments","events_url":"https://api.github.com/repos/darlinghq/darling/issues/310/events","html_url":"https://github.com/darlinghq/darling/issues/310","id":233632785,"number":310,"title":"Questions about AppleSystemInfo","user":{"login":"npyl","id":12190878,"avatar_url":"https://avatars2.githubusercontent.com/u/12190878?v=3","gravatar_id":"","url":"https://api.github.com/users/npyl","html_url":"https://github.com/npyl","followers_url":"https://api.github.com/users/npyl/followers","following_url":"https://api.github.com/users/npyl/following{/other_user}","gists_url":"https://api.github.com/users/npyl/gists{/gist_id}","starred_url":"https://api.github.com/users/npyl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/npyl/subscriptions","organizations_url":"https://api.github.com/users/npyl/orgs","repos_url":"https://api.github.com/users/npyl/repos","events_url":"https://api.github.com/users/npyl/events{/privacy}","received_events_url":"https://api.github.com/users/npyl/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2017-06-05T15:54:29Z","updated_at":"2017-06-06T15:26:55Z","closed_at":null,"body":"Hello, \r\nI saw the AppleSystemInfo directory in the source and I thought I may be able to help a bit with it with some ideas and some research I have done. ( Sorry it is not that much I know... )\r\n\r\nI was wondering though:\r\n\r\n- Could someone use Objective-C++ to write a framework for darling ??\r\n- I have found that for the function ASI_CPUSpeedInHz we can gather information from /dev/cpuinfo or the /sys interface... Is this solution ok enough?? ( Because I have seen that in some Linux kernels the sysfs interface doesn't exist... ) Are there any problems with portability on the many Linux distros???\r\n\r\n-  I have found that on macOS the ASI_CopyComputerModelName( int arg0 ) returns either a short form of the model name or a long form depending on the value of arg0.  \r\n\r\nIf arg0 = 0, it returns the short form.  If arg0 = 1, it returns the long form... ( It works as a bool, I guess it is a bool ( so maybe we need to change the int to bool  )).  \r\ne.g. short form: MacBook Pro\r\ne.g. long form: MacBookPro11,1\r\n\r\nSo we can have a config file in ~/.darling which will store the short and long model name,\r\nand everytime we call the ASI_CopyComputerModelName it will read these values from the config file.\r\n\r\n( This way the user will also be able to edit the model names in order to allow some software to run differently... I think I have seen some applications run differently on Mac Pros than MacBook Pros etc... )\r\n\r\nWhen Darling runs for the first time, it can ask the user if he is using a Macintosh or a PC.\r\nIf he types \"Macintosh\", then Darling will try to find the ModelNames of his Mac from the DMI tables (  e.g. using dmidecode ( available on Linux ) ) and then it will store it in a config file in ~/.darling.\r\nIf he types \"PC\", then Darling will ask for a \"Fake Macintosh Model Name (Short)\" and a \"Fake Macintosh Model Name (Long)\", and it will store the values...\r\n\r\nEdit: We can also have some code to identify on its own the platform... We could read the contents of the file /sys/class/dmi/id/sys_vendor when sysfs is enabled in the kernel.\r\n\r\n- Also I have written an alpha version of the AppleSystemInfo.h I will include here... \r\nPlease note, that I don't know how to reverse engineer a binary... What I did was to dump the functions from the AppleSystemInfo binary and to try to find return types so that using the AppleSystemInfo.framework would be possible..  ( Therefore these may not be the actual return types apple is using but they work (do they???) )\r\n\r\nAlso, please note that I haven't found the return types for ASI_CopyCPUDescription, CopyPropertyAsData, GetIOPlatformFeature, PlatformOverideExistsAndIsSet\r\nThis is why I have them in comments...\r\n\r\nWhat is more, I made my \"own\" AppleSystemInfo framework that used this AppleSystemInfo.h and in AppleSystemInfo.mm I returned the values that the original-apple framework returns... Then I replaced the original of macOS with mine, rebooted and macOS booted... I think it worked... The only problem i encountered was that I hadn't code signed my framework and Xcode and Safari couldn't run.. ( I could also see in terminal, when running `man`,  that dyld printed an error about mmap()... I don't remember  )\r\n\r\nEDIT: I haven't yet done research on the SPMachineTypes.plist and its job... It may have something to do though with the function ASI_CopyComputerModelName??? I don't know... \r\n\r\n```#ifndef APPLE_SYSTEM_INFO_H\r\n#define APPLE_SYSTEM_INFO_H\r\n\r\n#include <Cocoa/Cocoa.h>\r\n\r\n//! Project version number for AppleSystemInfo.\r\nFOUNDATION_EXPORT double AppleSystemInfoVersionNumber;                  // TODO1\r\n\r\n//! Project version string for AppleSystemInfo.\r\nFOUNDATION_EXPORT const unsigned char AppleSystemInfoVersionString[];   // TODO1\r\n\r\n// In this header, you should import all the public headers of your framework using statements like #import <AppleSystemInfo/PublicHeader.h>\r\n\r\n#include <CoreFoundation/CoreFoundation.h>\r\n#include <SystemConfiguration/SystemConfiguration.h>\r\n\r\nCF_IMPLICIT_BRIDGING_ENABLED\r\nCF_EXTERN_C_BEGIN\r\n\r\nCF_EXPORT long ASI_BusSpeedInHz(void); \r\nCF_EXPORT long ASI_CPUSpeedInHz(void);\r\nCF_EXPORT CFStringRef ASI_CopyBusSpeedDescription(void);\r\n//CF_EXPORT CFStringRef ASI_CopyCPUDescription(void);                 // doesn't work...\r\nCF_EXPORT CFStringRef ASI_CopyCPUKind(void);\r\nCF_EXPORT CFStringRef ASI_CopyComputerModelName( bool shortlong = 1 );   // bool??\r\n                                                                    // FIXME 1: is the default value 1???\r\n                                                                    // We could use the macros:\r\n                                                                    //  #define ASI_COMPUTER_MODEL_NAME         0\r\n                                                                    //  #define ASI_COMPUTER_MODEL_IDENTIFIER   1\r\n\r\nCF_EXPORT CFStringRef ASI_CopyCurrentBusSpeedDescription(void);\r\nCF_EXPORT CFStringRef ASI_CopyCurrentCPUDescription(void);\r\nCF_EXPORT CFStringRef ASI_CopyCurrentRAMDescription(void);\r\nCF_EXPORT CFStringRef ASI_CopyCurrentRAMDescriptionWithType(void);\r\nCF_EXPORT CFStringRef ASI_CopyDiskSizeDescription(void);\r\nCF_EXPORT CFStringRef ASI_CopyFormattedSerialNumber(void);\r\nCF_EXPORT CFStringRef ASI_CopyHostUUID(void);\r\nCF_EXPORT CFStringRef ASI_CopyMachineConfigurationCode(void);\r\nCF_EXPORT CFStringRef ASI_CopyRAMDescription(void);\r\n\r\nCF_EXPORT bool ASI_IsPlatformFeatureEnabled(void);\r\nCF_EXPORT unsigned int ASI_NumberOfCPUs(void);\r\nCF_EXPORT unsigned long ASI_PhysicalMemorySize(void);\r\nCF_EXPORT CFStringRef CopyIOPlatformSerialNumberString(void);\r\n\r\n// these dont work\r\n//CF_EXPORT CFStringRef CopyPropertyAsData(void);\r\n//CF_EXPORT CFStringRef GetIOPlatformFeature(void);\r\n//CF_EXPORT CFStringRef PlatformOverideExistsAndIsSet(void);\r\n\r\nCF_EXTERN_C_END\r\nCF_IMPLICIT_BRIDGING_DISABLED\r\n\r\n#endif"},"comment":{"url":"https://api.github.com/repos/darlinghq/darling/issues/comments/306522619","html_url":"https://github.com/darlinghq/darling/issues/310#issuecomment-306522619","issue_url":"https://api.github.com/repos/darlinghq/darling/issues/310","id":306522619,"user":{"login":"npyl","id":12190878,"avatar_url":"https://avatars2.githubusercontent.com/u/12190878?v=3","gravatar_id":"","url":"https://api.github.com/users/npyl","html_url":"https://github.com/npyl","followers_url":"https://api.github.com/users/npyl/followers","following_url":"https://api.github.com/users/npyl/following{/other_user}","gists_url":"https://api.github.com/users/npyl/gists{/gist_id}","starred_url":"https://api.github.com/users/npyl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/npyl/subscriptions","organizations_url":"https://api.github.com/users/npyl/orgs","repos_url":"https://api.github.com/users/npyl/repos","events_url":"https://api.github.com/users/npyl/events{/privacy}","received_events_url":"https://api.github.com/users/npyl/received_events","type":"User","site_admin":false},"created_at":"2017-06-06T15:26:55Z","updated_at":"2017-06-06T15:26:55Z","body":"Thank you, I will check it out!!"}}
{"actor":{"display_login":"npyl"}}