-
Notifications
You must be signed in to change notification settings - Fork 42
/
apple_set_os.c
53 lines (43 loc) · 1.62 KB
/
apple_set_os.c
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
// Copyright (c) 2015 Bruno Bierbaumer
#include <efibind.h>
#include <efidef.h>
#include <efidevp.h>
#include <eficon.h>
#include <efiprot.h>
#include <efiapi.h>
#include <efierr.h>
#define APPLE_SET_OS_VENDOR "Apple Inc."
#define APPLE_SET_OS_VERSION "Mac OS X 10.9"
static EFI_GUID APPLE_SET_OS_GUID = { 0xc5c5da95, 0x7d5c, 0x45e6, { 0xb2, 0xf1, 0x3f, 0xd5, 0x2b, 0xb1, 0x00, 0x77 }};
typedef struct efi_apple_set_os_interface {
UINT64 version;
EFI_STATUS (EFIAPI *set_os_version) (IN CHAR8 *version);
EFI_STATUS (EFIAPI *set_os_vendor) (IN CHAR8 *vendor);
} efi_apple_set_os_interface;
EFI_STATUS
efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *systemTable)
{
SIMPLE_TEXT_OUTPUT_INTERFACE *conOut = systemTable->ConOut;
conOut->OutputString(conOut, L"apple_set_os started\r\n");
efi_apple_set_os_interface *set_os = NULL;
EFI_STATUS status = systemTable->BootServices->LocateProtocol(&APPLE_SET_OS_GUID, NULL, (VOID**) &set_os);
if(EFI_ERROR(status) || set_os == NULL) {
conOut->OutputString(conOut, L"Could not locate the apple set os protocol.\r\n");
return status;
}
if(set_os->version != 0){
status = set_os->set_os_version((CHAR8 *) APPLE_SET_OS_VERSION);
if(EFI_ERROR(status)){
conOut->OutputString(conOut, L"Could not set version.\r\n");
return status;
}
conOut->OutputString(conOut, L"Set os version to " APPLE_SET_OS_VERSION ".\r\n");
}
status = set_os->set_os_vendor((CHAR8 *) APPLE_SET_OS_VENDOR);
if(EFI_ERROR(status)){
conOut->OutputString(conOut, L"Could not set vendor.\r\n");
return status;
}
conOut->OutputString(conOut, L"Set os vendor to " APPLE_SET_OS_VENDOR ".\r\n");
return EFI_SUCCESS;
}