From 6f58bf2be45f7775a91ae0cbac1b8329008ea676 Mon Sep 17 00:00:00 2001 From: vit9696 Date: Thu, 14 Mar 2019 12:07:35 +0300 Subject: [PATCH] Fix ReadFileSize not returning size --- Library/OcAppleKernelLib/ReadAppleKernel.c | 2 ++ Library/OcFileLib/FileProtocol.c | 2 ++ Tests/KernelTest/KernelTest.c | 12 +++++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Library/OcAppleKernelLib/ReadAppleKernel.c b/Library/OcAppleKernelLib/ReadAppleKernel.c index fa228675..9195de87 100644 --- a/Library/OcAppleKernelLib/ReadAppleKernel.c +++ b/Library/OcAppleKernelLib/ReadAppleKernel.c @@ -248,6 +248,8 @@ ReadAppleKernelImage ( DEBUG ((DEBUG_INFO, "Kernel size cannot be determined - %r\n", Status)); return EFI_OUT_OF_RESOURCES; } + + DEBUG ((DEBUG_VERBOSE, "Determined kernel size is %u bytes\n", *KernelSize)); } Status = ReplaceBuffer (*KernelSize, Buffer, AllocatedSize); diff --git a/Library/OcFileLib/FileProtocol.c b/Library/OcFileLib/FileProtocol.c index 8e7827c5..f720b871 100644 --- a/Library/OcFileLib/FileProtocol.c +++ b/Library/OcFileLib/FileProtocol.c @@ -68,5 +68,7 @@ ReadFileSize ( return EFI_OUT_OF_RESOURCES; } + *Size = (UINT32) Position; + return EFI_SUCCESS; } diff --git a/Tests/KernelTest/KernelTest.c b/Tests/KernelTest/KernelTest.c index bc2c65f6..40db045e 100644 --- a/Tests/KernelTest/KernelTest.c +++ b/Tests/KernelTest/KernelTest.c @@ -69,6 +69,16 @@ TestFileOpen ( if (!EFI_ERROR (Status) && OpenMode == EFI_FILE_MODE_READ && StrStr (FileName, L"kernel") != NULL) { + + // + // boot.efi uses kernel as is to determine valid filesystem. + // Just skip it to speedup the boot process. + // On 10.9 mach_kernel is loaded for manual linking aferwards, so we cannot skip it. + // + if (StrCmp (FileName, L"System\\Library\\Kernels\\kernel") == 0) { + return Status; + } + Print (L"Trying XNU hook on %s\n", FileName); Status = ReadAppleKernel (*NewHandle, &Kernel, &KernelSize, &AllocatedSize); Print (L"Result of XNU hook on %s is %r\n", FileName, Status); @@ -91,7 +101,7 @@ TestFileOpen ( (UINT8 *) "OpenCore Boot Version", Kernel, KernelSize, - 1, + 0, ///< At least on 10.14 we have BSD version string. 0 );