mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 01:24:38 +00:00
Symbol loading working in kdb.
svn path=/trunk/; revision=3249
This commit is contained in:
parent
90bd33d955
commit
2e467c56a3
13 changed files with 171 additions and 164 deletions
|
@ -8,12 +8,12 @@ ARCH := i386
|
|||
#
|
||||
# Whether to compile in the kernel debugger
|
||||
#
|
||||
KDBG := 0
|
||||
KDBG := 1
|
||||
|
||||
#
|
||||
# Whether to compile for debugging
|
||||
#
|
||||
DBG := 0
|
||||
DBG := 1
|
||||
|
||||
#
|
||||
# Whether to compile a multiprocessor or single processor version
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
#ifndef __NTOSKRNL_INCLUDE_INTERNAL_LDR_H
|
||||
#define __NTOSKRNL_INCLUDE_INTERNAL_LDR_H
|
||||
|
||||
#include <ntos/kdbgsyms.h>
|
||||
#include <roscfg.h>
|
||||
|
||||
|
@ -19,9 +22,9 @@ typedef struct _LDR_MODULE
|
|||
HANDLE SectionHandle;
|
||||
ULONG CheckSum;
|
||||
ULONG TimeDateStamp;
|
||||
#ifdef DBG
|
||||
#ifdef KDBG
|
||||
IMAGE_SYMBOL_INFO SymbolInfo;
|
||||
#endif /* DBG */
|
||||
#endif /* KDBG */
|
||||
} LDR_MODULE, *PLDR_MODULE;
|
||||
|
||||
typedef struct _LDR_SYMBOL_INFO {
|
||||
|
@ -57,7 +60,7 @@ typedef struct _MODULE_INFORMATION
|
|||
MODULE_ENTRY ModuleEntry[1];
|
||||
} MODULE_INFORMATION, *PMODULE_INFORMATION;
|
||||
|
||||
#ifdef DBG
|
||||
#ifdef KDBG
|
||||
|
||||
VOID
|
||||
LdrpLoadUserModuleSymbols(PLDR_MODULE LdrModule);
|
||||
|
@ -118,4 +121,6 @@ LdrShutdownThread(VOID);
|
|||
NTSTATUS STDCALL
|
||||
LdrUnloadDll(IN PVOID BaseAddress);
|
||||
|
||||
#endif /* __NTOSKRNL_INCLUDE_INTERNAL_LDR_H */
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $Id: Makefile,v 1.73 2002/07/13 12:44:07 chorns Exp $
|
||||
# $Id: Makefile,v 1.74 2002/07/18 00:25:30 dwelch Exp $
|
||||
#
|
||||
# ReactOS Operating System
|
||||
#
|
||||
|
@ -27,7 +27,7 @@ endif
|
|||
|
||||
ifeq ($(KDBG), 1)
|
||||
OBJECTS_KDBG := dbg/kdb.o dbg/kdb_keyboard.o dbg/rdebug.o \
|
||||
dbg/i386/kdb_help.o
|
||||
dbg/i386/kdb_help.o dbg/kdb_stabs.o
|
||||
else
|
||||
OBJECTS_KDBG :=
|
||||
endif
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <ddk/ntddk.h>
|
||||
#include <roscfg.h>
|
||||
#include <internal/ldr.h>
|
||||
#include <internal/kd.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
@ -52,8 +53,8 @@ NtSystemDebugControl(DEBUG_CONTROL_CODE ControlCode,
|
|||
break;
|
||||
#ifdef KDBG
|
||||
case DebugDbgLoadSymbols:
|
||||
LdrLoadUserModuleSymbols((PLDR_MODULE) InputBuffer);
|
||||
#endif /* DBG */
|
||||
KdbLdrLoadUserModuleSymbols((PLDR_MODULE) InputBuffer);
|
||||
#endif /* KDBG */
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: kdb.c,v 1.6 2002/05/05 14:57:43 chorns Exp $
|
||||
/* $Id: kdb.c,v 1.7 2002/07/18 00:25:30 dwelch Exp $
|
||||
*
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/dbg/kdb.c
|
||||
|
@ -33,6 +33,7 @@
|
|||
#include <internal/ps.h>
|
||||
#include <limits.h>
|
||||
#include <ctype.h>
|
||||
#include <internal/kd.h>
|
||||
#include "kdb.h"
|
||||
|
||||
#define NDEBUG
|
||||
|
@ -259,7 +260,11 @@ DbgPrintBackTrace(PULONG Frame, ULONG StackBase, ULONG StackLimit)
|
|||
while (Frame != NULL && (ULONG)Frame >= StackLimit &&
|
||||
(ULONG)Frame < StackBase)
|
||||
{
|
||||
#if 0
|
||||
DbgPrint("%.8x ", Frame[1]);
|
||||
#else
|
||||
KdbPrintAddress((PVOID)Frame[1]);
|
||||
#endif
|
||||
Frame = (PULONG)Frame[0];
|
||||
i++;
|
||||
}
|
||||
|
|
|
@ -39,14 +39,13 @@
|
|||
#include <internal/trap.h>
|
||||
#include <ntdll/ldr.h>
|
||||
#include <internal/safe.h>
|
||||
#include <internal/kd.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
||||
/* GLOBALS ******************************************************************/
|
||||
|
||||
#ifdef DBG
|
||||
|
||||
typedef struct _SYMBOLFILE_HEADER {
|
||||
unsigned long StabsOffset;
|
||||
unsigned long StabsLength;
|
||||
|
@ -91,11 +90,8 @@ typedef struct _STAB_ENTRY {
|
|||
*/
|
||||
#define N_SO 0x64
|
||||
|
||||
LIST_ENTRY SymbolListHead;
|
||||
|
||||
#endif /* DBG */
|
||||
|
||||
#ifdef DBG
|
||||
static LIST_ENTRY SymbolListHead;
|
||||
static KSPIN_LOCK SymbolListLock;
|
||||
|
||||
NTSTATUS
|
||||
LdrGetAddressInformation(IN PIMAGE_SYMBOL_INFO SymbolInfo,
|
||||
|
@ -104,24 +100,23 @@ LdrGetAddressInformation(IN PIMAGE_SYMBOL_INFO SymbolInfo,
|
|||
OUT PCH FileName OPTIONAL,
|
||||
OUT PCH FunctionName OPTIONAL);
|
||||
|
||||
#endif /* DBG */
|
||||
VOID
|
||||
KdbLdrUnloadModuleSymbols(PIMAGE_SYMBOL_INFO SymbolInfo);
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
STATIC BOOLEAN
|
||||
print_user_address(PVOID address)
|
||||
BOOLEAN
|
||||
KdbPrintUserAddress(PVOID address)
|
||||
{
|
||||
PLIST_ENTRY current_entry;
|
||||
PLDR_MODULE current;
|
||||
PEPROCESS CurrentProcess;
|
||||
PPEB Peb = NULL;
|
||||
ULONG_PTR RelativeAddress;
|
||||
#ifdef DBG
|
||||
NTSTATUS Status;
|
||||
ULONG LineNumber;
|
||||
CHAR FileName[256];
|
||||
CHAR FunctionName[256];
|
||||
#endif
|
||||
|
||||
CurrentProcess = PsGetCurrentProcess();
|
||||
if (NULL != CurrentProcess)
|
||||
|
@ -147,7 +142,6 @@ print_user_address(PVOID address)
|
|||
address < (PVOID)(current->BaseAddress + current->SizeOfImage))
|
||||
{
|
||||
RelativeAddress = (ULONG_PTR) address - (ULONG_PTR)current->BaseAddress;
|
||||
#ifdef DBG
|
||||
Status = LdrGetAddressInformation(¤t->SymbolInfo,
|
||||
RelativeAddress,
|
||||
&LineNumber,
|
||||
|
@ -162,10 +156,6 @@ print_user_address(PVOID address)
|
|||
{
|
||||
DbgPrint("<%wZ: %x>", ¤t->BaseDllName, RelativeAddress);
|
||||
}
|
||||
#else /* !DBG */
|
||||
DbgPrint("<%wZ: %x>", ¤t->BaseDllName, RelativeAddress);
|
||||
#endif /* !DBG */
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
|
@ -174,19 +164,17 @@ print_user_address(PVOID address)
|
|||
return(FALSE);
|
||||
}
|
||||
|
||||
STATIC BOOLEAN
|
||||
print_address(PVOID address)
|
||||
BOOLEAN
|
||||
KdbPrintAddress(PVOID address)
|
||||
{
|
||||
PLIST_ENTRY current_entry;
|
||||
MODULE_TEXT_SECTION* current;
|
||||
extern LIST_ENTRY ModuleTextListHead;
|
||||
ULONG_PTR RelativeAddress;
|
||||
#ifdef DBG
|
||||
NTSTATUS Status;
|
||||
ULONG LineNumber;
|
||||
CHAR FileName[256];
|
||||
CHAR FunctionName[256];
|
||||
#endif
|
||||
|
||||
current_entry = ModuleTextListHead.Flink;
|
||||
|
||||
|
@ -200,7 +188,6 @@ print_address(PVOID address)
|
|||
address < (PVOID)(current->Base + current->Length))
|
||||
{
|
||||
RelativeAddress = (ULONG_PTR) address - current->Base;
|
||||
#ifdef kDBG
|
||||
Status = LdrGetAddressInformation(¤t->SymbolInfo,
|
||||
RelativeAddress,
|
||||
&LineNumber,
|
||||
|
@ -215,9 +202,6 @@ print_address(PVOID address)
|
|||
{
|
||||
DbgPrint("<%ws: %x>", current->Name, RelativeAddress);
|
||||
}
|
||||
#else /* !DBG */
|
||||
DbgPrint("<%ws: %x>", current->Name, RelativeAddress);
|
||||
#endif /* !DBG */
|
||||
return(TRUE);
|
||||
}
|
||||
current_entry = current_entry->Flink;
|
||||
|
@ -225,10 +209,8 @@ print_address(PVOID address)
|
|||
return(FALSE);
|
||||
}
|
||||
|
||||
#ifdef DBG
|
||||
|
||||
VOID
|
||||
PiFreeSymbols(PPEB Peb)
|
||||
KdbFreeSymbolsProcess(PPEB Peb)
|
||||
{
|
||||
PLIST_ENTRY CurrentEntry;
|
||||
PLDR_MODULE Current;
|
||||
|
@ -245,34 +227,32 @@ PiFreeSymbols(PPEB Peb)
|
|||
InLoadOrderModuleList);
|
||||
|
||||
SymbolInfo = &Current->SymbolInfo;
|
||||
LdrUnloadModuleSymbols(SymbolInfo);
|
||||
KdbLdrUnloadModuleSymbols(SymbolInfo);
|
||||
|
||||
CurrentEntry = CurrentEntry->Flink;
|
||||
}
|
||||
}
|
||||
|
||||
VOID
|
||||
KdbLdrInit(VOID)
|
||||
KdbLdrInit(MODULE_TEXT_SECTION* NtoskrnlTextSection,
|
||||
MODULE_TEXT_SECTION* LdrHalTextSection)
|
||||
{
|
||||
#ifdef DBG
|
||||
RtlZeroMemory(&NtoskrnlTextSection.SymbolInfo, sizeof(NtoskrnlTextSection.SymbolInfo));
|
||||
NtoskrnlTextSection.SymbolInfo.ImageBase = OptionalHeader->ImageBase;
|
||||
NtoskrnlTextSection.SymbolInfo.ImageSize = NtoskrnlTextSection.Length;
|
||||
#endif
|
||||
RtlZeroMemory(&NtoskrnlTextSection->SymbolInfo,
|
||||
sizeof(NtoskrnlTextSection->SymbolInfo));
|
||||
NtoskrnlTextSection->SymbolInfo.ImageBase =
|
||||
NtoskrnlTextSection->OptionalHeader->ImageBase;
|
||||
NtoskrnlTextSection->SymbolInfo.ImageSize = NtoskrnlTextSection->Length;
|
||||
|
||||
#ifdef DBG
|
||||
RtlZeroMemory(&LdrHalTextSection.SymbolInfo, sizeof(LdrHalTextSection.SymbolInfo));
|
||||
LdrHalTextSection.SymbolInfo.ImageBase = OptionalHeader->ImageBase;
|
||||
LdrHalTextSection.SymbolInfo.ImageSize = LdrHalTextSection.Length;
|
||||
#endif
|
||||
RtlZeroMemory(&LdrHalTextSection->SymbolInfo,
|
||||
sizeof(LdrHalTextSection->SymbolInfo));
|
||||
LdrHalTextSection->SymbolInfo.ImageBase =
|
||||
LdrHalTextSection->OptionalHeader->ImageBase;
|
||||
LdrHalTextSection->SymbolInfo.ImageSize = LdrHalTextSection->Length;
|
||||
|
||||
#ifdef DBG
|
||||
InitializeListHead(&SymbolListHead);
|
||||
#endif
|
||||
KeInitializeSpinLock(&SymbolListLock);
|
||||
}
|
||||
|
||||
#ifdef DBG
|
||||
|
||||
VOID
|
||||
LdrpParseImageSymbols(PIMAGE_SYMBOL_INFO SymbolInfo)
|
||||
/* Note: It is important that the symbol strings buffer not be released after
|
||||
|
@ -577,7 +557,7 @@ LdrGetAddressInformation(IN PIMAGE_SYMBOL_INFO SymbolInfo,
|
|||
|
||||
VOID
|
||||
LdrpLoadModuleSymbols(PUNICODE_STRING FileName,
|
||||
PIMAGE_SYMBOL_INFO SymbolInfo)
|
||||
PIMAGE_SYMBOL_INFO SymbolInfo)
|
||||
{
|
||||
FILE_STANDARD_INFORMATION FileStdInfo;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
|
@ -681,9 +661,8 @@ LdrpLoadModuleSymbols(PUNICODE_STRING FileName,
|
|||
SymbolInfo->SymbolStringsLength = SymbolFileHeader->StabstrLength;
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
LdrUnloadModuleSymbols(PIMAGE_SYMBOL_INFO SymbolInfo)
|
||||
KdbLdrUnloadModuleSymbols(PIMAGE_SYMBOL_INFO SymbolInfo)
|
||||
{
|
||||
PSYMBOL NextSymbol;
|
||||
PSYMBOL Symbol;
|
||||
|
@ -752,7 +731,7 @@ LdrpLookupUserSymbolInfo(PLDR_MODULE LdrModule)
|
|||
|
||||
DPRINT("Searching symbols for %S\n", LdrModule->FullDllName.Buffer);
|
||||
|
||||
KeAcquireSpinLock(&ModuleListLock,&Irql);
|
||||
KeAcquireSpinLock(&SymbolListLock, &Irql);
|
||||
|
||||
CurrentEntry = SymbolListHead.Flink;
|
||||
while (CurrentEntry != (&SymbolListHead))
|
||||
|
@ -761,21 +740,20 @@ LdrpLookupUserSymbolInfo(PLDR_MODULE LdrModule)
|
|||
|
||||
if (RtlEqualUnicodeString(&Current->FullName, &LdrModule->FullDllName, TRUE))
|
||||
{
|
||||
KeReleaseSpinLock(&ModuleListLock, Irql);
|
||||
KeReleaseSpinLock(&SymbolListLock, Irql);
|
||||
return Current;
|
||||
}
|
||||
|
||||
CurrentEntry = CurrentEntry->Flink;
|
||||
}
|
||||
|
||||
KeReleaseSpinLock(&ModuleListLock, Irql);
|
||||
KeReleaseSpinLock(&SymbolListLock, Irql);
|
||||
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
LdrLoadUserModuleSymbols(PLDR_MODULE LdrModule)
|
||||
KdbLdrLoadUserModuleSymbols(PLDR_MODULE LdrModule)
|
||||
{
|
||||
PIMAGE_SYMBOL_INFO_CACHE CacheEntry;
|
||||
|
||||
|
@ -801,6 +779,7 @@ LdrLoadUserModuleSymbols(PLDR_MODULE LdrModule)
|
|||
CacheEntry = ExAllocatePool(NonPagedPool, sizeof(IMAGE_SYMBOL_INFO_CACHE));
|
||||
assert(CacheEntry);
|
||||
RtlZeroMemory(CacheEntry, sizeof(IMAGE_SYMBOL_INFO_CACHE));
|
||||
|
||||
RtlCreateUnicodeString(&CacheEntry->FullName, LdrModule->FullDllName.Buffer);
|
||||
assert(CacheEntry->FullName.Buffer);
|
||||
LdrpLoadModuleSymbols(&LdrModule->FullDllName, &LdrModule->SymbolInfo);
|
||||
|
@ -808,92 +787,99 @@ LdrLoadUserModuleSymbols(PLDR_MODULE LdrModule)
|
|||
}
|
||||
}
|
||||
|
||||
#endif /* DBG */
|
||||
|
||||
VOID
|
||||
KdbLoadDriver(VOID)
|
||||
KdbLoadDriver(PUNICODE_STRING Filename, PMODULE_OBJECT Module)
|
||||
{
|
||||
#ifdef DBG
|
||||
/* Load symbols for the image if available */
|
||||
LdrpLoadModuleSymbols(Filename, &Module->TextSection->SymbolInfo);
|
||||
#endif /* DBG */
|
||||
}
|
||||
|
||||
VOID
|
||||
KdbUnloadDriver(VOID)
|
||||
KdbUnloadDriver(PMODULE_OBJECT ModuleObject)
|
||||
{
|
||||
#ifdef DBG
|
||||
/* Unload symbols for module if available */
|
||||
LdrUnloadModuleSymbols(&ModuleObject->TextSection->SymbolInfo);
|
||||
#endif /* DBG */
|
||||
KdbLdrUnloadModuleSymbols(&ModuleObject->TextSection->SymbolInfo);
|
||||
}
|
||||
|
||||
VOID
|
||||
KdbInitializeDriver(VOID)
|
||||
KdbProcessSymbolFile(PVOID ModuleLoadBase, PCHAR FileName, ULONG Length)
|
||||
{
|
||||
#ifdef DBG
|
||||
PSYMBOLFILE_HEADER SymbolFileHeader;
|
||||
PIMAGE_SYMBOL_INFO SymbolInfo;
|
||||
#endif /* DBG */
|
||||
|
||||
#ifdef DBG
|
||||
PMODULE_OBJECT ModuleObject;
|
||||
UNICODE_STRING ModuleName;
|
||||
CHAR TmpBaseName[MAX_PATH];
|
||||
CHAR TmpFileName[MAX_PATH];
|
||||
PSYMBOLFILE_HEADER SymbolFileHeader;
|
||||
PIMAGE_SYMBOL_INFO SymbolInfo;
|
||||
ANSI_STRING AnsiString;
|
||||
#endif /* DBG */
|
||||
|
||||
#ifdef DBG
|
||||
DPRINT("Module %s is a symbol file\n", FileName);
|
||||
|
||||
if ((FileExt != NULL) && (strcmp(FileExt, ".sym") == 0))
|
||||
strncpy(TmpBaseName, FileName, Length);
|
||||
TmpBaseName[Length] = '\0';
|
||||
|
||||
DPRINT("base: %s (Length %d)\n", TmpBaseName, Length);
|
||||
|
||||
strcpy(TmpFileName, TmpBaseName);
|
||||
strcat(TmpFileName, ".sys");
|
||||
RtlInitAnsiString(&AnsiString, TmpFileName);
|
||||
|
||||
RtlAnsiStringToUnicodeString(&ModuleName, &AnsiString, TRUE);
|
||||
ModuleObject = LdrGetModuleObject(&ModuleName);
|
||||
RtlFreeUnicodeString(&ModuleName);
|
||||
if (ModuleObject == NULL)
|
||||
{
|
||||
DPRINT("Module %s is a symbol file\n", FileName);
|
||||
|
||||
strncpy(TmpBaseName, FileName, Length);
|
||||
TmpBaseName[Length] = '\0';
|
||||
|
||||
DPRINT("base: %s (Length %d)\n", TmpBaseName, Length);
|
||||
|
||||
strcpy(TmpFileName, TmpBaseName);
|
||||
strcat(TmpFileName, ".sys");
|
||||
strcat(TmpFileName, ".exe");
|
||||
RtlInitAnsiString(&AnsiString, TmpFileName);
|
||||
|
||||
RtlAnsiStringToUnicodeString(&ModuleName, &AnsiString, TRUE);
|
||||
ModuleObject = LdrGetModuleObject(&ModuleName);
|
||||
RtlFreeUnicodeString(&ModuleName);
|
||||
if (ModuleObject == NULL)
|
||||
{
|
||||
strcpy(TmpFileName, TmpBaseName);
|
||||
strcat(TmpFileName, ".exe");
|
||||
RtlInitAnsiString(&AnsiString, TmpFileName);
|
||||
RtlAnsiStringToUnicodeString(&ModuleName, &AnsiString, TRUE);
|
||||
ModuleObject = LdrGetModuleObject(&ModuleName);
|
||||
RtlFreeUnicodeString(&ModuleName);
|
||||
}
|
||||
if (ModuleObject != NULL)
|
||||
{
|
||||
SymbolInfo = (PIMAGE_SYMBOL_INFO) &ModuleObject->TextSection->SymbolInfo;
|
||||
SymbolFileHeader = (PSYMBOLFILE_HEADER) ModuleLoadBase;
|
||||
SymbolInfo->FileBuffer = ModuleLoadBase;
|
||||
SymbolInfo->SymbolsBase = ModuleLoadBase + SymbolFileHeader->StabsOffset;
|
||||
SymbolInfo->SymbolsLength = SymbolFileHeader->StabsLength;
|
||||
SymbolInfo->SymbolStringsBase = ModuleLoadBase + SymbolFileHeader->StabstrOffset;
|
||||
SymbolInfo->SymbolStringsLength = SymbolFileHeader->StabstrLength;
|
||||
}
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
else
|
||||
if (ModuleObject != NULL)
|
||||
{
|
||||
DPRINT("Module %s is non-symbol file\n", FileName);
|
||||
}
|
||||
|
||||
#endif /* !DBG */
|
||||
|
||||
#ifdef DBG
|
||||
RtlZeroMemory(&ModuleTextSection->SymbolInfo, sizeof(ModuleTextSection->SymbolInfo));
|
||||
ModuleTextSection->SymbolInfo.ImageBase = PEOptionalHeader->ImageBase;
|
||||
ModuleTextSection->SymbolInfo.ImageSize = ModuleTextSection->Length;
|
||||
#endif /* DBG */
|
||||
SymbolInfo = (PIMAGE_SYMBOL_INFO) &ModuleObject->TextSection->SymbolInfo;
|
||||
SymbolFileHeader = (PSYMBOLFILE_HEADER) ModuleLoadBase;
|
||||
SymbolInfo->FileBuffer = ModuleLoadBase;
|
||||
SymbolInfo->SymbolsBase = ModuleLoadBase + SymbolFileHeader->StabsOffset;
|
||||
SymbolInfo->SymbolsLength = SymbolFileHeader->StabsLength;
|
||||
SymbolInfo->SymbolStringsBase = ModuleLoadBase + SymbolFileHeader->StabstrOffset;
|
||||
SymbolInfo->SymbolStringsLength = SymbolFileHeader->StabstrLength;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* DBG */
|
||||
VOID
|
||||
KdbInitializeDriver(PMODULE_TEXT_SECTION ModuleTextSection)
|
||||
{
|
||||
RtlZeroMemory(&ModuleTextSection->SymbolInfo, sizeof(ModuleTextSection->SymbolInfo));
|
||||
ModuleTextSection->SymbolInfo.ImageBase =
|
||||
ModuleTextSection->OptionalHeader->ImageBase;
|
||||
ModuleTextSection->SymbolInfo.ImageSize = ModuleTextSection->Length;
|
||||
}
|
||||
|
||||
VOID
|
||||
KdbLdrLoadAutoConfigDrivers(VOID)
|
||||
{
|
||||
UNICODE_STRING ModuleName;
|
||||
PMODULE_OBJECT ModuleObject;
|
||||
|
||||
/*
|
||||
* Load symbols for ntoskrnl.exe and hal.dll because \SystemRoot
|
||||
* is created after their module entries
|
||||
*/
|
||||
|
||||
RtlInitUnicodeString(&ModuleName, KERNEL_MODULE_NAME);
|
||||
ModuleObject = LdrGetModuleObject(&ModuleName);
|
||||
if (ModuleObject != NULL)
|
||||
{
|
||||
LdrpLoadModuleSymbols(&ModuleName,
|
||||
&ModuleObject->TextSection->SymbolInfo);
|
||||
}
|
||||
|
||||
RtlInitUnicodeString(&ModuleName, HAL_MODULE_NAME);
|
||||
ModuleObject = LdrGetModuleObject(&ModuleName);
|
||||
if (ModuleObject != NULL)
|
||||
{
|
||||
LdrpLoadModuleSymbols(&ModuleName,
|
||||
&ModuleObject->TextSection->SymbolInfo);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: kd.h,v 1.11 2002/07/17 22:56:10 dwelch Exp $
|
||||
/* $Id: kd.h,v 1.12 2002/07/18 00:25:30 dwelch Exp $
|
||||
*
|
||||
* kernel debugger prototypes
|
||||
*/
|
||||
|
@ -7,6 +7,7 @@
|
|||
#define __INCLUDE_INTERNAL_KERNEL_DEBUGGER_H
|
||||
|
||||
#include <internal/ke.h>
|
||||
#include <internal/ldr.h>
|
||||
|
||||
#define KD_DEBUG_DISABLED 0x00
|
||||
#define KD_DEBUG_GDB 0x01
|
||||
|
@ -71,10 +72,31 @@ VOID KdPrintMda(PCH pch);
|
|||
#define KDB_DELETEPROCESS_HOOK(PROCESS)
|
||||
#define KDB_LOADDRIVER_HOOK(MODULE)
|
||||
#define KDB_UNLOADDRIVER_HOOK(MODULE)
|
||||
#define KDB_LOADERINIT_HOOK(NTOS, HAL)
|
||||
#define KDB_SYMBOLFILE_HOOK(LOADBASE, FILENAME, LENGTH)
|
||||
#else
|
||||
#define KDB_DELETEPROCESS_HOOK(PROCESS) XXXX
|
||||
#define KDB_LOADDRIVER_HOOK(MODULE) XXXX
|
||||
#define KDB_UNLOADDRIVER_HOOK(MODULE) XXXX
|
||||
#define KDB_DELETEPROCESS_HOOK(PROCESS) KdbFreeSymbolsProcess(PROCESS)
|
||||
#define KDB_LOADDRIVER_HOOK(FILENAME, MODULE) KdbLoadDriver(FILENAME, MODULE)
|
||||
#define KDB_UNLOADDRIVER_HOOK(MODULE) KdbUnloadDriver(MODULE)
|
||||
#define KDB_LOADERINIT_HOOK(NTOS, HAL) KdbLdrInit(NTOS, HAL)
|
||||
#define KDB_SYMBOLFILE_HOOK(LOADBASE, FILENAME, LENGTH) \
|
||||
KdbProcessSymbolFile(LOADBASE, FILENAME, LENGTH)
|
||||
#endif /* KDBG */
|
||||
|
||||
VOID
|
||||
KdbLdrLoadUserModuleSymbols(PLDR_MODULE LdrModule);
|
||||
VOID
|
||||
KdbProcessSymbolFile(PVOID ModuleLoadBase, PCHAR FileName, ULONG Length);
|
||||
VOID
|
||||
KdbLdrInit(MODULE_TEXT_SECTION* NtoskrnlTextSection,
|
||||
MODULE_TEXT_SECTION* LdrHalTextSection);
|
||||
VOID
|
||||
KdbUnloadDriver(PMODULE_OBJECT ModuleObject);
|
||||
VOID
|
||||
KdbLoadDriver(PUNICODE_STRING Filename, PMODULE_OBJECT Module);
|
||||
VOID
|
||||
KdbFreeSymbolsProcess(PPEB Peb);
|
||||
BOOLEAN
|
||||
KdbPrintAddress(PVOID address);
|
||||
|
||||
#endif /* __INCLUDE_INTERNAL_KERNEL_DEBUGGER_H */
|
||||
|
|
|
@ -13,9 +13,10 @@ typedef struct _MODULE_TEXT_SECTION
|
|||
ULONG Length;
|
||||
LIST_ENTRY ListEntry;
|
||||
PWCH Name;
|
||||
#ifdef DBG
|
||||
PIMAGE_OPTIONAL_HEADER OptionalHeader;
|
||||
#ifdef KDBG
|
||||
IMAGE_SYMBOL_INFO SymbolInfo;
|
||||
#endif /* DBG */
|
||||
#endif /* KDBG */
|
||||
} MODULE_TEXT_SECTION, *PMODULE_TEXT_SECTION;
|
||||
|
||||
typedef struct _MODULE_OBJECT
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: driver.c,v 1.8 2002/06/27 17:49:34 ekohl Exp $
|
||||
/* $Id: driver.c,v 1.9 2002/07/18 00:25:30 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -484,34 +484,8 @@ LdrLoadAutoConfigDrivers(VOID)
|
|||
CHAR TextBuffer [256];
|
||||
ULONG x, y, cx, cy;
|
||||
|
||||
#ifdef KDBG
|
||||
UNICODE_STRING ModuleName;
|
||||
PMODULE_OBJECT ModuleObject;
|
||||
#endif
|
||||
|
||||
DPRINT("LdrLoadAutoConfigDrivers() called\n");
|
||||
|
||||
#ifdef KDBG
|
||||
/*
|
||||
* Load symbols for ntoskrnl.exe and hal.dll because \SystemRoot
|
||||
* is created after their module entries
|
||||
*/
|
||||
|
||||
RtlInitUnicodeString(&ModuleName, KERNEL_MODULE_NAME);
|
||||
ModuleObject = LdrGetModuleObject(&ModuleName);
|
||||
if (ModuleObject != NULL)
|
||||
{
|
||||
LdrpLoadModuleSymbols(ModuleObject);
|
||||
}
|
||||
|
||||
RtlInitUnicodeString(&ModuleName, HAL_MODULE_NAME);
|
||||
ModuleObject = LdrGetModuleObject(&ModuleName);
|
||||
if (ModuleObject != NULL)
|
||||
{
|
||||
LdrpLoadModuleSymbols(ModuleObject);
|
||||
}
|
||||
#endif /* KDBG */
|
||||
|
||||
GroupEntry = GroupListHead.Flink;
|
||||
while (GroupEntry != &GroupListHead)
|
||||
{
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: catch.c,v 1.20 2002/05/08 17:05:32 chorns Exp $
|
||||
/* $Id: catch.c,v 1.21 2002/07/18 00:25:30 dwelch Exp $
|
||||
*
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/ke/catch.c
|
||||
|
@ -200,6 +200,7 @@ KiDispatchException(PEXCEPTION_RECORD ExceptionRecord,
|
|||
CONTEXT TContext;
|
||||
|
||||
DPRINT("KiDispatchException() called\n");
|
||||
|
||||
/* PCR->KeExceptionDispatchCount++; */
|
||||
|
||||
if (Context == NULL)
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include <internal/trap.h>
|
||||
#include <ntdll/ldr.h>
|
||||
#include <internal/safe.h>
|
||||
#include <internal/kd.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
@ -559,7 +560,7 @@ KeDumpStackFrames(PULONG Frame)
|
|||
print_address((PVOID)Frame[1]);
|
||||
Frame = (PULONG)Frame[0];
|
||||
i++;
|
||||
DbgPrint("\n");
|
||||
DbgPrint(" ");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: loader.c,v 1.117 2002/07/17 22:56:11 dwelch Exp $
|
||||
/* $Id: loader.c,v 1.118 2002/07/18 00:25:31 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -145,6 +145,7 @@ LdrInit1(VOID)
|
|||
NtoskrnlTextSection.Length = SectionList[0].Misc.VirtualSize +
|
||||
SectionList[0].VirtualAddress;
|
||||
NtoskrnlTextSection.Name = KERNEL_MODULE_NAME;
|
||||
NtoskrnlTextSection.OptionalHeader = OptionalHeader;
|
||||
InsertTailList(&ModuleTextListHead, &NtoskrnlTextSection.ListEntry);
|
||||
|
||||
/* Setup hal.dll text section */
|
||||
|
@ -160,7 +161,11 @@ LdrInit1(VOID)
|
|||
LdrHalTextSection.Length = SectionList[0].Misc.VirtualSize +
|
||||
SectionList[0].VirtualAddress;
|
||||
LdrHalTextSection.Name = HAL_MODULE_NAME;
|
||||
LdrHalTextSection.OptionalHeader = OptionalHeader;
|
||||
InsertTailList(&ModuleTextListHead, &LdrHalTextSection.ListEntry);
|
||||
|
||||
/* Hook for KDB on initialization of the loader. */
|
||||
KDB_LOADERINIT_HOOK(&NtoskrnlTextSection, &LdrHalTextSection);
|
||||
}
|
||||
|
||||
|
||||
|
@ -407,7 +412,7 @@ LdrLoadModule(PUNICODE_STRING Filename,
|
|||
*ModuleObject = Module;
|
||||
|
||||
/* Hook for KDB on loading a driver. */
|
||||
KDB_LOADDRIVER_HOOK(Module);
|
||||
KDB_LOADDRIVER_HOOK(Filename, Module);
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
@ -459,7 +464,6 @@ LdrInitializeBootStartDriver(PVOID ModuleLoadBase,
|
|||
LPWSTR Start;
|
||||
LPWSTR Ext;
|
||||
PCHAR FileExt;
|
||||
|
||||
CHAR TextBuffer [256];
|
||||
ULONG x, y, cx, cy;
|
||||
|
||||
|
@ -481,7 +485,12 @@ LdrInitializeBootStartDriver(PVOID ModuleLoadBase,
|
|||
else
|
||||
Length = strlen(FileName);
|
||||
|
||||
if ((FileExt != NULL) && !(strcmp(FileExt, ".sys") == 0))
|
||||
if ((FileExt != NULL) && (strcmp(FileExt, ".sym") == 0))
|
||||
{
|
||||
KDB_SYMBOLFILE_HOOK(ModuleLoadBase, FileName, Length);
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
else if ((FileExt != NULL) && !(strcmp(FileExt, ".sys") == 0))
|
||||
{
|
||||
CPRINT("Ignoring non-driver file %s\n", FileName);
|
||||
return STATUS_SUCCESS;
|
||||
|
@ -1142,6 +1151,8 @@ LdrPEProcessModule(PVOID ModuleLoadBase,
|
|||
ExAllocatePool(NonPagedPool,
|
||||
(wcslen(NameBuffer) + 1) * sizeof(WCHAR));
|
||||
wcscpy(ModuleTextSection->Name, NameBuffer);
|
||||
ModuleTextSection->OptionalHeader =
|
||||
CreatedModuleObject->Image.PE.OptionalHeader;
|
||||
InsertTailList(&ModuleTextListHead, &ModuleTextSection->ListEntry);
|
||||
|
||||
CreatedModuleObject->TextSection = ModuleTextSection;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: process.c,v 1.87 2002/07/17 22:56:11 dwelch Exp $
|
||||
/* $Id: process.c,v 1.88 2002/07/18 00:25:31 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -299,7 +299,7 @@ PiDeleteProcess(PVOID ObjectBody)
|
|||
KeReleaseSpinLock(&PsProcessListLock, oldIrql);
|
||||
|
||||
/* KDB hook */
|
||||
KDB_DELETEPROCESS_HOOK(Process);
|
||||
KDB_DELETEPROCESS_HOOK(Process->Peb);
|
||||
|
||||
ObDereferenceObject(Process->Token);
|
||||
|
||||
|
|
Loading…
Reference in a new issue