Use EFI BS FreePool, SetMem, CopyMem

This commit is contained in:
Lauri Kenttä
2023-11-20 16:10:36 +02:00
parent 0dfc49c800
commit 7dd048346d
3 changed files with 14 additions and 12 deletions

View File

@@ -181,9 +181,11 @@ void* LoadFileWithPadding(EFI_FILE_HANDLE dir, const CHAR16* path, UINTN* size_p
return 0;
}
EFI_FILE_INFO *info = LibFileInfo(handle);
UINTN size = info->FileSize;
FreePool(info);
UINT64 get_size = 0;
handle->SetPosition(handle, ~(UINT64)0);
handle->GetPosition(handle, &get_size);
handle->SetPosition(handle, 0);
UINTN size = (UINTN) get_size;
void* data = 0;
e = BS->AllocatePool(EfiBootServicesData, size + padding, &data);
@@ -197,7 +199,7 @@ void* LoadFileWithPadding(EFI_FILE_HANDLE dir, const CHAR16* path, UINTN* size_p
}
handle->Close(handle);
if (EFI_ERROR(e)) {
FreePool(data);
BS->FreePool(data);
return 0;
}
if (size_ptr) {