|
|
@ -136,7 +136,6 @@ EFI_DEVICE_PATH* EFIAPI GetBootMgfwPath(VOID)
|
|
|
|
UINTN HandleCount = NULL;
|
|
|
|
UINTN HandleCount = NULL;
|
|
|
|
EFI_STATUS Result;
|
|
|
|
EFI_STATUS Result;
|
|
|
|
EFI_HANDLE* Handles = NULL;
|
|
|
|
EFI_HANDLE* Handles = NULL;
|
|
|
|
EFI_DEVICE_PATH* DevicePath = NULL;
|
|
|
|
|
|
|
|
EFI_FILE_HANDLE VolumeHandle;
|
|
|
|
EFI_FILE_HANDLE VolumeHandle;
|
|
|
|
EFI_FILE_HANDLE BootMgfwHandle;
|
|
|
|
EFI_FILE_HANDLE BootMgfwHandle;
|
|
|
|
EFI_FILE_IO_INTERFACE* FileSystem = NULL;
|
|
|
|
EFI_FILE_IO_INTERFACE* FileSystem = NULL;
|
|
|
@ -144,34 +143,36 @@ EFI_DEVICE_PATH* EFIAPI GetBootMgfwPath(VOID)
|
|
|
|
if (EFI_ERROR((Result = gBS->LocateHandleBuffer(ByProtocol, &gEfiSimpleFileSystemProtocolGuid, NULL, &HandleCount, &Handles))))
|
|
|
|
if (EFI_ERROR((Result = gBS->LocateHandleBuffer(ByProtocol, &gEfiSimpleFileSystemProtocolGuid, NULL, &HandleCount, &Handles))))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Print(L"error getting file system handles -> 0x%p\n", Result);
|
|
|
|
Print(L"error getting file system handles -> 0x%p\n", Result);
|
|
|
|
return DevicePath;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (UINT32 Idx = 0u; Idx < HandleCount && !FileSystem; ++Idx)
|
|
|
|
for (UINT32 Idx = 0u; Idx < HandleCount; ++Idx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (EFI_ERROR((Result = gBS->OpenProtocol(Handles[Idx], &gEfiSimpleFileSystemProtocolGuid, (VOID**)&FileSystem, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL))))
|
|
|
|
if (EFI_ERROR((Result = gBS->OpenProtocol(Handles[Idx], &gEfiSimpleFileSystemProtocolGuid, (VOID**)&FileSystem, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL))))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Print(L"error opening protocol -> 0x%p\n", Result);
|
|
|
|
Print(L"error opening protocol -> 0x%p\n", Result);
|
|
|
|
return DevicePath;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (EFI_ERROR((Result = FileSystem->OpenVolume(FileSystem, &VolumeHandle))))
|
|
|
|
if (EFI_ERROR((Result = FileSystem->OpenVolume(FileSystem, &VolumeHandle))))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Print(L"error opening file system -> 0x%p\n", Result);
|
|
|
|
Print(L"error opening file system -> 0x%p\n", Result);
|
|
|
|
return DevicePath;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!EFI_ERROR(VolumeHandle->Open(VolumeHandle, &BootMgfwHandle, WINDOWS_BOOTMGFW_PATH, EFI_FILE_MODE_READ, EFI_FILE_READ_ONLY)))
|
|
|
|
if (!EFI_ERROR(VolumeHandle->Open(VolumeHandle, &BootMgfwHandle, WINDOWS_BOOTMGFW_PATH, EFI_FILE_MODE_READ, EFI_FILE_READ_ONLY)))
|
|
|
|
DevicePath = FileDevicePath(Handles[Idx], WINDOWS_BOOTMGFW_PATH);
|
|
|
|
{
|
|
|
|
|
|
|
|
VolumeHandle->Close(BootMgfwHandle);
|
|
|
|
|
|
|
|
return FileDevicePath(Handles[Idx], WINDOWS_BOOTMGFW_PATH);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VolumeHandle->Close(BootMgfwHandle);
|
|
|
|
|
|
|
|
if (EFI_ERROR((Result = gBS->CloseProtocol(Handles[Idx], &gEfiSimpleFileSystemProtocolGuid, gImageHandle, NULL))))
|
|
|
|
if (EFI_ERROR((Result = gBS->CloseProtocol(Handles[Idx], &gEfiSimpleFileSystemProtocolGuid, gImageHandle, NULL))))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Print(L"error closing protocol -> 0x%p\n", Result);
|
|
|
|
Print(L"error closing protocol -> 0x%p\n", Result);
|
|
|
|
return DevicePath;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return DevicePath;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EFI_STATUS EFIAPI InstallBootMgfwHooks(EFI_HANDLE ImageHandle)
|
|
|
|
EFI_STATUS EFIAPI InstallBootMgfwHooks(EFI_HANDLE ImageHandle)
|
|
|
@ -192,9 +193,6 @@ EFI_STATUS EFIAPI InstallBootMgfwHooks(EFI_HANDLE ImageHandle)
|
|
|
|
START_BOOT_APPLICATION_MASK
|
|
|
|
START_BOOT_APPLICATION_MASK
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
if (!ArchStartBootApplication)
|
|
|
|
|
|
|
|
return EFI_ABORTED;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Print(L"BootMgfw.ArchStartBootApplication -> 0x%p\n", ArchStartBootApplication);
|
|
|
|
Print(L"BootMgfw.ArchStartBootApplication -> 0x%p\n", ArchStartBootApplication);
|
|
|
|
MakeShitHook(&BootMgfwShitHook, RESOLVE_RVA(ArchStartBootApplication, 5, 1), &ArchStartBootApplicationHook, TRUE);
|
|
|
|
MakeShitHook(&BootMgfwShitHook, RESOLVE_RVA(ArchStartBootApplication, 5, 1), &ArchStartBootApplicationHook, TRUE);
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
return EFI_SUCCESS;
|
|
|
@ -214,6 +212,7 @@ EFI_STATUS EFIAPI ArchStartBootApplicationHook(VOID* AppEntry, VOID* ImageBase,
|
|
|
|
gST->ConOut->ClearScreen(gST->ConOut);
|
|
|
|
gST->ConOut->ClearScreen(gST->ConOut);
|
|
|
|
gST->ConOut->OutputString(gST->ConOut, AsciiArt);
|
|
|
|
gST->ConOut->OutputString(gST->ConOut, AsciiArt);
|
|
|
|
Print(L"\n");
|
|
|
|
Print(L"\n");
|
|
|
|
|
|
|
|
|
|
|
|
Print(L"PE PayLoad Size -> 0x%x\n", PayLoadSize());
|
|
|
|
Print(L"PE PayLoad Size -> 0x%x\n", PayLoadSize());
|
|
|
|
Print(L"winload.BlImgLoadPEImageEx -> 0x%p\n", RESOLVE_RVA(ImgLoadPEImageEx, 5, 1));
|
|
|
|
Print(L"winload.BlImgLoadPEImageEx -> 0x%p\n", RESOLVE_RVA(ImgLoadPEImageEx, 5, 1));
|
|
|
|
|
|
|
|
|
|
|
|