mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
Fixed null pointer exceptions.
Removed private install script. Moved stabs reading to a seperate file. Added hooks for the kernel debugger. svn path=/trunk/; revision=3245
This commit is contained in:
parent
82ad78524a
commit
e646abc58c
9 changed files with 37 additions and 818 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: msfs.c,v 1.2 2001/06/12 12:33:42 ekohl Exp $
|
/* $Id: msfs.c,v 1.3 2002/07/17 22:56:10 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -29,7 +29,7 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
|
||||||
|
|
||||||
DbgPrint("Mailslot FSD 0.0.1\n");
|
DbgPrint("Mailslot FSD 0.0.1\n");
|
||||||
|
|
||||||
DeviceObject->Flags = 0;
|
DriverObject->Flags = 0;
|
||||||
DriverObject->MajorFunction[IRP_MJ_CREATE] = MsfsCreate;
|
DriverObject->MajorFunction[IRP_MJ_CREATE] = MsfsCreate;
|
||||||
DriverObject->MajorFunction[IRP_MJ_CREATE_MAILSLOT] =
|
DriverObject->MajorFunction[IRP_MJ_CREATE_MAILSLOT] =
|
||||||
MsfsCreateMailslot;
|
MsfsCreateMailslot;
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
/sbin/modprobe loop
|
|
||||||
echo "Installing to disk."
|
|
||||||
mount -t vfat /home/welch/devel/bochs/10M.vga.dos /mnt/floppy -o loop,offset=8704,rw
|
|
||||||
cp -rv reactos /mnt/floppy
|
|
||||||
umount /mnt/floppy
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ NtSystemDebugControl(DEBUG_CONTROL_CODE ControlCode,
|
||||||
case DebugQuerySpecialCalls:
|
case DebugQuerySpecialCalls:
|
||||||
case DebugDbgBreakPoint:
|
case DebugDbgBreakPoint:
|
||||||
break;
|
break;
|
||||||
#ifdef DBG
|
#ifdef KDBG
|
||||||
case DebugDbgLoadSymbols:
|
case DebugDbgLoadSymbols:
|
||||||
LdrLoadUserModuleSymbols((PLDR_MODULE) InputBuffer);
|
LdrLoadUserModuleSymbols((PLDR_MODULE) InputBuffer);
|
||||||
#endif /* DBG */
|
#endif /* DBG */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: kd.h,v 1.10 2002/07/04 19:56:35 dwelch Exp $
|
/* $Id: kd.h,v 1.11 2002/07/17 22:56:10 dwelch Exp $
|
||||||
*
|
*
|
||||||
* kernel debugger prototypes
|
* kernel debugger prototypes
|
||||||
*/
|
*/
|
||||||
|
@ -67,4 +67,14 @@ KdEnterDebuggerException(PEXCEPTION_RECORD ExceptionRecord,
|
||||||
VOID KdInitializeMda(VOID);
|
VOID KdInitializeMda(VOID);
|
||||||
VOID KdPrintMda(PCH pch);
|
VOID KdPrintMda(PCH pch);
|
||||||
|
|
||||||
|
#ifndef KDBG
|
||||||
|
#define KDB_DELETEPROCESS_HOOK(PROCESS)
|
||||||
|
#define KDB_LOADDRIVER_HOOK(MODULE)
|
||||||
|
#define KDB_UNLOADDRIVER_HOOK(MODULE)
|
||||||
|
#else
|
||||||
|
#define KDB_DELETEPROCESS_HOOK(PROCESS) XXXX
|
||||||
|
#define KDB_LOADDRIVER_HOOK(MODULE) XXXX
|
||||||
|
#define KDB_UNLOADDRIVER_HOOK(MODULE) XXXX
|
||||||
|
#endif /* KDBG */
|
||||||
|
|
||||||
#endif /* __INCLUDE_INTERNAL_KERNEL_DEBUGGER_H */
|
#endif /* __INCLUDE_INTERNAL_KERNEL_DEBUGGER_H */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: pnpmgr.c,v 1.5 2002/06/10 23:03:33 ekohl Exp $
|
/* $Id: pnpmgr.c,v 1.6 2002/07/17 22:56:10 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -350,7 +350,10 @@ IopCreateDeviceNode(PDEVICE_NODE ParentNode,
|
||||||
KeAcquireSpinLock(&IopDeviceTreeLock, &OldIrql);
|
KeAcquireSpinLock(&IopDeviceTreeLock, &OldIrql);
|
||||||
Node->Parent = ParentNode;
|
Node->Parent = ParentNode;
|
||||||
Node->NextSibling = ParentNode->Child;
|
Node->NextSibling = ParentNode->Child;
|
||||||
ParentNode->Child->PrevSibling = Node;
|
if (ParentNode->Child != NULL)
|
||||||
|
{
|
||||||
|
ParentNode->Child->PrevSibling = Node;
|
||||||
|
}
|
||||||
ParentNode->Child = Node;
|
ParentNode->Child = Node;
|
||||||
KeReleaseSpinLock(&IopDeviceTreeLock, OldIrql);
|
KeReleaseSpinLock(&IopDeviceTreeLock, OldIrql);
|
||||||
}
|
}
|
||||||
|
@ -1061,17 +1064,6 @@ IopInterrogateBusExtender(
|
||||||
|
|
||||||
DPRINT("Got %d PDOs\n", DeviceRelations->Count);
|
DPRINT("Got %d PDOs\n", DeviceRelations->Count);
|
||||||
|
|
||||||
#ifdef DBG
|
|
||||||
{
|
|
||||||
ULONG i;
|
|
||||||
|
|
||||||
DPRINT("DeviceRelations %x\n", DeviceRelations);
|
|
||||||
DPRINT("Count %x\n", DeviceRelations->Count);
|
|
||||||
for (i = 0; i < DeviceRelations->Count; i++)
|
|
||||||
DPRINT("Object(PDO) %x\n", DeviceRelations->Objects[i]);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Create device nodes for all discovered devices */
|
/* Create device nodes for all discovered devices */
|
||||||
for (i = 0; i < DeviceRelations->Count; i++)
|
for (i = 0; i < DeviceRelations->Count; i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -45,17 +45,6 @@
|
||||||
|
|
||||||
/* GLOBALS *****************************************************************/
|
/* GLOBALS *****************************************************************/
|
||||||
|
|
||||||
#ifdef DBG
|
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
LdrGetAddressInformation(IN PIMAGE_SYMBOL_INFO SymbolInfo,
|
|
||||||
IN ULONG_PTR RelativeAddress,
|
|
||||||
OUT PULONG LineNumber,
|
|
||||||
OUT PCH FileName OPTIONAL,
|
|
||||||
OUT PCH FunctionName OPTIONAL);
|
|
||||||
|
|
||||||
#endif /* DBG */
|
|
||||||
|
|
||||||
#define _STR(x) #x
|
#define _STR(x) #x
|
||||||
#define STR(x) _STR(x)
|
#define STR(x) _STR(x)
|
||||||
|
|
||||||
|
@ -139,12 +128,6 @@ print_address(PVOID address)
|
||||||
MODULE_TEXT_SECTION* current;
|
MODULE_TEXT_SECTION* current;
|
||||||
extern LIST_ENTRY ModuleTextListHead;
|
extern LIST_ENTRY ModuleTextListHead;
|
||||||
ULONG_PTR RelativeAddress;
|
ULONG_PTR RelativeAddress;
|
||||||
#ifdef DBG
|
|
||||||
NTSTATUS Status;
|
|
||||||
ULONG LineNumber;
|
|
||||||
CHAR FileName[256];
|
|
||||||
CHAR FunctionName[256];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
current_entry = ModuleTextListHead.Flink;
|
current_entry = ModuleTextListHead.Flink;
|
||||||
|
|
||||||
|
@ -158,25 +141,8 @@ print_address(PVOID address)
|
||||||
address < (PVOID)(current->Base + current->Length))
|
address < (PVOID)(current->Base + current->Length))
|
||||||
{
|
{
|
||||||
RelativeAddress = (ULONG_PTR) address - current->Base;
|
RelativeAddress = (ULONG_PTR) address - current->Base;
|
||||||
#ifdef DBG
|
DbgPrint("<%ws: %x>", current->Name, RelativeAddress);
|
||||||
Status = LdrGetAddressInformation(¤t->SymbolInfo,
|
return(TRUE);
|
||||||
RelativeAddress,
|
|
||||||
&LineNumber,
|
|
||||||
FileName,
|
|
||||||
FunctionName);
|
|
||||||
if (NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DbgPrint("<%ws: %x (%s:%d (%s))>",
|
|
||||||
current->Name, RelativeAddress, FileName, LineNumber, FunctionName);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DbgPrint("<%ws: %x>", current->Name, RelativeAddress);
|
|
||||||
}
|
|
||||||
#else /* !DBG */
|
|
||||||
DbgPrint("<%ws: %x>", current->Name, RelativeAddress);
|
|
||||||
#endif /* !DBG */
|
|
||||||
return(TRUE);
|
|
||||||
}
|
}
|
||||||
current_entry = current_entry->Flink;
|
current_entry = current_entry->Flink;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,17 +45,6 @@
|
||||||
|
|
||||||
/* GLOBALS *****************************************************************/
|
/* GLOBALS *****************************************************************/
|
||||||
|
|
||||||
#ifdef DBG
|
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
LdrGetAddressInformation(IN PIMAGE_SYMBOL_INFO SymbolInfo,
|
|
||||||
IN ULONG_PTR RelativeAddress,
|
|
||||||
OUT PULONG LineNumber,
|
|
||||||
OUT PCH FileName OPTIONAL,
|
|
||||||
OUT PCH FunctionName OPTIONAL);
|
|
||||||
|
|
||||||
#endif /* DBG */
|
|
||||||
|
|
||||||
static char *ExceptionTypeStrings[] =
|
static char *ExceptionTypeStrings[] =
|
||||||
{
|
{
|
||||||
"Divide Error",
|
"Divide Error",
|
||||||
|
@ -88,12 +77,6 @@ print_user_address(PVOID address)
|
||||||
PEPROCESS CurrentProcess;
|
PEPROCESS CurrentProcess;
|
||||||
PPEB Peb = NULL;
|
PPEB Peb = NULL;
|
||||||
ULONG_PTR RelativeAddress;
|
ULONG_PTR RelativeAddress;
|
||||||
#ifdef DBG
|
|
||||||
NTSTATUS Status;
|
|
||||||
ULONG LineNumber;
|
|
||||||
CHAR FileName[256];
|
|
||||||
CHAR FunctionName[256];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
CurrentProcess = PsGetCurrentProcess();
|
CurrentProcess = PsGetCurrentProcess();
|
||||||
if (NULL != CurrentProcess)
|
if (NULL != CurrentProcess)
|
||||||
|
@ -118,27 +101,10 @@ print_user_address(PVOID address)
|
||||||
if (address >= (PVOID)current->BaseAddress &&
|
if (address >= (PVOID)current->BaseAddress &&
|
||||||
address < (PVOID)(current->BaseAddress + current->SizeOfImage))
|
address < (PVOID)(current->BaseAddress + current->SizeOfImage))
|
||||||
{
|
{
|
||||||
RelativeAddress = (ULONG_PTR) address - (ULONG_PTR)current->BaseAddress;
|
RelativeAddress =
|
||||||
#ifdef DBG
|
(ULONG_PTR) address - (ULONG_PTR)current->BaseAddress;
|
||||||
Status = LdrGetAddressInformation(¤t->SymbolInfo,
|
DbgPrint("<%wZ: %x>", ¤t->BaseDllName, RelativeAddress);
|
||||||
RelativeAddress,
|
return(TRUE);
|
||||||
&LineNumber,
|
|
||||||
FileName,
|
|
||||||
FunctionName);
|
|
||||||
if (NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DbgPrint("<%wZ: %x (%s:%d (%s))>",
|
|
||||||
¤t->BaseDllName, RelativeAddress, FileName, LineNumber, FunctionName);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DbgPrint("<%wZ: %x>", ¤t->BaseDllName, RelativeAddress);
|
|
||||||
}
|
|
||||||
#else /* !DBG */
|
|
||||||
DbgPrint("<%wZ: %x>", ¤t->BaseDllName, RelativeAddress);
|
|
||||||
#endif /* !DBG */
|
|
||||||
|
|
||||||
return(TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
current_entry = current_entry->Flink;
|
current_entry = current_entry->Flink;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: loader.c,v 1.116 2002/07/17 21:04:56 dwelch Exp $
|
/* $Id: loader.c,v 1.117 2002/07/17 22:56:11 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -34,6 +34,7 @@
|
||||||
#include <internal/ps.h>
|
#include <internal/ps.h>
|
||||||
#include <internal/ldr.h>
|
#include <internal/ldr.h>
|
||||||
#include <internal/pool.h>
|
#include <internal/pool.h>
|
||||||
|
#include <internal/kd.h>
|
||||||
|
|
||||||
#ifdef HALDBG
|
#ifdef HALDBG
|
||||||
#include <internal/ntosdbg.h>
|
#include <internal/ntosdbg.h>
|
||||||
|
@ -46,56 +47,6 @@
|
||||||
|
|
||||||
/* GLOBALS *******************************************************************/
|
/* GLOBALS *******************************************************************/
|
||||||
|
|
||||||
#ifdef DBG
|
|
||||||
|
|
||||||
typedef struct _SYMBOLFILE_HEADER {
|
|
||||||
unsigned long StabsOffset;
|
|
||||||
unsigned long StabsLength;
|
|
||||||
unsigned long StabstrOffset;
|
|
||||||
unsigned long StabstrLength;
|
|
||||||
} SYMBOLFILE_HEADER, *PSYMBOLFILE_HEADER;
|
|
||||||
|
|
||||||
typedef struct _IMAGE_SYMBOL_INFO_CACHE {
|
|
||||||
LIST_ENTRY ListEntry;
|
|
||||||
UNICODE_STRING FullName;
|
|
||||||
PVOID FileBuffer;
|
|
||||||
PVOID SymbolsBase;
|
|
||||||
ULONG SymbolsLength;
|
|
||||||
PVOID SymbolStringsBase;
|
|
||||||
ULONG SymbolStringsLength;
|
|
||||||
} IMAGE_SYMBOL_INFO_CACHE, *PIMAGE_SYMBOL_INFO_CACHE;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct _STAB_ENTRY {
|
|
||||||
unsigned long n_strx; /* index into string table of name */
|
|
||||||
unsigned char n_type; /* type of symbol */
|
|
||||||
unsigned char n_other; /* misc info (usually empty) */
|
|
||||||
unsigned short n_desc; /* description field */
|
|
||||||
unsigned long n_value; /* value of symbol */
|
|
||||||
} _STAB_ENTRY, *PSTAB_ENTRY;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Desc - Line number
|
|
||||||
* Value - Relative virtual address
|
|
||||||
*/
|
|
||||||
#define N_FUN 0x24
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Desc - Line number
|
|
||||||
* Value - Relative virtual address
|
|
||||||
*/
|
|
||||||
#define N_SLINE 0x44
|
|
||||||
|
|
||||||
/*
|
|
||||||
* String - First containing a '/' is the compillation directory (CD)
|
|
||||||
* Not containing a '/' is a source file relative to CD
|
|
||||||
*/
|
|
||||||
#define N_SO 0x64
|
|
||||||
|
|
||||||
LIST_ENTRY SymbolListHead;
|
|
||||||
|
|
||||||
#endif /* DBG */
|
|
||||||
|
|
||||||
LIST_ENTRY ModuleListHead;
|
LIST_ENTRY ModuleListHead;
|
||||||
KSPIN_LOCK ModuleListLock;
|
KSPIN_LOCK ModuleListLock;
|
||||||
|
|
||||||
|
@ -194,11 +145,6 @@ LdrInit1(VOID)
|
||||||
NtoskrnlTextSection.Length = SectionList[0].Misc.VirtualSize +
|
NtoskrnlTextSection.Length = SectionList[0].Misc.VirtualSize +
|
||||||
SectionList[0].VirtualAddress;
|
SectionList[0].VirtualAddress;
|
||||||
NtoskrnlTextSection.Name = KERNEL_MODULE_NAME;
|
NtoskrnlTextSection.Name = KERNEL_MODULE_NAME;
|
||||||
#ifdef DBG
|
|
||||||
RtlZeroMemory(&NtoskrnlTextSection.SymbolInfo, sizeof(NtoskrnlTextSection.SymbolInfo));
|
|
||||||
NtoskrnlTextSection.SymbolInfo.ImageBase = OptionalHeader->ImageBase;
|
|
||||||
NtoskrnlTextSection.SymbolInfo.ImageSize = NtoskrnlTextSection.Length;
|
|
||||||
#endif
|
|
||||||
InsertTailList(&ModuleTextListHead, &NtoskrnlTextSection.ListEntry);
|
InsertTailList(&ModuleTextListHead, &NtoskrnlTextSection.ListEntry);
|
||||||
|
|
||||||
/* Setup hal.dll text section */
|
/* Setup hal.dll text section */
|
||||||
|
@ -214,16 +160,7 @@ LdrInit1(VOID)
|
||||||
LdrHalTextSection.Length = SectionList[0].Misc.VirtualSize +
|
LdrHalTextSection.Length = SectionList[0].Misc.VirtualSize +
|
||||||
SectionList[0].VirtualAddress;
|
SectionList[0].VirtualAddress;
|
||||||
LdrHalTextSection.Name = HAL_MODULE_NAME;
|
LdrHalTextSection.Name = HAL_MODULE_NAME;
|
||||||
#ifdef DBG
|
|
||||||
RtlZeroMemory(&LdrHalTextSection.SymbolInfo, sizeof(LdrHalTextSection.SymbolInfo));
|
|
||||||
LdrHalTextSection.SymbolInfo.ImageBase = OptionalHeader->ImageBase;
|
|
||||||
LdrHalTextSection.SymbolInfo.ImageSize = LdrHalTextSection.Length;
|
|
||||||
#endif
|
|
||||||
InsertTailList(&ModuleTextListHead, &LdrHalTextSection.ListEntry);
|
InsertTailList(&ModuleTextListHead, &LdrHalTextSection.ListEntry);
|
||||||
|
|
||||||
#ifdef DBG
|
|
||||||
InitializeListHead(&SymbolListHead);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -299,546 +236,6 @@ LdrInitModuleManagement(VOID)
|
||||||
&ModuleObject->ListEntry);
|
&ModuleObject->ListEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DBG
|
|
||||||
|
|
||||||
VOID
|
|
||||||
LdrpParseImageSymbols(PIMAGE_SYMBOL_INFO SymbolInfo)
|
|
||||||
/* Note: It is important that the symbol strings buffer not be released after
|
|
||||||
this function is called because the strings are still referenced */
|
|
||||||
{
|
|
||||||
PSYMBOL CurrentFileNameSymbol;
|
|
||||||
PSYMBOL CurrentFunctionSymbol;
|
|
||||||
PSYMBOL CurrentLineNumberSymbol;
|
|
||||||
PSYMBOL Symbol;
|
|
||||||
PSTAB_ENTRY StabEntry;
|
|
||||||
PVOID StabsEnd;
|
|
||||||
PCHAR String;
|
|
||||||
ULONG_PTR FunRelativeAddress;
|
|
||||||
ULONG FunLineNumber;
|
|
||||||
ULONG_PTR ImageBase;
|
|
||||||
|
|
||||||
assert(SymbolInfo);
|
|
||||||
|
|
||||||
DPRINT("Parsing symbols.\n");
|
|
||||||
|
|
||||||
SymbolInfo->FileNameSymbols.SymbolCount = 0;
|
|
||||||
SymbolInfo->FileNameSymbols.Symbols = NULL;
|
|
||||||
SymbolInfo->FunctionSymbols.SymbolCount = 0;
|
|
||||||
SymbolInfo->FunctionSymbols.Symbols = NULL;
|
|
||||||
SymbolInfo->LineNumberSymbols.SymbolCount = 0;
|
|
||||||
SymbolInfo->LineNumberSymbols.Symbols = NULL;
|
|
||||||
StabsEnd = SymbolInfo->SymbolsBase + SymbolInfo->SymbolsLength;
|
|
||||||
StabEntry = (PSTAB_ENTRY) SymbolInfo->SymbolsBase;
|
|
||||||
ImageBase = SymbolInfo->ImageBase;
|
|
||||||
FunRelativeAddress = 0;
|
|
||||||
FunLineNumber = 0;
|
|
||||||
CurrentFileNameSymbol = NULL;
|
|
||||||
CurrentFunctionSymbol = NULL;
|
|
||||||
CurrentLineNumberSymbol = NULL;
|
|
||||||
while ((ULONG_PTR) StabEntry < (ULONG_PTR) StabsEnd)
|
|
||||||
{
|
|
||||||
Symbol = NULL;
|
|
||||||
|
|
||||||
if (StabEntry->n_type == N_FUN)
|
|
||||||
{
|
|
||||||
if (StabEntry->n_desc > 0)
|
|
||||||
{
|
|
||||||
assert(StabEntry->n_value >= ImageBase);
|
|
||||||
|
|
||||||
FunRelativeAddress = StabEntry->n_value - ImageBase;
|
|
||||||
FunLineNumber = StabEntry->n_desc;
|
|
||||||
|
|
||||||
Symbol = ExAllocatePool(NonPagedPool, sizeof(SYMBOL));
|
|
||||||
assert(Symbol);
|
|
||||||
Symbol->Next = NULL;
|
|
||||||
Symbol->SymbolType = ST_FUNCTION;
|
|
||||||
Symbol->RelativeAddress = FunRelativeAddress;
|
|
||||||
Symbol->LineNumber = FunLineNumber;
|
|
||||||
String = (PCHAR)SymbolInfo->SymbolStringsBase + StabEntry->n_strx;
|
|
||||||
RtlInitAnsiString(&Symbol->Name, String);
|
|
||||||
|
|
||||||
DPRINT("FUN found. '%s' %d @ %x\n",
|
|
||||||
Symbol->Name.Buffer, FunLineNumber, FunRelativeAddress);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (StabEntry->n_type == N_SLINE)
|
|
||||||
{
|
|
||||||
Symbol = ExAllocatePool(NonPagedPool, sizeof(SYMBOL));
|
|
||||||
assert(Symbol);
|
|
||||||
Symbol->Next = NULL;
|
|
||||||
Symbol->SymbolType = ST_LINENUMBER;
|
|
||||||
Symbol->RelativeAddress = FunRelativeAddress + StabEntry->n_value;
|
|
||||||
Symbol->LineNumber = StabEntry->n_desc;
|
|
||||||
|
|
||||||
DPRINT("SLINE found. %d @ %x\n",
|
|
||||||
Symbol->LineNumber, Symbol->RelativeAddress);
|
|
||||||
}
|
|
||||||
else if (StabEntry->n_type == N_SO)
|
|
||||||
{
|
|
||||||
Symbol = ExAllocatePool(NonPagedPool, sizeof(SYMBOL));
|
|
||||||
assert(Symbol);
|
|
||||||
Symbol->Next = NULL;
|
|
||||||
Symbol->SymbolType = ST_FILENAME;
|
|
||||||
Symbol->RelativeAddress = StabEntry->n_value - ImageBase;
|
|
||||||
Symbol->LineNumber = 0;
|
|
||||||
String = (PCHAR)SymbolInfo->SymbolStringsBase + StabEntry->n_strx;
|
|
||||||
RtlInitAnsiString(&Symbol->Name, String);
|
|
||||||
|
|
||||||
DPRINT("SO found. '%s' @ %x\n",
|
|
||||||
Symbol->Name.Buffer, Symbol->RelativeAddress);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Symbol != NULL)
|
|
||||||
{
|
|
||||||
switch (Symbol->SymbolType)
|
|
||||||
{
|
|
||||||
case ST_FILENAME:
|
|
||||||
if (SymbolInfo->FileNameSymbols.Symbols == NULL)
|
|
||||||
SymbolInfo->FileNameSymbols.Symbols = Symbol;
|
|
||||||
else
|
|
||||||
CurrentFileNameSymbol->Next = Symbol;
|
|
||||||
|
|
||||||
CurrentFileNameSymbol = Symbol;
|
|
||||||
|
|
||||||
SymbolInfo->FileNameSymbols.SymbolCount++;
|
|
||||||
break;
|
|
||||||
case ST_FUNCTION:
|
|
||||||
if (SymbolInfo->FunctionSymbols.Symbols == NULL)
|
|
||||||
SymbolInfo->FunctionSymbols.Symbols = Symbol;
|
|
||||||
else
|
|
||||||
CurrentFunctionSymbol->Next = Symbol;
|
|
||||||
|
|
||||||
CurrentFunctionSymbol = Symbol;
|
|
||||||
|
|
||||||
SymbolInfo->FunctionSymbols.SymbolCount++;
|
|
||||||
break;
|
|
||||||
case ST_LINENUMBER:
|
|
||||||
if (SymbolInfo->LineNumberSymbols.Symbols == NULL)
|
|
||||||
SymbolInfo->LineNumberSymbols.Symbols = Symbol;
|
|
||||||
else
|
|
||||||
CurrentLineNumberSymbol->Next = Symbol;
|
|
||||||
|
|
||||||
CurrentLineNumberSymbol = Symbol;
|
|
||||||
|
|
||||||
SymbolInfo->LineNumberSymbols.SymbolCount++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
StabEntry++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static NTSTATUS
|
|
||||||
LdrpGetFileName(IN PIMAGE_SYMBOL_INFO SymbolInfo,
|
|
||||||
IN ULONG_PTR RelativeAddress,
|
|
||||||
OUT PCH FileName)
|
|
||||||
{
|
|
||||||
PSYMBOL NextSymbol;
|
|
||||||
ULONG_PTR NextAddress;
|
|
||||||
PSYMBOL Symbol;
|
|
||||||
|
|
||||||
Symbol = SymbolInfo->FileNameSymbols.Symbols;
|
|
||||||
while (Symbol != NULL)
|
|
||||||
{
|
|
||||||
NextSymbol = Symbol->Next;
|
|
||||||
if (NextSymbol != NULL)
|
|
||||||
NextAddress = NextSymbol->RelativeAddress;
|
|
||||||
else
|
|
||||||
NextAddress = SymbolInfo->ImageSize;
|
|
||||||
|
|
||||||
DPRINT("FN SEARCH: Type %d RelativeAddress %x >= Symbol->RelativeAddress %x < NextAddress %x\n",
|
|
||||||
Symbol->SymbolType, RelativeAddress, Symbol->RelativeAddress, NextAddress);
|
|
||||||
|
|
||||||
if ((Symbol->SymbolType == ST_FILENAME) &&
|
|
||||||
(RelativeAddress >= Symbol->RelativeAddress) &&
|
|
||||||
(RelativeAddress < NextAddress))
|
|
||||||
{
|
|
||||||
DPRINT("FN found\n");
|
|
||||||
strcpy(FileName, Symbol->Name.Buffer);
|
|
||||||
return STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
Symbol = NextSymbol;
|
|
||||||
}
|
|
||||||
|
|
||||||
DPRINT("FN not found\n");
|
|
||||||
|
|
||||||
return STATUS_UNSUCCESSFUL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static NTSTATUS
|
|
||||||
LdrpGetFunctionName(IN PIMAGE_SYMBOL_INFO SymbolInfo,
|
|
||||||
IN ULONG_PTR RelativeAddress,
|
|
||||||
OUT PCH FunctionName)
|
|
||||||
{
|
|
||||||
PSYMBOL NextSymbol;
|
|
||||||
ULONG_PTR NextAddress;
|
|
||||||
PSYMBOL Symbol;
|
|
||||||
|
|
||||||
Symbol = SymbolInfo->FunctionSymbols.Symbols;
|
|
||||||
while (Symbol != NULL)
|
|
||||||
{
|
|
||||||
NextSymbol = Symbol->Next;
|
|
||||||
if (NextSymbol != NULL)
|
|
||||||
NextAddress = NextSymbol->RelativeAddress;
|
|
||||||
else
|
|
||||||
NextAddress = SymbolInfo->ImageSize;
|
|
||||||
|
|
||||||
DPRINT("FUN SEARCH: Type %d RelativeAddress %x >= Symbol->RelativeAddress %x < NextAddress %x\n",
|
|
||||||
Symbol->SymbolType, RelativeAddress, Symbol->RelativeAddress, NextAddress);
|
|
||||||
|
|
||||||
if ((Symbol->SymbolType == ST_FUNCTION) &&
|
|
||||||
(RelativeAddress >= Symbol->RelativeAddress) &&
|
|
||||||
(RelativeAddress < NextAddress))
|
|
||||||
{
|
|
||||||
PCHAR ExtraInfo;
|
|
||||||
ULONG Length;
|
|
||||||
|
|
||||||
DPRINT("FUN found\n");
|
|
||||||
|
|
||||||
/* Remove the extra information from the function name */
|
|
||||||
ExtraInfo = strchr(Symbol->Name.Buffer, ':');
|
|
||||||
if (ExtraInfo != NULL)
|
|
||||||
Length = ExtraInfo - Symbol->Name.Buffer;
|
|
||||||
else
|
|
||||||
Length = strlen(Symbol->Name.Buffer);
|
|
||||||
|
|
||||||
strncpy(FunctionName, Symbol->Name.Buffer, Length);
|
|
||||||
return STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
Symbol = NextSymbol;
|
|
||||||
}
|
|
||||||
|
|
||||||
DPRINT("FUN not found\n");
|
|
||||||
|
|
||||||
return STATUS_UNSUCCESSFUL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static NTSTATUS
|
|
||||||
LdrpGetLineNumber(IN PIMAGE_SYMBOL_INFO SymbolInfo,
|
|
||||||
IN ULONG_PTR RelativeAddress,
|
|
||||||
OUT PULONG LineNumber)
|
|
||||||
{
|
|
||||||
PSYMBOL NextSymbol;
|
|
||||||
ULONG_PTR NextAddress;
|
|
||||||
PSYMBOL Symbol;
|
|
||||||
|
|
||||||
Symbol = SymbolInfo->LineNumberSymbols.Symbols;
|
|
||||||
while (Symbol != NULL)
|
|
||||||
{
|
|
||||||
NextSymbol = Symbol->Next;
|
|
||||||
if (NextSymbol != NULL)
|
|
||||||
NextAddress = NextSymbol->RelativeAddress;
|
|
||||||
else
|
|
||||||
NextAddress = SymbolInfo->ImageSize;
|
|
||||||
|
|
||||||
DPRINT("LN SEARCH: Type %d RelativeAddress %x >= Symbol->RelativeAddress %x < NextAddress %x\n",
|
|
||||||
Symbol->SymbolType, RelativeAddress, Symbol->RelativeAddress, NextAddress);
|
|
||||||
|
|
||||||
if ((Symbol->SymbolType == ST_LINENUMBER) &&
|
|
||||||
(RelativeAddress >= Symbol->RelativeAddress) &&
|
|
||||||
(RelativeAddress < NextAddress))
|
|
||||||
{
|
|
||||||
DPRINT("LN found\n");
|
|
||||||
*LineNumber = Symbol->LineNumber;
|
|
||||||
return STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
Symbol = NextSymbol;
|
|
||||||
}
|
|
||||||
|
|
||||||
DPRINT("LN not found\n");
|
|
||||||
|
|
||||||
return STATUS_UNSUCCESSFUL;
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
LdrGetAddressInformation(IN PIMAGE_SYMBOL_INFO SymbolInfo,
|
|
||||||
IN ULONG_PTR RelativeAddress,
|
|
||||||
OUT PULONG LineNumber,
|
|
||||||
OUT PCH FileName OPTIONAL,
|
|
||||||
OUT PCH FunctionName OPTIONAL)
|
|
||||||
{
|
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
*LineNumber = 0;
|
|
||||||
|
|
||||||
DPRINT("RelativeAddress %p\n", RelativeAddress);
|
|
||||||
|
|
||||||
if (RelativeAddress >= SymbolInfo->ImageSize)
|
|
||||||
{
|
|
||||||
DPRINT("Address is not within .text section. RelativeAddress %p Length 0x%x\n",
|
|
||||||
RelativeAddress, SymbolInfo->ImageSize);
|
|
||||||
return STATUS_UNSUCCESSFUL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!AreSymbolsParsed(SymbolInfo))
|
|
||||||
{
|
|
||||||
LdrpParseImageSymbols(SymbolInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
Status = LdrpGetLineNumber(SymbolInfo, RelativeAddress, LineNumber);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (FileName)
|
|
||||||
{
|
|
||||||
Status = LdrpGetFileName(SymbolInfo, RelativeAddress, FileName);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
strcpy(FileName, "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (FunctionName)
|
|
||||||
{
|
|
||||||
Status = LdrpGetFunctionName(SymbolInfo, RelativeAddress, FunctionName);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
strcpy(FunctionName, "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
VOID
|
|
||||||
LdrpLoadModuleSymbols(PUNICODE_STRING FileName,
|
|
||||||
PIMAGE_SYMBOL_INFO SymbolInfo)
|
|
||||||
{
|
|
||||||
FILE_STANDARD_INFORMATION FileStdInfo;
|
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
|
||||||
WCHAR TmpFileName[MAX_PATH];
|
|
||||||
UNICODE_STRING SymFileName;
|
|
||||||
LPWSTR Start, Ext;
|
|
||||||
HANDLE FileHandle;
|
|
||||||
PVOID FileBuffer;
|
|
||||||
NTSTATUS Status;
|
|
||||||
ULONG Length;
|
|
||||||
IO_STATUS_BLOCK IoStatusBlock;
|
|
||||||
PSYMBOLFILE_HEADER SymbolFileHeader;
|
|
||||||
|
|
||||||
/* Get the path to the symbol store */
|
|
||||||
wcscpy(TmpFileName, L"\\SystemRoot\\symbols\\");
|
|
||||||
|
|
||||||
/* Get the symbol filename from the module name */
|
|
||||||
Start = wcsrchr(FileName->Buffer, L'\\');
|
|
||||||
if (Start == NULL)
|
|
||||||
Start = FileName->Buffer;
|
|
||||||
else
|
|
||||||
Start++;
|
|
||||||
|
|
||||||
Ext = wcsrchr(FileName->Buffer, L'.');
|
|
||||||
if (Ext != NULL)
|
|
||||||
Length = Ext - Start;
|
|
||||||
else
|
|
||||||
Length = wcslen(Start);
|
|
||||||
|
|
||||||
wcsncat(TmpFileName, Start, Length);
|
|
||||||
wcscat(TmpFileName, L".sym");
|
|
||||||
RtlInitUnicodeString(&SymFileName, TmpFileName);
|
|
||||||
|
|
||||||
/* Open the file */
|
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
|
||||||
&SymFileName,
|
|
||||||
0,
|
|
||||||
NULL,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
Status = ZwOpenFile(&FileHandle,
|
|
||||||
FILE_ALL_ACCESS,
|
|
||||||
&ObjectAttributes,
|
|
||||||
&IoStatusBlock,
|
|
||||||
0,
|
|
||||||
0);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DPRINT("Could not open symbol file: %wZ\n", &SymFileName);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
CPRINT("Loading symbols from %wZ...\n", &SymFileName);
|
|
||||||
|
|
||||||
/* Get the size of the file */
|
|
||||||
Status = ZwQueryInformationFile(FileHandle,
|
|
||||||
&IoStatusBlock,
|
|
||||||
&FileStdInfo,
|
|
||||||
sizeof(FileStdInfo),
|
|
||||||
FileStandardInformation);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DPRINT("Could not get file size\n");
|
|
||||||
ZwClose(FileHandle);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Allocate nonpageable memory for symbol file */
|
|
||||||
FileBuffer = ExAllocatePool(NonPagedPool,
|
|
||||||
FileStdInfo.EndOfFile.u.LowPart);
|
|
||||||
|
|
||||||
if (FileBuffer == NULL)
|
|
||||||
{
|
|
||||||
DPRINT("Could not allocate memory for symbol file\n");
|
|
||||||
ZwClose(FileHandle);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Load file into memory chunk */
|
|
||||||
Status = ZwReadFile(FileHandle,
|
|
||||||
0, 0, 0,
|
|
||||||
&IoStatusBlock,
|
|
||||||
FileBuffer,
|
|
||||||
FileStdInfo.EndOfFile.u.LowPart,
|
|
||||||
0, 0);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DPRINT("Could not read symbol file into memory (Status 0x%x)\n", Status);
|
|
||||||
ExFreePool(FileBuffer);
|
|
||||||
ZwClose(FileHandle);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ZwClose(FileHandle);
|
|
||||||
|
|
||||||
SymbolFileHeader = (PSYMBOLFILE_HEADER) FileBuffer;
|
|
||||||
SymbolInfo->FileBuffer = FileBuffer;
|
|
||||||
SymbolInfo->SymbolsBase = FileBuffer + SymbolFileHeader->StabsOffset;
|
|
||||||
SymbolInfo->SymbolsLength = SymbolFileHeader->StabsLength;
|
|
||||||
SymbolInfo->SymbolStringsBase = FileBuffer + SymbolFileHeader->StabstrOffset;
|
|
||||||
SymbolInfo->SymbolStringsLength = SymbolFileHeader->StabstrLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
VOID
|
|
||||||
LdrUnloadModuleSymbols(PIMAGE_SYMBOL_INFO SymbolInfo)
|
|
||||||
{
|
|
||||||
PSYMBOL NextSymbol;
|
|
||||||
PSYMBOL Symbol;
|
|
||||||
|
|
||||||
DPRINT("Unloading symbols\n");
|
|
||||||
|
|
||||||
if (SymbolInfo != NULL)
|
|
||||||
{
|
|
||||||
Symbol = SymbolInfo->FileNameSymbols.Symbols;
|
|
||||||
while (Symbol != NULL)
|
|
||||||
{
|
|
||||||
NextSymbol = Symbol->Next;
|
|
||||||
RtlFreeAnsiString(&Symbol->Name);
|
|
||||||
ExFreePool(Symbol);
|
|
||||||
Symbol = NextSymbol;
|
|
||||||
}
|
|
||||||
|
|
||||||
SymbolInfo->FileNameSymbols.SymbolCount = 0;
|
|
||||||
SymbolInfo->FileNameSymbols.Symbols = NULL;
|
|
||||||
|
|
||||||
Symbol = SymbolInfo->FunctionSymbols.Symbols;
|
|
||||||
while (Symbol != NULL)
|
|
||||||
{
|
|
||||||
NextSymbol = Symbol->Next;
|
|
||||||
RtlFreeAnsiString(&Symbol->Name);
|
|
||||||
ExFreePool(Symbol);
|
|
||||||
Symbol = NextSymbol;
|
|
||||||
}
|
|
||||||
|
|
||||||
SymbolInfo->FunctionSymbols.SymbolCount = 0;
|
|
||||||
SymbolInfo->FunctionSymbols.Symbols = NULL;
|
|
||||||
|
|
||||||
Symbol = SymbolInfo->LineNumberSymbols.Symbols;
|
|
||||||
while (Symbol != NULL)
|
|
||||||
{
|
|
||||||
NextSymbol = Symbol->Next;
|
|
||||||
RtlFreeAnsiString(&Symbol->Name);
|
|
||||||
ExFreePool(Symbol);
|
|
||||||
Symbol = NextSymbol;
|
|
||||||
}
|
|
||||||
|
|
||||||
SymbolInfo->LineNumberSymbols.SymbolCount = 0;
|
|
||||||
SymbolInfo->LineNumberSymbols.Symbols = NULL;
|
|
||||||
#if 0
|
|
||||||
/* Don't free buffers because we cache symbol buffers
|
|
||||||
(eg. they are shared across processes) */
|
|
||||||
/* FIXME: We can free them if we do reference counting */
|
|
||||||
if (SymbolInfo->FileBuffer != NULL)
|
|
||||||
{
|
|
||||||
ExFreePool(SymbolInfo->FileBuffer);
|
|
||||||
SymbolInfo->FileBuffer = NULL;
|
|
||||||
SymbolInfo->SymbolsBase = NULL;
|
|
||||||
SymbolInfo->SymbolsLength = 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
PIMAGE_SYMBOL_INFO_CACHE
|
|
||||||
LdrpLookupUserSymbolInfo(PLDR_MODULE LdrModule)
|
|
||||||
{
|
|
||||||
PIMAGE_SYMBOL_INFO_CACHE Current;
|
|
||||||
PLIST_ENTRY CurrentEntry;
|
|
||||||
KIRQL Irql;
|
|
||||||
|
|
||||||
DPRINT("Searching symbols for %S\n", LdrModule->FullDllName.Buffer);
|
|
||||||
|
|
||||||
KeAcquireSpinLock(&ModuleListLock,&Irql);
|
|
||||||
|
|
||||||
CurrentEntry = SymbolListHead.Flink;
|
|
||||||
while (CurrentEntry != (&SymbolListHead))
|
|
||||||
{
|
|
||||||
Current = CONTAINING_RECORD(CurrentEntry, IMAGE_SYMBOL_INFO_CACHE, ListEntry);
|
|
||||||
|
|
||||||
if (RtlEqualUnicodeString(&Current->FullName, &LdrModule->FullDllName, TRUE))
|
|
||||||
{
|
|
||||||
KeReleaseSpinLock(&ModuleListLock, Irql);
|
|
||||||
return Current;
|
|
||||||
}
|
|
||||||
|
|
||||||
CurrentEntry = CurrentEntry->Flink;
|
|
||||||
}
|
|
||||||
|
|
||||||
KeReleaseSpinLock(&ModuleListLock, Irql);
|
|
||||||
|
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
VOID
|
|
||||||
LdrLoadUserModuleSymbols(PLDR_MODULE LdrModule)
|
|
||||||
{
|
|
||||||
PIMAGE_SYMBOL_INFO_CACHE CacheEntry;
|
|
||||||
|
|
||||||
DPRINT("LdrModule %p\n", LdrModule);
|
|
||||||
|
|
||||||
RtlZeroMemory(&LdrModule->SymbolInfo, sizeof(LdrModule->SymbolInfo));
|
|
||||||
LdrModule->SymbolInfo.ImageBase = (ULONG_PTR) LdrModule->BaseAddress;
|
|
||||||
LdrModule->SymbolInfo.ImageSize = LdrModule->SizeOfImage;
|
|
||||||
|
|
||||||
CacheEntry = LdrpLookupUserSymbolInfo(LdrModule);
|
|
||||||
if (CacheEntry != NULL)
|
|
||||||
{
|
|
||||||
DPRINT("Symbol cache hit for %S\n", CacheEntry->FullName.Buffer);
|
|
||||||
|
|
||||||
LdrModule->SymbolInfo.FileBuffer = CacheEntry->FileBuffer;
|
|
||||||
LdrModule->SymbolInfo.SymbolsBase = CacheEntry->SymbolsBase;
|
|
||||||
LdrModule->SymbolInfo.SymbolsLength = CacheEntry->SymbolsLength;
|
|
||||||
LdrModule->SymbolInfo.SymbolStringsBase = CacheEntry->SymbolStringsBase;
|
|
||||||
LdrModule->SymbolInfo.SymbolStringsLength = CacheEntry->SymbolStringsLength;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
InsertTailList(&SymbolListHead, &CacheEntry->ListEntry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* DBG */
|
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
LdrpLoadImage(PUNICODE_STRING DriverName,
|
LdrpLoadImage(PUNICODE_STRING DriverName,
|
||||||
PVOID *ModuleBase,
|
PVOID *ModuleBase,
|
||||||
|
@ -1007,13 +404,11 @@ LdrLoadModule(PUNICODE_STRING Filename,
|
||||||
/* Cleanup */
|
/* Cleanup */
|
||||||
ExFreePool(ModuleLoadBase);
|
ExFreePool(ModuleLoadBase);
|
||||||
|
|
||||||
#ifdef DBG
|
|
||||||
/* Load symbols for the image if available */
|
|
||||||
LdrpLoadModuleSymbols(Filename, &Module->TextSection->SymbolInfo);
|
|
||||||
#endif /* DBG */
|
|
||||||
|
|
||||||
*ModuleObject = Module;
|
*ModuleObject = Module;
|
||||||
|
|
||||||
|
/* Hook for KDB on loading a driver. */
|
||||||
|
KDB_LOADDRIVER_HOOK(Module);
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1028,10 +423,8 @@ LdrUnloadModule(PMODULE_OBJECT ModuleObject)
|
||||||
RemoveEntryList(&ModuleObject->ListEntry);
|
RemoveEntryList(&ModuleObject->ListEntry);
|
||||||
KeReleaseSpinLock(&ModuleListLock, Irql);
|
KeReleaseSpinLock(&ModuleListLock, Irql);
|
||||||
|
|
||||||
#ifdef DBG
|
/* Hook for KDB on unloading a driver. */
|
||||||
/* Unload symbols for module if available */
|
KDB_UNLOADDRIVER_HOOK(ModuleObject);
|
||||||
LdrUnloadModuleSymbols(&ModuleObject->TextSection->SymbolInfo);
|
|
||||||
#endif /* DBG */
|
|
||||||
|
|
||||||
/* Free text section */
|
/* Free text section */
|
||||||
if (ModuleObject->TextSection != NULL)
|
if (ModuleObject->TextSection != NULL)
|
||||||
|
@ -1056,10 +449,6 @@ LdrInitializeBootStartDriver(PVOID ModuleLoadBase,
|
||||||
PCHAR FileName,
|
PCHAR FileName,
|
||||||
ULONG ModuleLength)
|
ULONG ModuleLength)
|
||||||
{
|
{
|
||||||
#ifdef DBG
|
|
||||||
PSYMBOLFILE_HEADER SymbolFileHeader;
|
|
||||||
PIMAGE_SYMBOL_INFO SymbolInfo;
|
|
||||||
#endif /* DBG */
|
|
||||||
PMODULE_OBJECT ModuleObject;
|
PMODULE_OBJECT ModuleObject;
|
||||||
UNICODE_STRING ModuleName;
|
UNICODE_STRING ModuleName;
|
||||||
PDEVICE_NODE DeviceNode;
|
PDEVICE_NODE DeviceNode;
|
||||||
|
@ -1074,12 +463,6 @@ LdrInitializeBootStartDriver(PVOID ModuleLoadBase,
|
||||||
CHAR TextBuffer [256];
|
CHAR TextBuffer [256];
|
||||||
ULONG x, y, cx, cy;
|
ULONG x, y, cx, cy;
|
||||||
|
|
||||||
#ifdef DBG
|
|
||||||
CHAR TmpBaseName[MAX_PATH];
|
|
||||||
CHAR TmpFileName[MAX_PATH];
|
|
||||||
ANSI_STRING AnsiString;
|
|
||||||
#endif /* DBG */
|
|
||||||
|
|
||||||
HalQueryDisplayParameters(&x, &y, &cx, &cy);
|
HalQueryDisplayParameters(&x, &y, &cx, &cy);
|
||||||
RtlFillMemory(TextBuffer, x, ' ');
|
RtlFillMemory(TextBuffer, x, ' ');
|
||||||
TextBuffer[x] = '\0';
|
TextBuffer[x] = '\0';
|
||||||
|
@ -1098,53 +481,6 @@ LdrInitializeBootStartDriver(PVOID ModuleLoadBase,
|
||||||
else
|
else
|
||||||
Length = strlen(FileName);
|
Length = strlen(FileName);
|
||||||
|
|
||||||
#ifdef DBG
|
|
||||||
|
|
||||||
if ((FileExt != NULL) && (strcmp(FileExt, ".sym") == 0))
|
|
||||||
{
|
|
||||||
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");
|
|
||||||
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
|
|
||||||
{
|
|
||||||
DPRINT("Module %s is non-symbol file\n", FileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* !DBG */
|
|
||||||
|
|
||||||
if ((FileExt != NULL) && !(strcmp(FileExt, ".sys") == 0))
|
if ((FileExt != NULL) && !(strcmp(FileExt, ".sys") == 0))
|
||||||
{
|
{
|
||||||
CPRINT("Ignoring non-driver file %s\n", FileName);
|
CPRINT("Ignoring non-driver file %s\n", FileName);
|
||||||
|
@ -1802,11 +1138,6 @@ LdrPEProcessModule(PVOID ModuleLoadBase,
|
||||||
RtlZeroMemory(ModuleTextSection, sizeof(MODULE_TEXT_SECTION));
|
RtlZeroMemory(ModuleTextSection, sizeof(MODULE_TEXT_SECTION));
|
||||||
ModuleTextSection->Base = (ULONG)DriverBase;
|
ModuleTextSection->Base = (ULONG)DriverBase;
|
||||||
ModuleTextSection->Length = DriverSize;
|
ModuleTextSection->Length = DriverSize;
|
||||||
#ifdef DBG
|
|
||||||
RtlZeroMemory(&ModuleTextSection->SymbolInfo, sizeof(ModuleTextSection->SymbolInfo));
|
|
||||||
ModuleTextSection->SymbolInfo.ImageBase = PEOptionalHeader->ImageBase;
|
|
||||||
ModuleTextSection->SymbolInfo.ImageSize = ModuleTextSection->Length;
|
|
||||||
#endif /* DBG */
|
|
||||||
ModuleTextSection->Name =
|
ModuleTextSection->Name =
|
||||||
ExAllocatePool(NonPagedPool,
|
ExAllocatePool(NonPagedPool,
|
||||||
(wcslen(NameBuffer) + 1) * sizeof(WCHAR));
|
(wcslen(NameBuffer) + 1) * sizeof(WCHAR));
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: process.c,v 1.86 2002/07/17 21:04:56 dwelch Exp $
|
/* $Id: process.c,v 1.87 2002/07/17 22:56:11 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -27,6 +27,7 @@
|
||||||
#include <internal/pool.h>
|
#include <internal/pool.h>
|
||||||
#include <roscfg.h>
|
#include <roscfg.h>
|
||||||
#include <internal/se.h>
|
#include <internal/se.h>
|
||||||
|
#include <internal/kd.h>
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
@ -277,34 +278,6 @@ PsInitProcessManagment(VOID)
|
||||||
&SystemProcessHandle);
|
&SystemProcessHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DBG
|
|
||||||
|
|
||||||
VOID
|
|
||||||
PiFreeSymbols(PPEB Peb)
|
|
||||||
{
|
|
||||||
PLIST_ENTRY CurrentEntry;
|
|
||||||
PLDR_MODULE Current;
|
|
||||||
PIMAGE_SYMBOL_INFO SymbolInfo;
|
|
||||||
|
|
||||||
assert (Peb);
|
|
||||||
assert (Peb->Ldr);
|
|
||||||
|
|
||||||
CurrentEntry = Peb->Ldr->InLoadOrderModuleList.Flink;
|
|
||||||
while (CurrentEntry != &Peb->Ldr->InLoadOrderModuleList &&
|
|
||||||
CurrentEntry != NULL)
|
|
||||||
{
|
|
||||||
Current = CONTAINING_RECORD(CurrentEntry, LDR_MODULE,
|
|
||||||
InLoadOrderModuleList);
|
|
||||||
|
|
||||||
SymbolInfo = &Current->SymbolInfo;
|
|
||||||
LdrUnloadModuleSymbols(SymbolInfo);
|
|
||||||
|
|
||||||
CurrentEntry = CurrentEntry->Flink;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* DBG */
|
|
||||||
|
|
||||||
VOID STDCALL
|
VOID STDCALL
|
||||||
PiDeleteProcess(PVOID ObjectBody)
|
PiDeleteProcess(PVOID ObjectBody)
|
||||||
{
|
{
|
||||||
|
@ -325,10 +298,8 @@ PiDeleteProcess(PVOID ObjectBody)
|
||||||
RemoveEntryList(&Process->ProcessListEntry);
|
RemoveEntryList(&Process->ProcessListEntry);
|
||||||
KeReleaseSpinLock(&PsProcessListLock, oldIrql);
|
KeReleaseSpinLock(&PsProcessListLock, oldIrql);
|
||||||
|
|
||||||
#ifdef DBG
|
/* KDB hook */
|
||||||
PiFreeSymbols(Process->Peb);
|
KDB_DELETEPROCESS_HOOK(Process);
|
||||||
#endif /* DBG */
|
|
||||||
|
|
||||||
|
|
||||||
ObDereferenceObject(Process->Token);
|
ObDereferenceObject(Process->Token);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue