2 Provides services to perform additional actions to relocate and unload
3 PE/Coff image for Emu environment specific purpose such as souce level debug.
4 This version only works for DXE phase
6 Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
7 Portions copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>
8 SPDX-License-Identifier: BSD-2-Clause-Patent
14 #include <Protocol/EmuThunk.h>
16 #include <Library/PeCoffLib.h>
17 #include <Library/BaseLib.h>
18 #include <Library/DebugLib.h>
19 #include <Library/HobLib.h>
20 #include <Library/BaseMemoryLib.h>
21 #include <Library/PeCoffExtraActionLib.h>
24 // Cache of UnixThunk protocol
26 EMU_THUNK_PROTOCOL
*mThunk
= NULL
;
30 The constructor function gets the pointer of the WinNT thunk functions
31 It will ASSERT() if Unix thunk protocol is not installed.
33 @retval EFI_SUCCESS Unix thunk protocol is found and cached.
38 DxeEmuPeCoffLibExtraActionConstructor (
39 IN EFI_HANDLE ImageHandle
,
40 IN EFI_SYSTEM_TABLE
*SystemTable
43 EFI_HOB_GUID_TYPE
*GuidHob
;
46 // Retrieve EmuThunkProtocol from GUID'ed HOB
48 GuidHob
= GetFirstGuidHob (&gEmuThunkProtocolGuid
);
49 ASSERT (GuidHob
!= NULL
);
50 mThunk
= (EMU_THUNK_PROTOCOL
*)(*(UINTN
*)(GET_GUID_HOB_DATA (GuidHob
)));
51 ASSERT (mThunk
!= NULL
);
57 Performs additional actions after a PE/COFF image has been loaded and relocated.
59 If ImageContext is NULL, then ASSERT().
61 @param ImageContext Pointer to the image context structure that describes the
62 PE/COFF image that has already been loaded and relocated.
67 PeCoffLoaderRelocateImageExtraAction (
68 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT
*ImageContext
72 mThunk
->PeCoffRelocateImageExtraAction (ImageContext
);
79 Performs additional actions just before a PE/COFF image is unloaded. Any resources
80 that were allocated by PeCoffLoaderRelocateImageExtraAction() must be freed.
82 If ImageContext is NULL, then ASSERT().
84 @param ImageContext Pointer to the image context structure that describes the
85 PE/COFF image that is being unloaded.
90 PeCoffLoaderUnloadImageExtraAction (
91 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT
*ImageContext
95 mThunk
->PeCoffUnloadImageExtraAction (ImageContext
);