InitializeLibary() now saves parameters data in BlpApplicationParameters, BlpApplicationEntry, and BlpBootDevice. Moved BlGetBootOptionSize() and BlGetBootOptionListSize() to bootopt.c
264 lines
5.2 KiB
C
264 lines
5.2 KiB
C
/*++
|
|
|
|
Copyright (c) 2024, Quinn Stephens.
|
|
Provided under the BSD 3-Clause license.
|
|
|
|
Module Name:
|
|
|
|
bootmgr.h
|
|
|
|
Abstract:
|
|
|
|
Boot manager definitions.
|
|
|
|
--*/
|
|
|
|
#ifndef _BOOTMGR_H
|
|
#define _BOOTMGR_H
|
|
|
|
#include <nt.h>
|
|
#include "efi.h"
|
|
|
|
//
|
|
// Set machine type.
|
|
//
|
|
#if defined(__x86_64__)
|
|
#define BOOT_MACHINE_TYPE IMAGE_FILE_MACHINE_AMD64
|
|
#elif defined(__i386__)
|
|
#define BOOT_MACHINE_TYPE IMAGE_FILE_MACHINE_I386
|
|
#endif
|
|
|
|
//
|
|
// No address translation.
|
|
//
|
|
#define BOOT_TRANSLATION_TYPE 0
|
|
|
|
//
|
|
// Use EFI page size.
|
|
//
|
|
#define PAGE_SIZE EFI_PAGE_SIZE
|
|
#define PAGE_SHIFT EFI_PAGE_SHIFT
|
|
|
|
#define BOOT_INPUT_PARAMETERS_SIGNATURE 0x50504120544f4f42 /* "BOOT APP" */
|
|
#define BOOT_INPUT_PARAMETERS_VERSION 2
|
|
|
|
typedef struct {
|
|
ULONGLONG Signature;
|
|
ULONG Version;
|
|
ULONG Size;
|
|
|
|
//
|
|
// Machine information.
|
|
//
|
|
ULONG MachineType;
|
|
ULONG TranslationType;
|
|
|
|
//
|
|
// Image information.
|
|
//
|
|
PVOID ImageBase;
|
|
ULONG ImageSize;
|
|
|
|
//
|
|
// Offsets to ancillary structures.
|
|
//
|
|
ULONG MemoryInfoOffset;
|
|
ULONG ApplicationEntryOffset;
|
|
ULONG BootDeviceOffset;
|
|
ULONG FirmwareDataOffset;
|
|
ULONG ReturnDataOffset;
|
|
ULONG PlatformDataOffset;
|
|
} BOOT_INPUT_PARAMETERS, *PBOOT_INPUT_PARAMETERS;
|
|
|
|
typedef struct {
|
|
ULONG Type;
|
|
ULONG DataOffset;
|
|
ULONG DataSize;
|
|
ULONG OtherOptionsOffset;
|
|
ULONG NextOptionOffset;
|
|
BOOLEAN IsInvalid;
|
|
UCHAR Unknown[3];
|
|
} BOOT_APPLICATION_OPTION, *PBOOT_APPLICATION_OPTION;
|
|
|
|
#define BOOT_INPUT_APPLICATION_ENTRY_SIGNATURE 0x544e4550415442 /* "BTAPENT" */
|
|
|
|
#define BOOT_INPUT_APPLICATION_ENTRY_NO_BCD_IDENTIFIER 0x01
|
|
|
|
typedef struct {
|
|
ULONGLONG Signature;
|
|
ULONG Attributes;
|
|
GUID BcdIdentifier;
|
|
UCHAR Unknown[16];
|
|
BOOT_APPLICATION_OPTION Options;
|
|
} BOOT_INPUT_APPLICATION_ENTRY, *PBOOT_INPUT_APPLICATION_ENTRY;
|
|
|
|
typedef struct {
|
|
ULONG Attributes;
|
|
GUID BcdIdentifier;
|
|
PBOOT_APPLICATION_OPTION Options;
|
|
} BOOT_APPLICATION_ENTRY, *PBOOT_APPLICATION_ENTRY;
|
|
|
|
#define BOOT_MEMORY_INFO_VERSION 1
|
|
|
|
typedef struct {
|
|
ULONG Version;
|
|
ULONG MdlOffset;
|
|
ULONG DescriptorCount;
|
|
ULONG DescriptorSize;
|
|
ULONG BasePageOffset;
|
|
} BOOT_MEMORY_INFO, *PBOOT_MEMORY_INFO;
|
|
|
|
#define MEMORY_ATTRIBUTE_CACHE_WB 0x08
|
|
|
|
#define MEMORY_TYPE_BOOT_APPLICATION 0xd0000002
|
|
|
|
typedef struct {
|
|
LIST_ENTRY ListEntry;
|
|
|
|
ULONGLONG BasePage;
|
|
ULONG Pages;
|
|
|
|
ULONG Attributes;
|
|
ULONG Type;
|
|
} BOOT_MEMORY_DESCRIPTOR, *PBOOT_MEMORY_DESCRIPTOR;
|
|
|
|
#define BOOT_FIRMWARE_DATA_VERSION 2
|
|
|
|
typedef struct {
|
|
ULONG Version;
|
|
ULONG Reserved;
|
|
EFI_HANDLE ImageHandle;
|
|
EFI_SYSTEM_TABLE *SystemTable;
|
|
} BOOT_FIRMWARE_DATA, *PBOOT_FIRMWARE_DATA;
|
|
|
|
#define BOOT_RETURN_DATA_VERSION 1
|
|
|
|
typedef struct {
|
|
ULONG Version;
|
|
NTSTATUS Status;
|
|
ULONG Flags;
|
|
} BOOT_RETURN_DATA, *PBOOT_RETURN_DATA;
|
|
|
|
typedef struct {
|
|
LARGE_INTEGER ImageBase;
|
|
ULONG ImageSize;
|
|
ULONG ImageOffset;
|
|
} BOOT_RAMDISK_IDENTIFIER, *PBOOT_RAMDISK_IDENTIFIER;
|
|
|
|
#define BOOT_HARDDRIVE_PARTITION_TYPE_GPT 0x00
|
|
#define BOOT_HARDDRIVE_PARTITION_TYPE_MBR 0x01
|
|
#define BOOT_HARDDRIVE_PARTITION_TYPE_RAW 0x02
|
|
|
|
typedef struct {
|
|
ULONG PartitionType;
|
|
|
|
union {
|
|
struct {
|
|
ULONG Signature;
|
|
} Mbr;
|
|
|
|
struct {
|
|
GUID Signature;
|
|
} Gpt;
|
|
|
|
struct {
|
|
ULONG DriveNumber;
|
|
} Raw;
|
|
};
|
|
} BOOT_HARDDRIVE_IDENTIFIER, *PBOOT_HARDDRIVE_IDENTIFIER;
|
|
|
|
typedef struct {
|
|
ULONG DriveNumber;
|
|
} BOOT_CDROM_IDENTIFIER, *PBOOT_CDROM_IDENTIFIER;
|
|
|
|
#define BOOT_BLOCK_DEVICE_TYPE_HARDDRIVE 0x00
|
|
#define BOOT_BLOCK_DEVICE_TYPE_CDROM 0x02
|
|
#define BOOT_BLOCK_DEVICE_TYPE_RAMDISK 0x03
|
|
|
|
typedef struct {
|
|
ULONG Type;
|
|
|
|
union {
|
|
BOOT_RAMDISK_IDENTIFIER Ramdisk;
|
|
BOOT_HARDDRIVE_IDENTIFIER Harddrive;
|
|
BOOT_CDROM_IDENTIFIER Cdrom;
|
|
};
|
|
} BOOT_BLOCK_IDENTIFIER, *PBOOT_BLOCK_IDENTIFIER;
|
|
|
|
typedef struct {
|
|
union {
|
|
struct {
|
|
ULONG PartitionNumber;
|
|
} Mbr;
|
|
|
|
struct {
|
|
GUID PartitionIdentifier;
|
|
} Gpt;
|
|
|
|
struct {
|
|
ULONG BootEntry;
|
|
} ElTorito;
|
|
};
|
|
|
|
BOOT_BLOCK_IDENTIFIER Parent;
|
|
} BOOT_PARTITION_IDENTIFIER, *PBOOT_PARTITION_IDENTIFIER;
|
|
|
|
typedef struct {
|
|
union {
|
|
struct {
|
|
PVOID PartitionOffset;
|
|
} Mbr;
|
|
|
|
struct {
|
|
GUID PartitionIdentifier;
|
|
} Gpt;
|
|
|
|
struct {
|
|
ULONG BootEntry;
|
|
} ElTorito;
|
|
};
|
|
|
|
BOOT_BLOCK_IDENTIFIER Parent;
|
|
} BOOT_PARTITION_IDENTIFIER_EX, *PBOOT_PARTITION_IDENTIFIER_EX;
|
|
|
|
#define BOOT_DEVICE_TYPE_BLOCK 0x00
|
|
#define BOOT_DEVICE_TYPE_PARTITION 0x02
|
|
#define BOOT_DEVICE_TYPE_PARTITION_EX 0x06
|
|
|
|
#define BOOT_DEVICE_ATTRIBUTE_NO_PARENT_SIGNATURE 0x04
|
|
|
|
typedef struct {
|
|
ULONG Type;
|
|
ULONG Attributes;
|
|
ULONG Size;
|
|
ULONG Pad;
|
|
|
|
union {
|
|
BOOT_BLOCK_IDENTIFIER Block;
|
|
BOOT_PARTITION_IDENTIFIER Partition;
|
|
BOOT_PARTITION_IDENTIFIER_EX PartitionEx;
|
|
};
|
|
} BOOT_DEVICE, *PBOOT_DEVICE;
|
|
|
|
typedef enum {
|
|
BCDE_DATA_TYPE_APPLICATION_DEVICE = 0x11000001,
|
|
BCDE_DATA_TYPE_APPLICATION_PATH = 0x22000002
|
|
} BCDE_DATA_TYPE;
|
|
|
|
typedef struct {
|
|
GUID OtherOptions;
|
|
BOOT_DEVICE Device;
|
|
} BCDE_DEVICE, *PBCDE_DEVICE;
|
|
|
|
NTSTATUS
|
|
BmOpenDataStore (
|
|
IN OUT PHANDLE DataStore
|
|
);
|
|
|
|
NTSTATUS
|
|
BmMain (
|
|
IN PBOOT_INPUT_PARAMETERS InputParameters
|
|
);
|
|
|
|
#endif
|