|
From: Jack \(Butch\) G. <bu...@qw...> - 2001-09-26 01:54:18
|
Included below is a patch (I think) for a problem I mentioned earlier.
Basically the behavior between Windows 2000 and ReactosOS was different in
the case of a call to VirtualAlloc with a NULL base address and MEM_COMMIT.
The patch below adds a simple test case to vmtest.c and update
NtAllocateVirtualMemory() to handle this case by calling itself recursively
first with MEM_RESERVE to reserve the address space, and then with
MEM_COMMIT to commit the memory.
Thanks
Jack (Butch) Griffin
diff -Naur reactos.orig/apps/vmtest/vmtest.c reactos/apps/vmtest/vmtest.c
--- reactos.orig/apps/vmtest/vmtest.c Tue Sep 25 16:08:53 2001
+++ reactos/apps/vmtest/vmtest.c Tue Sep 25 18:48:44 2001
@@ -5,7 +5,14 @@
{
PVOID Base;
PVOID Ret;
-
+
+ Base = VirtualAlloc(NULL,
+ 4096 * 64,
+ MEM_COMMIT,
+ PAGE_READWRITE) ;
+ if (Base == NULL)
+ printf("VirtualAlloc failed 0\n") ;
+
Base = VirtualAlloc(NULL,
1048576,
MEM_RESERVE,
diff -Naur reactos.orig/ntoskrnl/mm/virtual.c reactos/ntoskrnl/mm/virtual.c
--- reactos.orig/ntoskrnl/mm/virtual.c Tue Sep 25 16:09:18 2001
+++ reactos/ntoskrnl/mm/virtual.c Tue Sep 25 18:48:46 2001
@@ -887,10 +887,30 @@
{
return(STATUS_INVALID_PARAMETER);
}
+
if (((AllocationType & (MEM_COMMIT | MEM_RESERVE)) == MEM_COMMIT) &&
(*UBaseAddress == 0))
{
- return(STATUS_INVALID_PARAMETER);
+ DbgPrint("In my routine\n") ;
+ Status = NtAllocateVirtualMemory(ProcessHandle,
+ UBaseAddress,
+ ZeroBits,
+ URegionSize,
+ MEM_RESERVE,
+ Protect) ;
+ if (!NT_SUCCESS(Status))
+ return Status ;
+
+ Status = NtAllocateVirtualMemory(ProcessHandle,
+ UBaseAddress,
+ ZeroBits,
+ URegionSize,
+ MEM_COMMIT,
+ Protect) ;
+ if (!NT_SUCCESS(Status))
+ return Status ;
+
+ return STATUS_SUCCESS ;
}
PBaseAddress = *UBaseAddress;
====================================================
= To remove yourself from this mailing list, go to =
= http://www.reactos.com/home/mailing.html =
====================================================
|