Author: akhaldi
Date: Tue Apr 19 18:13:10 2011
New Revision: 51404
URL:
http://svn.reactos.org/svn/reactos?rev=51404&view=rev
Log:
[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.
Added:
branches/cmake-bringup/lib/rossym/iofile.c (with props)
Modified:
branches/cmake-bringup/include/reactos/rossym.h
branches/cmake-bringup/lib/rossym/CMakeLists.txt
branches/cmake-bringup/lib/rossym/initkm.c
branches/cmake-bringup/lib/rossym/rossympriv.h
branches/cmake-bringup/ntoskrnl/CMakeLists.txt
branches/cmake-bringup/ntoskrnl/cache/section/io.c
branches/cmake-bringup/ntoskrnl/cache/section/newmm.h
branches/cmake-bringup/ntoskrnl/kdbg/kdb_symbols.c
Modified: branches/cmake-bringup/include/reactos/rossym.h
URL:
http://svn.reactos.org/svn/reactos/branches/cmake-bringup/include/reactos/r…
==============================================================================
--- branches/cmake-bringup/include/reactos/rossym.h [iso-8859-1] (original)
+++ branches/cmake-bringup/include/reactos/rossym.h [iso-8859-1] Tue Apr 19 18:13:10 2011
@@ -24,6 +24,11 @@
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;
Modified: branches/cmake-bringup/lib/rossym/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/branches/cmake-bringup/lib/rossym/CMakeL…
==============================================================================
--- branches/cmake-bringup/lib/rossym/CMakeLists.txt [iso-8859-1] (original)
+++ branches/cmake-bringup/lib/rossym/CMakeLists.txt [iso-8859-1] Tue Apr 19 18:13:10
2011
@@ -16,6 +16,7 @@
dwarfpubnames.c
find.c
fromfile.c
+ iofile.c
init.c
initkm.c
initum.c
Modified: branches/cmake-bringup/lib/rossym/initkm.c
URL:
http://svn.reactos.org/svn/reactos/branches/cmake-bringup/lib/rossym/initkm…
==============================================================================
--- branches/cmake-bringup/lib/rossym/initkm.c [iso-8859-1] (original)
+++ branches/cmake-bringup/lib/rossym/initkm.c [iso-8859-1] Tue Apr 19 18:13:10 2011
@@ -38,8 +38,8 @@
{
RosSymAllocMemKM,
RosSymFreeMemKM,
- RosSymZwReadFile,
- RosSymZwSeekFile
+ RosSymIoReadFile,
+ RosSymIoSeekFile
};
RosSymInit(&KmCallbacks);
Added: branches/cmake-bringup/lib/rossym/iofile.c
URL:
http://svn.reactos.org/svn/reactos/branches/cmake-bringup/lib/rossym/iofile…
==============================================================================
--- branches/cmake-bringup/lib/rossym/iofile.c (added)
+++ branches/cmake-bringup/lib/rossym/iofile.c [iso-8859-1] Tue Apr 19 18:13:10 2011
@@ -1,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(a)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 */
Propchange: branches/cmake-bringup/lib/rossym/iofile.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: branches/cmake-bringup/lib/rossym/rossympriv.h
URL:
http://svn.reactos.org/svn/reactos/branches/cmake-bringup/lib/rossym/rossym…
==============================================================================
--- branches/cmake-bringup/lib/rossym/rossympriv.h [iso-8859-1] (original)
+++ branches/cmake-bringup/lib/rossym/rossympriv.h [iso-8859-1] Tue Apr 19 18:13:10 2011
@@ -19,6 +19,9 @@
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 \
Modified: branches/cmake-bringup/ntoskrnl/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/branches/cmake-bringup/ntoskrnl/CMakeLis…
==============================================================================
--- branches/cmake-bringup/ntoskrnl/CMakeLists.txt [iso-8859-1] (original)
+++ branches/cmake-bringup/ntoskrnl/CMakeLists.txt [iso-8859-1] Tue Apr 19 18:13:10 2011
@@ -32,7 +32,6 @@
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 @@
endif()
list(APPEND SOURCE
+ cache/section/io.c
config/cmalloc.c
config/cmapi.c
config/cmboot.c
Modified: branches/cmake-bringup/ntoskrnl/cache/section/io.c
URL:
http://svn.reactos.org/svn/reactos/branches/cmake-bringup/ntoskrnl/cache/se…
==============================================================================
--- branches/cmake-bringup/ntoskrnl/cache/section/io.c [iso-8859-1] (original)
+++ branches/cmake-bringup/ntoskrnl/cache/section/io.c [iso-8859-1] Tue Apr 19 18:13:10
2011
@@ -99,6 +99,7 @@
PLARGE_INTEGER FileOffset,
PVOID Buffer,
ULONG Length,
+ BOOLEAN Paging,
PIO_STATUS_BLOCK ReadStatus)
{
NTSTATUS Status;
@@ -127,7 +128,7 @@
Length);
KeInitializeEvent(&ReadWait, NotificationEvent, FALSE);
-
+
Irp = IoBuildAsynchronousFsdRequest
(IRP_MJ_READ,
DeviceObject,
@@ -141,7 +142,7 @@
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 @@
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)
{
Modified: branches/cmake-bringup/ntoskrnl/cache/section/newmm.h
URL:
http://svn.reactos.org/svn/reactos/branches/cmake-bringup/ntoskrnl/cache/se…
==============================================================================
--- branches/cmake-bringup/ntoskrnl/cache/section/newmm.h [iso-8859-1] (original)
+++ branches/cmake-bringup/ntoskrnl/cache/section/newmm.h [iso-8859-1] Tue Apr 19 18:13:10
2011
@@ -181,6 +181,7 @@
PLARGE_INTEGER FileOffset,
PVOID Buffer,
ULONG Length,
+ BOOLEAN Paging,
PIO_STATUS_BLOCK ReadStatus);
NTSTATUS
@@ -404,40 +405,6 @@
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);
Modified: branches/cmake-bringup/ntoskrnl/kdbg/kdb_symbols.c
URL:
http://svn.reactos.org/svn/reactos/branches/cmake-bringup/ntoskrnl/kdbg/kdb…
==============================================================================
--- branches/cmake-bringup/ntoskrnl/kdbg/kdb_symbols.c [iso-8859-1] (original)
+++ branches/cmake-bringup/ntoskrnl/kdbg/kdb_symbols.c [iso-8859-1] Tue Apr 19 18:13:10
2011
@@ -12,7 +12,8 @@
#include <ntoskrnl.h>
-#define NDEBUG
+//#define NDEBUG
+#include "../cache/section/newmm.h"
#include <debug.h>
/* GLOBALS ******************************************************************/
@@ -25,6 +26,12 @@
PROSSYM_INFO RosSymInfo;
}
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;
@@ -34,6 +41,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(
@@ -127,12 +178,9 @@
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 @@
}
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;
+
+ KdbpReleaseFileForSymbols(FileContext);
}
-
- if (!RosSymCreateFromFile(&FileHandle, &KdbpRosSymInfo))
- {
- KdbpRosSymInfo = NULL;
- }
-
- ZwClose(FileHandle);
- KdbpImageBase = SectionObject->ImageSection->ImageBase;
}
if (KdbpRosSymInfo)
@@ -402,6 +428,8 @@
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 @@
/* Open the file */
InitializeObjectAttributes(&ObjectAttributes,
FileName,
- 0,
+ OBJ_CASE_INSENSITIVE,
NULL,
NULL);
@@ -443,20 +471,34 @@
DPRINT("Loading symbols from %wZ...\n", FileName);
- if (!RosSymCreateFromFile(&FileHandle, RosSymInfo))
- {
- DPRINT("Failed to load symbols from %wZ\n", FileName);
+ Status = ObReferenceObjectByHandle
+ (FileHandle,
+ FILE_READ_DATA|SYNCHRONIZE,
+ NULL,
+ KernelMode,
+ (PVOID*)&FileObject,
+ NULL);
+
+ if (!NT_SUCCESS(Status))
+ {
+ 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