/**
  Performs additional actions just before a PE/COFF image is unloaded.  Any resources
  that were allocated by PeCoffLoaderRelocateImageExtraAction() must be freed.

  If ImageContext is NULL, then ASSERT().

  @param  ImageContext  Pointer to the image context structure that describes the
                        PE/COFF image that is being unloaded.

**/
VOID
EFIAPI
PeCoffLoaderUnloadImageExtraAction (
  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext
  )
{
  if (EMU_MAGIC_PAGE()->Thunk == NULL) {
    EmuPeCoffGetThunkStucture ();
  }
  EMU_MAGIC_PAGE()->Thunk->PeCoffUnloadImageExtraAction (ImageContext);
}
Beispiel #2
0
/**
  This service enables PEIMs to discover a given instance of an interface.

  So this is, well a hack, so we can reuse the same libraries as the PEI Core
  for XIP modules....

  @param  Guid                  A pointer to the GUID whose corresponding interface needs to be
                                found.
  @param  Instance              The N-th instance of the interface that is required.
  @param  PpiDescriptor         A pointer to instance of the EFI_PEI_PPI_DESCRIPTOR.
  @param  Ppi                   A pointer to the instance of the interface.

  @retval EFI_SUCCESS           The interface was successfully returned.
  @retval EFI_NOT_FOUND         The PPI descriptor is not found in the database.

**/
EFI_STATUS
EFIAPI
PeiServicesLocatePpi (
  IN CONST EFI_GUID             *Guid,
  IN UINTN                      Instance,
  IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,
  IN OUT VOID                   **Ppi
  )
{
  EFI_PEI_PPI_DESCRIPTOR *PpiList;

  if (Instance != 0) {
    return EFI_NOT_FOUND;
  }

  for (PpiList = EMU_MAGIC_PAGE()->PpiList; ; PpiList++) {
    if (CompareGuid (PpiList->Guid, Guid)) {
      if (PpiDescriptor != NULL) {
        *PpiDescriptor = PpiList;
      }
      if (Ppi != NULL) {
        *Ppi = PpiList->Ppi;
      }
      return EFI_SUCCESS;
    }

    if ((PpiList->Flags & EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) == EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) {
      break;
    }
  }


  return EFI_NOT_FOUND;
}
/**
  The function caches the pointer of the Unix thunk functions
  It will ASSERT() if Unix thunk ppi is not installed.

  @retval EFI_SUCCESS   WinNT thunk protocol is found and cached.

**/
EFI_STATUS
EFIAPI
EmuPeCoffGetThunkStucture (
  )
{
  EMU_THUNK_PPI     *ThunkPpi;
  EFI_STATUS        Status;


  //
  // Locate Unix ThunkPpi for retrieving standard output handle
  //
  Status = PeiServicesLocatePpi (
              &gEmuThunkPpiGuid,
              0,
              NULL,
              (VOID **) &ThunkPpi
              );
  ASSERT_EFI_ERROR (Status);

  EMU_MAGIC_PAGE()->Thunk = (EMU_THUNK_PROTOCOL *) ThunkPpi->Thunk ();

  return EFI_SUCCESS;
}