Author: cfinck
Date: Tue Sep 22 23:31:55 2009
New Revision: 43118
URL:
http://svn.reactos.org/svn/reactos?rev=43118&view=rev
Log:
- Get rid of the KDB_MODULE_INFO and operate with LDR_DATA_TABLE_ENTRYs directly.
This saves us from some copy steps and unneeded search operations.
- Fix loading HAL.DLL symbols.
This module is not guaranteed to be the second one in PsLoadedModuleList due to the
kernel loading bootvid.dll.
- Don't duplicate code in KdbpSymFindModule and KdbpSymFindUserModule. Use a helper
function instead and call it twice from KdbpSymFindModule.
- Get rid of KdbpSymFindModuleByAddress, KdbpSymFindModuleByName and
KdbpSymFindModuleByIndex. Instead use a single KdbpSymFindModule for all three variants.
- Remove some unused functions and defines.
Modified:
trunk/reactos/ntoskrnl/include/internal/kd.h
trunk/reactos/ntoskrnl/kd/kdmain.c
trunk/reactos/ntoskrnl/kdbg/kdb.c
trunk/reactos/ntoskrnl/kdbg/kdb.h
trunk/reactos/ntoskrnl/kdbg/kdb_cli.c
trunk/reactos/ntoskrnl/kdbg/kdb_symbols.c
Modified: trunk/reactos/ntoskrnl/include/internal/kd.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/kd.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/kd.h [iso-8859-1] Tue Sep 22 23:31:55 2009
@@ -69,41 +69,13 @@
#if defined(KDBG) || DBG
VOID
-KdbSymLoadUserModuleSymbols(
- IN PLDR_DATA_TABLE_ENTRY LdrModule);
-
-VOID
-KdbSymFreeProcessSymbols(
- IN PEPROCESS Process);
-
-VOID
-KdbSymLoadDriverSymbols(
- IN PUNICODE_STRING Filename,
- IN PLDR_DATA_TABLE_ENTRY Module
-);
-
-VOID
-KdbSymUnloadDriverSymbols(
- IN PLDR_DATA_TABLE_ENTRY ModuleObject);
-
-VOID
-KdbSymProcessBootSymbols(
- IN PANSI_STRING AnsiFileName,
- IN BOOLEAN FullName,
- IN BOOLEAN LoadFromFile);
-
-VOID
KdbSymProcessSymbols(
- IN PANSI_STRING FileName,
- IN PKD_SYMBOLS_INFO SymbolInfo);
+ IN PLDR_DATA_TABLE_ENTRY LdrEntry);
+
BOOLEAN
KdbSymPrintAddress(
IN PVOID Address);
-
-VOID
-KdbDeleteProcessHook(
- IN PEPROCESS Process);
NTSTATUS
KdbSymGetAddressInformation(
@@ -113,46 +85,16 @@
OUT PCH FileName OPTIONAL,
OUT PCH FunctionName OPTIONAL
);
-
-typedef struct _KDB_MODULE_INFO
-{
- WCHAR Name[256];
- ULONG_PTR Base;
- ULONG Size;
- PROSSYM_INFO RosSymInfo;
-}
-KDB_MODULE_INFO, *PKDB_MODULE_INFO;
-
-/* MACROS FOR NON-KDBG BUILDS ************************************************/
-
-# define KDB_LOADUSERMODULE_HOOK(LDRMOD) KdbSymLoadUserModuleSymbols(LDRMOD)
-# define KDB_LOADDRIVER_HOOK(FILENAME, MODULE) KdbSymLoadDriverSymbols(FILENAME,
MODULE)
-# define KDB_UNLOADDRIVER_HOOK(MODULE) KdbSymUnloadDriverSymbols(MODULE)
-# define KDB_SYMBOLFILE_HOOK(FILENAME, SYMBOLINFO) KdbSymProcessSymbols((FILENAME),
(SYMBOLINFO))
-#else
-# define KDB_LOADUSERMODULE_HOOK(LDRMOD) do { } while (0)
-# define KDB_LOADDRIVER_HOOK(FILENAME, MODULE) do { } while (0)
-# define KDB_UNLOADDRIVER_HOOK(MODULE) do { } while (0)
-# define KDB_SYMBOLFILE_HOOK(FILENAME, SYMBOLINFO) do { } while (0)
-# define KDB_CREATE_THREAD_HOOK(CONTEXT) do { } while (0)
-#endif
-
-#if defined(KDBG) || DBG
-# define KeRosPrintAddress(ADDRESS) KdbSymPrintAddress(ADDRESS)
-#else
-# define KeRosPrintAddress(ADDRESS) KiRosPrintAddress(ADDRESS)
#endif
#ifdef KDBG
# define KdbInit() KdbpCliInit()
# define KdbModuleLoaded(FILENAME) KdbpCliModuleLoaded(FILENAME)
-# define KDB_DELETEPROCESS_HOOK(PROCESS) KdbDeleteProcessHook(PROCESS)
#else
# define KdbEnterDebuggerException(ER, PM, C, TF, F) kdHandleException
# define KdbInit() do { } while (0)
# define KdbEnter() do { } while (0)
# define KdbModuleLoaded(X) do { } while (0)
-# define KDB_DELETEPROCESS_HOOK(PROCESS) do { } while (0)
#endif
/* KD ROUTINES ***************************************************************/
Modified: trunk/reactos/ntoskrnl/kd/kdmain.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kd/kdmain.c?rev=4…
==============================================================================
--- trunk/reactos/ntoskrnl/kd/kdmain.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/kd/kdmain.c [iso-8859-1] Tue Sep 22 23:31:55 2009
@@ -135,9 +135,13 @@
}
else if (ExceptionCommand == BREAKPOINT_LOAD_SYMBOLS)
{
+#ifdef KDBG
+ PLDR_DATA_TABLE_ENTRY LdrEntry;
+
/* Load symbols. Currently implemented only for KDBG! */
-
KDB_SYMBOLFILE_HOOK((PANSI_STRING)ExceptionRecord->ExceptionInformation[1],
- (PKD_SYMBOLS_INFO)ExceptionRecord->ExceptionInformation[2]);
+
if(KdbpSymFindModule(((PKD_SYMBOLS_INFO)ExceptionRecord->ExceptionInformation[2])->BaseOfDll,
NULL, -1, &LdrEntry))
+ KdbSymProcessSymbols(LdrEntry);
+#endif
}
/* This we can handle: simply bump EIP */
Modified: trunk/reactos/ntoskrnl/kdbg/kdb.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kdbg/kdb.c?rev=43…
==============================================================================
--- trunk/reactos/ntoskrnl/kdbg/kdb.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/kdbg/kdb.c [iso-8859-1] Tue Sep 22 23:31:55 2009
@@ -1678,15 +1678,6 @@
}
VOID
-KdbDeleteProcessHook(
- IN PEPROCESS Process)
-{
- KdbSymFreeProcessSymbols(Process);
-
- /* FIXME: Delete breakpoints for process */
-}
-
-VOID
NTAPI
KdbpGetCommandLineSettings(
PCHAR p1)
Modified: trunk/reactos/ntoskrnl/kdbg/kdb.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kdbg/kdb.h?rev=43…
==============================================================================
--- trunk/reactos/ntoskrnl/kdbg/kdb.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/kdbg/kdb.h [iso-8859-1] Tue Sep 22 23:31:55 2009
@@ -142,16 +142,11 @@
/* from kdb_symbols.c */
BOOLEAN
-KdbpSymFindModuleByAddress(IN PVOID Address,
- OUT PKDB_MODULE_INFO pInfo);
-
-BOOLEAN
-KdbpSymFindModuleByName(IN LPCWSTR Name,
- OUT PKDB_MODULE_INFO pInfo);
-
-BOOLEAN
-KdbpSymFindModuleByIndex(IN INT Index,
- OUT PKDB_MODULE_INFO pInfo);
+KdbpSymFindModule(
+ IN PVOID Address OPTIONAL,
+ IN LPCWSTR Name OPTIONAL,
+ IN INT Index OPTIONAL,
+ OUT PLDR_DATA_TABLE_ENTRY* pLdrEntry);
/* from kdb.c */
Modified: trunk/reactos/ntoskrnl/kdbg/kdb_cli.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kdbg/kdb_cli.c?re…
==============================================================================
--- trunk/reactos/ntoskrnl/kdbg/kdb_cli.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/kdbg/kdb_cli.c [iso-8859-1] Tue Sep 22 23:31:55 2009
@@ -1476,7 +1476,7 @@
{
ULONGLONG Result = 0;
ULONG_PTR Address;
- KDB_MODULE_INFO Info;
+ PLDR_DATA_TABLE_ENTRY LdrEntry;
BOOLEAN DisplayOnlyOneModule = FALSE;
INT i = 0;
@@ -1498,7 +1498,7 @@
Address = (ULONG_PTR)Result;
- if (!KdbpSymFindModuleByAddress((PVOID)Address, &Info))
+ if (!KdbpSymFindModule((PVOID)Address, NULL, -1, &LdrEntry))
{
KdbpPrint("No module containing address 0x%p found!\n", Address);
return TRUE;
@@ -1508,7 +1508,7 @@
}
else
{
- if (!KdbpSymFindModuleByIndex(0, &Info))
+ if (!KdbpSymFindModule(NULL, NULL, 0, &LdrEntry))
{
ULONG_PTR ntoskrnlBase = ((ULONG_PTR)KdbpCmdMod) & 0xfff00000;
KdbpPrint(" Base Size Name\n");
@@ -1522,13 +1522,10 @@
KdbpPrint(" Base Size Name\n");
for (;;)
{
- KdbpPrint(" %08x %08x %ws\n", Info.Base, Info.Size, Info.Name);
-
- if ((!DisplayOnlyOneModule && !KdbpSymFindModuleByIndex(i++, &Info))
||
- DisplayOnlyOneModule)
- {
+ KdbpPrint(" %08x %08x %wZ\n", LdrEntry->DllBase,
LdrEntry->SizeOfImage, &LdrEntry->BaseDllName);
+
+ if(DisplayOnlyOneModule || !KdbpSymFindModule(NULL, NULL, i++, &LdrEntry))
break;
- }
}
return TRUE;
Modified: trunk/reactos/ntoskrnl/kdbg/kdb_symbols.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kdbg/kdb_symbols.…
==============================================================================
--- trunk/reactos/ntoskrnl/kdbg/kdb_symbols.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/kdbg/kdb_symbols.c [iso-8859-1] Tue Sep 22 23:31:55 2009
@@ -5,6 +5,7 @@
* PURPOSE: Getting symbol information...
*
* PROGRAMMERS: David Welch (welch(a)cwcom.net)
+ * Colin Finck (colin(a)reactos.org)
*/
/* INCLUDES *****************************************************************/
@@ -32,60 +33,24 @@
/* FUNCTIONS ****************************************************************/
-/*! \brief Find a user-mode module...
- *
- * \param Address If \a Address is not NULL the module containing \a Address
- * is searched.
- * \param Name If \a Name is not NULL the module named \a Name will be
- * searched.
- * \param Index If \a Index is >= 0 the Index'th module will be returned.
- * \param pInfo Pointer to a KDB_MODULE_INFO which is filled.
- *
- * \retval TRUE Module was found, \a pInfo was filled.
- * \retval FALSE No module was found.
- *
- * \sa KdbpSymFindModule
- */
static BOOLEAN
-KdbpSymFindUserModule(
- IN PVOID Address OPTIONAL,
- IN LPCWSTR Name OPTIONAL,
- IN INT Index OPTIONAL,
- OUT PKDB_MODULE_INFO pInfo)
-{
- PLIST_ENTRY current_entry;
- PLDR_DATA_TABLE_ENTRY current;
- PEPROCESS CurrentProcess;
- PPEB Peb = NULL;
- INT Count = 0;
- INT Length;
-
- if (!KdbpSymbolsInitialized)
- return FALSE;
-
- CurrentProcess = PsGetCurrentProcess();
- if (CurrentProcess)
- Peb = CurrentProcess->Peb;
-
- if (!Peb || !Peb->Ldr)
- return FALSE;
-
- current_entry = Peb->Ldr->InLoadOrderModuleList.Flink;
-
- while (current_entry != &Peb->Ldr->InLoadOrderModuleList &&
current_entry)
- {
- current = CONTAINING_RECORD(current_entry, LDR_DATA_TABLE_ENTRY,
InLoadOrderLinks);
- Length = min(current->BaseDllName.Length / sizeof(WCHAR), 255);
- if ((Address && (Address >= (PVOID)current->DllBase &&
- Address < (PVOID)((char *)current->DllBase +
current->SizeOfImage))) ||
- (Name && _wcsnicmp(current->BaseDllName.Buffer, Name, Length) ==
0) ||
- (Index >= 0 && Count++ == Index))
+KdbpSymSearchModuleList(
+ IN PLIST_ENTRY current_entry,
+ IN PLIST_ENTRY end_entry,
+ IN PLONG Count,
+ IN PVOID Address,
+ IN LPCWSTR Name,
+ IN INT Index,
+ OUT PLDR_DATA_TABLE_ENTRY* pLdrEntry)
+{
+ while (current_entry && current_entry != end_entry)
+ {
+ *pLdrEntry = CONTAINING_RECORD(current_entry, LDR_DATA_TABLE_ENTRY,
InLoadOrderLinks);
+
+ if ((Address && Address >= (PVOID)(*pLdrEntry)->DllBase &&
Address < (PVOID)((ULONG_PTR)(*pLdrEntry)->DllBase + (*pLdrEntry)->SizeOfImage))
||
+ (Name && !_wcsnicmp((*pLdrEntry)->BaseDllName.Buffer, Name,
(*pLdrEntry)->BaseDllName.Length / sizeof(WCHAR))) ||
+ (Index >= 0 && (*Count)++ == Index))
{
- wcsncpy(pInfo->Name, current->BaseDllName.Buffer, Length);
- pInfo->Name[Length] = L'\0';
- pInfo->Base = (ULONG_PTR)current->DllBase;
- pInfo->Size = current->SizeOfImage;
- pInfo->RosSymInfo = current->PatchInformation;
return TRUE;
}
@@ -95,111 +60,53 @@
return FALSE;
}
-/*! \brief Find a kernel-mode module...
- *
- * Works like \a KdbpSymFindUserModule.
- *
- * \sa KdbpSymFindUserModule
- */
-static BOOLEAN
+/*! \brief Find a module...
+ *
+ * \param Address If \a Address is not NULL the module containing \a Address
+ * is searched.
+ * \param Name If \a Name is not NULL the module named \a Name will be
+ * searched.
+ * \param Index If \a Index is >= 0 the Index'th module will be returned.
+ * \param pLdrEntry Pointer to a PLDR_DATA_TABLE_ENTRY which is filled.
+ *
+ * \retval TRUE Module was found, \a pLdrEntry was filled.
+ * \retval FALSE No module was found.
+ */
+BOOLEAN
KdbpSymFindModule(
IN PVOID Address OPTIONAL,
IN LPCWSTR Name OPTIONAL,
IN INT Index OPTIONAL,
- OUT PKDB_MODULE_INFO pInfo)
-{
- PLIST_ENTRY current_entry;
- PLDR_DATA_TABLE_ENTRY current;
- INT Count = 0;
- INT Length;
-
- if (!KdbpSymbolsInitialized)
+ OUT PLDR_DATA_TABLE_ENTRY* pLdrEntry)
+{
+ LONG Count = 0;
+ PEPROCESS CurrentProcess;
+
+ /* First try to look up the module in the kernel module list. */
+ if(KdbpSymSearchModuleList(PsLoadedModuleList.Flink,
+ &PsLoadedModuleList,
+ &Count,
+ Address,
+ Name,
+ Index,
+ pLdrEntry))
+ {
+ return TRUE;
+ }
+
+ /* That didn't succeed. Try the module list of the current process now. */
+ CurrentProcess = PsGetCurrentProcess();
+
+ if(!CurrentProcess || !CurrentProcess->Peb || !CurrentProcess->Peb->Ldr)
return FALSE;
- current_entry = PsLoadedModuleList.Flink;
-
- while (current_entry != &PsLoadedModuleList)
- {
- current = CONTAINING_RECORD(current_entry, LDR_DATA_TABLE_ENTRY,
InLoadOrderLinks);
-
- Length = min(current->BaseDllName.Length / sizeof(WCHAR), 255);
- if ((Address && (Address >= (PVOID)current->DllBase &&
- Address < (PVOID)((ULONG_PTR)current->DllBase +
current->SizeOfImage))) ||
- (Name && _wcsnicmp(current->BaseDllName.Buffer, Name, Length) == 0)
||
- (Index >= 0 && Count++ == Index))
- {
- wcsncpy(pInfo->Name, current->BaseDllName.Buffer, Length);
- pInfo->Name[Length] = L'\0';
- pInfo->Base = (ULONG_PTR)current->DllBase;
- pInfo->Size = current->SizeOfImage;
- pInfo->RosSymInfo = current->PatchInformation;
- return TRUE;
- }
-
- current_entry = current_entry->Flink;
- }
-
- return KdbpSymFindUserModule(Address, Name, Index-Count, pInfo);
-}
-
-/*! \brief Find module by address...
- *
- * \param Address Any address inside the module to look for.
- * \param pInfo Pointer to a KDB_MODULE_INFO struct which is filled on
- * success.
- *
- * \retval TRUE Success - module found.
- * \retval FALSE Failure - module not found.
- *
- * \sa KdbpSymFindModuleByName
- * \sa KdbpSymFindModuleByIndex
- */
-BOOLEAN
-KdbpSymFindModuleByAddress(
- IN PVOID Address,
- OUT PKDB_MODULE_INFO pInfo)
-{
- return KdbpSymFindModule(Address, NULL, -1, pInfo);
-}
-
-/*! \brief Find module by name...
- *
- * \param Name Name of the module to look for.
- * \param pInfo Pointer to a KDB_MODULE_INFO struct which is filled on
- * success.
- *
- * \retval TRUE Success - module found.
- * \retval FALSE Failure - module not found.
- *
- * \sa KdbpSymFindModuleByAddress
- * \sa KdbpSymFindModuleByIndex
- */
-BOOLEAN
-KdbpSymFindModuleByName(
- IN LPCWSTR Name,
- OUT PKDB_MODULE_INFO pInfo)
-{
- return KdbpSymFindModule(NULL, Name, -1, pInfo);
-}
-
-/*! \brief Find module by index...
- *
- * \param Index Index of the module to return.
- * \param pInfo Pointer to a KDB_MODULE_INFO struct which is filled on
- * success.
- *
- * \retval TRUE Success - module found.
- * \retval FALSE Failure - module not found.
- *
- * \sa KdbpSymFindModuleByName
- * \sa KdbpSymFindModuleByAddress
- */
-BOOLEAN
-KdbpSymFindModuleByIndex(
- IN INT Index,
- OUT PKDB_MODULE_INFO pInfo)
-{
- return KdbpSymFindModule(NULL, NULL, Index, pInfo);
+ return
KdbpSymSearchModuleList(CurrentProcess->Peb->Ldr->InLoadOrderModuleList.Flink,
+
&CurrentProcess->Peb->Ldr->InLoadOrderModuleList,
+ &Count,
+ Address,
+ Name,
+ Index,
+ pLdrEntry);
}
/*! \brief Print address...
@@ -217,30 +124,30 @@
KdbSymPrintAddress(
IN PVOID Address)
{
- KDB_MODULE_INFO Info;
+ PLDR_DATA_TABLE_ENTRY LdrEntry;
ULONG_PTR RelativeAddress;
NTSTATUS Status;
ULONG LineNumber;
CHAR FileName[256];
CHAR FunctionName[256];
- if (!KdbpSymbolsInitialized || !KdbpSymFindModuleByAddress(Address, &Info))
+ if (!KdbpSymbolsInitialized || !KdbpSymFindModule(Address, NULL, -1, &LdrEntry))
return FALSE;
- RelativeAddress = (ULONG_PTR) Address - Info.Base;
- Status = KdbSymGetAddressInformation(Info.RosSymInfo,
+ RelativeAddress = (ULONG_PTR)Address - (ULONG_PTR)LdrEntry->DllBase;
+ Status = KdbSymGetAddressInformation(LdrEntry->PatchInformation,
RelativeAddress,
&LineNumber,
FileName,
FunctionName);
if (NT_SUCCESS(Status))
{
- DbgPrint("<%ws:%x (%s:%d (%s))>",
- Info.Name, RelativeAddress, FileName, LineNumber, FunctionName);
+ DbgPrint("<%wZ:%x (%s:%d (%s))>",
+ &LdrEntry->BaseDllName, RelativeAddress, FileName, LineNumber,
FunctionName);
}
else
{
- DbgPrint("<%ws:%x>", Info.Name, RelativeAddress);
+ DbgPrint("<%wZ:%x>", &LdrEntry->BaseDllName,
RelativeAddress);
}
return TRUE;
@@ -480,156 +387,10 @@
DPRINT("Installed symbols: %wZ %p\n", FileName, *RosSymInfo);
}
-/*! \brief Unloads symbol info.
- *
- * \param RosSymInfo Pointer to the symbol info to unload.
- *
- * \sa KdbpSymLoadModuleSymbols
- */
-static VOID
-KdbpSymUnloadModuleSymbols(
- IN PROSSYM_INFO RosSymInfo)
-{
- DPRINT("Unloading symbols\n");
-
- if (RosSymInfo)
- KdbpSymRemoveCachedFile(RosSymInfo);
-}
-
-/*! \brief Load symbol info for a user module.
- *
- * \param LdrModule Pointer to the module to load symbols for.
- */
-VOID
-KdbSymLoadUserModuleSymbols(
- IN PLDR_DATA_TABLE_ENTRY LdrModule)
-{
- static WCHAR Prefix[] = L"\\??\\";
- UNICODE_STRING KernelName;
- DPRINT("LdrModule %p\n", LdrModule);
-
- LdrModule->PatchInformation = NULL;
-
- KernelName.MaximumLength = sizeof(Prefix) + LdrModule->FullDllName.Length;
- KernelName.Length = KernelName.MaximumLength - sizeof(WCHAR);
- KernelName.Buffer = ExAllocatePoolWithTag(NonPagedPool, KernelName.MaximumLength,
TAG_KDBS);
-
- if (!KernelName.Buffer)
- return;
-
- memcpy(KernelName.Buffer, Prefix, sizeof(Prefix) - sizeof(WCHAR));
- memcpy(KernelName.Buffer + sizeof(Prefix) / sizeof(WCHAR) - 1,
LdrModule->FullDllName.Buffer, LdrModule->FullDllName.Length);
- KernelName.Buffer[KernelName.Length / sizeof(WCHAR)] = L'\0';
-
- KdbpSymLoadModuleSymbols(&KernelName,
(PROSSYM_INFO*)&LdrModule->PatchInformation);
-
- ExFreePool(KernelName.Buffer);
-}
-
-/*! \brief Frees all symbols loaded for a process.
- *
- * \param Process Pointer to a process.
- */
-VOID
-KdbSymFreeProcessSymbols(
- IN PEPROCESS Process)
-{
- PLIST_ENTRY CurrentEntry;
- PLDR_DATA_TABLE_ENTRY Current;
- PEPROCESS CurrentProcess;
- PPEB Peb;
-
- CurrentProcess = PsGetCurrentProcess();
- if (CurrentProcess != Process)
- KeAttachProcess(&Process->Pcb);
-
- Peb = Process->Peb;
- ASSERT(Peb);
- ASSERT(Peb->Ldr);
-
- CurrentEntry = Peb->Ldr->InLoadOrderModuleList.Flink;
- while (CurrentEntry != &Peb->Ldr->InLoadOrderModuleList &&
CurrentEntry)
- {
- Current = CONTAINING_RECORD(CurrentEntry, LDR_DATA_TABLE_ENTRY,
InLoadOrderLinks);
- KdbpSymUnloadModuleSymbols(Current->PatchInformation);
-
- CurrentEntry = CurrentEntry->Flink;
- }
-
- if (CurrentProcess != Process)
- KeDetachProcess();
-}
-
-/*! \brief Load symbol info for a driver.
- *
- * \param Filename Filename of the driver.
- * \param Module Pointer to the driver LDR_DATA_TABLE_ENTRY.
- */
-VOID
-KdbSymLoadDriverSymbols(
- IN PUNICODE_STRING Filename,
- IN PLDR_DATA_TABLE_ENTRY Module)
-{
- /* Load symbols for the image if available */
- DPRINT("Loading driver %wZ symbols (driver @ %08x)\n", Filename,
Module->DllBase);
-
- Module->PatchInformation = NULL;
-
- KdbpSymLoadModuleSymbols(Filename, (PROSSYM_INFO*)&Module->PatchInformation);
-}
-
-/*! \brief Unloads symbol info for a driver.
- *
- * \param ModuleObject Pointer to the driver LDR_DATA_TABLE_ENTRY.
- */
-VOID
-KdbSymUnloadDriverSymbols(
- IN PLDR_DATA_TABLE_ENTRY ModuleObject)
-{
- /* Unload symbols for module if available */
- KdbpSymUnloadModuleSymbols(ModuleObject->PatchInformation);
- ModuleObject->PatchInformation = NULL;
-}
-
VOID
KdbSymProcessSymbols(
- IN PANSI_STRING AnsiFileName,
- IN PKD_SYMBOLS_INFO SymbolInfo)
-{
- BOOLEAN Found = FALSE;
- PLIST_ENTRY ListHead, NextEntry;
- PLDR_DATA_TABLE_ENTRY LdrEntry = NULL;
-
- //DPRINT("KdbSymProcessSymbols(%Z)\n", AnsiFileName);
-
- /* We use PsLoadedModuleList here, otherwise (in case of
- using KeLoaderBlock) all our data will be just lost */
- ListHead = &PsLoadedModuleList;
-
- /* Found module we are interested in */
- NextEntry = ListHead->Flink;
- while (ListHead != NextEntry)
- {
- /* Get the entry */
- LdrEntry = CONTAINING_RECORD(NextEntry,
- LDR_DATA_TABLE_ENTRY,
- InLoadOrderLinks);
-
- if (SymbolInfo->BaseOfDll == LdrEntry->DllBase)
- {
- Found = TRUE;
- break;
- }
-
- /* Go to the next one */
- NextEntry = NextEntry->Flink;
- }
-
- /* Exit if we didn't find the module requested */
- if (!Found)
- return;
-
- DPRINT("Found LdrEntry=%p\n", LdrEntry);
+ IN PLDR_DATA_TABLE_ENTRY LdrEntry)
+{
if (!LoadSymbols)
{
LdrEntry->PatchInformation = NULL;
@@ -689,9 +450,7 @@
PCHAR p1, p2;
SHORT Found = FALSE;
CHAR YesNo;
- LIST_ENTRY *ModuleEntry;
- PLDR_DATA_TABLE_ENTRY DataTableEntry;
- KD_SYMBOLS_INFO SymbolsInfo;
+ PLDR_DATA_TABLE_ENTRY LdrEntry;
DPRINT("KdbSymInit() BootPhase=%d\n", BootPhase);
@@ -765,29 +524,16 @@
}
else if (BootPhase == 1)
{
- /* Load symbols for NTOSKRNL.EXE */
- ModuleEntry = &KeLoaderBlock->LoadOrderListHead;
- DataTableEntry = CONTAINING_RECORD(ModuleEntry,
- LDR_DATA_TABLE_ENTRY, InLoadOrderLinks);
-
- SymbolsInfo.BaseOfDll = DataTableEntry->DllBase;
- SymbolsInfo.CheckSum = DataTableEntry->CheckSum;
- SymbolsInfo.ProcessId = 0;
- SymbolsInfo.SizeOfImage = DataTableEntry->SizeOfImage;
-
- KdbSymProcessSymbols(NULL, &SymbolsInfo);
-
- /* and HAL.DLL */
- ModuleEntry = ModuleEntry->Flink;
- DataTableEntry = CONTAINING_RECORD(ModuleEntry,
- LDR_DATA_TABLE_ENTRY, InLoadOrderLinks);
-
- SymbolsInfo.BaseOfDll = DataTableEntry->DllBase;
- SymbolsInfo.CheckSum = DataTableEntry->CheckSum;
- SymbolsInfo.ProcessId = 0;
- SymbolsInfo.SizeOfImage = DataTableEntry->SizeOfImage;
-
- KdbSymProcessSymbols(NULL, &SymbolsInfo);
+ /* Load symbols for NTOSKRNL.EXE.
+ It is always the first module in PsLoadedModuleList. KeLoaderBlock can't
be used here as its content is just temporary. */
+ LdrEntry = CONTAINING_RECORD(PsLoadedModuleList.Flink, LDR_DATA_TABLE_ENTRY,
InLoadOrderLinks);
+ KdbSymProcessSymbols(LdrEntry);
+
+ /* Also load them for HAL.DLL.
+ This module has no fixed position, so search for it. */
+ if(KdbpSymFindModule(NULL, L"HAL.DLL", -1, &LdrEntry))
+ KdbSymProcessSymbols(LdrEntry);
+
KdbpSymbolsInitialized = TRUE;
}
}