Ejemplo n.º 1
0
EFI_STATUS EFIAPI
OvrCalculateCrc32(
	IN VOID				*Data,
	IN UINTN			DataSize,
	OUT UINT32			*Crc32
)
{
	EFI_STATUS			Status;
	Status = gOrgBS.CalculateCrc32(Data, DataSize, Crc32);
	
	// Omit printing this when using append while logging, as it can end up in calling a file operating inside another file operation
	// (some implementations of File functions use CalculateCrc32)
	#if (LOG_TO_FILE <= 2) && (CLEANER_LOG != 1)
	// Better not print this for cleaner logs - reported by XyZ
	PRINT("->CalculateCrc32(%p, %d, 0x%x) = %r\n", Data, DataSize, Crc32, Status);
	#endif
	return Status;
}
Ejemplo n.º 2
0
/** Installs our boot services overrides. */
EFI_STATUS EFIAPI
OvrBootServices(EFI_BOOT_SERVICES	*BS)
{
	
	PRINT("Overriding boot services ...\n");
	
	// store orig BS
	CopyMem(&gOrgBS, BS, sizeof(EFI_BOOT_SERVICES));
	
	BS->RaiseTPL = OvrRaiseTPL;
	BS->RestoreTPL = OvrRestoreTPL;
	
	BS->AllocatePages = OvrAllocatePages;
	BS->FreePages = OvrFreePages;
	BS->GetMemoryMap = OvrGetMemoryMap;
	BS->AllocatePool = OvrAllocatePool;
	BS->FreePool = OvrFreePool;
	
	BS->CreateEvent = OvrCreateEvent;
	BS->SetTimer = OvrSetTimer;
	BS->WaitForEvent = OvrWaitForEvent;
	BS->SignalEvent = OvrSignalEvent;
	BS->CloseEvent = OvrCloseEvent;
	BS->CheckEvent = OvrCheckEvent;
	
	BS->InstallProtocolInterface = OvrInstallProtocolInterface;
	BS->ReinstallProtocolInterface = OvrReinstallProtocolInterface;
	BS->UninstallProtocolInterface = OvrUninstallProtocolInterface;

	BS->HandleProtocol = OvrHandleProtocol;
	BS->RegisterProtocolNotify = OvrRegisterProtocolNotify;
	BS->LocateHandle = OvrLocateHandle;
	BS->LocateDevicePath = OvrLocateDevicePath;

	BS->InstallConfigurationTable = OvrInstallConfigurationTable;

	BS->LoadImage = OvrLoadImage;
	BS->StartImage = OvrStartImage;
	BS->Exit = OvrExit;
	BS->UnloadImage = OvrUnloadImage;
	
	BS->ExitBootServices = OvrExitBootServices;
	BS->GetNextMonotonicCount = OvrGetNextMonotonicCount;
	BS->Stall = OvrStall;
	BS->SetWatchdogTimer = OvrSetWatchdogTimer;
	
	BS->ConnectController = OvrConnectController;
	BS->DisconnectController = OvrDisconnectController;

	BS->OpenProtocol = OvrOpenProtocol;
	BS->CloseProtocol = OvrCloseProtocol;
	BS->OpenProtocolInformation = OvrOpenProtocolInformation;
	BS->ProtocolsPerHandle = OvrProtocolsPerHandle;
	BS->LocateHandleBuffer = OvrLocateHandleBuffer;
	BS->LocateProtocol = OvrLocateProtocol;
	BS->InstallMultipleProtocolInterfaces = OvrInstallMultipleProtocolInterfaces;
	BS->UninstallMultipleProtocolInterfaces = OvrUninstallMultipleProtocolInterfaces;
	
	BS->CalculateCrc32 = OvrCalculateCrc32;
	BS->CopyMem = OvrCopyMem;
	BS->SetMem = OvrSetMem;
	BS->CreateEventEx = OvrCreateEventEx;
	
	BS->Hdr.CRC32 = 0;
	// use orig function to avoid our PRINT
	gOrgBS.CalculateCrc32(BS, BS->Hdr.HeaderSize, &BS->Hdr.CRC32);
	PRINT("Boot services overriden!\n");
	
	#if CAPTURE_CONSOLE_OUTPUT >= 1
	PRINT("Overriding console output ...\n");
	#if CAPTURE_CONSOLE_OUTPUT == 2
	PRINT("Preventing any further console output, please wait until booting starts ...\n");
	#endif
	gOrgConOutOutputString = gST->ConOut->OutputString;
	gST->ConOut->OutputString = OvrConOutOutputString;
	PRINT("Console output overriden!\n");
	#endif
	
	return EFI_SUCCESS;
}