Author: sir_richard
Date: Tue Oct 12 21:17:58 2010
New Revision: 49133
URL: http://svn.reactos.org/svn/reactos?rev=49133&view=rev
Log:
[SMSS]: Remove the ROS_DOESNT_SUCK hack, and correctly started subsystem processes with the first MB reserved.
[CSRSRV]: CSRSS was started with a free address space, and was able to map 0xA0000 into it by luck, because the ReactOS Mm allocator picks address ranges randomly, and it somehow managed to avoid the low 1MB addresses. Were this algorithm to change, or perhaps, were we to implement VADs for VM allocations, the 0xA0000 region might already be allocated (by an early-process-initialization allocation, such as the heap). This is what the flag referenced above was designed for, but it was not used. Using this flag, on the other hand, now makes CSRSS fail, because it attempts to map the RAM into 0xA0000, which fails since you can map a section on top of reserved memory. To work around this Brobdingnagian annoyance, CSRSS simply releases the first MB of memory that SMSS has nicely reserved for it, and then proceeds with the mapping. This fixes the issue of getting 0xA0000 by luck and now guarantees it can be mapped.
Modified:
trunk/reactos/base/system/smss/smapiexec.c
trunk/reactos/subsystems/win32/csrss/csrsrv/init.c
Modified: trunk/reactos/base/system/smss/smapiexec.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/smss/smapiexec…
==============================================================================
--- trunk/reactos/base/system/smss/smapiexec.c [iso-8859-1] (original)
+++ trunk/reactos/base/system/smss/smapiexec.c [iso-8859-1] Tue Oct 12 21:17:58 2010
@@ -108,11 +108,11 @@
__FUNCTION__, Status);
return Status;
}
-#ifdef ROS_DOESNT_SUCK
+
/* Reserve lower 1Mb, if requested */
if (Flags & SM_CREATE_FLAG_RESERVE_1MB)
ProcessParameters->Flags |= RTL_USER_PROCESS_PARAMETERS_RESERVE_1MB;
-#endif
+
/* Create the user process */
Status = RtlCreateUserProcess (& ImagePathString,
OBJ_CASE_INSENSITIVE,
Modified: trunk/reactos/subsystems/win32/csrss/csrsrv/init.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/csrsrv/init.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/csrsrv/init.c [iso-8859-1] Tue Oct 12 21:17:58 2010
@@ -38,7 +38,20 @@
LARGE_INTEGER Offset;
SIZE_T ViewSize;
CHAR IVTAndBda[1024+256];
-
+
+ /* Free the 1MB pre-reserved region. In reality, ReactOS should simply support us mapping the view into the reserved area, but it doesn't. */
+ BaseAddress = 0;
+ ViewSize = 1024 * 1024;
+ Status = ZwFreeVirtualMemory(NtCurrentProcess(),
+ &BaseAddress,
+ &ViewSize,
+ MEM_RELEASE);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("Couldn't unmap reserved memory (%x)\n", Status);
+ return 0;
+ }
+
/* Open the physical memory section */
InitializeObjectAttributes(&ObjectAttributes,
&PhysMemName,