[KERNEL32]
[reactos.git] / reactos / dll / win32 / kernel32 / client / proc.c
index a4b35fe..245687b 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id$
+/* $Id: proc.c 57086 2012-08-16 15:39:40Z akhaldi $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
@@ -778,8 +778,7 @@ BasePushProcessParameters(IN ULONG ParameterFlags,
     if ((Size) && (Size <= (MAX_PATH + 4)))
     {
         /* Get the DLL Path */
-        DllPathString = BaseComputeProcessDllPath((LPWSTR)ApplicationPathName,
-                                                  lpEnvironment);
+        DllPathString = BaseComputeProcessDllPath(FullPath, lpEnvironment);
         if (!DllPathString)
         {
             /* Fail */
@@ -789,12 +788,13 @@ BasePushProcessParameters(IN ULONG ParameterFlags,
 
         /* Initialize Strings */
         RtlInitUnicodeString(&DllPath, DllPathString);
-        RtlInitUnicodeString(&ImageName, ApplicationPathName);
+        RtlInitUnicodeString(&ImageName, FullPath);
     }
     else
     {
-        /* Get the DLL Path */
-        DllPathString = BaseComputeProcessDllPath(FullPath, lpEnvironment);
+        /* Couldn't get the path name. Just take the original path */
+        DllPathString = BaseComputeProcessDllPath((LPWSTR)ApplicationPathName,
+                                                  lpEnvironment);
         if (!DllPathString)
         {
             /* Fail */
@@ -804,7 +804,7 @@ BasePushProcessParameters(IN ULONG ParameterFlags,
 
         /* Initialize Strings */
         RtlInitUnicodeString(&DllPath, DllPathString);
-        RtlInitUnicodeString(&ImageName, FullPath);
+        RtlInitUnicodeString(&ImageName, ApplicationPathName);
     }
 
     /* Initialize Strings */
@@ -889,7 +889,7 @@ BasePushProcessParameters(IN ULONG ParameterFlags,
         /* Allocate and Initialize new Environment Block */
         Size = EnviroSize;
         ProcessParameters->Environment = NULL;
-        Status = ZwAllocateVirtualMemory(ProcessHandle,
+        Status = NtAllocateVirtualMemory(ProcessHandle,
                                          (PVOID*)&ProcessParameters->Environment,
                                          0,
                                          &Size,
@@ -898,7 +898,7 @@ BasePushProcessParameters(IN ULONG ParameterFlags,
         if (!NT_SUCCESS(Status)) goto FailPath;
 
         /* Write the Environment Block */
-        Status = ZwWriteVirtualMemory(ProcessHandle,
+        Status = NtWriteVirtualMemory(ProcessHandle,
                                       ProcessParameters->Environment,
                                       lpEnvironment,
                                       EnviroSize,
@@ -1656,7 +1656,7 @@ GetStartupInfoA(IN LPSTARTUPINFOA lpStartupInfo)
                         /* Someone beat us to it, use their data instead */
                         StartupInfo = BaseAnsiStartupInfo;
                         Status = STATUS_SUCCESS;
-                        
+
                         /* We're going to free our own stuff, but not raise */
                         RtlFreeAnsiString(&TitleString);
                     }
@@ -2625,7 +2625,7 @@ CreateProcessInternalW(HANDLE hToken,
         while (NULL != (ScanString = wcschr(ScanString, L'^')))
         {
             ScanString++;
-            if (*ScanString == L'\"' || *ScanString == L'^' || *ScanString == L'\"')
+            if (*ScanString == L'\"' || *ScanString == L'^' || *ScanString == L'\\')
             {
                 Escape = TRUE;
                 break;
@@ -2947,7 +2947,7 @@ GetAppName:
     /* FIXME: Allow CREATE_SEPARATE only for WOW Apps, once we have that. */
 
     /* Get some information about the executable */
-    Status = ZwQuerySection(hSection,
+    Status = NtQuerySection(hSection,
                             SectionImageInformation,
                             &SectionImageInfo,
                             sizeof(SectionImageInfo),
@@ -2976,7 +2976,11 @@ GetAppName:
         IMAGE_SUBSYSTEM_WINDOWS_CUI != SectionImageInfo.SubSystemType)
     {
         DPRINT1("Invalid subsystem %d\n", SectionImageInfo.SubSystemType);
-        SetLastError(ERROR_BAD_EXE_FORMAT);
+        /*
+         * Despite the name of the error code suggests, it corresponds to the
+         * well-known "The %1 application cannot be run in Win32 mode" message.
+         */
+        SetLastError(ERROR_CHILD_NOT_COMPLETE);
         goto Cleanup;
     }
 
@@ -3016,7 +3020,8 @@ GetAppName:
         /* Check if only this process will be debugged */
         if (dwCreationFlags & DEBUG_ONLY_THIS_PROCESS)
         {
-            /* FIXME: Set process flag */
+            /* Set process flag */
+            hDebug = (HANDLE)((ULONG_PTR)hDebug | 0x1);
         }
     }
 
@@ -3268,7 +3273,7 @@ Cleanup:
     if (hSection) NtClose(hSection);
     if (hThread)
     {
-        /* We don't know any more details then this */
+        /* We don't know any more details than this */
         NtTerminateProcess(hProcess, STATUS_UNSUCCESSFUL);
         NtClose(hThread);
     }