From 649974b7331bd17b28f0d243f53f62d3eb6dff18 Mon Sep 17 00:00:00 2001 From: belliash Date: Wed, 5 Oct 2022 19:57:46 +0200 Subject: [PATCH] BlOpenVolume() now correctly opens a Simple File System protocol --- xtldr/volume.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/xtldr/volume.c b/xtldr/volume.c index 77e6dc7..8f4109e 100644 --- a/xtldr/volume.c +++ b/xtldr/volume.c @@ -320,10 +320,6 @@ BlOpenVolume(IN PEFI_DEVICE_PATH_PROTOCOL DevicePath, /* Failed to locate device path */ return Status; } - - /* Open the filesystem protocol */ - Status = EfiSystemTable->BootServices->OpenProtocol(*DiskHandle, &SFSGuid, (PVOID *)&FileSystemProtocol, - EfiImageHandle, NULL, EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL); } else { @@ -337,18 +333,18 @@ BlOpenVolume(IN PEFI_DEVICE_PATH_PROTOCOL DevicePath, } /* Store disk handle */ - DiskHandle = ImageProtocol->DeviceHandle; - - /* Open the filesystem protocol */ - Status = EfiSystemTable->BootServices->OpenProtocol(DiskHandle, &SFSGuid, (PVOID *)&FileSystemProtocol, - EfiImageHandle, NULL, EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL); + *DiskHandle = ImageProtocol->DeviceHandle; } + /* Open the filesystem protocol */ + Status = EfiSystemTable->BootServices->OpenProtocol(*DiskHandle, &SFSGuid, (PVOID *)&FileSystemProtocol, + EfiImageHandle, NULL, EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL); + /* Check if filesystem protocol opened successfully */ if(Status != STATUS_EFI_SUCCESS) { /* Failed to open the filesystem protocol, close volume */ - BlCloseVolume(DiskHandle); + BlCloseVolume(*DiskHandle); return Status; } @@ -357,7 +353,7 @@ BlOpenVolume(IN PEFI_DEVICE_PATH_PROTOCOL DevicePath, if(Status != STATUS_EFI_SUCCESS) { /* Failed to open the filesystem, close volume */ - BlCloseVolume(DiskHandle); + BlCloseVolume(*DiskHandle); return Status; }