2019-09-03 11:58:42 +02:00
|
|
|
/*
|
|
|
|
* refit/scan/entry_scan.h
|
|
|
|
*
|
|
|
|
* Copyright (c) 2006-2010 Christoph Pfisterer
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are
|
|
|
|
* met:
|
|
|
|
*
|
|
|
|
* * Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* * Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
*
|
|
|
|
* * Neither the name of Christoph Pfisterer nor the names of the
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2020-08-17 21:40:52 +02:00
|
|
|
#include "../gui/menu_items/menu_items.h"
|
2019-09-03 11:58:42 +02:00
|
|
|
|
2020-02-28 21:28:33 +01:00
|
|
|
extern REFIT_MENU_ITEM_RETURN MenuEntryReturn;
|
|
|
|
extern REFIT_MENU_ITEM_OPTIONS MenuEntryOptions;
|
|
|
|
extern REFIT_MENU_ITEM_ABOUT MenuEntryAbout;
|
|
|
|
extern REFIT_MENU_ITEM_RESET MenuEntryReset;
|
|
|
|
extern REFIT_MENU_ITEM_SHUTDOWN MenuEntryShutdown;
|
2019-09-03 11:58:42 +02:00
|
|
|
//extern REFIT_MENU_ENTRY MenuEntryHelp;
|
2020-02-28 21:28:33 +01:00
|
|
|
//extern REFIT_MENU_ENTRY MenuEntryExit;
|
2019-09-03 11:58:42 +02:00
|
|
|
|
|
|
|
// common
|
2020-09-28 17:57:50 +02:00
|
|
|
const XIcon& ScanVolumeDefaultIcon(REFIT_VOLUME *Volume, IN UINT8 OSType, const EFI_DEVICE_PATH_PROTOCOL *DevicePath);
|
2020-04-10 12:04:21 +02:00
|
|
|
|
2019-09-03 11:58:42 +02:00
|
|
|
|
|
|
|
// Ask user for file path from directory menu
|
2021-09-28 10:28:45 +02:00
|
|
|
XBool AskUserForFilePathFromDir(const CHAR16 *Title OPTIONAL, IN REFIT_VOLUME *Volume,
|
2021-04-08 17:07:05 +02:00
|
|
|
const CHAR16 *ParentPath, const EFI_FILE *Dir,
|
2019-09-03 11:58:42 +02:00
|
|
|
OUT EFI_DEVICE_PATH_PROTOCOL **Result);
|
|
|
|
// Ask user for file path from volumes menu
|
2021-09-28 10:28:45 +02:00
|
|
|
XBool AskUserForFilePathFromVolumes(const CHAR16 *Title OPTIONAL, OUT EFI_DEVICE_PATH_PROTOCOL **Result);
|
2019-09-03 11:58:42 +02:00
|
|
|
// Ask user for file path
|
2021-09-28 10:28:45 +02:00
|
|
|
XBool AskUserForFilePath(IN CHAR16 *Title OPTIONAL, IN EFI_DEVICE_PATH_PROTOCOL *Root OPTIONAL, OUT EFI_DEVICE_PATH_PROTOCOL **Result);
|
2019-09-03 11:58:42 +02:00
|
|
|
|
|
|
|
// legacy
|
2020-10-03 19:02:31 +02:00
|
|
|
void ScanLegacy(void);
|
|
|
|
void AddCustomLegacy(void);
|
2019-09-03 11:58:42 +02:00
|
|
|
|
|
|
|
// loader
|
2020-10-03 19:02:31 +02:00
|
|
|
void ScanLoader(void);
|
|
|
|
void AddCustomEntries(void);
|
2021-09-28 10:28:45 +02:00
|
|
|
XBool IsCustomBootEntry(IN LOADER_ENTRY *Entry);
|
2019-09-03 11:58:42 +02:00
|
|
|
|
|
|
|
// tool
|
2020-10-03 19:02:31 +02:00
|
|
|
void ScanTool(void);
|
|
|
|
void AddCustomTool(void);
|
2019-09-03 11:58:42 +02:00
|
|
|
|
|
|
|
// locked graphics
|
2020-10-03 19:02:31 +02:00
|
|
|
EFI_STATUS LockBootScreen(void);
|
|
|
|
EFI_STATUS UnlockBootScreen(void);
|
2019-09-03 11:58:42 +02:00
|
|
|
|
|
|
|
// secure boot
|
|
|
|
#ifdef ENABLE_SECURE_BOOT
|
|
|
|
#define PLATFORM_DATABASE_NAME L"PK"
|
|
|
|
#define PLATFORM_DATABASE_GUID gEfiGlobalVariableGuid
|
|
|
|
#define EXCHANGE_DATABASE_NAME L"KEK"
|
|
|
|
#define EXCHANGE_DATABASE_GUID gEfiGlobalVariableGuid
|
|
|
|
#define AUTHORIZED_DATABASE_NAME EFI_IMAGE_SECURITY_DATABASE
|
|
|
|
#define AUTHORIZED_DATABASE_GUID gEfiImageSecurityDatabaseGuid
|
|
|
|
#define UNAUTHORIZED_DATABASE_NAME EFI_IMAGE_SECURITY_DATABASE1
|
|
|
|
#define UNAUTHORIZED_DATABASE_GUID gEfiImageSecurityDatabaseGuid
|
|
|
|
#define DEFAULT_PLATFORM_DATABASE_NAME L"PKDefault"
|
|
|
|
#define DEFAULT_PLATFORM_DATABASE_GUID gEfiGlobalVariableGuid
|
|
|
|
#define DEFAULT_EXCHANGE_DATABASE_NAME L"KEKDefault"
|
|
|
|
#define DEFAULT_EXCHANGE_DATABASE_GUID gEfiGlobalVariableGuid
|
|
|
|
#define DEFAULT_AUTHORIZED_DATABASE_NAME L"dbDefault"
|
|
|
|
#define DEFAULT_AUTHORIZED_DATABASE_GUID gEfiGlobalVariableGuid
|
|
|
|
#define DEFAULT_UNAUTHORIZED_DATABASE_NAME L"dbxDefault"
|
|
|
|
#define DEFAULT_UNAUTHORIZED_DATABASE_GUID gEfiGlobalVariableGuid
|
|
|
|
|
2020-10-03 19:02:31 +02:00
|
|
|
void AddSecureBootTool(void);
|
|
|
|
EFI_STATUS InstallSecureBoot(void);
|
|
|
|
void UninstallSecureBoot(void);
|
|
|
|
void EnableSecureBoot(void);
|
|
|
|
void DisableSecureBoot(void);
|
2021-09-28 10:28:45 +02:00
|
|
|
XBool ConfigureSecureBoot(void);
|
2019-09-03 11:58:42 +02:00
|
|
|
CONST CHAR16 *SecureBootPolicyToStr(IN UINTN Policy);
|
|
|
|
EFI_STATUS VerifySecureBootImage(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath);
|
|
|
|
UINTN QuerySecureBootUser(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath);
|
2020-10-03 19:02:31 +02:00
|
|
|
EFI_STATUS EnrollSecureBootKeys(IN void *AuthorizedDatabase,
|
2019-09-03 11:58:42 +02:00
|
|
|
IN UINTN AuthorizedDatabaseSize,
|
2021-09-28 15:54:31 +02:00
|
|
|
IN XBool WantDefaultKeys);
|
2020-10-03 19:02:31 +02:00
|
|
|
EFI_STATUS ClearSecureBootKeys(void);
|
2019-09-03 11:58:42 +02:00
|
|
|
|
|
|
|
// secure boot database
|
2021-05-09 16:13:37 +02:00
|
|
|
void *GetSignatureDatabase(const wchar_t* DatabaseName,
|
|
|
|
IN EFI_GUID * DatabaseGuid,
|
|
|
|
OUT UINTN * DatabaseSize);
|
|
|
|
EFI_STATUS SetSignatureDatabase(const wchar_t* DatabaseName,
|
|
|
|
IN EFI_GUID * DatabaseGuid,
|
|
|
|
IN void * Database,
|
|
|
|
IN UINTN DatabaseSize);
|
2019-09-03 11:58:42 +02:00
|
|
|
|
|
|
|
// secure boot authorized database
|
2020-10-03 19:02:31 +02:00
|
|
|
void *GetAuthorizedDatabase(UINTN *DatabaseSize);
|
|
|
|
EFI_STATUS SetAuthorizedDatabase(IN void *Database,
|
2019-09-03 11:58:42 +02:00
|
|
|
IN UINTN DatabaseSize);
|
2020-10-03 19:02:31 +02:00
|
|
|
EFI_STATUS ClearAuthorizedDatabase(void);
|
|
|
|
void *GetImageSignatureDatabase(IN void *FileBuffer,
|
2019-09-03 11:58:42 +02:00
|
|
|
IN UINT64 FileSize,
|
|
|
|
IN UINTN *DatabaseSize,
|
2021-09-28 15:54:31 +02:00
|
|
|
IN XBool HashIfNoDatabase);
|
2020-10-03 19:02:31 +02:00
|
|
|
EFI_STATUS AppendImageDatabaseToAuthorizedDatabase(IN void *Database,
|
2019-09-03 11:58:42 +02:00
|
|
|
IN UINTN DatabaseSize);
|
2020-10-03 19:02:31 +02:00
|
|
|
EFI_STATUS RemoveImageDatabaseFromAuthorizedDatabase(IN void *Database,
|
2019-09-03 11:58:42 +02:00
|
|
|
IN UINTN DatabaseSize);
|
|
|
|
EFI_STATUS AppendImageToAuthorizedDatabase(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
|
2020-10-03 19:02:31 +02:00
|
|
|
IN void *FileBuffer,
|
2019-09-03 11:58:42 +02:00
|
|
|
IN UINTN FileSize);
|
|
|
|
EFI_STATUS RemoveImageFromAuthorizedDatabase(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
|
2020-10-03 19:02:31 +02:00
|
|
|
IN void *FileBuffer,
|
2019-09-03 11:58:42 +02:00
|
|
|
IN UINTN FileSize);
|
2020-10-03 19:02:31 +02:00
|
|
|
EFI_STATUS AppendSignatureDatabaseToDatabase(IN OUT void **Database,
|
2019-09-03 11:58:42 +02:00
|
|
|
IN OUT UINTN *DatabaseSize,
|
2020-10-03 19:02:31 +02:00
|
|
|
IN void *SignatureDatabase,
|
2019-09-03 11:58:42 +02:00
|
|
|
IN UINTN SignatureDatabaseSize);
|
2020-10-03 19:02:31 +02:00
|
|
|
EFI_STATUS AppendSignatureToDatabase(IN OUT void **Database,
|
2019-09-03 11:58:42 +02:00
|
|
|
IN OUT UINTN *DatabaseSize,
|
|
|
|
IN EFI_GUID *SignatureType,
|
2020-10-03 19:02:31 +02:00
|
|
|
IN void *Signature,
|
2019-09-03 11:58:42 +02:00
|
|
|
IN UINTN SignatureSize);
|
|
|
|
#endif //ENABLE_SECURE_BOOT
|