Author: fireball
Date: Thu Jun 12 04:18:11 2008
New Revision: 33944
URL:
http://svn.reactos.org/svn/reactos?rev=33944&view=rev
Log:
- Fix two bugs in MiDoMappedCopy: MI_MAPPED_PAGES is pages, not bytes; and a misuse of
TotalSize / BufferSize.
- Fix similar mistake in MiDoPoolCopy.
- Patch from bug 3341.
See issue #3341 for more details.
Modified:
trunk/reactos/ntoskrnl/mm/virtual.c
Modified: trunk/reactos/ntoskrnl/mm/virtual.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/virtual.c?rev=…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/virtual.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/virtual.c [iso-8859-1] Thu Jun 12 04:18:11 2008
@@ -67,7 +67,7 @@
IN KPROCESSOR_MODE PreviousMode,
OUT PULONG ReturnSize)
{
- PFN_NUMBER MdlBuffer[(sizeof(MDL) / sizeof(PFN_NUMBER)) + (MI_MAPPED_COPY_PAGES
>> PAGE_SHIFT) + 1];
+ PFN_NUMBER MdlBuffer[(sizeof(MDL) / sizeof(PFN_NUMBER)) + MI_MAPPED_COPY_PAGES + 1];
PMDL Mdl = (PMDL)MdlBuffer;
ULONG TotalSize, CurrentSize, RemainingSize;
BOOLEAN FailedInProbe = FALSE, FailedInMapping = FALSE, FailedInMoving;
@@ -82,8 +82,8 @@
/* Calculate the maximum amount of data to move */
TotalSize = (MI_MAPPED_COPY_PAGES - 2) * PAGE_SIZE;
if (BufferSize <= TotalSize) TotalSize = BufferSize;
- CurrentSize = BufferSize;
- RemainingSize = TotalSize;
+ CurrentSize = TotalSize;
+ RemainingSize = BufferSize;
/* Loop as long as there is still data */
while (RemainingSize > 0)
@@ -117,7 +117,7 @@
}
/* Initialize and probe and lock the MDL */
- MmInitializeMdl (Mdl, CurrentAddress, CurrentSize);
+ MmInitializeMdl (Mdl, CurrentAddress, CurrentSize);
MmProbeAndLockPages (Mdl, PreviousMode, IoReadAccess);
PagesLocked = TRUE;
@@ -236,8 +236,8 @@
/* Calculate the maximum amount of data to move */
TotalSize = MI_MAX_TRANSFER_SIZE;
if (BufferSize <= MI_MAX_TRANSFER_SIZE) TotalSize = BufferSize;
- CurrentSize = BufferSize;
- RemainingSize = TotalSize;
+ CurrentSize = TotalSize;
+ RemainingSize = BufferSize;
/* Check if we can use the stack */
if (BufferSize <= MI_POOL_COPY_BYTES)