80 lines
1.6 KiB
Objective-C
80 lines
1.6 KiB
Objective-C
#ifndef MMSMCDefines_h
|
|
#define MMSMCDefines_h
|
|
|
|
#import <Foundation/Foundation.h>
|
|
#import <IOKit/IOKitLib.h>
|
|
|
|
#define KERNEL_INDEX_SMC 2
|
|
|
|
// SMC Call Selectors
|
|
#define kSMCUserClientOpen 0
|
|
#define kSMCUserClientClose 1
|
|
#define kSMCHandleYPCEvent 2
|
|
#define kSMCReadKey 5
|
|
#define kSMCWriteKey 6
|
|
#define kSMCGetKeyFromIndex 8
|
|
#define kSMCGetKeyInfo 9
|
|
|
|
#pragma pack(push, 1)
|
|
|
|
typedef struct {
|
|
unsigned char major;
|
|
unsigned char minor;
|
|
unsigned char build;
|
|
unsigned char reserved[1];
|
|
unsigned short release;
|
|
} SMCVersion;
|
|
|
|
typedef struct {
|
|
uint16_t version;
|
|
uint16_t length;
|
|
uint32_t cpuPLimit;
|
|
uint32_t gpuPLimit;
|
|
uint32_t memPLimit;
|
|
} SMCPLimitData;
|
|
|
|
typedef struct {
|
|
IOByteCount dataSize;
|
|
UInt32 dataType;
|
|
UInt8 dataAttributes;
|
|
} SMCKeyInfoData;
|
|
|
|
typedef struct {
|
|
UInt32 key;
|
|
SMCVersion vers;
|
|
SMCPLimitData pLimitData;
|
|
SMCKeyInfoData keyInfo;
|
|
UInt8 result;
|
|
UInt8 status;
|
|
UInt8 data8;
|
|
UInt32 data32;
|
|
UInt8 bytes[32];
|
|
} SMCKeyData_t;
|
|
|
|
typedef struct {
|
|
char key[5];
|
|
UInt32 dataSize;
|
|
char dataType[5];
|
|
UInt8 bytes[32];
|
|
} SMCVal_t;
|
|
|
|
#pragma pack(pop)
|
|
|
|
static inline UInt32 MMSMCToFourCharCode(const char * _Nonnull str) {
|
|
UInt32 code = 0;
|
|
for (int i = 0; i < 4 && str[i] != '\0'; i++) {
|
|
code = (code << 8) | (UInt8)str[i];
|
|
}
|
|
return code;
|
|
}
|
|
|
|
static inline void MMSMCFromFourCharCode(UInt32 code, char * _Nonnull outStr) {
|
|
outStr[0] = (char)((code >> 24) & 0xFF);
|
|
outStr[1] = (char)((code >> 16) & 0xFF);
|
|
outStr[2] = (char)((code >> 8) & 0xFF);
|
|
outStr[3] = (char)(code & 0xFF);
|
|
outStr[4] = '\0';
|
|
}
|
|
|
|
#endif /* MMSMCDefines_h */
|