well that was stupid and overcomplicated, fixed bad apple video
This commit is contained in:
1 parent
18599151b4
commit
2a61ec8d6b
2 files changed
+8
-21
No files matched your search
Binary file not shown.
@@ -71,7 +71,7 @@ UINT64 FileSize(EFI_FILE_HANDLE FileHandle) {
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* LoadFile(EFI_FILE_HANDLE volume, const wchar_t* filename, UINT64* out_size, bool just_the_size_please) {
|
void* LoadFile(EFI_FILE_HANDLE volume, const wchar_t* filename) {
|
||||||
EFI_FILE_HANDLE file;
|
EFI_FILE_HANDLE file;
|
||||||
EFI_STATUS file_loading_status = volume->Open(volume, &file, (wchar_t*)filename,
|
EFI_STATUS file_loading_status = volume->Open(volume, &file, (wchar_t*)filename,
|
||||||
EFI_FILE_MODE_READ, 0);
|
EFI_FILE_MODE_READ, 0);
|
||||||
@@ -87,17 +87,7 @@ void* LoadFile(EFI_FILE_HANDLE volume, const wchar_t* filename, UINT64* out_size
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (just_the_size_please) {
|
VOID* file_buffer = AllocatePool(file_size);
|
||||||
*out_size = file_size;
|
|
||||||
file->Close(file);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (out_size) {
|
|
||||||
*out_size = file_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
VOID* file_buffer = Malloc(file_size);
|
|
||||||
if (!file_buffer) { return NULL; }
|
if (!file_buffer) { return NULL; }
|
||||||
|
|
||||||
SetMem(file_buffer, file_size, 0);
|
SetMem(file_buffer, file_size, 0);
|
||||||
@@ -110,13 +100,13 @@ void* LoadFile(EFI_FILE_HANDLE volume, const wchar_t* filename, UINT64* out_size
|
|||||||
if (EFI_ERROR(file_loading_status)) {
|
if (EFI_ERROR(file_loading_status)) {
|
||||||
printf("Failed to read file: %r\n", file_loading_status);
|
printf("Failed to read file: %r\n", file_loading_status);
|
||||||
// Free the allocated memory if the read fails
|
// Free the allocated memory if the read fails
|
||||||
Free(file_buffer);
|
FreePool(file_buffer);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (read_size != file_size) {
|
if (read_size != file_size) {
|
||||||
printf("Read size mismatch: expected %llu, got %llu\n", file_size, read_size);
|
printf("Read size mismatch: expected %llu, got %llu\n", file_size, read_size);
|
||||||
Free(file_buffer);
|
FreePool(file_buffer);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -323,7 +313,7 @@ void SavePhysicalScreen(EFI_FILE_HANDLE volume, EFI_GRAPHICS_OUTPUT_PROTOCOL* Go
|
|||||||
}
|
}
|
||||||
|
|
||||||
EFI_STATUS efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE* SystemTable) {
|
EFI_STATUS efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE* SystemTable) {
|
||||||
const wchar_t* filename = L"video.bk2";
|
const wchar_t* filename = L"apple.bk2";
|
||||||
InitializeLib(ImageHandle, SystemTable);
|
InitializeLib(ImageHandle, SystemTable);
|
||||||
SystemTable->BootServices->SetWatchdogTimer(0, 0, 0, NULL);
|
SystemTable->BootServices->SetWatchdogTimer(0, 0, 0, NULL);
|
||||||
Print(L"Hello, World!\n");
|
Print(L"Hello, World!\n");
|
||||||
@@ -338,11 +328,8 @@ EFI_STATUS efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE* SystemTable) {
|
|||||||
|
|
||||||
printf("Got volume\n");
|
printf("Got volume\n");
|
||||||
|
|
||||||
UINT64 filesize = 0;
|
|
||||||
LoadFile(volume, filename, &filesize, true);
|
|
||||||
|
|
||||||
VOID* HeapMemory = NULL;
|
VOID* HeapMemory = NULL;
|
||||||
UINT64 AllocationSize = filesize + 64 * 1024 * 1024; // file size + 64MB for heap
|
UINT64 AllocationSize = 64 * 1024 * 1024; // 64MB for heap
|
||||||
UINTN Pages = AllocationSize / EFI_PAGE_SIZE;
|
UINTN Pages = AllocationSize / EFI_PAGE_SIZE;
|
||||||
|
|
||||||
EFI_STATUS Status = gBS->AllocatePages(
|
EFI_STATUS Status = gBS->AllocatePages(
|
||||||
@@ -367,7 +354,7 @@ EFI_STATUS efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE* SystemTable) {
|
|||||||
|
|
||||||
SetMaxResolution(gop);
|
SetMaxResolution(gop);
|
||||||
|
|
||||||
VOID* binkFileBuffer = LoadFile(volume, L"bink2w64.dll", &filesize, false);
|
VOID* binkFileBuffer = LoadFile(volume, L"bink2w64.dll");
|
||||||
if (!binkFileBuffer) {
|
if (!binkFileBuffer) {
|
||||||
printf("Failed to load Bink DLL into memory!\n");
|
printf("Failed to load Bink DLL into memory!\n");
|
||||||
gBS->Stall(5 * 1000 * 1000);
|
gBS->Stall(5 * 1000 * 1000);
|
||||||
@@ -390,7 +377,7 @@ EFI_STATUS efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE* SystemTable) {
|
|||||||
|
|
||||||
printf("BinkSet* called\n");
|
printf("BinkSet* called\n");
|
||||||
|
|
||||||
void* video_file = LoadFile(volume, filename, NULL, false);
|
void* video_file = LoadFile(volume, filename);
|
||||||
if (!video_file) {
|
if (!video_file) {
|
||||||
printf("Failed to load video file into memory!\n");
|
printf("Failed to load video file into memory!\n");
|
||||||
gBS->Stall(5 * 1000 * 1000);
|
gBS->Stall(5 * 1000 * 1000);
|
||||||
|
|||||||
Reference in new issue
Block a user