Reuse buffer in IopQueryNameFile, since it's temporary and the first one
we allocate is already large enough. Also block out SEH in ntread/write
file since it seems to crash some user mode code.
Modified: trunk/reactos/ntoskrnl/io/file.c
_____
Modified: trunk/reactos/ntoskrnl/io/file.c
--- trunk/reactos/ntoskrnl/io/file.c 2005-05-09 22:35:43 UTC (rev
15195)
+++ trunk/reactos/ntoskrnl/io/file.c 2005-05-09 23:39:08 UTC (rev
15196)
@@ -414,62 +414,57 @@
ULONG Length,
PULONG ReturnLength)
{
- POBJECT_NAME_INFORMATION LocalInfo;
- PFILE_NAME_INFORMATION FileNameInfo;
- PFILE_OBJECT FileObject;
- ULONG LocalReturnLength;
- NTSTATUS Status;
+ PVOID LocalInfo;
+ PFILE_OBJECT FileObject;
+ ULONG LocalReturnLength;
+ NTSTATUS Status;
- DPRINT ("IopQueryNameFile() called\n");
+ DPRINT1("IopQueryNameFile() called\n");
- FileObject = (PFILE_OBJECT)ObjectBody;
+ FileObject = (PFILE_OBJECT)ObjectBody;
- LocalInfo = ExAllocatePool (NonPagedPool,
- sizeof(OBJECT_NAME_INFORMATION) +
- MAX_PATH * sizeof(WCHAR));
- if (LocalInfo == NULL)
- return STATUS_INSUFFICIENT_RESOURCES;
+ /* Allocate Buffer */
+ LocalInfo = ExAllocatePool(PagedPool,
+ sizeof(OBJECT_NAME_INFORMATION) +
+ MAX_PATH * sizeof(WCHAR));
+ if (LocalInfo == NULL) return STATUS_INSUFFICIENT_RESOURCES;
- Status = ObQueryNameString
(FileObject->DeviceObject->Vpb->RealDevice,
- LocalInfo,
- MAX_PATH * sizeof(WCHAR),
- &LocalReturnLength);
- if (!NT_SUCCESS (Status))
+ /* Query the name */
+ Status = ObQueryNameString(FileObject->DeviceObject,
+ LocalInfo,
+ MAX_PATH * sizeof(WCHAR),
+ &LocalReturnLength);
+ if (!NT_SUCCESS (Status))
{
- ExFreePool (LocalInfo);
- return Status;
+ ExFreePool (LocalInfo);
+ return Status;
}
- DPRINT ("Device path: %wZ\n", &LocalInfo->Name);
+ DPRINT ("Device path: %wZ\n", &LocalInfo->Name);
+
+ /* Write Device Path */
+ Status = RtlAppendUnicodeStringToString(&ObjectNameInfo->Name,
+
&((POBJECT_NAME_INFORMATION)LocalInfo)->Name);
- Status = RtlAppendUnicodeStringToString (&ObjectNameInfo->Name,
- &LocalInfo->Name);
-
- ExFreePool (LocalInfo);
-
- FileNameInfo = ExAllocatePool (NonPagedPool,
- MAX_PATH * sizeof(WCHAR) + sizeof(ULONG));
- if (FileNameInfo == NULL)
- return STATUS_INSUFFICIENT_RESOURCES;
-
- Status = IoQueryFileInformation (FileObject,
- FileNameInformation,
- MAX_PATH * sizeof(WCHAR) + sizeof(ULONG),
- FileNameInfo,
- NULL);
- if (Status != STATUS_SUCCESS)
+ /* Query the File name */
+ Status = IoQueryFileInformation(FileObject,
+ FileNameInformation,
+ LocalReturnLength,
+ LocalInfo,
+ NULL);
+ if (Status != STATUS_SUCCESS)
{
- ExFreePool (FileNameInfo);
- return Status;
+ ExFreePool(LocalInfo);
+ return Status;
}
- Status = RtlAppendUnicodeToString (&ObjectNameInfo->Name,
- FileNameInfo->FileName);
+ /* Write the Name */
+ Status = RtlAppendUnicodeToString(&ObjectNameInfo->Name,
+
((PFILE_NAME_INFORMATION)LocalInfo)->FileName);
+ DPRINT ("Total path: %wZ\n", &ObjectNameInfo->Name);
- DPRINT ("Total path: %wZ\n", &ObjectNameInfo->Name);
-
- ExFreePool (FileNameInfo);
-
- return Status;
+ /* Free buffer and return */
+ ExFreePool(LocalInfo);
+ return Status;
}
VOID
@@ -3004,10 +2999,11 @@
{
_SEH_TRY
{
+ #if 0
ProbeForWrite(IoStatusBlock,
sizeof(IO_STATUS_BLOCK),
sizeof(ULONG));
- #if 0
+
ProbeForRead(Buffer,
Length,
sizeof(ULONG));
Show replies by date
ion(a)svn.reactos.com wrote:
Reuse buffer in IopQueryNameFile, since it's
temporary and the first one we allocate is already large enough. Also block out SEH in
ntread/write file since it seems to crash some user mode code.
Modified: trunk/reactos/ntoskrnl/io/file.c
------------------------------------------------------------------------
*Modified: trunk/reactos/ntoskrnl/io/file.c*
VOID
@@ -3004,10 +2999,11 @@
{
_SEH_TRY
{
+ #if 0
ProbeForWrite(IoStatusBlock,
sizeof(IO_STATUS_BLOCK),
sizeof(ULONG));
- #if 0
+
ProbeForRead(Buffer,
Length,
sizeof(ULONG));
Do you know the error status? IoStatusBlock doesn't need a alignment of
4 bytes.
- Hartmut
Hartmut Birr wrote:
Do you know the error status? IoStatusBlock
doesn't need a alignment of
4 bytes.
This actually applies to many other things, most pointers to variables
<= 4 bytes don't need any alignment, i made some tests a month or so
ago. Since the ProbeForRead/Write functions are for general purpose, we
might add some probe functions that don't do alignment checks to improve
performance. Unfortunately, there are many Probe calls that'd have to be
fixed.
Best Regards,
Thomas
Thomas Weidenmueller wrote:
Hartmut Birr wrote:
Do you know the error status? IoStatusBlock
doesn't need a alignment of
4 bytes.
This actually applies to many other things, most pointers to variables
<= 4 bytes don't need any alignment, i made some tests a month or so
ago. Since the ProbeForRead/Write functions are for general purpose, we
might add some probe functions that don't do alignment checks to improve
performance. Unfortunately, there are many Probe calls that'd have to be
fixed.
Best Regards,
Thomas
_______________________________________________
Ros-diffs mailing list
Ros-diffs(a)reactos.com
http://reactos.com:8080/mailman/listinfo/ros-diffs
Most of our probe calls should indeed be replaced by a simple if (Ptr >
MM_USER_PROBE_ADDRESS (or whatever the name is)) then FAIL. But someone
needs to change them all ;)
Best regards,
Alex Ionescu