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 This program and the accompanying materials
14 are licensed and made available under the terms and conditions of the BSD License
15 which accompanies this distribution. The full text of the license may be found at
16 http://opensource.org/licenses/bsd-license.php
18 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
19 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
24 #ifndef SE_TIME_ZONE_NAME
25 #define SE_TIME_ZONE_NAME TEXT("SeTimeZonePrivilege")
29 // Default information about where the FD is located.
30 // This array gets filled in with information from PcdWinNtFirmwareVolume
31 // The number of array elements is allocated base on parsing
32 // PcdWinNtFirmwareVolume and the memory is never freed.
34 UINTN gFdInfoCount
= 0;
38 // Array that supports seperate memory rantes.
39 // The memory ranges are set by PcdWinNtMemorySizeForSecMain.
40 // The number of array elements is allocated base on parsing
41 // PcdWinNtMemorySizeForSecMain value and the memory is never freed.
43 UINTN gSystemMemoryCount
= 0;
44 NT_SYSTEM_MEMORY
*gSystemMemory
;
49 This service is called from Index == 0 until it returns EFI_UNSUPPORTED.
50 It allows discontinuous memory regions to be supported by the emulator.
51 It uses gSystemMemory[] and gSystemMemoryCount that were created by
52 parsing the host environment variable EFI_MEMORY_SIZE.
53 The size comes from the varaible and the address comes from the call to
57 Index - Which memory region to use
58 MemoryBase - Return Base address of memory region
59 MemorySize - Return size in bytes of the memory region
62 EFI_SUCCESS - If memory region was mapped
63 EFI_UNSUPPORTED - If Index is not supported
69 OUT EFI_PHYSICAL_ADDRESS
*MemoryBase
,
70 OUT UINT64
*MemorySize
73 if (Index
>= gSystemMemoryCount
) {
74 return EFI_UNSUPPORTED
;
78 // Allocate enough memory space for emulator
80 gSystemMemory
[Index
].Memory
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) VirtualAlloc (NULL
, (SIZE_T
) (gSystemMemory
[Index
].Size
), MEM_COMMIT
, PAGE_EXECUTE_READWRITE
);
81 if (gSystemMemory
[Index
].Memory
== 0) {
82 return EFI_OUT_OF_RESOURCES
;
85 *MemoryBase
= gSystemMemory
[Index
].Memory
;
86 *MemorySize
= gSystemMemory
[Index
].Size
;
94 Return the FD Size and base address. Since the FD is loaded from a
95 file into host memory only the SEC will know it's address.
98 Index - Which FD, starts at zero.
99 FdSize - Size of the FD in bytes
100 FdBase - Start address of the FD. Assume it points to an FV Header
101 FixUp - Difference between actual FD address and build address
104 EFI_SUCCESS - Return the Base address and size of the FV
105 EFI_UNSUPPORTED - Index does nto map to an FD in the system
111 IN OUT EFI_PHYSICAL_ADDRESS
*FdBase
,
112 IN OUT UINT64
*FdSize
,
113 IN OUT EFI_PHYSICAL_ADDRESS
*FixUp
116 if (Index
>= gFdInfoCount
) {
117 return EFI_UNSUPPORTED
;
121 *FdBase
= (EFI_PHYSICAL_ADDRESS
)(UINTN
)gFdInfo
[Index
].Address
;
122 *FdSize
= (UINT64
)gFdInfo
[Index
].Size
;
125 if (*FdBase
== 0 && *FdSize
== 0) {
126 return EFI_UNSUPPORTED
;
131 // FD 0 has XIP code and well known PCD values
132 // If the memory buffer could not be allocated at the FD build address
133 // the Fixup is the difference.
135 *FixUp
= *FdBase
- PcdGet64 (PcdEmuFdBaseAddress
);
144 Since the SEC is the only Unix program in stack it must export
145 an interface to do POSIX calls. gUnix is initialized in UnixThunk.c.
148 InterfaceSize - sizeof (EFI_WIN_NT_THUNK_PROTOCOL);
149 InterfaceBase - Address of the gUnix global
152 EFI_SUCCESS - Data returned
160 return &gEmuThunkProtocol
;
164 EMU_THUNK_PPI mSecEmuThunkPpi
= {
178 CHAR8 Buffer
[0x1000];
180 va_start (Marker
, Format
);
182 _vsnprintf (Buffer
, sizeof (Buffer
), Format
, Marker
);
186 CharCount
= strlen (Buffer
);
188 GetStdHandle (STD_OUTPUT_HANDLE
),
199 Check to see if an address range is in the EFI GCD memory map.
201 This is all of GCD for system memory passed to DXE Core. FV
202 mapping and other device mapped into system memory are not
203 inlcuded in the check.
206 Index - Which memory region to use
207 MemoryBase - Return Base address of memory region
208 MemorySize - Return size in bytes of the memory region
211 TRUE - Address is in the EFI GCD memory map
212 FALSE - Address is NOT in memory map
216 EfiSystemMemoryRange (
217 IN VOID
*MemoryAddress
221 EFI_PHYSICAL_ADDRESS MemoryBase
;
223 MemoryBase
= (EFI_PHYSICAL_ADDRESS
)(UINTN
)MemoryAddress
;
224 for (Index
= 0; Index
< gSystemMemoryCount
; Index
++) {
225 if ((MemoryBase
>= gSystemMemory
[Index
].Memory
) &&
226 (MemoryBase
< (gSystemMemory
[Index
].Memory
+ gSystemMemory
[Index
].Size
)) ) {
237 IN CHAR16
*FileName
, OPTIONAL
239 IN DWORD CreationDisposition
,
240 IN OUT VOID
**BaseAddress
,
246 Opens and memory maps a file using WinNt services. If *BaseAddress is non zero
247 the process will try and allocate the memory starting at BaseAddress.
250 FileName - The name of the file to open and map
251 MapSize - The amount of the file to map in bytes
252 CreationDisposition - The flags to pass to CreateFile(). Use to create new files for
253 memory emulation, and exiting files for firmware volume emulation
254 BaseAddress - The base address of the mapped file in the user address space.
255 If *BaseAddress is 0, the new memory region is used.
256 If *BaseAddress is not 0, the request memory region is used for
257 the mapping of the file into the process space.
258 Length - The size of the mapped region in bytes
261 EFI_SUCCESS - The file was opened and mapped.
262 EFI_NOT_FOUND - FileName was not found in the current directory
263 EFI_DEVICE_ERROR - An error occured attempting to map the opened file
269 VOID
*VirtualAddress
;
273 // Use Win API to open/create a file
275 NtFileHandle
= INVALID_HANDLE_VALUE
;
276 if (FileName
!= NULL
) {
277 NtFileHandle
= CreateFile (
279 GENERIC_READ
| GENERIC_WRITE
| GENERIC_EXECUTE
,
283 FILE_ATTRIBUTE_NORMAL
,
286 if (NtFileHandle
== INVALID_HANDLE_VALUE
) {
287 return EFI_NOT_FOUND
;
291 // Map the open file into a memory range
293 NtMapHandle
= CreateFileMapping (
296 PAGE_EXECUTE_READWRITE
,
301 if (NtMapHandle
== NULL
) {
302 return EFI_DEVICE_ERROR
;
305 // Get the virtual address (address in the emulator) of the mapped file
307 VirtualAddress
= MapViewOfFileEx (
309 FILE_MAP_EXECUTE
| FILE_MAP_ALL_ACCESS
,
315 if (VirtualAddress
== NULL
) {
316 return EFI_DEVICE_ERROR
;
321 // Seek to the end of the file to figure out the true file size.
323 FileSize
= SetFilePointer (
329 if (FileSize
== -1) {
330 return EFI_DEVICE_ERROR
;
338 *BaseAddress
= VirtualAddress
;
353 Main entry point to SEC for WinNt. This is a Windows program
356 Argc - Number of command line arguments
357 Argv - Array of command line argument strings
358 Envp - Array of environment variable strings
368 TOKEN_PRIVILEGES TokenPrivileges
;
370 UINT32 TemporaryRamSize
;
377 EFI_PEI_FILE_HANDLE FileHandle
;
379 CHAR16
*MemorySizeStr
;
380 CHAR16
*FirmwareVolumesStr
;
381 UINT32 ProcessAffinityMask
;
382 UINT32 SystemAffinityMask
;
386 // Enable the privilege so that RTC driver can successfully run SetTime()
388 OpenProcessToken (GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES
|TOKEN_QUERY
, &Token
);
389 if (LookupPrivilegeValue(NULL
, SE_TIME_ZONE_NAME
, &TokenPrivileges
.Privileges
[0].Luid
)) {
390 TokenPrivileges
.PrivilegeCount
= 1;
391 TokenPrivileges
.Privileges
[0].Attributes
= SE_PRIVILEGE_ENABLED
;
392 AdjustTokenPrivileges(Token
, FALSE
, &TokenPrivileges
, 0, (PTOKEN_PRIVILEGES
) NULL
, 0);
395 MemorySizeStr
= (CHAR16
*) PcdGetPtr (PcdEmuMemorySize
);
396 FirmwareVolumesStr
= (CHAR16
*) PcdGetPtr (PcdEmuFirmwareVolume
);
398 SecPrint ("\nEDK II WIN Host Emulation Environment from http://www.tianocore.org/edk2/\n");
401 // Determine the first thread available to this process.
403 if (GetProcessAffinityMask (GetCurrentProcess (), &ProcessAffinityMask
, &SystemAffinityMask
)) {
404 LowBit
= (INT32
)LowBitSet32 (ProcessAffinityMask
);
407 // Force the system to bind the process to a single thread to work
408 // around odd semaphore type crashes.
410 SetProcessAffinityMask (GetCurrentProcess (), (INTN
)(BIT0
<< LowBit
));
415 // Make some Windows calls to Set the process to the highest priority in the
416 // idle class. We need this to have good performance.
418 SetPriorityClass (GetCurrentProcess (), IDLE_PRIORITY_CLASS
);
419 SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_HIGHEST
);
421 SecInitializeThunk ();
423 // PPIs pased into PEI_CORE
425 AddThunkPpi (EFI_PEI_PPI_DESCRIPTOR_PPI
, &gEmuThunkPpiGuid
, &mSecEmuThunkPpi
);
428 // Emulator Bus Driver Thunks
430 AddThunkProtocol (&mWinNtWndThunkIo
, (CHAR16
*)PcdGetPtr (PcdEmuGop
), TRUE
);
431 AddThunkProtocol (&mWinNtFileSystemThunkIo
, (CHAR16
*)PcdGetPtr (PcdEmuFileSystem
), TRUE
);
432 AddThunkProtocol (&mWinNtBlockIoThunkIo
, (CHAR16
*)PcdGetPtr (PcdEmuVirtualDisk
), TRUE
);
435 // Allocate space for gSystemMemory Array
437 gSystemMemoryCount
= CountSeparatorsInString (MemorySizeStr
, '!') + 1;
438 gSystemMemory
= calloc (gSystemMemoryCount
, sizeof (NT_SYSTEM_MEMORY
));
439 if (gSystemMemory
== NULL
) {
440 SecPrint ("ERROR : Can not allocate memory for %S. Exiting.\n", MemorySizeStr
);
445 // Allocate space for gSystemMemory Array
447 gFdInfoCount
= CountSeparatorsInString (FirmwareVolumesStr
, '!') + 1;
448 gFdInfo
= calloc (gFdInfoCount
, sizeof (NT_FD_INFO
));
449 if (gFdInfo
== NULL
) {
450 SecPrint ("ERROR : Can not allocate memory for %S. Exiting.\n", FirmwareVolumesStr
);
456 SecPrint (" BootMode 0x%02x\n", PcdGet32 (PcdEmuBootMode
));
459 // Allocate 128K memory to emulate temp memory for PEI.
460 // on a real platform this would be SRAM, or using the cache as RAM.
461 // Set TemporaryRam to zero so WinNtOpenFile will allocate a new mapping
463 TemporaryRamSize
= TEMPORARY_RAM_SIZE
;
464 TemporaryRam
= VirtualAlloc (NULL
, (SIZE_T
) (TemporaryRamSize
), MEM_COMMIT
, PAGE_EXECUTE_READWRITE
);
465 if (TemporaryRam
== NULL
) {
466 SecPrint ("ERROR : Can not allocate enough space for SecStack\n");
469 SetMem32 (TemporaryRam
, TemporaryRamSize
, PcdGet32 (PcdInitValueInTempStack
));
471 SecPrint (" OS Emulator passing in %u KB of temp RAM at 0x%08lx to SEC\n",
472 TemporaryRamSize
/ SIZE_1KB
,
477 // If enabled use the magic page to communicate between modules
478 // This replaces the PI PeiServicesTable pointer mechanism that
479 // deos not work in the emulator. It also allows the removal of
480 // writable globals from SEC, PEI_CORE (libraries), PEIMs
482 EmuMagicPage
= (VOID
*)(UINTN
)(FixedPcdGet64 (PcdPeiServicesTablePage
) & MAX_UINTN
);
483 if (EmuMagicPage
!= NULL
) {
485 Status
= WinNtOpenFile (
492 if (EFI_ERROR (Status
)) {
493 SecPrint ("ERROR : Could not allocate PeiServicesTablePage @ %p\n", EmuMagicPage
);
494 return EFI_DEVICE_ERROR
;
499 // Open All the firmware volumes and remember the info in the gFdInfo global
500 // Meanwhile, find the SEC Core.
502 FileNamePtr
= AllocateCopyPool (StrSize (FirmwareVolumesStr
), FirmwareVolumesStr
);
503 if (FileNamePtr
== NULL
) {
504 SecPrint ("ERROR : Can not allocate memory for firmware volume string\n");
508 for (Done
= FALSE
, Index
= 0, SecFile
= NULL
; !Done
; Index
++) {
509 FileName
= FileNamePtr
;
510 for (Index1
= 0; (FileNamePtr
[Index1
] != '!') && (FileNamePtr
[Index1
] != 0); Index1
++)
512 if (FileNamePtr
[Index1
] == 0) {
515 FileNamePtr
[Index1
] = '\0';
516 FileNamePtr
= &FileNamePtr
[Index1
+ 1];
520 // Open the FD and remember where it got mapped into our processes address space
522 Status
= WinNtOpenFile (
526 &gFdInfo
[Index
].Address
,
529 if (EFI_ERROR (Status
)) {
530 SecPrint ("ERROR : Can not open Firmware Device File %S (0x%X). Exiting.\n", FileName
, Status
);
534 SecPrint (" FD loaded from %S\n", FileName
);
536 if (SecFile
== NULL
) {
538 // Assume the beginning of the FD is an FV and look for the SEC Core.
539 // Load the first one we find.
542 Status
= PeiServicesFfsFindNextFile (
543 EFI_FV_FILETYPE_SECURITY_CORE
,
544 (EFI_PEI_FV_HANDLE
)gFdInfo
[Index
].Address
,
547 if (!EFI_ERROR (Status
)) {
548 Status
= PeiServicesFfsFindSectionData (EFI_SECTION_PE32
, FileHandle
, &SecFile
);
549 if (!EFI_ERROR (Status
)) {
550 SecPrint (" contains SEC Core");
558 // Calculate memory regions and store the information in the gSystemMemory
559 // global for later use. The autosizing code will use this data to
560 // map this memory into the SEC process memory space.
562 for (Index
= 0, Done
= FALSE
; !Done
; Index
++) {
564 // Save the size of the memory and make a Unicode filename SystemMemory00, ...
566 gSystemMemory
[Index
].Size
= _wtoi (MemorySizeStr
) * SIZE_1MB
;
569 // Find the next region
571 for (Index1
= 0; MemorySizeStr
[Index1
] != '!' && MemorySizeStr
[Index1
] != 0; Index1
++)
573 if (MemorySizeStr
[Index1
] == 0) {
577 MemorySizeStr
= MemorySizeStr
+ Index1
+ 1;
583 // Hand off to SEC Core
585 SecLoadSecCore ((UINTN
)TemporaryRam
, TemporaryRamSize
, gFdInfo
[0].Address
, gFdInfo
[0].Size
, SecFile
);
588 // If we get here, then the SEC Core returned. This is an error as SEC should
589 // always hand off to PEI Core and then on to DXE Core.
591 SecPrint ("ERROR : SEC returned\n");
597 IN UINTN TemporaryRam
,
598 IN UINTN TemporaryRamSize
,
599 IN VOID
*BootFirmwareVolumeBase
,
600 IN UINTN BootFirmwareVolumeSize
,
601 IN VOID
*SecCorePe32File
606 This is the service to load the SEC Core from the Firmware Volume
609 TemporaryRam - Memory to use for SEC.
610 TemporaryRamSize - Size of Memory to use for SEC
611 BootFirmwareVolumeBase - Start of the Boot FV
612 SecCorePe32File - SEC Core PE32
615 Success means control is transfered and thus we should never return
621 VOID
*SecCoreEntryPoint
;
622 EFI_SEC_PEI_HAND_OFF
*SecCoreData
;
626 // Compute Top Of Memory for Stack and PEI Core Allocations
628 SecStackSize
= TemporaryRamSize
>> 1;
631 // |-----------| <---- TemporaryRamBase + TemporaryRamSize
634 // |-----------| <---- StackBase / PeiTemporaryMemoryBase
637 // |-----------| <---- TemporaryRamBase
639 TopOfStack
= (VOID
*)(TemporaryRam
+ SecStackSize
);
642 // Reservet space for storing PeiCore's parament in stack.
644 TopOfStack
= (VOID
*)((UINTN
)TopOfStack
- sizeof (EFI_SEC_PEI_HAND_OFF
) - CPU_STACK_ALIGNMENT
);
645 TopOfStack
= ALIGN_POINTER (TopOfStack
, CPU_STACK_ALIGNMENT
);
648 // Bind this information into the SEC hand-off state
650 SecCoreData
= (EFI_SEC_PEI_HAND_OFF
*)(UINTN
)TopOfStack
;
651 SecCoreData
->DataSize
= sizeof (EFI_SEC_PEI_HAND_OFF
);
652 SecCoreData
->BootFirmwareVolumeBase
= BootFirmwareVolumeBase
;
653 SecCoreData
->BootFirmwareVolumeSize
= BootFirmwareVolumeSize
;
654 SecCoreData
->TemporaryRamBase
= (VOID
*)TemporaryRam
;
655 SecCoreData
->TemporaryRamSize
= TemporaryRamSize
;
656 SecCoreData
->StackBase
= SecCoreData
->TemporaryRamBase
;
657 SecCoreData
->StackSize
= SecStackSize
;
658 SecCoreData
->PeiTemporaryRamBase
= (VOID
*) ((UINTN
) SecCoreData
->TemporaryRamBase
+ SecStackSize
);
659 SecCoreData
->PeiTemporaryRamSize
= TemporaryRamSize
- SecStackSize
;
662 // Load the PEI Core from a Firmware Volume
664 Status
= SecPeCoffGetEntryPoint (
668 if (EFI_ERROR (Status
)) {
673 // Transfer control to the SEC Core
676 (SWITCH_STACK_ENTRY_POINT
)(UINTN
)SecCoreEntryPoint
,
682 // If we get here, then the SEC Core returned. This is an error
689 SecPeCoffGetEntryPoint (
691 IN OUT VOID
**EntryPoint
695 PE_COFF_LOADER_IMAGE_CONTEXT ImageContext
;
697 ZeroMem (&ImageContext
, sizeof (ImageContext
));
698 ImageContext
.Handle
= Pe32Data
;
700 ImageContext
.ImageRead
= (PE_COFF_LOADER_READ_FILE
) SecImageRead
;
702 Status
= PeCoffLoaderGetImageInfo (&ImageContext
);
703 if (EFI_ERROR (Status
)) {
707 // Allocate space in NT (not emulator) memory with ReadWrite and Execute attribute.
708 // Extra space is for alignment
710 ImageContext
.ImageAddress
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) VirtualAlloc (NULL
, (SIZE_T
) (ImageContext
.ImageSize
+ (ImageContext
.SectionAlignment
* 2)), MEM_COMMIT
, PAGE_EXECUTE_READWRITE
);
711 if (ImageContext
.ImageAddress
== 0) {
712 return EFI_OUT_OF_RESOURCES
;
715 // Align buffer on section boundary
717 ImageContext
.ImageAddress
+= ImageContext
.SectionAlignment
- 1;
718 ImageContext
.ImageAddress
&= ~((EFI_PHYSICAL_ADDRESS
)ImageContext
.SectionAlignment
- 1);
720 Status
= PeCoffLoaderLoadImage (&ImageContext
);
721 if (EFI_ERROR (Status
)) {
725 Status
= PeCoffLoaderRelocateImage (&ImageContext
);
726 if (EFI_ERROR (Status
)) {
730 *EntryPoint
= (VOID
*)(UINTN
)ImageContext
.EntryPoint
;
740 IN OUT UINTN
*ReadSize
,
746 Support routine for the PE/COFF Loader that reads a buffer from a PE/COFF file
749 FileHandle - The handle to the PE/COFF file
750 FileOffset - The offset, in bytes, into the file to read
751 ReadSize - The number of bytes to read from the file starting at FileOffset
752 Buffer - A pointer to the buffer to read the data into.
755 EFI_SUCCESS - ReadSize bytes of data were read into Buffer from the PE/COFF file starting at FileOffset
763 Destination8
= Buffer
;
764 Source8
= (CHAR8
*) ((UINTN
) FileHandle
+ FileOffset
);
767 *(Destination8
++) = *(Source8
++);
776 IN UINTN
*StrLen OPTIONAL
781 Convert the passed in Ascii string to Unicode.
782 Optionally return the length of the strings.
785 Ascii - Ascii string to convert
786 StrLen - Length of string
789 Pointer to malloc'ed Unicode version of Ascii
797 // Allocate a buffer for unicode string
799 for (Index
= 0; Ascii
[Index
] != '\0'; Index
++)
801 Unicode
= malloc ((Index
+ 1) * sizeof (CHAR16
));
802 if (Unicode
== NULL
) {
806 for (Index
= 0; Ascii
[Index
] != '\0'; Index
++) {
807 Unicode
[Index
] = (CHAR16
) Ascii
[Index
];
810 Unicode
[Index
] = '\0';
812 if (StrLen
!= NULL
) {
820 CountSeparatorsInString (
821 IN CONST CHAR16
*String
,
827 Count the number of separators in String
830 String - String to process
831 Separator - Item to count
834 Number of Separator in String
840 for (Count
= 0; *String
!= '\0'; String
++) {
841 if (*String
== Separator
) {
852 PeCoffLoaderRelocateImageExtraAction (
853 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT
*ImageContext
861 ASSERT (ImageContext
!= NULL
);
863 // If we load our own PE COFF images the Windows debugger can not source
864 // level debug our code. If a valid PDB pointer exists usw it to load
865 // the *.dll file as a library using Windows* APIs. This allows
866 // source level debug. The image is still loaded and relocated
867 // in the Framework memory space like on a real system (by the code above),
868 // but the entry point points into the DLL loaded by the code bellow.
871 DllEntryPoint
= NULL
;
874 // Load the DLL if it's not an EBC image.
876 if ((ImageContext
->PdbPointer
!= NULL
) &&
877 (ImageContext
->Machine
!= EFI_IMAGE_MACHINE_EBC
)) {
879 // Convert filename from ASCII to Unicode
881 DllFileName
= AsciiToUnicode (ImageContext
->PdbPointer
, &Index
);
884 // Check that we have a valid filename
886 if (Index
< 5 || DllFileName
[Index
- 4] != '.') {
890 // Never return an error if PeCoffLoaderRelocateImage() succeeded.
891 // The image will run, but we just can't source level debug. If we
892 // return an error the image will not run.
897 // Replace .PDB with .DLL on the filename
899 DllFileName
[Index
- 3] = 'D';
900 DllFileName
[Index
- 2] = 'L';
901 DllFileName
[Index
- 1] = 'L';
904 // Load the .DLL file into the user process's address space for source
907 Library
= LoadLibraryEx (DllFileName
, NULL
, DONT_RESOLVE_DLL_REFERENCES
);
908 if (Library
!= NULL
) {
910 // InitializeDriver is the entry point we put in all our EFI DLL's. The
911 // DONT_RESOLVE_DLL_REFERENCES argument to LoadLIbraryEx() suppresses the
912 // normal DLL entry point of DllMain, and prevents other modules that are
913 // referenced in side the DllFileName from being loaded. There is no error
914 // checking as the we can point to the PE32 image loaded by Tiano. This
915 // step is only needed for source level debugging
917 DllEntryPoint
= (VOID
*) (UINTN
) GetProcAddress (Library
, "InitializeDriver");
921 if ((Library
!= NULL
) && (DllEntryPoint
!= NULL
)) {
922 ImageContext
->EntryPoint
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) DllEntryPoint
;
923 SecPrint ("LoadLibraryEx (%S,\n NULL, DONT_RESOLVE_DLL_REFERENCES)\n", DllFileName
);
925 SecPrint ("WARNING: No source level debug %S. \n", DllFileName
);
934 PeCoffLoaderUnloadImageExtraAction (
935 IN PE_COFF_LOADER_IMAGE_CONTEXT
*ImageContext
938 ASSERT (ImageContext
!= NULL
);