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
\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 suported.\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