2 WinNt emulator of pre-SEC phase. It's really a Win32 application, but this is
3 Ok since all the other modules for NT32 are NOT Win32 applications.
5 This program gets NT32 PCD setting and figures out what the memory layout
6 will be, how may FD's will be loaded and also what the boot mode is.
8 This code produces 128 K of temporary memory for the SEC stack by directly
9 allocate memory space with ReadWrite and Execute attribute.
11 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
12 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
13 SPDX-License-Identifier: BSD-2-Clause-Patent
18 #ifndef SE_TIME_ZONE_NAME
19 #define SE_TIME_ZONE_NAME TEXT("SeTimeZonePrivilege")
23 // Default information about where the FD is located.
24 // This array gets filled in with information from PcdWinNtFirmwareVolume
25 // The number of array elements is allocated base on parsing
26 // PcdWinNtFirmwareVolume and the memory is never freed.
28 UINTN gFdInfoCount
= 0;
32 // Array that supports seperate memory rantes.
33 // The memory ranges are set by PcdWinNtMemorySizeForSecMain.
34 // The number of array elements is allocated base on parsing
35 // PcdWinNtMemorySizeForSecMain value and the memory is never freed.
37 UINTN gSystemMemoryCount
= 0;
38 NT_SYSTEM_MEMORY
*gSystemMemory
;
43 This service is called from Index == 0 until it returns EFI_UNSUPPORTED.
44 It allows discontinuous memory regions to be supported by the emulator.
45 It uses gSystemMemory[] and gSystemMemoryCount that were created by
46 parsing the host environment variable EFI_MEMORY_SIZE.
47 The size comes from the varaible and the address comes from the call to
51 Index - Which memory region to use
52 MemoryBase - Return Base address of memory region
53 MemorySize - Return size in bytes of the memory region
56 EFI_SUCCESS - If memory region was mapped
57 EFI_UNSUPPORTED - If Index is not supported
63 OUT EFI_PHYSICAL_ADDRESS
*MemoryBase
,
64 OUT UINT64
*MemorySize
67 if (Index
>= gSystemMemoryCount
) {
68 return EFI_UNSUPPORTED
;
72 // Allocate enough memory space for emulator
74 gSystemMemory
[Index
].Memory
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) VirtualAlloc (NULL
, (SIZE_T
) (gSystemMemory
[Index
].Size
), MEM_COMMIT
, PAGE_EXECUTE_READWRITE
);
75 if (gSystemMemory
[Index
].Memory
== 0) {
76 return EFI_OUT_OF_RESOURCES
;
79 *MemoryBase
= gSystemMemory
[Index
].Memory
;
80 *MemorySize
= gSystemMemory
[Index
].Size
;
88 Return the FD Size and base address. Since the FD is loaded from a
89 file into host memory only the SEC will know it's address.
92 Index - Which FD, starts at zero.
93 FdSize - Size of the FD in bytes
94 FdBase - Start address of the FD. Assume it points to an FV Header
95 FixUp - Difference between actual FD address and build address
98 EFI_SUCCESS - Return the Base address and size of the FV
99 EFI_UNSUPPORTED - Index does nto map to an FD in the system
105 IN OUT EFI_PHYSICAL_ADDRESS
*FdBase
,
106 IN OUT UINT64
*FdSize
,
107 IN OUT EFI_PHYSICAL_ADDRESS
*FixUp
110 if (Index
>= gFdInfoCount
) {
111 return EFI_UNSUPPORTED
;
115 *FdBase
= (EFI_PHYSICAL_ADDRESS
)(UINTN
)gFdInfo
[Index
].Address
;
116 *FdSize
= (UINT64
)gFdInfo
[Index
].Size
;
119 if (*FdBase
== 0 && *FdSize
== 0) {
120 return EFI_UNSUPPORTED
;
125 // FD 0 has XIP code and well known PCD values
126 // If the memory buffer could not be allocated at the FD build address
127 // the Fixup is the difference.
129 *FixUp
= *FdBase
- PcdGet64 (PcdEmuFdBaseAddress
);
138 Since the SEC is the only Unix program in stack it must export
139 an interface to do POSIX calls. gUnix is initialized in UnixThunk.c.
142 InterfaceSize - sizeof (EFI_WIN_NT_THUNK_PROTOCOL);
143 InterfaceBase - Address of the gUnix global
146 EFI_SUCCESS - Data returned
154 return &gEmuThunkProtocol
;
158 EMU_THUNK_PPI mSecEmuThunkPpi
= {
172 CHAR8 Buffer
[0x1000];
174 va_start (Marker
, Format
);
176 _vsnprintf (Buffer
, sizeof (Buffer
), Format
, Marker
);
180 CharCount
= strlen (Buffer
);
182 GetStdHandle (STD_OUTPUT_HANDLE
),
193 Check to see if an address range is in the EFI GCD memory map.
195 This is all of GCD for system memory passed to DXE Core. FV
196 mapping and other device mapped into system memory are not
197 inlcuded in the check.
200 Index - Which memory region to use
201 MemoryBase - Return Base address of memory region
202 MemorySize - Return size in bytes of the memory region
205 TRUE - Address is in the EFI GCD memory map
206 FALSE - Address is NOT in memory map
210 EfiSystemMemoryRange (
211 IN VOID
*MemoryAddress
215 EFI_PHYSICAL_ADDRESS MemoryBase
;
217 MemoryBase
= (EFI_PHYSICAL_ADDRESS
)(UINTN
)MemoryAddress
;
218 for (Index
= 0; Index
< gSystemMemoryCount
; Index
++) {
219 if ((MemoryBase
>= gSystemMemory
[Index
].Memory
) &&
220 (MemoryBase
< (gSystemMemory
[Index
].Memory
+ gSystemMemory
[Index
].Size
)) ) {
231 IN CHAR16
*FileName
, OPTIONAL
233 IN DWORD CreationDisposition
,
234 IN OUT VOID
**BaseAddress
,
240 Opens and memory maps a file using WinNt services. If *BaseAddress is non zero
241 the process will try and allocate the memory starting at BaseAddress.
244 FileName - The name of the file to open and map
245 MapSize - The amount of the file to map in bytes
246 CreationDisposition - The flags to pass to CreateFile(). Use to create new files for
247 memory emulation, and exiting files for firmware volume emulation
248 BaseAddress - The base address of the mapped file in the user address space.
249 If *BaseAddress is 0, the new memory region is used.
250 If *BaseAddress is not 0, the request memory region is used for
251 the mapping of the file into the process space.
252 Length - The size of the mapped region in bytes
255 EFI_SUCCESS - The file was opened and mapped.
256 EFI_NOT_FOUND - FileName was not found in the current directory
257 EFI_DEVICE_ERROR - An error occured attempting to map the opened file
263 VOID
*VirtualAddress
;
267 // Use Win API to open/create a file
269 NtFileHandle
= INVALID_HANDLE_VALUE
;
270 if (FileName
!= NULL
) {
271 NtFileHandle
= CreateFile (
273 GENERIC_READ
| GENERIC_WRITE
| GENERIC_EXECUTE
,
277 FILE_ATTRIBUTE_NORMAL
,
280 if (NtFileHandle
== INVALID_HANDLE_VALUE
) {
281 return EFI_NOT_FOUND
;
285 // Map the open file into a memory range
287 NtMapHandle
= CreateFileMapping (
290 PAGE_EXECUTE_READWRITE
,
295 if (NtMapHandle
== NULL
) {
296 return EFI_DEVICE_ERROR
;
299 // Get the virtual address (address in the emulator) of the mapped file
301 VirtualAddress
= MapViewOfFileEx (
303 FILE_MAP_EXECUTE
| FILE_MAP_ALL_ACCESS
,
309 if (VirtualAddress
== NULL
) {
310 return EFI_DEVICE_ERROR
;
315 // Seek to the end of the file to figure out the true file size.
317 FileSize
= SetFilePointer (
323 if (FileSize
== -1) {
324 return EFI_DEVICE_ERROR
;
332 *BaseAddress
= VirtualAddress
;
347 Main entry point to SEC for WinNt. This is a Windows program
350 Argc - Number of command line arguments
351 Argv - Array of command line argument strings
352 Envp - Array of environment variable strings
362 TOKEN_PRIVILEGES TokenPrivileges
;
364 UINT32 TemporaryRamSize
;
371 EFI_PEI_FILE_HANDLE FileHandle
;
373 CHAR16
*MemorySizeStr
;
374 CHAR16
*FirmwareVolumesStr
;
375 UINT32 ProcessAffinityMask
;
376 UINT32 SystemAffinityMask
;
380 // Enable the privilege so that RTC driver can successfully run SetTime()
382 OpenProcessToken (GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES
|TOKEN_QUERY
, &Token
);
383 if (LookupPrivilegeValue(NULL
, SE_TIME_ZONE_NAME
, &TokenPrivileges
.Privileges
[0].Luid
)) {
384 TokenPrivileges
.PrivilegeCount
= 1;
385 TokenPrivileges
.Privileges
[0].Attributes
= SE_PRIVILEGE_ENABLED
;
386 AdjustTokenPrivileges(Token
, FALSE
, &TokenPrivileges
, 0, (PTOKEN_PRIVILEGES
) NULL
, 0);
389 MemorySizeStr
= (CHAR16
*) PcdGetPtr (PcdEmuMemorySize
);
390 FirmwareVolumesStr
= (CHAR16
*) PcdGetPtr (PcdEmuFirmwareVolume
);
392 SecPrint ("\nEDK II WIN Host Emulation Environment from http://www.tianocore.org/edk2/\n");
395 // Determine the first thread available to this process.
397 if (GetProcessAffinityMask (GetCurrentProcess (), &ProcessAffinityMask
, &SystemAffinityMask
)) {
398 LowBit
= (INT32
)LowBitSet32 (ProcessAffinityMask
);
401 // Force the system to bind the process to a single thread to work
402 // around odd semaphore type crashes.
404 SetProcessAffinityMask (GetCurrentProcess (), (INTN
)(BIT0
<< LowBit
));
409 // Make some Windows calls to Set the process to the highest priority in the
410 // idle class. We need this to have good performance.
412 SetPriorityClass (GetCurrentProcess (), IDLE_PRIORITY_CLASS
);
413 SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_HIGHEST
);
415 SecInitializeThunk ();
417 // PPIs pased into PEI_CORE
419 AddThunkPpi (EFI_PEI_PPI_DESCRIPTOR_PPI
, &gEmuThunkPpiGuid
, &mSecEmuThunkPpi
);
422 // Emulator Bus Driver Thunks
424 AddThunkProtocol (&mWinNtWndThunkIo
, (CHAR16
*)PcdGetPtr (PcdEmuGop
), TRUE
);
425 AddThunkProtocol (&mWinNtFileSystemThunkIo
, (CHAR16
*)PcdGetPtr (PcdEmuFileSystem
), TRUE
);
426 AddThunkProtocol (&mWinNtBlockIoThunkIo
, (CHAR16
*)PcdGetPtr (PcdEmuVirtualDisk
), TRUE
);
429 // Allocate space for gSystemMemory Array
431 gSystemMemoryCount
= CountSeparatorsInString (MemorySizeStr
, '!') + 1;
432 gSystemMemory
= calloc (gSystemMemoryCount
, sizeof (NT_SYSTEM_MEMORY
));
433 if (gSystemMemory
== NULL
) {
434 SecPrint ("ERROR : Can not allocate memory for %S. Exiting.\n", MemorySizeStr
);
439 // Allocate space for gSystemMemory Array
441 gFdInfoCount
= CountSeparatorsInString (FirmwareVolumesStr
, '!') + 1;
442 gFdInfo
= calloc (gFdInfoCount
, sizeof (NT_FD_INFO
));
443 if (gFdInfo
== NULL
) {
444 SecPrint ("ERROR : Can not allocate memory for %S. Exiting.\n", FirmwareVolumesStr
);
450 SecPrint (" BootMode 0x%02x\n", PcdGet32 (PcdEmuBootMode
));
453 // Allocate 128K memory to emulate temp memory for PEI.
454 // on a real platform this would be SRAM, or using the cache as RAM.
455 // Set TemporaryRam to zero so WinNtOpenFile will allocate a new mapping
457 TemporaryRamSize
= TEMPORARY_RAM_SIZE
;
458 TemporaryRam
= VirtualAlloc (NULL
, (SIZE_T
) (TemporaryRamSize
), MEM_COMMIT
, PAGE_EXECUTE_READWRITE
);
459 if (TemporaryRam
== NULL
) {
460 SecPrint ("ERROR : Can not allocate enough space for SecStack\n");
463 SetMem32 (TemporaryRam
, TemporaryRamSize
, PcdGet32 (PcdInitValueInTempStack
));
465 SecPrint (" OS Emulator passing in %u KB of temp RAM at 0x%08lx to SEC\n",
466 TemporaryRamSize
/ SIZE_1KB
,
471 // If enabled use the magic page to communicate between modules
472 // This replaces the PI PeiServicesTable pointer mechanism that
473 // deos not work in the emulator. It also allows the removal of
474 // writable globals from SEC, PEI_CORE (libraries), PEIMs
476 EmuMagicPage
= (VOID
*)(UINTN
)(FixedPcdGet64 (PcdPeiServicesTablePage
) & MAX_UINTN
);
477 if (EmuMagicPage
!= NULL
) {
479 Status
= WinNtOpenFile (
486 if (EFI_ERROR (Status
)) {
487 SecPrint ("ERROR : Could not allocate PeiServicesTablePage @ %p\n", EmuMagicPage
);
488 return EFI_DEVICE_ERROR
;
493 // Open All the firmware volumes and remember the info in the gFdInfo global
494 // Meanwhile, find the SEC Core.
496 FileNamePtr
= AllocateCopyPool (StrSize (FirmwareVolumesStr
), FirmwareVolumesStr
);
497 if (FileNamePtr
== NULL
) {
498 SecPrint ("ERROR : Can not allocate memory for firmware volume string\n");
502 for (Done
= FALSE
, Index
= 0, SecFile
= NULL
; !Done
; Index
++) {
503 FileName
= FileNamePtr
;
504 for (Index1
= 0; (FileNamePtr
[Index1
] != '!') && (FileNamePtr
[Index1
] != 0); Index1
++)
506 if (FileNamePtr
[Index1
] == 0) {
509 FileNamePtr
[Index1
] = '\0';
510 FileNamePtr
= &FileNamePtr
[Index1
+ 1];
514 // Open the FD and remember where it got mapped into our processes address space
516 Status
= WinNtOpenFile (
520 &gFdInfo
[Index
].Address
,
523 if (EFI_ERROR (Status
)) {
524 SecPrint ("ERROR : Can not open Firmware Device File %S (0x%X). Exiting.\n", FileName
, Status
);
528 SecPrint (" FD loaded from %S\n", FileName
);
530 if (SecFile
== NULL
) {
532 // Assume the beginning of the FD is an FV and look for the SEC Core.
533 // Load the first one we find.
536 Status
= PeiServicesFfsFindNextFile (
537 EFI_FV_FILETYPE_SECURITY_CORE
,
538 (EFI_PEI_FV_HANDLE
)gFdInfo
[Index
].Address
,
541 if (!EFI_ERROR (Status
)) {
542 Status
= PeiServicesFfsFindSectionData (EFI_SECTION_PE32
, FileHandle
, &SecFile
);
543 if (!EFI_ERROR (Status
)) {
544 SecPrint (" contains SEC Core");
552 // Calculate memory regions and store the information in the gSystemMemory
553 // global for later use. The autosizing code will use this data to
554 // map this memory into the SEC process memory space.
556 for (Index
= 0, Done
= FALSE
; !Done
; Index
++) {
558 // Save the size of the memory and make a Unicode filename SystemMemory00, ...
560 gSystemMemory
[Index
].Size
= _wtoi (MemorySizeStr
) * SIZE_1MB
;
563 // Find the next region
565 for (Index1
= 0; MemorySizeStr
[Index1
] != '!' && MemorySizeStr
[Index1
] != 0; Index1
++)
567 if (MemorySizeStr
[Index1
] == 0) {
571 MemorySizeStr
= MemorySizeStr
+ Index1
+ 1;
577 // Hand off to SEC Core
579 SecLoadSecCore ((UINTN
)TemporaryRam
, TemporaryRamSize
, gFdInfo
[0].Address
, gFdInfo
[0].Size
, SecFile
);
582 // If we get here, then the SEC Core returned. This is an error as SEC should
583 // always hand off to PEI Core and then on to DXE Core.
585 SecPrint ("ERROR : SEC returned\n");
591 IN UINTN TemporaryRam
,
592 IN UINTN TemporaryRamSize
,
593 IN VOID
*BootFirmwareVolumeBase
,
594 IN UINTN BootFirmwareVolumeSize
,
595 IN VOID
*SecCorePe32File
600 This is the service to load the SEC Core from the Firmware Volume
603 TemporaryRam - Memory to use for SEC.
604 TemporaryRamSize - Size of Memory to use for SEC
605 BootFirmwareVolumeBase - Start of the Boot FV
606 SecCorePe32File - SEC Core PE32
609 Success means control is transfered and thus we should never return
615 VOID
*SecCoreEntryPoint
;
616 EFI_SEC_PEI_HAND_OFF
*SecCoreData
;
620 // Compute Top Of Memory for Stack and PEI Core Allocations
622 SecStackSize
= TemporaryRamSize
>> 1;
625 // |-----------| <---- TemporaryRamBase + TemporaryRamSize
628 // |-----------| <---- StackBase / PeiTemporaryMemoryBase
631 // |-----------| <---- TemporaryRamBase
633 TopOfStack
= (VOID
*)(TemporaryRam
+ SecStackSize
);
636 // Reservet space for storing PeiCore's parament in stack.
638 TopOfStack
= (VOID
*)((UINTN
)TopOfStack
- sizeof (EFI_SEC_PEI_HAND_OFF
) - CPU_STACK_ALIGNMENT
);
639 TopOfStack
= ALIGN_POINTER (TopOfStack
, CPU_STACK_ALIGNMENT
);
642 // Bind this information into the SEC hand-off state
644 SecCoreData
= (EFI_SEC_PEI_HAND_OFF
*)(UINTN
)TopOfStack
;
645 SecCoreData
->DataSize
= sizeof (EFI_SEC_PEI_HAND_OFF
);
646 SecCoreData
->BootFirmwareVolumeBase
= BootFirmwareVolumeBase
;
647 SecCoreData
->BootFirmwareVolumeSize
= BootFirmwareVolumeSize
;
648 SecCoreData
->TemporaryRamBase
= (VOID
*)TemporaryRam
;
649 SecCoreData
->TemporaryRamSize
= TemporaryRamSize
;
650 SecCoreData
->StackBase
= SecCoreData
->TemporaryRamBase
;
651 SecCoreData
->StackSize
= SecStackSize
;
652 SecCoreData
->PeiTemporaryRamBase
= (VOID
*) ((UINTN
) SecCoreData
->TemporaryRamBase
+ SecStackSize
);
653 SecCoreData
->PeiTemporaryRamSize
= TemporaryRamSize
- SecStackSize
;
656 // Load the PEI Core from a Firmware Volume
658 Status
= SecPeCoffGetEntryPoint (
662 if (EFI_ERROR (Status
)) {
667 // Transfer control to the SEC Core
670 (SWITCH_STACK_ENTRY_POINT
)(UINTN
)SecCoreEntryPoint
,
676 // If we get here, then the SEC Core returned. This is an error
683 SecPeCoffGetEntryPoint (
685 IN OUT VOID
**EntryPoint
689 PE_COFF_LOADER_IMAGE_CONTEXT ImageContext
;
691 ZeroMem (&ImageContext
, sizeof (ImageContext
));
692 ImageContext
.Handle
= Pe32Data
;
694 ImageContext
.ImageRead
= (PE_COFF_LOADER_READ_FILE
) SecImageRead
;
696 Status
= PeCoffLoaderGetImageInfo (&ImageContext
);
697 if (EFI_ERROR (Status
)) {
701 // Allocate space in NT (not emulator) memory with ReadWrite and Execute attribute.
702 // Extra space is for alignment
704 ImageContext
.ImageAddress
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) VirtualAlloc (NULL
, (SIZE_T
) (ImageContext
.ImageSize
+ (ImageContext
.SectionAlignment
* 2)), MEM_COMMIT
, PAGE_EXECUTE_READWRITE
);
705 if (ImageContext
.ImageAddress
== 0) {
706 return EFI_OUT_OF_RESOURCES
;
709 // Align buffer on section boundary
711 ImageContext
.ImageAddress
+= ImageContext
.SectionAlignment
- 1;
712 ImageContext
.ImageAddress
&= ~((EFI_PHYSICAL_ADDRESS
)ImageContext
.SectionAlignment
- 1);
714 Status
= PeCoffLoaderLoadImage (&ImageContext
);
715 if (EFI_ERROR (Status
)) {
719 Status
= PeCoffLoaderRelocateImage (&ImageContext
);
720 if (EFI_ERROR (Status
)) {
724 *EntryPoint
= (VOID
*)(UINTN
)ImageContext
.EntryPoint
;
734 IN OUT UINTN
*ReadSize
,
740 Support routine for the PE/COFF Loader that reads a buffer from a PE/COFF file
743 FileHandle - The handle to the PE/COFF file
744 FileOffset - The offset, in bytes, into the file to read
745 ReadSize - The number of bytes to read from the file starting at FileOffset
746 Buffer - A pointer to the buffer to read the data into.
749 EFI_SUCCESS - ReadSize bytes of data were read into Buffer from the PE/COFF file starting at FileOffset
757 Destination8
= Buffer
;
758 Source8
= (CHAR8
*) ((UINTN
) FileHandle
+ FileOffset
);
761 *(Destination8
++) = *(Source8
++);
770 IN UINTN
*StrLen OPTIONAL
775 Convert the passed in Ascii string to Unicode.
776 Optionally return the length of the strings.
779 Ascii - Ascii string to convert
780 StrLen - Length of string
783 Pointer to malloc'ed Unicode version of Ascii
791 // Allocate a buffer for unicode string
793 for (Index
= 0; Ascii
[Index
] != '\0'; Index
++)
795 Unicode
= malloc ((Index
+ 1) * sizeof (CHAR16
));
796 if (Unicode
== NULL
) {
800 for (Index
= 0; Ascii
[Index
] != '\0'; Index
++) {
801 Unicode
[Index
] = (CHAR16
) Ascii
[Index
];
804 Unicode
[Index
] = '\0';
806 if (StrLen
!= NULL
) {
814 CountSeparatorsInString (
815 IN CONST CHAR16
*String
,
821 Count the number of separators in String
824 String - String to process
825 Separator - Item to count
828 Number of Separator in String
834 for (Count
= 0; *String
!= '\0'; String
++) {
835 if (*String
== Separator
) {
846 PeCoffLoaderRelocateImageExtraAction (
847 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT
*ImageContext
855 ASSERT (ImageContext
!= NULL
);
857 // If we load our own PE COFF images the Windows debugger can not source
858 // level debug our code. If a valid PDB pointer exists usw it to load
859 // the *.dll file as a library using Windows* APIs. This allows
860 // source level debug. The image is still loaded and relocated
861 // in the Framework memory space like on a real system (by the code above),
862 // but the entry point points into the DLL loaded by the code bellow.
865 DllEntryPoint
= NULL
;
868 // Load the DLL if it's not an EBC image.
870 if ((ImageContext
->PdbPointer
!= NULL
) &&
871 (ImageContext
->Machine
!= EFI_IMAGE_MACHINE_EBC
)) {
873 // Convert filename from ASCII to Unicode
875 DllFileName
= AsciiToUnicode (ImageContext
->PdbPointer
, &Index
);
878 // Check that we have a valid filename
880 if (Index
< 5 || DllFileName
[Index
- 4] != '.') {
884 // Never return an error if PeCoffLoaderRelocateImage() succeeded.
885 // The image will run, but we just can't source level debug. If we
886 // return an error the image will not run.
891 // Replace .PDB with .DLL on the filename
893 DllFileName
[Index
- 3] = 'D';
894 DllFileName
[Index
- 2] = 'L';
895 DllFileName
[Index
- 1] = 'L';
898 // Load the .DLL file into the user process's address space for source
901 Library
= LoadLibraryEx (DllFileName
, NULL
, DONT_RESOLVE_DLL_REFERENCES
);
902 if (Library
!= NULL
) {
904 // InitializeDriver is the entry point we put in all our EFI DLL's. The
905 // DONT_RESOLVE_DLL_REFERENCES argument to LoadLIbraryEx() suppresses the
906 // normal DLL entry point of DllMain, and prevents other modules that are
907 // referenced in side the DllFileName from being loaded. There is no error
908 // checking as the we can point to the PE32 image loaded by Tiano. This
909 // step is only needed for source level debugging
911 DllEntryPoint
= (VOID
*) (UINTN
) GetProcAddress (Library
, "InitializeDriver");
915 if ((Library
!= NULL
) && (DllEntryPoint
!= NULL
)) {
916 ImageContext
->EntryPoint
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) DllEntryPoint
;
917 SecPrint ("LoadLibraryEx (%S,\n NULL, DONT_RESOLVE_DLL_REFERENCES)\n", DllFileName
);
919 SecPrint ("WARNING: No source level debug %S. \n", DllFileName
);
928 PeCoffLoaderUnloadImageExtraAction (
929 IN PE_COFF_LOADER_IMAGE_CONTEXT
*ImageContext
932 ASSERT (ImageContext
!= NULL
);