From 66352173507452dc6812269db140a3b2a470e90d Mon Sep 17 00:00:00 2001 From: mdkinney Date: Thu, 11 Feb 2010 04:32:34 +0000 Subject: Update PeCoffExtraActionLib for NT32 to allow an app or driver to be loaded more than once. Only the first instance will support source level debug. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9983 6f19259b-4bc3-4df7-8a09-765794883524 --- .../DxeNt32PeCoffExtraActionLib.c | 31 +++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'Nt32Pkg') diff --git a/Nt32Pkg/Library/DxeNt32PeCoffExtraActionLib/DxeNt32PeCoffExtraActionLib.c b/Nt32Pkg/Library/DxeNt32PeCoffExtraActionLib/DxeNt32PeCoffExtraActionLib.c index bead36ae15..93a2044cac 100644 --- a/Nt32Pkg/Library/DxeNt32PeCoffExtraActionLib/DxeNt32PeCoffExtraActionLib.c +++ b/Nt32Pkg/Library/DxeNt32PeCoffExtraActionLib/DxeNt32PeCoffExtraActionLib.c @@ -160,6 +160,16 @@ AddModHandle ( PDB_NAME_TO_MOD_HANDLE *TempArray; HANDLE Handle; + // + // Return EFI_ALREADY_STARTED if this DLL has already been loaded + // + Array = mPdbNameModHandleArray; + for (Index = 0; Index < mPdbNameModHandleArraySize; Index++, Array++) { + if (Array->PdbPointer != NULL && Array->ModHandle == ModHandle) { + return EFI_ALREADY_STARTED; + } + } + Array = mPdbNameModHandleArray; for (Index = 0; Index < mPdbNameModHandleArraySize; Index++, Array++) { if (Array->PdbPointer == NULL) { @@ -266,6 +276,7 @@ PeCoffLoaderRelocateImageExtraAction ( IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext ) { + EFI_STATUS Status; VOID *DllEntryPoint; CHAR16 *DllFileName; HMODULE Library; @@ -333,10 +344,24 @@ PeCoffLoaderRelocateImageExtraAction ( } if ((Library != NULL) && (DllEntryPoint != NULL)) { - AddModHandle (ImageContext, Library); - ImageContext->EntryPoint = (EFI_PHYSICAL_ADDRESS) (UINTN) DllEntryPoint; - DEBUG ((EFI_D_INFO, "LoadLibraryEx (%s,\n NULL, DONT_RESOLVE_DLL_REFERENCES)\n", DllFileName)); + Status = AddModHandle (ImageContext, Library); + if (Status == EFI_ALREADY_STARTED) { + // + // If the DLL has already been loaded before, then this instance of the DLL can not be debugged. + // + ImageContext->PdbPointer = NULL; + DEBUG ((EFI_D_ERROR, "WARNING: DLL already loaded. No source level debug %s. \n", DllFileName)); + } else { + // + // This DLL is not already loaded, so source level debugging is suported. + // + ImageContext->EntryPoint = (EFI_PHYSICAL_ADDRESS) (UINTN) DllEntryPoint; + DEBUG ((EFI_D_INFO, "LoadLibraryEx (%s,\n NULL, DONT_RESOLVE_DLL_REFERENCES)\n", DllFileName)); + } } else { + // + // This DLL does not support source level debugging at all. + // DEBUG ((EFI_D_ERROR, "WARNING: No source level debug %s. \n", DllFileName)); } -- cgit v1.2.3