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
;
29 The constructor function gets the pointer of the WinNT thunk functions
30 It will ASSERT() if Unix thunk protocol is not installed.
32 @retval EFI_SUCCESS Unix thunk protocol is found and cached.
37 DxeEmuPeCoffLibExtraActionConstructor (
38 IN EFI_HANDLE ImageHandle
,
39 IN EFI_SYSTEM_TABLE
*SystemTable
42 EFI_HOB_GUID_TYPE
*GuidHob
;
45 // Retrieve EmuThunkProtocol from GUID'ed HOB
47 GuidHob
= GetFirstGuidHob (&gEmuThunkProtocolGuid
);
48 ASSERT (GuidHob
!= NULL
);
49 mThunk
= (EMU_THUNK_PROTOCOL
*)(*(UINTN
*)(GET_GUID_HOB_DATA (GuidHob
)));
50 ASSERT (mThunk
!= NULL
);
56 Performs additional actions after a PE/COFF image has been loaded and relocated.
58 If ImageContext is NULL, then ASSERT().
60 @param ImageContext Pointer to the image context structure that describes the
61 PE/COFF image that has already been loaded and relocated.
66 PeCoffLoaderRelocateImageExtraAction (
67 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT
*ImageContext
71 mThunk
->PeCoffRelocateImageExtraAction (ImageContext
);
76 Performs additional actions just before a PE/COFF image is unloaded. Any resources
77 that were allocated by PeCoffLoaderRelocateImageExtraAction() must be freed.
79 If ImageContext is NULL, then ASSERT().
81 @param ImageContext Pointer to the image context structure that describes the
82 PE/COFF image that is being unloaded.
87 PeCoffLoaderUnloadImageExtraAction (
88 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT
*ImageContext
92 mThunk
->PeCoffUnloadImageExtraAction (ImageContext
);