[RTL/NDK/NTDLL]
[reactos.git] / reactos / lib / rtl / process.c
index ae91e24..679f986 100644 (file)
@@ -42,7 +42,7 @@ RtlpMapFile(PUNICODE_STRING ImageFileName,
                         FILE_SYNCHRONOUS_IO_NONALERT | FILE_NON_DIRECTORY_FILE);
     if (!NT_SUCCESS(Status))
     {
-        DPRINT1("Failed to read image file from disk\n");
+        DPRINT1("Failed to read image file from disk, Status = 0x%08X\n", Status);
         return Status;
     }
 
@@ -56,7 +56,7 @@ RtlpMapFile(PUNICODE_STRING ImageFileName,
                              hFile);
     if (!NT_SUCCESS(Status))
     {
-        DPRINT1("Failed to create section for image file\n");
+        DPRINT1("Failed to create section for image file, Status = 0x%08X\n", Status);
     }
 
     ZwClose(hFile);
@@ -84,7 +84,7 @@ RtlpInitEnvironment(HANDLE ProcessHandle,
     {
         /* Give 1MB starting at 0x4 */
         BaseAddress = (PVOID)4;
-        EnviroSize = 1024 * 1024;
+        EnviroSize = (1024 * 1024) - 256;
         Status = ZwAllocateVirtualMemory(ProcessHandle,
                                          &BaseAddress,
                                          0,
@@ -203,7 +203,7 @@ RtlCreateUserProcess(IN PUNICODE_STRING ImageFileName,
     Status = RtlpMapFile(ImageFileName,
                          Attributes,
                          &hSection);
-    if(!NT_SUCCESS(Status))
+    if (!NT_SUCCESS(Status))
     {
         DPRINT1("Could not map process image\n");
         return Status;
@@ -263,11 +263,11 @@ RtlCreateUserProcess(IN PUNICODE_STRING ImageFileName,
     }
 
     /* Get some information about the process */
-    ZwQueryInformationProcess(ProcessInfo->ProcessHandle,
-                              ProcessBasicInformation,
-                              &ProcessBasicInfo,
-                              sizeof(ProcessBasicInfo),
-                              NULL);
+    Status = ZwQueryInformationProcess(ProcessInfo->ProcessHandle,
+                                       ProcessBasicInformation,
+                                       &ProcessBasicInfo,
+                                       sizeof(ProcessBasicInfo),
+                                       NULL);
     if (!NT_SUCCESS(Status))
     {
         DPRINT1("Could not query Process Info\n");
@@ -357,21 +357,24 @@ RtlEncodeSystemPointer(IN PVOID Pointer)
  *   http://www.geoffchappell.com/studies/windows/win32/ntdll/api/rtl/peb/setprocessiscritical.htm
  */
 NTSTATUS
-NTAPI
+__cdecl
 RtlSetProcessIsCritical(IN BOOLEAN NewValue,
                         OUT PBOOLEAN OldValue OPTIONAL,
                         IN BOOLEAN NeedBreaks)
 {
-    ULONG BreakOnTermination = FALSE;
+    ULONG BreakOnTermination;
 
-    if (OldValue)
-        *OldValue = FALSE;
+    /* Initialize to FALSE */
+    if (OldValue) *OldValue = FALSE;
 
     /* Fail, if the critical breaks flag is required but is not set */
-    if (NeedBreaks == TRUE &&
+    if ((NeedBreaks) &&
         !(NtCurrentPeb()->NtGlobalFlag & FLG_ENABLE_SYSTEM_CRIT_BREAKS))
+    {
         return STATUS_UNSUCCESSFUL;
+    }
 
+    /* Check if the caller wants the old value */
     if (OldValue)
     {
         /* Query and return the old break on termination flag for the process */