Author: ion
Date: Thu Nov 30 08:22:20 2006
New Revision: 24985
URL:
http://svn.reactos.org/svn/reactos?rev=24985&view=rev
Log:
- Fix DbgkSectionHandleToFileHandle.
- Implement MmGetFileNameForSection.
- There is a bug in ObQueryNameString for file objects, so the full name isn't
returned...
Modified:
trunk/reactos/ntoskrnl/dbgk/dbgkutil.c
trunk/reactos/ntoskrnl/dbgk/debug.c
trunk/reactos/ntoskrnl/include/internal/mm.h
trunk/reactos/ntoskrnl/mm/section.c
Modified: trunk/reactos/ntoskrnl/dbgk/dbgkutil.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/dbgk/dbgkutil.c?r…
==============================================================================
--- trunk/reactos/ntoskrnl/dbgk/dbgkutil.c (original)
+++ trunk/reactos/ntoskrnl/dbgk/dbgkutil.c Thu Nov 30 08:22:20 2006
@@ -19,7 +19,7 @@
DbgkpSectionToFileHandle(IN PVOID Section)
{
NTSTATUS Status;
- UNICODE_STRING FileName;
+ POBJECT_NAME_INFORMATION FileName;
OBJECT_ATTRIBUTES ObjectAttributes;
IO_STATUS_BLOCK IoStatusBlock;
HANDLE Handle;
@@ -31,7 +31,7 @@
/* Initialize object attributes */
InitializeObjectAttributes(&ObjectAttributes,
- &FileName,
+ &FileName->Name,
OBJ_CASE_INSENSITIVE |
OBJ_FORCE_ACCESS_CHECK |
OBJ_KERNEL_HANDLE,
@@ -39,15 +39,17 @@
NULL);
/* Open the file */
+ DPRINT1("Trying to open: %wZ\n", &FileName->Name);
Status = ZwOpenFile(&Handle,
GENERIC_READ | SYNCHRONIZE,
&ObjectAttributes,
&IoStatusBlock,
FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE,
FILE_SYNCHRONOUS_IO_NONALERT);
+ DPRINT1("Status: %lx\n", Status);
/* Free the name and return the handle if we succeeded */
- ExFreePool(FileName.Buffer);
+ ExFreePool(FileName);
if (!NT_SUCCESS(Status)) return NULL;
return Handle;
}
@@ -91,7 +93,8 @@
ULONG ProcessFlags;
IMAGE_INFO ImageInfo;
PIMAGE_NT_HEADERS NtHeader;
- UNICODE_STRING ModuleName;
+ POBJECT_NAME_INFORMATION ModuleName;
+ UNICODE_STRING NtDllName;
NTSTATUS Status;
PVOID DebugPort;
DBGKM_MSG ApiMessage;
@@ -130,10 +133,10 @@
if (NT_SUCCESS(Status))
{
/* Call the notify routines and free the name */
- PspRunLoadImageNotifyRoutines(&ModuleName,
+ PspRunLoadImageNotifyRoutines(&ModuleName->Name,
Process->UniqueProcessId,
&ImageInfo);
- ExFreePool(ModuleName.Buffer);
+ ExFreePool(ModuleName);
}
else
{
@@ -160,9 +163,9 @@
}
/* Call the notify routines */
- RtlInitUnicodeString(&ModuleName,
+ RtlInitUnicodeString(&NtDllName,
L"\\SystemRoot\\System32\\ntdll.dll");
- PspRunLoadImageNotifyRoutines(&ModuleName,
+ PspRunLoadImageNotifyRoutines(&NtDllName,
Process->UniqueProcessId,
&ImageInfo);
}
Modified: trunk/reactos/ntoskrnl/dbgk/debug.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/dbgk/debug.c?rev=…
==============================================================================
--- trunk/reactos/ntoskrnl/dbgk/debug.c (original)
+++ trunk/reactos/ntoskrnl/dbgk/debug.c Thu Nov 30 08:22:20 2006
@@ -653,14 +653,17 @@
if (First)
{
/* So we'll start with the create process message */
+ DPRINT1("new proces!\n");
ApiMessage.ApiNumber = DbgKmCreateProcessApi;
/* Get the file handle */
+ DPRINT1("section object: %p\n", Process->SectionObject);
if (Process->SectionObject)
{
/* Use the section object */
CreateProcess->FileHandle =
DbgkpSectionToFileHandle(Process->SectionObject);
+ DPRINT1("FileHandle: %p\n", CreateProcess->FileHandle);
}
else
{
@@ -669,7 +672,9 @@
}
/* Set the base address */
+ DPRINT1("SectionBaseAddress: %p\n",
Process->SectionBaseAddress);
CreateProcess->BaseOfImage = Process->SectionBaseAddress;
+ KEBUGCHECK(0);
/* Get the NT Header */
NtHeader = RtlImageNtHeader(Process->SectionBaseAddress);
Modified: trunk/reactos/ntoskrnl/include/internal/mm.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/mm.h (original)
+++ trunk/reactos/ntoskrnl/include/internal/mm.h Thu Nov 30 08:22:20 2006
@@ -1326,7 +1326,7 @@
NTAPI
MmGetFileNameForSection(
IN PROS_SECTION_OBJECT Section,
- OUT PUNICODE_STRING ModuleName
+ OUT POBJECT_NAME_INFORMATION *ModuleName
);
PVOID
Modified: trunk/reactos/ntoskrnl/mm/section.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/section.c?rev=…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/section.c (original)
+++ trunk/reactos/ntoskrnl/mm/section.c Thu Nov 30 08:22:20 2006
@@ -109,10 +109,40 @@
NTSTATUS
NTAPI
MmGetFileNameForSection(IN PROS_SECTION_OBJECT Section,
- OUT PUNICODE_STRING ModuleName)
-{
- /* FIXME: TODO. ObQueryNameString on the FileObject */
- RtlCreateUnicodeString(ModuleName, L"C:\\ReactOS\\system32\\ntdll.dll");
+ OUT POBJECT_NAME_INFORMATION *ModuleName)
+{
+ POBJECT_NAME_INFORMATION ObjectNameInfo;
+ NTSTATUS Status;
+ ULONG ReturnLength;
+
+ /* Make sure it's an image section */
+ *ModuleName = NULL;
+ if (!(Section->AllocationAttributes & SEC_IMAGE))
+ {
+ /* It's not, fail */
+ return STATUS_SECTION_NOT_IMAGE;
+ }
+
+ /* Allocate memory for our structure */
+ ObjectNameInfo = ExAllocatePoolWithTag(PagedPool,
+ 1024,
+ TAG('M', 'm', ' ',
' '));
+ if (!ObjectNameInfo) return STATUS_NO_MEMORY;
+
+ /* Query the name */
+ Status = ObQueryNameString(Section->FileObject,
+ ObjectNameInfo,
+ 1024,
+ &ReturnLength);
+ if (!NT_SUCCESS(Status))
+ {
+ /* Failed, free memory */
+ ExFreePool(ObjectNameInfo);
+ return Status;
+ }
+
+ /* Success */
+ *ModuleName = ObjectNameInfo;
return STATUS_SUCCESS;
}