diff options
Diffstat (limited to 'documentation/code examples/boot_services.c')
-rw-r--r-- | documentation/code examples/boot_services.c | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/documentation/code examples/boot_services.c b/documentation/code examples/boot_services.c deleted file mode 100644 index 1cb57d7..0000000 --- a/documentation/code examples/boot_services.c +++ /dev/null @@ -1,55 +0,0 @@ - /* -extern EFI_BOOT_SERVICES *gBS; -EFI_EXIT_BOOT_SERVICES gOrigExitBootServices; - - - -EFI_STATUS -EFIAPI -ExitBootServicesHook(IN EFI_HANDLE ImageHandle, IN UINTN MapKey){ - - // <hook related fun> - // Do fun hook-related stuff here - // </hook-related fun> - - // Fix the pointer in the boot services table - // If you don't do this, sometimes your hook method will be called repeatedly, which you don't want - gBS->ExitBootServices = gOrigExitBootServices; - - // Get the memory map - UINTN MemoryMapSize; - EFI_MEMORY_DESCRIPTOR *MemoryMap; - UINTN LocalMapKey; - UINTN DescriptorSize; - UINT32 DescriptorVersion; - MemoryMap = NULL; - MemoryMapSize = 0; - - - do { - Status = gBS->GetMemoryMap(&MemoryMapSize, MemoryMap, &LocalMapKey, &DescriptorSize,&DescriptorVersion); - if (Status == EFI_BUFFER_TOO_SMALL){ - MemoryMap = AllocatePool(MemoryMapSize + 1); - Status = gBS->GetMemoryMap(&MemoryMapSize, MemoryMap, &LocalMapKey, &DescriptorSize,&DescriptorVersion); - } else { - // Status is likely success - let the while() statement check success - } - DbgPrint(L"This time through the memory map loop, status = %r\n",Status); - - } while (Status != EFI_SUCCESS); - - return gOrigExitBootServices(ImageHandle,LocalMapKey); - -} -EFI_STATUS -EFIAPI -HookDriverMain(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable){ - - // Store off the original pointer and replace it with your own - gOrigExitBootServices = gBS->ExitBootServices; - gBS->ExitBootServices = ExitBootServicesHook; - - // It's hooked! Return EFI_SUCCESS so your driver stays in memory - return EFI_SUCCESS; -} - */ |