]> code.delx.au - refind/blobdiff - refind/mok.c
Added "1024" as code to not change the mode to the "textmode" token.
[refind] / refind / mok.c
index 6c4ef38e20f021b845ada1fb6b4438e84a742884..091028abcb9f2b3677f47432c96091caf2cd714f 100644 (file)
@@ -130,6 +130,15 @@ BOOLEAN secure_mode (VOID)
    return TRUE;
 } // secure_mode()
 
+// Returns TRUE if the shim program is available to verify binaries,
+// FALSE if not
+BOOLEAN ShimLoaded(void) {
+   SHIM_LOCK   *shim_lock;
+   EFI_GUID    ShimLockGuid = SHIM_LOCK_GUID;
+
+   return (BS->LocateProtocol(&ShimLockGuid, NULL, (VOID**) &shim_lock) == EFI_SUCCESS);
+} // ShimLoaded()
+
 /*
  * Currently, shim/MOK only works on x86-64 (X64) systems, and some of this code
  * generates warnings on x86 (IA32) builds, so don't bother compiling it at all
@@ -330,8 +339,8 @@ static EFI_STATUS read_header(void *data, unsigned int datasize,
 // Returns TRUE if the specified data is validated by Shim's MOK, FALSE otherwise
 static BOOLEAN ShimValidate (VOID *data, UINT32 size)
 {
-   EFI_GUID    ShimLockGuid = SHIM_LOCK_GUID;
    SHIM_LOCK   *shim_lock;
+   EFI_GUID    ShimLockGuid = SHIM_LOCK_GUID;
 
    if (BS->LocateProtocol(&ShimLockGuid, NULL, (VOID**) &shim_lock) == EFI_SUCCESS) {
       if (!shim_lock)
@@ -348,7 +357,7 @@ static BOOLEAN ShimValidate (VOID *data, UINT32 size)
  * Once the image has been loaded it needs to be validated and relocated
  */
 static EFI_STATUS handle_image (void *data, unsigned int datasize, EFI_LOADED_IMAGE *li,
-                                CHAR16 *Options, REFIT_VOLUME *DeviceVolume, IN EFI_DEVICE_PATH *DevicePath)
+                                CHAR16 *Options, REFIT_VOLUME *DeviceVolume, IN CHAR16 *FileName)
 {
    EFI_STATUS efi_status;
    char *buffer;
@@ -356,6 +365,7 @@ static EFI_STATUS handle_image (void *data, unsigned int datasize, EFI_LOADED_IM
    EFI_IMAGE_SECTION_HEADER *Section;
    char *base, *end;
    GNUEFI_PE_COFF_LOADER_IMAGE_CONTEXT context;
+   EFI_DEVICE_PATH *DevicePath;
 
    /*
     * The binary header contains relevant context and section pointers
@@ -425,6 +435,8 @@ static EFI_STATUS handle_image (void *data, unsigned int datasize, EFI_LOADED_IM
     * grub needs to know its location and size in memory, its location on
     * disk, and its load options, so fix up the loaded image protocol values
     */
+   DevicePath = FileDevicePath(NULL, FileName);
+//   DevicePath = FileDevicePath(DeviceVolume->DeviceHandle, FileName);
    li->DeviceHandle = DeviceVolume->DeviceHandle;
    li->FilePath = DevicePath;
    li->LoadOptionsSize = ((UINT32)StrLen(Options) + 1) * sizeof(CHAR16);
@@ -483,7 +495,7 @@ EFI_STATUS start_image(EFI_HANDLE image_handle, CHAR16 *ImagePath, VOID *data, U
    /*
     * Verify and, if appropriate, relocate and execute the executable
     */
-   efi_status = handle_image(data, datasize, li, Options, DeviceVolume, DevicePath);
+   efi_status = handle_image(data, datasize, li, Options, DeviceVolume, ImagePath);
 
    if (efi_status != EFI_SUCCESS) {
       Print(L"Failed to load image\n");