mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 08:25:03 +00:00
[CMAKE]
* The cmake branch is so awesome you don't even need to manually translate addresses. Automagic usermode address translation brought to you by the Arty. svn path=/branches/cmake-bringup/; revision=51404
This commit is contained in:
parent
eed6bbd835
commit
c3d35eaa65
9 changed files with 137 additions and 83 deletions
|
@ -24,6 +24,11 @@ typedef struct _ROSSYM_CALLBACKS {
|
|||
BOOLEAN (*SeekFileProc)(PVOID FileContext, ULONG_PTR Position);
|
||||
} ROSSYM_CALLBACKS, *PROSSYM_CALLBACKS;
|
||||
|
||||
typedef struct _ROSSYM_OWN_FILECONTEXT {
|
||||
BOOLEAN (*ReadFileProc)(PVOID FileContext, PVOID Buffer, ULONG Size);
|
||||
BOOLEAN (*SeekFileProc)(PVOID FileContext, ULONG_PTR Position);
|
||||
} ROSSYM_OWN_FILECONTEXT, *PROSSYM_OWN_FILECONTEXT;
|
||||
|
||||
struct Dwarf;
|
||||
typedef struct Dwarf *PROSSYM_INFO;
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ list(APPEND SOURCE
|
|||
dwarfpubnames.c
|
||||
find.c
|
||||
fromfile.c
|
||||
iofile.c
|
||||
init.c
|
||||
initkm.c
|
||||
initum.c
|
||||
|
|
|
@ -38,8 +38,8 @@ RosSymInitKernelMode(VOID)
|
|||
{
|
||||
RosSymAllocMemKM,
|
||||
RosSymFreeMemKM,
|
||||
RosSymZwReadFile,
|
||||
RosSymZwSeekFile
|
||||
RosSymIoReadFile,
|
||||
RosSymIoSeekFile
|
||||
};
|
||||
|
||||
RosSymInit(&KmCallbacks);
|
||||
|
|
34
lib/rossym/iofile.c
Normal file
34
lib/rossym/iofile.c
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: lib/rossym/zwfile.c
|
||||
* PURPOSE: File I/O using native functions
|
||||
*
|
||||
* PROGRAMMERS: Ge van Geldorp (gvg@reactos.com)
|
||||
*/
|
||||
|
||||
#define NTOSAPI
|
||||
#include <ntddk.h>
|
||||
#include <reactos/rossym.h>
|
||||
#include "rossympriv.h"
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
NTSTATUS RosSymStatus;
|
||||
|
||||
BOOLEAN
|
||||
RosSymIoReadFile(PVOID FileContext, PVOID Buffer, ULONG Size)
|
||||
{
|
||||
PROSSYM_OWN_FILECONTEXT OwnContext = (PROSSYM_OWN_FILECONTEXT)FileContext;
|
||||
return OwnContext->ReadFileProc(FileContext, Buffer, Size);
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
RosSymIoSeekFile(PVOID FileContext, ULONG_PTR Position)
|
||||
{
|
||||
PROSSYM_OWN_FILECONTEXT OwnContext = (PROSSYM_OWN_FILECONTEXT)FileContext;
|
||||
return OwnContext->SeekFileProc(FileContext, Position);
|
||||
}
|
||||
|
||||
/* EOF */
|
|
@ -19,6 +19,9 @@ extern ROSSYM_CALLBACKS RosSymCallbacks;
|
|||
extern BOOLEAN RosSymZwReadFile(PVOID FileContext, PVOID Buffer, ULONG Size);
|
||||
extern BOOLEAN RosSymZwSeekFile(PVOID FileContext, ULONG_PTR Position);
|
||||
|
||||
extern BOOLEAN RosSymIoReadFile(PVOID FileContext, PVOID Buffer, ULONG Size);
|
||||
extern BOOLEAN RosSymIoSeekFile(PVOID FileContext, ULONG_PTR Position);
|
||||
|
||||
#define ROSSYM_IS_VALID_DOS_HEADER(DosHeader) (IMAGE_DOS_SIGNATURE == (DosHeader)->e_magic \
|
||||
&& 0L != (DosHeader)->e_lfanew)
|
||||
#define ROSSYM_IS_VALID_NT_HEADERS(NtHeaders) (IMAGE_NT_SIGNATURE == (NtHeaders)->Signature \
|
||||
|
|
|
@ -32,7 +32,6 @@ if(NEWCC)
|
|||
cache/pinsup.c
|
||||
cache/section/data.c
|
||||
cache/section/fault.c
|
||||
cache/section/io.c
|
||||
cache/section/reqtools.c
|
||||
cache/section/sptab.c
|
||||
cache/section/swapout.c)
|
||||
|
@ -47,6 +46,7 @@ else()
|
|||
endif()
|
||||
|
||||
list(APPEND SOURCE
|
||||
cache/section/io.c
|
||||
config/cmalloc.c
|
||||
config/cmapi.c
|
||||
config/cmboot.c
|
||||
|
|
8
ntoskrnl/cache/section/io.c
vendored
8
ntoskrnl/cache/section/io.c
vendored
|
@ -99,6 +99,7 @@ MiSimpleRead
|
|||
PLARGE_INTEGER FileOffset,
|
||||
PVOID Buffer,
|
||||
ULONG Length,
|
||||
BOOLEAN Paging,
|
||||
PIO_STATUS_BLOCK ReadStatus)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
|
@ -127,7 +128,7 @@ MiSimpleRead
|
|||
Length);
|
||||
|
||||
KeInitializeEvent(&ReadWait, NotificationEvent, FALSE);
|
||||
|
||||
|
||||
Irp = IoBuildAsynchronousFsdRequest
|
||||
(IRP_MJ_READ,
|
||||
DeviceObject,
|
||||
|
@ -141,7 +142,7 @@ MiSimpleRead
|
|||
return STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
Irp->Flags |= IRP_PAGING_IO | IRP_SYNCHRONOUS_PAGING_IO | IRP_NOCACHE | IRP_SYNCHRONOUS_API;
|
||||
Irp->Flags |= (Paging ? IRP_PAGING_IO | IRP_SYNCHRONOUS_PAGING_IO | IRP_NOCACHE : 0) | IRP_SYNCHRONOUS_API;
|
||||
|
||||
Irp->UserEvent = &ReadWait;
|
||||
Irp->Tail.Overlay.OriginalFileObject = FileObject;
|
||||
|
@ -150,7 +151,8 @@ MiSimpleRead
|
|||
IrpSp->Control |= SL_INVOKE_ON_SUCCESS | SL_INVOKE_ON_ERROR;
|
||||
IrpSp->FileObject = FileObject;
|
||||
IrpSp->CompletionRoutine = MiSimpleReadComplete;
|
||||
|
||||
ObReferenceObject(FileObject);
|
||||
|
||||
Status = IoCallDriver(DeviceObject, Irp);
|
||||
if (Status == STATUS_PENDING)
|
||||
{
|
||||
|
|
35
ntoskrnl/cache/section/newmm.h
vendored
35
ntoskrnl/cache/section/newmm.h
vendored
|
@ -181,6 +181,7 @@ MiSimpleRead
|
|||
PLARGE_INTEGER FileOffset,
|
||||
PVOID Buffer,
|
||||
ULONG Length,
|
||||
BOOLEAN Paging,
|
||||
PIO_STATUS_BLOCK ReadStatus);
|
||||
|
||||
NTSTATUS
|
||||
|
@ -404,40 +405,6 @@ MmCreateCacheSection
|
|||
ULONG AllocationAttributes,
|
||||
PFILE_OBJECT FileObject);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
MiSimpleRead
|
||||
(PFILE_OBJECT FileObject,
|
||||
PLARGE_INTEGER FileOffset,
|
||||
PVOID Buffer,
|
||||
ULONG Length,
|
||||
PIO_STATUS_BLOCK ReadStatus);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
_MiSimpleWrite
|
||||
(PFILE_OBJECT FileObject,
|
||||
PLARGE_INTEGER FileOffset,
|
||||
PVOID Buffer,
|
||||
ULONG Length,
|
||||
PIO_STATUS_BLOCK ReadStatus,
|
||||
const char *file,
|
||||
int line);
|
||||
|
||||
#define MiSimpleWrite(F,O,B,L,R) _MiSimpleWrite(F,O,B,L,R,__FILE__,__LINE__)
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
_MiWriteBackPage
|
||||
(PFILE_OBJECT FileObject,
|
||||
PLARGE_INTEGER Offset,
|
||||
ULONG Length,
|
||||
PFN_NUMBER Page,
|
||||
const char *File,
|
||||
int Line);
|
||||
|
||||
#define MiWriteBackPage(F,O,L,P) _MiWriteBackPage(F,O,L,P,__FILE__,__LINE__)
|
||||
|
||||
PVOID
|
||||
NTAPI
|
||||
MmGetSegmentRmap(PFN_NUMBER Page, PULONG RawOffset);
|
||||
|
|
|
@ -12,7 +12,8 @@
|
|||
|
||||
#include <ntoskrnl.h>
|
||||
|
||||
#define NDEBUG
|
||||
//#define NDEBUG
|
||||
#include "../cache/section/newmm.h"
|
||||
#include <debug.h>
|
||||
|
||||
/* GLOBALS ******************************************************************/
|
||||
|
@ -26,6 +27,12 @@ typedef struct _IMAGE_SYMBOL_INFO_CACHE
|
|||
}
|
||||
IMAGE_SYMBOL_INFO_CACHE, *PIMAGE_SYMBOL_INFO_CACHE;
|
||||
|
||||
typedef struct _ROSSYM_KM_OWN_CONTEXT {
|
||||
ROSSYM_OWN_FILECONTEXT Rossym;
|
||||
LARGE_INTEGER FileOffset;
|
||||
PFILE_OBJECT FileObject;
|
||||
} ROSSYM_KM_OWN_CONTEXT, *PROSSYM_KM_OWN_CONTEXT;
|
||||
|
||||
static BOOLEAN LoadSymbols;
|
||||
static LIST_ENTRY SymbolFileListHead;
|
||||
static KSPIN_LOCK SymbolFileListLock;
|
||||
|
@ -35,6 +42,50 @@ BOOLEAN KdbpSymbolsInitialized = FALSE;
|
|||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
static BOOLEAN
|
||||
KdbpSeekSymFile(PVOID FileContext, ULONG_PTR Target)
|
||||
{
|
||||
PROSSYM_KM_OWN_CONTEXT Context = (PROSSYM_KM_OWN_CONTEXT)FileContext;
|
||||
Context->FileOffset.QuadPart = Target;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOLEAN
|
||||
KdbpReadSymFile(PVOID FileContext, PVOID Buffer, ULONG Length)
|
||||
{
|
||||
PROSSYM_KM_OWN_CONTEXT Context = (PROSSYM_KM_OWN_CONTEXT)FileContext;
|
||||
IO_STATUS_BLOCK Iosb;
|
||||
NTSTATUS Status = MiSimpleRead
|
||||
(Context->FileObject,
|
||||
&Context->FileOffset,
|
||||
Buffer,
|
||||
Length,
|
||||
FALSE,
|
||||
&Iosb);
|
||||
return NT_SUCCESS(Status);
|
||||
}
|
||||
|
||||
static PROSSYM_OWN_FILECONTEXT
|
||||
KdbpCaptureFileForSymbols(PFILE_OBJECT FileObject)
|
||||
{
|
||||
PROSSYM_KM_OWN_CONTEXT Context = ExAllocatePool(NonPagedPool, sizeof(*Context));
|
||||
if (!Context) return NULL;
|
||||
ObReferenceObject(FileObject);
|
||||
Context->FileOffset.QuadPart = 0;
|
||||
Context->FileObject = FileObject;
|
||||
Context->Rossym.ReadFileProc = KdbpReadSymFile;
|
||||
Context->Rossym.SeekFileProc = KdbpSeekSymFile;
|
||||
return &Context->Rossym;
|
||||
}
|
||||
|
||||
static VOID
|
||||
KdbpReleaseFileForSymbols(PROSSYM_OWN_FILECONTEXT FileContext)
|
||||
{
|
||||
PROSSYM_KM_OWN_CONTEXT Context = (PROSSYM_KM_OWN_CONTEXT)FileContext;
|
||||
ObDereferenceObject(Context->FileObject);
|
||||
ExFreePool(Context);
|
||||
}
|
||||
|
||||
static BOOLEAN
|
||||
KdbpSymSearchModuleList(
|
||||
IN PLIST_ENTRY current_entry,
|
||||
|
@ -127,12 +178,9 @@ KdbSymPrintAddress(
|
|||
IN PVOID Address)
|
||||
{
|
||||
PMEMORY_AREA MemoryArea = NULL;
|
||||
HANDLE FileHandle = NULL;
|
||||
PROS_SECTION_OBJECT SectionObject;
|
||||
PLDR_DATA_TABLE_ENTRY LdrEntry;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
IO_STATUS_BLOCK IoStatusBlock;
|
||||
UNICODE_STRING ModuleFileName;
|
||||
PROSSYM_OWN_FILECONTEXT FileContext;
|
||||
ULONG_PTR RelativeAddress;
|
||||
NTSTATUS Status;
|
||||
ULONG LineNumber;
|
||||
|
@ -163,44 +211,22 @@ KdbSymPrintAddress(
|
|||
}
|
||||
SectionObject = MemoryArea->Data.SectionData.Section;
|
||||
if (!(SectionObject->AllocationAttributes & SEC_IMAGE)) goto end;
|
||||
if (SectionObject->ImageSection->ImageBase != KdbpImageBase)
|
||||
if (MemoryArea->StartingAddress != KdbpImageBase)
|
||||
{
|
||||
if (KdbpRosSymInfo)
|
||||
{
|
||||
RosSymDelete(KdbpRosSymInfo);
|
||||
KdbpRosSymInfo = NULL;
|
||||
KdbpImageBase = 0;
|
||||
}
|
||||
|
||||
Status = MmGetFileNameForAddress(Address, &ModuleFileName);
|
||||
if (!NT_SUCCESS(Status))
|
||||
goto end;
|
||||
|
||||
InitializeObjectAttributes
|
||||
(&ObjectAttributes,
|
||||
&ModuleFileName,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
if (!NT_SUCCESS
|
||||
(ZwOpenFile
|
||||
(&FileHandle,
|
||||
FILE_READ_ACCESS,
|
||||
&ObjectAttributes,
|
||||
&IoStatusBlock,
|
||||
FILE_SHARE_READ,
|
||||
FILE_SYNCHRONOUS_IO_NONALERT)))
|
||||
if ((FileContext = KdbpCaptureFileForSymbols(SectionObject->FileObject)))
|
||||
{
|
||||
goto end;
|
||||
}
|
||||
if (RosSymCreateFromFile(FileContext, &KdbpRosSymInfo))
|
||||
KdbpImageBase = MemoryArea->StartingAddress;
|
||||
|
||||
if (!RosSymCreateFromFile(&FileHandle, &KdbpRosSymInfo))
|
||||
{
|
||||
KdbpRosSymInfo = NULL;
|
||||
KdbpReleaseFileForSymbols(FileContext);
|
||||
}
|
||||
|
||||
ZwClose(FileHandle);
|
||||
KdbpImageBase = SectionObject->ImageSection->ImageBase;
|
||||
}
|
||||
|
||||
if (KdbpRosSymInfo)
|
||||
|
@ -402,6 +428,8 @@ KdbpSymLoadModuleSymbols(
|
|||
HANDLE FileHandle;
|
||||
NTSTATUS Status;
|
||||
IO_STATUS_BLOCK IoStatusBlock;
|
||||
PFILE_OBJECT FileObject;
|
||||
PROSSYM_OWN_FILECONTEXT FileContext;
|
||||
|
||||
/* Allow KDB to break on module load */
|
||||
KdbModuleLoaded(FileName);
|
||||
|
@ -423,7 +451,7 @@ KdbpSymLoadModuleSymbols(
|
|||
/* Open the file */
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
FileName,
|
||||
0,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
|
@ -443,20 +471,34 @@ KdbpSymLoadModuleSymbols(
|
|||
|
||||
DPRINT("Loading symbols from %wZ...\n", FileName);
|
||||
|
||||
if (!RosSymCreateFromFile(&FileHandle, RosSymInfo))
|
||||
Status = ObReferenceObjectByHandle
|
||||
(FileHandle,
|
||||
FILE_READ_DATA|SYNCHRONIZE,
|
||||
NULL,
|
||||
KernelMode,
|
||||
(PVOID*)&FileObject,
|
||||
NULL);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("Failed to load symbols from %wZ\n", FileName);
|
||||
DPRINT("Could not get the file object\n");
|
||||
ZwClose(FileHandle);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((FileContext = KdbpCaptureFileForSymbols(FileObject)))
|
||||
{
|
||||
if (RosSymCreateFromFile(FileContext, RosSymInfo))
|
||||
{
|
||||
/* add file to cache */
|
||||
KdbpSymAddCachedFile(FileName, *RosSymInfo);
|
||||
DPRINT("Installed symbols: %wZ %p\n", FileName, *RosSymInfo);
|
||||
}
|
||||
KdbpReleaseFileForSymbols(FileContext);
|
||||
}
|
||||
|
||||
ObDereferenceObject(FileObject);
|
||||
ZwClose(FileHandle);
|
||||
|
||||
DPRINT("Symbols loaded.\n");
|
||||
|
||||
/* add file to cache */
|
||||
KdbpSymAddCachedFile(FileName, *RosSymInfo);
|
||||
|
||||
DPRINT("Installed symbols: %wZ %p\n", FileName, *RosSymInfo);
|
||||
}
|
||||
|
||||
VOID
|
||||
|
|
Loading…
Reference in a new issue