ReactOS  0.4.15-dev-2979-gfd8baca
kdb_symbols.c File Reference
#include <ntoskrnl.h>
#include <debug.h>
Include dependency graph for kdb_symbols.c:

Go to the source code of this file.

Classes

struct  _IMAGE_SYMBOL_INFO_CACHE
 

Macros

#define NDEBUG
 

Typedefs

typedef struct _IMAGE_SYMBOL_INFO_CACHE IMAGE_SYMBOL_INFO_CACHE
 
typedef struct _IMAGE_SYMBOL_INFO_CACHEPIMAGE_SYMBOL_INFO_CACHE
 

Functions

static BOOLEAN KdbpSymSearchModuleList (IN PLIST_ENTRY current_entry, IN PLIST_ENTRY end_entry, IN PLONG Count, IN PVOID Address, IN INT Index, OUT PLDR_DATA_TABLE_ENTRY *pLdrEntry)
 
BOOLEAN KdbpSymFindModule (IN PVOID Address OPTIONAL, IN INT Index OPTIONAL, OUT PLDR_DATA_TABLE_ENTRY *pLdrEntry)
 Find a module... More...
 
static PCHAR NTAPI KdbpSymUnicodeToAnsi (IN PUNICODE_STRING Unicode, OUT PCHAR Ansi, IN ULONG Length)
 
BOOLEAN KdbSymPrintAddress (IN PVOID Address, IN PCONTEXT Context)
 Print address... More...
 
_Use_decl_annotations_ VOID NTAPI LoadSymbolsRoutine (_In_ PVOID Context)
 The symbol loader thread routine. This opens the image file for reading and loads the symbols section from there. More...
 
VOID KdbSymProcessSymbols (_Inout_ PLDR_DATA_TABLE_ENTRY LdrEntry, _In_ BOOLEAN Load)
 Load symbols from image mapping. If this fails,. More...
 
VOID NTAPI KdbDebugPrint (PCH Message, ULONG Length)
 
VOID NTAPI KdbInitialize (PKD_DISPATCH_TABLE DispatchTable, ULONG BootPhase)
 Initializes the KDB symbols implementation. More...
 

Variables

static BOOLEAN LoadSymbols
 
static LIST_ENTRY SymbolsToLoad
 
static KSPIN_LOCK SymbolsToLoadLock
 
static KEVENT SymbolsToLoadEvent
 
static KSTART_ROUTINE LoadSymbolsRoutine
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 15 of file kdb_symbols.c.

Typedef Documentation

◆ IMAGE_SYMBOL_INFO_CACHE

◆ PIMAGE_SYMBOL_INFO_CACHE

Function Documentation

◆ KdbDebugPrint()

VOID NTAPI KdbDebugPrint ( PCH  Message,
ULONG  Length 
)

Definition at line 335 of file kdb_symbols.c.

338 {
339  /* Nothing here */
340 }

Referenced by KdbInitialize().

◆ KdbInitialize()

VOID NTAPI KdbInitialize ( PKD_DISPATCH_TABLE  DispatchTable,
ULONG  BootPhase 
)

Initializes the KDB symbols implementation.

Parameters
DispatchTablePointer to the KD dispatch table
BootPhasePhase of initialization

Definition at line 350 of file kdb_symbols.c.

353 {
354  PCHAR p1, p2;
355  SHORT Found = FALSE;
356  CHAR YesNo;
357 
358  DPRINT("KdbSymInit() BootPhase=%d\n", BootPhase);
359 
360  LoadSymbols = FALSE;
361 
362 #if DBG
363  /* Load symbols only if we have 96Mb of RAM or more */
364  if (MmNumberOfPhysicalPages >= 0x6000)
365  LoadSymbols = TRUE;
366 #endif
367 
368  if (BootPhase == 0)
369  {
370  /* Write out the functions that we support for now */
371  DispatchTable->KdpInitRoutine = KdpKdbgInit;
372  DispatchTable->KdpPrintRoutine = KdbDebugPrint;
373 
374  /* Register as a Provider */
375  InsertTailList(&KdProviders, &DispatchTable->KdProvidersList);
376 
377  /* Perform actual initialization of symbol module */
378  //NtoskrnlModuleObject->PatchInformation = NULL;
379  //LdrHalModuleObject->PatchInformation = NULL;
380 
381  /* Check the command line for /LOADSYMBOLS, /NOLOADSYMBOLS,
382  * /LOADSYMBOLS={YES|NO}, /NOLOADSYMBOLS={YES|NO} */
385  while('\0' != *p1 && NULL != (p2 = strchr(p1, '/')))
386  {
387  p2++;
388  Found = 0;
389  if (0 == _strnicmp(p2, "LOADSYMBOLS", 11))
390  {
391  Found = +1;
392  p2 += 11;
393  }
394  else if (0 == _strnicmp(p2, "NOLOADSYMBOLS", 13))
395  {
396  Found = -1;
397  p2 += 13;
398  }
399  if (0 != Found)
400  {
401  while (isspace(*p2))
402  {
403  p2++;
404  }
405  if ('=' == *p2)
406  {
407  p2++;
408  while (isspace(*p2))
409  {
410  p2++;
411  }
412  YesNo = toupper(*p2);
413  if ('N' == YesNo || 'F' == YesNo || '0' == YesNo)
414  {
415  Found = -1 * Found;
416  }
417  }
418  LoadSymbols = (0 < Found);
419  }
420  p1 = p2;
421  }
422  }
423  else if ((BootPhase == 1) && LoadSymbols)
424  {
425  HANDLE Thread;
427  KIRQL OldIrql;
428 
429  /* Launch our worker thread */
433 
435  if (!NT_SUCCESS(Status))
436  {
437  DPRINT1("Failed starting symbols loader thread: 0x%08x\n", Status);
438  LoadSymbols = FALSE;
439  return;
440  }
441 
443 
445 
447  while (ListEntry != &PsLoadedModuleList)
448  {
449  PLDR_DATA_TABLE_ENTRY LdrEntry = CONTAINING_RECORD(ListEntry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks);
450  KdbSymProcessSymbols(LdrEntry, TRUE);
451  ListEntry = ListEntry->Flink;
452  }
453 
455  }
456 }
signed char * PCHAR
Definition: retypes.h:7
#define isspace(c)
Definition: acclib.h:69
VOID RosSymInitKernelMode(VOID)
Definition: initkm.c:32
#define THREAD_ALL_ACCESS
Definition: nt_native.h:1339
VOID NTAPI KdpKdbgInit(PKD_DISPATCH_TABLE DispatchTable, ULONG BootPhase)
Definition: kdbg.c:21
#define TRUE
Definition: types.h:120
char CHAR
Definition: xmlstorage.h:175
LONG NTSTATUS
Definition: precomp.h:26
static LIST_ENTRY SymbolsToLoad
Definition: kdb_symbols.c:30
static KSTART_ROUTINE LoadSymbolsRoutine
Definition: kdb_symbols.c:196
#define InsertTailList(ListHead, Entry)
UCHAR KIRQL
Definition: env_spec_w32.h:591
KSPIN_LOCK PsLoadedModuleSpinLock
Definition: sysldr.c:36
#define FALSE
Definition: types.h:117
short SHORT
Definition: pedump.c:59
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:238
VOID KdbSymProcessSymbols(_Inout_ PLDR_DATA_TABLE_ENTRY LdrEntry, _In_ BOOLEAN Load)
Load symbols from image mapping. If this fails,.
Definition: kdb_symbols.c:298
return Found
Definition: dirsup.c:1270
PLOADER_PARAMETER_BLOCK KeLoaderBlock
Definition: krnlinit.c:29
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
VOID NTAPI KdbDebugPrint(PCH Message, ULONG Length)
Definition: kdb_symbols.c:335
KIRQL OldIrql
Definition: mm.h:1502
Status
Definition: gdiplustypes.h:24
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
int toupper(int c)
Definition: utclib.c:881
#define ASSERT(a)
Definition: mode.c:44
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
LIST_ENTRY PsLoadedModuleList
Definition: sysldr.c:34
static KSPIN_LOCK SymbolsToLoadLock
Definition: kdb_symbols.c:31
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2652
#define _strnicmp(_String1, _String2, _MaxCount)
Definition: compat.h:23
Definition: btrfs_drv.h:1922
Definition: typedefs.h:119
PFN_COUNT MmNumberOfPhysicalPages
Definition: init.c:48
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
NTSTATUS NTAPI PsCreateSystemThread(OUT PHANDLE ThreadHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN HANDLE ProcessHandle, IN PCLIENT_ID ClientId, IN PKSTART_ROUTINE StartRoutine, IN PVOID StartContext)
Definition: thread.c:602
#define NULL
Definition: types.h:112
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
char * strchr(const char *String, int ch)
Definition: utclib.c:501
#define DPRINT1
Definition: precomp.h:8
static BOOLEAN LoadSymbols
Definition: kdb_symbols.c:29
#define DPRINT
Definition: sndvol32.h:71
static KEVENT SymbolsToLoadEvent
Definition: kdb_symbols.c:32
_In_ PWDFDEVICE_INIT _In_ PWDF_PDO_EVENT_CALLBACKS DispatchTable
Definition: wdfpdo.h:245
LIST_ENTRY KdProviders
Definition: kdio.c:49

Referenced by KdpKdbgInit().

◆ KdbpSymFindModule()

BOOLEAN KdbpSymFindModule ( IN PVOID Address  OPTIONAL,
IN INT Index  OPTIONAL,
OUT PLDR_DATA_TABLE_ENTRY pLdrEntry 
)

Find a module...

Parameters
AddressIf Address is not NULL the module containing Address is searched.
NameIf Name is not NULL the module named Name will be searched.
IndexIf Index is >= 0 the Index'th module will be returned.
pLdrEntryPointer to a PLDR_DATA_TABLE_ENTRY which is filled.
Return values
TRUEModule was found, pLdrEntry was filled.
FALSENo module was found.

Definition at line 75 of file kdb_symbols.c.

79 {
80  LONG Count = 0;
82 
83  /* First try to look up the module in the kernel module list. */
87  &Count,
88  Address,
89  Index,
90  pLdrEntry))
91  {
93  return TRUE;
94  }
96 
97  /* That didn't succeed. Try the module list of the current process now. */
99 
100  if(!CurrentProcess || !CurrentProcess->Peb || !CurrentProcess->Peb->Ldr)
101  return FALSE;
102 
103  return KdbpSymSearchModuleList(CurrentProcess->Peb->Ldr->InLoadOrderModuleList.Flink,
104  &CurrentProcess->Peb->Ldr->InLoadOrderModuleList,
105  &Count,
106  Address,
107  Index,
108  pLdrEntry);
109 }
#define TRUE
Definition: types.h:120
VOID NTAPI KeAcquireSpinLockAtDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:198
KSPIN_LOCK PsLoadedModuleSpinLock
Definition: sysldr.c:36
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
#define PsGetCurrentProcess
Definition: psfuncs.h:17
static WCHAR Address[46]
Definition: ping.c:68
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
int Count
Definition: noreturn.cpp:7
ULONG CurrentProcess
Definition: shell.c:125
_In_ WDFCOLLECTION _In_ ULONG Index
LIST_ENTRY PsLoadedModuleList
Definition: sysldr.c:34
VOID NTAPI KeReleaseSpinLockFromDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:221
static BOOLEAN KdbpSymSearchModuleList(IN PLIST_ENTRY current_entry, IN PLIST_ENTRY end_entry, IN PLONG Count, IN PVOID Address, IN INT Index, OUT PLDR_DATA_TABLE_ENTRY *pLdrEntry)
Definition: kdb_symbols.c:38

Referenced by KdbpCmdMod(), KdbSymPrintAddress(), and KdSendPacket().

◆ KdbpSymSearchModuleList()

static BOOLEAN KdbpSymSearchModuleList ( IN PLIST_ENTRY  current_entry,
IN PLIST_ENTRY  end_entry,
IN PLONG  Count,
IN PVOID  Address,
IN INT  Index,
OUT PLDR_DATA_TABLE_ENTRY pLdrEntry 
)
static

Definition at line 38 of file kdb_symbols.c.

45 {
46  while (current_entry && current_entry != end_entry)
47  {
48  *pLdrEntry = CONTAINING_RECORD(current_entry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks);
49 
50  if ((Address && Address >= (PVOID)(*pLdrEntry)->DllBase && Address < (PVOID)((ULONG_PTR)(*pLdrEntry)->DllBase + (*pLdrEntry)->SizeOfImage)) ||
51  (Index >= 0 && (*Count)++ == Index))
52  {
53  return TRUE;
54  }
55 
56  current_entry = current_entry->Flink;
57  }
58 
59  return FALSE;
60 }
#define TRUE
Definition: types.h:120
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define FALSE
Definition: types.h:117
static WCHAR Address[46]
Definition: ping.c:68
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
int Count
Definition: noreturn.cpp:7
_In_ WDFCOLLECTION _In_ ULONG Index
Definition: btrfs_drv.h:1922

Referenced by KdbpSymFindModule().

◆ KdbpSymUnicodeToAnsi()

static PCHAR NTAPI KdbpSymUnicodeToAnsi ( IN PUNICODE_STRING  Unicode,
OUT PCHAR  Ansi,
IN ULONG  Length 
)
static

Definition at line 114 of file kdb_symbols.c.

117 {
118  PCHAR p;
119  PWCHAR pw;
120  ULONG i;
121 
122  /* Set length and normalize it */
123  i = Unicode->Length / sizeof(WCHAR);
124  i = min(i, Length - 1);
125 
126  /* Set source and destination, and copy */
127  pw = Unicode->Buffer;
128  p = Ansi;
129  while (i--) *p++ = (CHAR)*pw++;
130 
131  /* Null terminate and return */
132  *p = ANSI_NULL;
133  return Ansi;
134 }
signed char * PCHAR
Definition: retypes.h:7
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
uint16_t * PWCHAR
Definition: typedefs.h:56
#define ANSI_NULL
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define min(a, b)
Definition: monoChain.cc:55
unsigned int ULONG
Definition: retypes.h:1
GLfloat GLfloat p
Definition: glext.h:8902
#define CHAR(Char)

Referenced by KdbSymPrintAddress().

◆ KdbSymPrintAddress()

BOOLEAN KdbSymPrintAddress ( IN PVOID  Address,
IN PCONTEXT  Context 
)

Print address...

Tries to lookup line number, file name and function name for the given address and prints it. If no such information is found the address is printed in the format <module: offset>, otherwise the format will be <module: offset (filename:linenumber (functionname))>

Return values
TRUEModule containing Address was found, Address was printed.
FALSENo module containing Address was found, nothing was printed.

Definition at line 148 of file kdb_symbols.c.

151 {
152  PLDR_DATA_TABLE_ENTRY LdrEntry;
153  ULONG_PTR RelativeAddress;
154  BOOLEAN Printed = FALSE;
155  CHAR ModuleNameAnsi[64];
156 
157  if (!KdbpSymFindModule(Address, -1, &LdrEntry))
158  return FALSE;
159 
160  RelativeAddress = (ULONG_PTR)Address - (ULONG_PTR)LdrEntry->DllBase;
161 
163  ModuleNameAnsi,
164  sizeof(ModuleNameAnsi));
165 
166  if (LdrEntry->PatchInformation)
167  {
169  CHAR FileName[256];
170  CHAR FunctionName[256];
171 
173  {
174  STRING str;
175  /* Use KdpPrintString because KdpDprintf is limited wrt string size */
176  KdpDprintf("<%s:%x (", ModuleNameAnsi, RelativeAddress);
177  str.Buffer = FileName;
178  str.Length = strnlen(FileName, sizeof(FileName));
179  str.MaximumLength = sizeof(FileName);
181  KdpDprintf(":%d (%s))>", LineNumber, FunctionName);
182 
183  Printed = TRUE;
184  }
185  }
186 
187  if (!Printed)
188  {
189  /* Just print module & address */
190  KdpDprintf("<%s:%x>", ModuleNameAnsi, RelativeAddress);
191  }
192 
193  return TRUE;
194 }
BOOLEAN NTAPI KdpPrintString(_In_ PSTRING Output)
Definition: kdprint.c:22
#define TRUE
Definition: types.h:120
char CHAR
Definition: xmlstorage.h:175
uint32_t ULONG_PTR
Definition: typedefs.h:65
PVOID DllBase
Definition: btrfs_drv.h:1926
#define FALSE
Definition: types.h:117
const WCHAR * str
unsigned char BOOLEAN
static WCHAR Address[46]
Definition: ping.c:68
BOOLEAN RosSymGetAddressInformation(PROSSYM_INFO RosSymInfo, ULONG_PTR RelativeAddress, ULONG *LineNumber, char *FileName, char *FunctionName)
Definition: find.c:94
static PCHAR NTAPI KdbpSymUnicodeToAnsi(IN PUNICODE_STRING Unicode, OUT PCHAR Ansi, IN ULONG Length)
Definition: kdb_symbols.c:114
PVOID PatchInformation
Definition: ldrtypes.h:164
std::wstring STRING
Definition: fontsub.cpp:33
Definition: btrfs_drv.h:1922
BOOLEAN KdbpSymFindModule(IN PVOID Address OPTIONAL, IN INT Index OPTIONAL, OUT PLDR_DATA_TABLE_ENTRY *pLdrEntry)
Find a module...
Definition: kdb_symbols.c:75
struct _FileName FileName
Definition: fatprocs.h:893
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 LineNumber
Definition: acpixf.h:1216
UNICODE_STRING BaseDllName
Definition: ldrtypes.h:145
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char UINT32 ACPI_STATUS const char UINT32 const char * FunctionName
Definition: acpixf.h:1274
unsigned int ULONG
Definition: retypes.h:1
#define ULONG_PTR
Definition: config.h:101
#define KdpDprintf(...)
Definition: mmdbg.c:19

Referenced by KdbpCliMainLoop(), KdbpCmdBackTrace(), KdbpCmdDisassembleX(), KdbpPrintAddressInCode(), and KeRosDumpStackFrameArray().

◆ KdbSymProcessSymbols()

VOID KdbSymProcessSymbols ( _Inout_ PLDR_DATA_TABLE_ENTRY  LdrEntry,
_In_ BOOLEAN  Load 
)

Load symbols from image mapping. If this fails,.

Parameters
LdrEntryThe entry to load symbols from

Definition at line 298 of file kdb_symbols.c.

301 {
302  if (!LoadSymbols)
303  return;
304 
305  /* Check if this is unload */
306  if (!Load)
307  {
308  /* Did we process it */
309  if (LdrEntry->PatchInformation)
310  {
311  RosSymDelete(LdrEntry->PatchInformation);
312  LdrEntry->PatchInformation = NULL;
313  }
314  return;
315  }
316 
317  if (RosSymCreateFromMem(LdrEntry->DllBase, LdrEntry->SizeOfImage, (PROSSYM_INFO*)&LdrEntry->PatchInformation))
318  {
319  return;
320  }
321 
322  /* Add a ref until we really process it */
323  LdrEntry->LoadCount++;
324 
325  /* Tell our worker thread to read from it */
327  InsertTailList(&SymbolsToLoad, &LdrEntry->InInitializationOrderLinks);
329 
331 }
BOOLEAN RosSymCreateFromMem(PVOID ImageStart, ULONG_PTR ImageSize, PROSSYM_INFO *RosSymInfo)
Definition: frommem.c:20
VOID NTAPI KeAcquireSpinLockAtDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:198
VOID RosSymDelete(PROSSYM_INFO RosSymInfo)
Definition: delete.c:16
static LIST_ENTRY SymbolsToLoad
Definition: kdb_symbols.c:30
#define InsertTailList(ListHead, Entry)
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
#define FALSE
Definition: types.h:117
static KSPIN_LOCK SymbolsToLoadLock
Definition: kdb_symbols.c:31
VOID NTAPI KeReleaseSpinLockFromDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:221
#define NULL
Definition: types.h:112
#define IO_NO_INCREMENT
Definition: iotypes.h:598
static BOOLEAN LoadSymbols
Definition: kdb_symbols.c:29
static KEVENT SymbolsToLoadEvent
Definition: kdb_symbols.c:32

Referenced by KdbInitialize(), and KdSendPacket().

◆ LoadSymbolsRoutine()

_Use_decl_annotations_ VOID NTAPI LoadSymbolsRoutine ( _In_ PVOID  Context)

The symbol loader thread routine. This opens the image file for reading and loads the symbols section from there.

Note
We must do this because KdbSymProcessSymbols is called at high IRQL and we can't set the event from here
Parameters
ContextUnused

Definition at line 209 of file kdb_symbols.c.

211 {
213 
214  while (TRUE)
215  {
216  PLIST_ENTRY ListEntry;
218  if (!NT_SUCCESS(Status))
219  {
220  DPRINT1("KeWaitForSingleObject failed?! 0x%08x\n", Status);
221  LoadSymbols = FALSE;
222  return;
223  }
224 
226  {
227  PLDR_DATA_TABLE_ENTRY LdrEntry = CONTAINING_RECORD(ListEntry, LDR_DATA_TABLE_ENTRY, InInitializationOrderLinks);
229  OBJECT_ATTRIBUTES Attrib;
232  DPRINT1("Trying %wZ\n", &LdrEntry->FullDllName);
235  &Attrib,
236  &Iosb,
239  if (!NT_SUCCESS(Status))
240  {
241  /* Try system paths */
242  static const UNICODE_STRING System32Dir = RTL_CONSTANT_STRING(L"\\SystemRoot\\system32\\");
243  UNICODE_STRING ImagePath;
244  WCHAR ImagePathBuffer[256];
245  RtlInitEmptyUnicodeString(&ImagePath, ImagePathBuffer, sizeof(ImagePathBuffer));
246  RtlCopyUnicodeString(&ImagePath, &System32Dir);
247  RtlAppendUnicodeStringToString(&ImagePath, &LdrEntry->BaseDllName);
249  DPRINT1("Trying %wZ\n", &ImagePath);
252  &Attrib,
253  &Iosb,
256  if (!NT_SUCCESS(Status))
257  {
258  static const UNICODE_STRING DriversDir= RTL_CONSTANT_STRING(L"\\SystemRoot\\system32\\drivers\\");
259 
260  RtlInitEmptyUnicodeString(&ImagePath, ImagePathBuffer, sizeof(ImagePathBuffer));
261  RtlCopyUnicodeString(&ImagePath, &DriversDir);
262  RtlAppendUnicodeStringToString(&ImagePath, &LdrEntry->BaseDllName);
264  DPRINT1("Trying %wZ\n", &ImagePath);
267  &Attrib,
268  &Iosb,
271  }
272  }
273 
274  if (!NT_SUCCESS(Status))
275  {
276  DPRINT1("Failed opening file %wZ (%wZ) for reading symbols (0x%08x)\n", &LdrEntry->FullDllName, &LdrEntry->BaseDllName, Status);
277  /* We took a ref previously */
278  MmUnloadSystemImage(LdrEntry);
279  continue;
280  }
281 
282  /* Hand it to Rossym */
284  LdrEntry->PatchInformation = NULL;
285 
286  /* We're done for this one. */
288  MmUnloadSystemImage(LdrEntry);
289  }
290  }
291 }
#define FILE_READ_ACCESS
Definition: nt_native.h:610
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN RosSymCreateFromFile(PVOID FileContext, PROSSYM_INFO *RosSymInfo)
Definition: fromfile.c:20
static LIST_ENTRY SymbolsToLoad
Definition: kdb_symbols.c:30
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define FILE_SHARE_READ
Definition: compat.h:136
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
HANDLE FileHandle
Definition: stats.c:38
#define FALSE
Definition: types.h:117
PLIST_ENTRY NTAPI ExInterlockedRemoveHeadList(IN OUT PLIST_ENTRY ListHead, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:166
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
NTSTATUS NTAPI MmUnloadSystemImage(IN PVOID ImageHandle)
Definition: sysldr.c:911
Status
Definition: gdiplustypes.h:24
PVOID PatchInformation
Definition: ldrtypes.h:164
__wchar_t WCHAR
Definition: xmlstorage.h:180
return Iosb
Definition: create.c:4402
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static KSPIN_LOCK SymbolsToLoadLock
Definition: kdb_symbols.c:31
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3398
NTSYSAPI NTSTATUS NTAPI ZwOpenFile(_Out_ PHANDLE FileHandle, _In_ ACCESS_MASK DesiredAccess, _In_ POBJECT_ATTRIBUTES ObjectAttributes, _Out_ PIO_STATUS_BLOCK IoStatusBlock, _In_ ULONG ShareAccess, _In_ ULONG OpenOptions)
static const WCHAR L[]
Definition: oid.c:1250
Definition: btrfs_drv.h:1922
Definition: typedefs.h:119
#define SYNCHRONIZE
Definition: nt_native.h:61
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
UNICODE_STRING FullDllName
Definition: btrfs_drv.h:1928
UNICODE_STRING BaseDllName
Definition: ldrtypes.h:145
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
static BOOLEAN LoadSymbols
Definition: kdb_symbols.c:29
static KEVENT SymbolsToLoadEvent
Definition: kdb_symbols.c:32
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14

Variable Documentation

◆ LoadSymbols

BOOLEAN LoadSymbols
static

◆ LoadSymbolsRoutine

KSTART_ROUTINE LoadSymbolsRoutine
static

Definition at line 196 of file kdb_symbols.c.

Referenced by KdbInitialize().

◆ SymbolsToLoad

LIST_ENTRY SymbolsToLoad
static

Definition at line 30 of file kdb_symbols.c.

Referenced by KdbInitialize(), KdbSymProcessSymbols(), and LoadSymbolsRoutine().

◆ SymbolsToLoadEvent

KEVENT SymbolsToLoadEvent
static

Definition at line 32 of file kdb_symbols.c.

Referenced by KdbInitialize(), KdbSymProcessSymbols(), and LoadSymbolsRoutine().

◆ SymbolsToLoadLock

KSPIN_LOCK SymbolsToLoadLock
static

Definition at line 31 of file kdb_symbols.c.

Referenced by KdbInitialize(), KdbSymProcessSymbols(), and LoadSymbolsRoutine().