mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
- Initialize the symbols for boot load driver before the driver entry routine is called.
- Store the symbols for boot load driver within the non paged pool. svn path=/trunk/; revision=12830
This commit is contained in:
parent
6f39b3e0e0
commit
a91d61b02e
3 changed files with 90 additions and 86 deletions
|
@ -548,6 +548,7 @@ KdbpSymFindCachedFile(IN PUNICODE_STRING FileName)
|
|||
DPRINT("Current->FileName %wZ FileName %wZ\n", &Current->FileName, FileName);
|
||||
if (RtlEqualUnicodeString(&Current->FileName, FileName, TRUE))
|
||||
{
|
||||
Current->RefCount++;
|
||||
KeReleaseSpinLock(&SymbolFileListLock, Irql);
|
||||
DPRINT("Found cached file!\n");
|
||||
return Current;
|
||||
|
@ -690,7 +691,6 @@ KdbpSymLoadModuleSymbols(IN PUNICODE_STRING FileName,
|
|||
if (CachedSymbolFile != NULL)
|
||||
{
|
||||
DPRINT("Found cached symbol file %wZ\n", &SymFileName);
|
||||
CachedSymbolFile->RefCount++;
|
||||
SymbolInfo->FileBuffer = CachedSymbolFile->FileBuffer;
|
||||
SymbolInfo->SymbolsBase = CachedSymbolFile->SymbolsBase;
|
||||
SymbolInfo->SymbolsLength = CachedSymbolFile->SymbolsLength;
|
||||
|
@ -897,68 +897,75 @@ KdbSymUnloadDriverSymbols(IN PMODULE_OBJECT ModuleObject)
|
|||
* module.
|
||||
* Used to load ntoskrnl and hal symbols before the SystemRoot is available to us.
|
||||
*
|
||||
* \param ModuleLoadBase Base address of the loaded symbol file.
|
||||
* \param FileName Filename of the symbol file.
|
||||
* \param Length Length of the loaded symbol file/module.
|
||||
* \param FileName Filename for which the symbols are loaded.
|
||||
*/
|
||||
VOID
|
||||
KdbSymProcessSymbolFile(IN PVOID ModuleLoadBase,
|
||||
IN PCHAR FileName,
|
||||
IN ULONG Length)
|
||||
KdbSymProcessBootSymbols(IN PCHAR FileName)
|
||||
{
|
||||
PMODULE_OBJECT ModuleObject;
|
||||
UNICODE_STRING ModuleName;
|
||||
CHAR TmpBaseName[MAX_PATH];
|
||||
CHAR TmpFileName[MAX_PATH];
|
||||
UNICODE_STRING UnicodeString;
|
||||
PLOADER_MODULE KeLoaderModules = (PLOADER_MODULE)KeLoaderBlock.ModsAddr;
|
||||
CHAR SymbolName[MAX_PATH];
|
||||
PSYMBOLFILE_HEADER SymbolFileHeader;
|
||||
PIMAGE_SYMBOL_INFO SymbolInfo;
|
||||
ANSI_STRING AnsiString;
|
||||
PCHAR Extension;
|
||||
ULONG i;
|
||||
const char *KnownExtension[] = {".exe", ".sys", ".dll"};
|
||||
|
||||
DPRINT("Module %s is a symbol file\n", FileName);
|
||||
DPRINT("KdbSymProcessBootSymbols(%s)\n", FileName);
|
||||
|
||||
strncpy(TmpBaseName, FileName, MAX_PATH-1);
|
||||
TmpBaseName[MAX_PATH-1] = '\0';
|
||||
/* remove the extension '.sym' */
|
||||
Extension = strrchr(TmpBaseName, '.');
|
||||
if (Extension && 0 == _stricmp(Extension, ".sym"))
|
||||
RtlInitAnsiString(&AnsiString, FileName);
|
||||
RtlAnsiStringToUnicodeString(&UnicodeString, &AnsiString, TRUE);
|
||||
ModuleObject = LdrGetModuleObject(&UnicodeString);
|
||||
RtlFreeUnicodeString(&UnicodeString);
|
||||
|
||||
if (ModuleObject != NULL)
|
||||
{
|
||||
*Extension = 0;
|
||||
strcpy(SymbolName, FileName);
|
||||
Extension = strrchr(SymbolName, '.');
|
||||
if (Extension == NULL)
|
||||
{
|
||||
Extension = SymbolName + strlen(SymbolName);
|
||||
}
|
||||
|
||||
DPRINT("base: %s (Length %d)\n", TmpBaseName, Length);
|
||||
|
||||
for (i = 0; i < sizeof(KnownExtension) / sizeof(*KnownExtension); i++)
|
||||
strcpy(Extension, ".sym");
|
||||
for (i = 0; i < KeLoaderBlock.ModsCount; i++)
|
||||
{
|
||||
strcpy(TmpFileName, TmpBaseName);
|
||||
strcat(TmpFileName, KnownExtension[i]);
|
||||
RtlInitAnsiString(&AnsiString, TmpFileName);
|
||||
|
||||
RtlAnsiStringToUnicodeString(&ModuleName, &AnsiString, TRUE);
|
||||
ModuleObject = LdrGetModuleObject(&ModuleName);
|
||||
RtlFreeUnicodeString(&ModuleName);
|
||||
if (ModuleObject)
|
||||
if (KeLoaderModules[i].Reserved == 0 && !_stricmp(SymbolName, (PCHAR)KeLoaderModules[i].String))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ModuleObject != NULL)
|
||||
if (i < KeLoaderBlock.ModsCount)
|
||||
{
|
||||
KeLoaderModules[i].Reserved = 1;
|
||||
SymbolInfo = (PIMAGE_SYMBOL_INFO) &ModuleObject->TextSection->SymbolInfo;
|
||||
if (SymbolInfo->FileBuffer != NULL)
|
||||
{
|
||||
KdbpSymRemoveCachedFile(SymbolInfo);
|
||||
}
|
||||
|
||||
SymbolFileHeader = (PSYMBOLFILE_HEADER) ModuleLoadBase;
|
||||
SymbolInfo->FileBuffer = ModuleLoadBase;
|
||||
SymbolInfo->SymbolsBase = ModuleLoadBase + SymbolFileHeader->StabsOffset;
|
||||
SymbolFileHeader = ExAllocatePool(NonPagedPool, KeLoaderModules[i].ModEnd - KeLoaderModules[i].ModStart);
|
||||
if (SymbolFileHeader == NULL)
|
||||
{
|
||||
DPRINT("Could not allocate memory for symbol file\n");
|
||||
return;
|
||||
}
|
||||
memcpy(SymbolFileHeader,
|
||||
(PVOID)KeLoaderModules[i].ModStart,
|
||||
KeLoaderModules[i].ModEnd - KeLoaderModules[i].ModStart);
|
||||
|
||||
SymbolInfo->FileBuffer = SymbolFileHeader;
|
||||
SymbolInfo->SymbolsBase = (PVOID)SymbolFileHeader + SymbolFileHeader->StabsOffset;
|
||||
SymbolInfo->SymbolsLength = SymbolFileHeader->StabsLength;
|
||||
SymbolInfo->SymbolStringsBase = ModuleLoadBase + SymbolFileHeader->StabstrOffset;
|
||||
SymbolInfo->SymbolStringsBase = (PVOID)SymbolFileHeader + SymbolFileHeader->StabstrOffset;
|
||||
SymbolInfo->SymbolStringsLength = SymbolFileHeader->StabstrLength;
|
||||
|
||||
/* add file to cache */
|
||||
RtlInitAnsiString(&AnsiString, SymbolName);
|
||||
RtlAnsiStringToUnicodeString(&UnicodeString, &AnsiString, TRUE);
|
||||
KdbpSymAddCachedFile(&UnicodeString, SymbolInfo);
|
||||
RtlFreeUnicodeString(&UnicodeString);
|
||||
|
||||
DPRINT("Installed stabs: %s@%08x-%08x (%08x-%08x,%08x)\n",
|
||||
FileName,
|
||||
ModuleObject->Base,
|
||||
|
@ -967,6 +974,7 @@ KdbSymProcessSymbolFile(IN PVOID ModuleLoadBase,
|
|||
SymbolInfo->SymbolsLength + SymbolInfo->SymbolsBase,
|
||||
SymbolInfo->SymbolStringsBase);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*! \brief Initializes the KDB symbols implementation.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: kd.h,v 1.29 2004/12/09 14:20:06 royce Exp $
|
||||
/* $Id$
|
||||
*
|
||||
* kernel debugger prototypes
|
||||
*/
|
||||
|
@ -114,7 +114,7 @@ VOID KdPrintMda(PCH pch);
|
|||
# define KDB_LOADDRIVER_HOOK(FILENAME, MODULE) do { } while (0)
|
||||
# define KDB_UNLOADDRIVER_HOOK(MODULE) do { } while (0)
|
||||
# define KDB_LOADERINIT_HOOK(NTOS, HAL) do { } while (0)
|
||||
# define KDB_SYMBOLFILE_HOOK(LOADBASE, FILENAME, LENGTH) do { } while (0)
|
||||
# define KDB_SYMBOLFILE_HOOK(FILENAME) do { } while (0)
|
||||
# define KDB_CREATE_THREAD_HOOK(CONTEXT) do { } while (0)
|
||||
#else
|
||||
# define KDB_LOADUSERMODULE_HOOK(LDRMOD) KdbSymLoadUserModuleSymbols(LDRMOD)
|
||||
|
@ -122,8 +122,7 @@ VOID KdPrintMda(PCH pch);
|
|||
# define KDB_LOADDRIVER_HOOK(FILENAME, MODULE) KdbSymLoadDriverSymbols(FILENAME, MODULE)
|
||||
# define KDB_UNLOADDRIVER_HOOK(MODULE) KdbSymUnloadDriverSymbols(MODULE)
|
||||
# define KDB_LOADERINIT_HOOK(NTOS, HAL) KdbSymInit(NTOS, HAL)
|
||||
# define KDB_SYMBOLFILE_HOOK(LOADBASE, FILENAME, LENGTH) \
|
||||
KdbSymProcessSymbolFile(LOADBASE, FILENAME, LENGTH)
|
||||
# define KDB_SYMBOLFILE_HOOK(FILENAME) KdbSymProcessBootSymbols(FILENAME)
|
||||
/*#define KDB_CREATE_THREAD_HOOK(CONTEXT) \
|
||||
KdbCreateThreadHook(CONTEXT)
|
||||
*/
|
||||
|
@ -141,9 +140,7 @@ VOID
|
|||
KdbSymUnloadDriverSymbols(IN PMODULE_OBJECT ModuleObject);
|
||||
|
||||
VOID
|
||||
KdbSymProcessSymbolFile(IN PVOID ModuleLoadBase,
|
||||
IN PCHAR FileName,
|
||||
IN ULONG Length);
|
||||
KdbSymProcessBootSymbols(IN PCHAR FileName);
|
||||
|
||||
VOID
|
||||
KdbSymInit(IN PMODULE_TEXT_SECTION NtoskrnlTextSection,
|
||||
|
|
|
@ -448,6 +448,8 @@ IopLoadServiceModule(
|
|||
&ServiceImagePath,
|
||||
ModuleObject);
|
||||
|
||||
KDB_SYMBOLFILE_HOOK(SearchName);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1135,6 +1137,9 @@ IopInitializeBuiltinDriver(
|
|||
return Status;
|
||||
}
|
||||
|
||||
/* Load symbols */
|
||||
KDB_SYMBOLFILE_HOOK(FileName);
|
||||
|
||||
/*
|
||||
* Strip the file extension from ServiceName
|
||||
*/
|
||||
|
@ -1205,13 +1210,11 @@ IopInitializeBootDrivers(VOID)
|
|||
if (Extension == NULL)
|
||||
Extension = "";
|
||||
|
||||
if (!_stricmp(Extension, ".sym"))
|
||||
{
|
||||
/* Pass symbol files to kernel debugger */
|
||||
KDB_SYMBOLFILE_HOOK((PVOID)ModuleStart, ModuleName, ModuleSize);
|
||||
}
|
||||
else if (!_stricmp(Extension, ".exe") || !_stricmp(Extension, ".dll"))
|
||||
if (!_stricmp(Extension, ".exe") || !_stricmp(Extension, ".dll"))
|
||||
{
|
||||
/* Process symbols for *.exe and *.dll */
|
||||
KDB_SYMBOLFILE_HOOK(ModuleName);
|
||||
|
||||
/* Log *.exe and *.dll files */
|
||||
RtlCreateUnicodeStringFromAsciiz(&DriverName, ModuleName);
|
||||
IopBootLog(&DriverName, TRUE);
|
||||
|
@ -1232,21 +1235,17 @@ IopInitializeBootDrivers(VOID)
|
|||
}
|
||||
BootDriverCount++;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Free memory for all boot files, except ntoskrnl.exe
|
||||
* and symbol files, if the kernel debugger is active
|
||||
* Free memory for all boot files, except ntoskrnl.exe.
|
||||
*/
|
||||
if (i != 0 /* ntoskrnl.exe is always the first module */
|
||||
#if defined(DBG) || defined(KDBG)
|
||||
&& _stricmp(Extension, ".sym")
|
||||
#endif
|
||||
)
|
||||
for (i = 1; i < KeLoaderBlock.ModsCount; i++)
|
||||
{
|
||||
|
||||
MiFreeBootDriverMemory((PVOID)KeLoaderModules[i].ModStart,
|
||||
KeLoaderModules[i].ModEnd - KeLoaderModules[i].ModStart);
|
||||
}
|
||||
}
|
||||
|
||||
if (BootDriverCount == 0)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue