/**@file\r
\r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
Module Name:\r
\r
//\r
// The package level header files this module uses\r
//\r
-#include <FrameworkDxe.h>\r
#include <WinNtDxe.h>\r
\r
//\r
#include <Protocol/WinNtThunk.h>\r
\r
#include <Library/PeCoffLib.h>\r
-#include <Library/PeiServicesLib.h>\r
\r
#include <Library/BaseLib.h>\r
#include <Library/DebugLib.h>\r
**/\r
EFI_STATUS\r
EFIAPI\r
-DxeNt32PeCoffLibExtraActionConstructor (\r
- IN EFI_HANDLE ImageHandle,\r
- IN EFI_SYSTEM_TABLE *SystemTable\r
+Nt32PeCoffGetWinNtThunkStucture (\r
+ VOID\r
)\r
{\r
- EFI_HOB_GUID_TYPE *GuidHob;\r
+ EFI_HOB_GUID_TYPE *GuidHob;\r
\r
//\r
// Retrieve WinNtThunkProtocol from GUID'ed HOB\r
PDB_NAME_TO_MOD_HANDLE *TempArray;\r
HANDLE Handle;\r
\r
+ //\r
+ // Return EFI_ALREADY_STARTED if this DLL has already been loaded\r
+ //\r
+ Array = mPdbNameModHandleArray;\r
+ for (Index = 0; Index < mPdbNameModHandleArraySize; Index++, Array++) {\r
+ if (Array->PdbPointer != NULL && Array->ModHandle == ModHandle) {\r
+ return EFI_ALREADY_STARTED;\r
+ }\r
+ }\r
+ \r
Array = mPdbNameModHandleArray;\r
for (Index = 0; Index < mPdbNameModHandleArraySize; Index++, Array++) {\r
if (Array->PdbPointer == NULL) {\r
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r
)\r
{\r
+ EFI_STATUS Status;\r
VOID *DllEntryPoint;\r
CHAR16 *DllFileName;\r
HMODULE Library;\r
\r
ASSERT (ImageContext != NULL);\r
\r
- //\r
+ if (mWinNt == NULL) {\r
+ Nt32PeCoffGetWinNtThunkStucture ();\r
+ }\r
+\r
+ //\r
// If we load our own PE COFF images the Windows debugger can not source\r
// level debug our code. If a valid PDB pointer exists usw it to load\r
// the *.dll file as a library using Windows* APIs. This allows \r
- // source level debug. The image is still loaded and reloaced\r
+ // source level debug. The image is still loaded and relocated\r
// in the Framework memory space like on a real system (by the code above),\r
// but the entry point points into the DLL loaded by the code bellow. \r
//\r
if (Library != NULL) {\r
//\r
// InitializeDriver is the entry point we put in all our EFI DLL's. The\r
- // DONT_RESOLVE_DLL_REFERENCES argument to LoadLIbraryEx() supresses the \r
+ // DONT_RESOLVE_DLL_REFERENCES argument to LoadLIbraryEx() suppresses the \r
// normal DLL entry point of DllMain, and prevents other modules that are\r
// referenced in side the DllFileName from being loaded. There is no error \r
// checking as the we can point to the PE32 image loaded by Tiano. This \r
- // step is only needed for source level debuging\r
+ // step is only needed for source level debugging\r
//\r
DllEntryPoint = (VOID *) (UINTN) mWinNt->GetProcAddress (Library, "InitializeDriver");\r
\r
}\r
\r
if ((Library != NULL) && (DllEntryPoint != NULL)) {\r
- AddModHandle (ImageContext, Library);\r
- ImageContext->EntryPoint = (EFI_PHYSICAL_ADDRESS) (UINTN) DllEntryPoint;\r
- DEBUG ((EFI_D_INFO, "LoadLibraryEx (%s,\n NULL, DONT_RESOLVE_DLL_REFERENCES)\n", DllFileName));\r
+ Status = AddModHandle (ImageContext, Library);\r
+ if (Status == EFI_ALREADY_STARTED) {\r
+ //\r
+ // If the DLL has already been loaded before, then this instance of the DLL can not be debugged.\r
+ //\r
+ ImageContext->PdbPointer = NULL;\r
+ DEBUG ((EFI_D_ERROR, "WARNING: DLL already loaded. No source level debug %s. \n", DllFileName));\r
+ } else {\r
+ //\r
+ // This DLL is not already loaded, so source level debugging is supported.\r
+ //\r
+ ImageContext->EntryPoint = (EFI_PHYSICAL_ADDRESS) (UINTN) DllEntryPoint;\r
+ DEBUG ((EFI_D_INFO, "LoadLibraryEx (%s,\n NULL, DONT_RESOLVE_DLL_REFERENCES)\n", DllFileName));\r
+ }\r
} else {\r
+ //\r
+ // This DLL does not support source level debugging at all.\r
+ //\r
DEBUG ((EFI_D_ERROR, "WARNING: No source level debug %s. \n", DllFileName));\r
}\r
\r
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r
)\r
{\r
- VOID *ModHandle;\r
+ VOID *ModHandle;\r
\r
ASSERT (ImageContext != NULL);\r
\r