forked from brunexgeek/smbios-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmacos_hardware.h
More file actions
79 lines (68 loc) · 1.8 KB
/
Copy pathmacos_hardware.h
File metadata and controls
79 lines (68 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/**
* Copyright (c) 2026 Bivex
*
* Author: Bivex
* Available for contact via email: support@b-b.top
* For up-to-date contact information:
* https://github.com/bivex
*
* Created: 2026-02-21 03:43
* Last Updated: 2026-02-21 03:43
*
* Licensed under the MIT License.
* Commercial licensing available upon request.
*/
/*
* macOS hardware info via IOKit
* Reads: IOPlatformUUID, serial-number, model (board-id)
*
* Compile: -framework IOKit -framework CoreFoundation
*/
#ifndef MACOS_HARDWARE_H
#define MACOS_HARDWARE_H
#include <CoreFoundation/CoreFoundation.h>
#include <IOKit/IOKitLib.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Maximum string lengths */
enum { HW_INFO_STR_MAX = 256 };
/* Hardware info structure */
typedef struct {
char uuid[HW_INFO_STR_MAX];
char serial_number[HW_INFO_STR_MAX];
char model[HW_INFO_STR_MAX];
char board_id[HW_INFO_STR_MAX];
char platform_uuid[HW_INFO_STR_MAX];
char manufacturer[HW_INFO_STR_MAX];
char platform_name[HW_INFO_STR_MAX];
} hw_info_t;
/**
* Read hardware information from IOKit IOPlatformExpertDevice
*
* @param info Output structure to fill
* @return 0 on success, -1 on error
*/
int32_t hw_info_get(hw_info_t *info);
/**
* Get a single string property from IOPlatformExpertDevice
*
* @param key CFStringRef property name (e.g. CFSTR(kIOPlatformUUIDKey))
* @param out Output buffer
* @param size Buffer size
* @return 0 on success, -1 on error
*/
int32_t hw_info_get_string(CFStringRef key, char *out, size_t size);
/**
* Convert CFString to C string (UTF-8)
*
* @param cfstr CFString to convert
* @param out Output buffer
* @param size Buffer size
* @return 0 on success, -1 on error
*/
int32_t cfstring_to_cstr(CFStringRef cfstr, char *out, size_t size);
#ifdef __cplusplus
}
#endif
#endif /* MACOS_HARDWARE_H */