Fixed the loading of the global flag.
Modified: trunk/reactos/lib/ntdll/ldr/startup.c

Modified: trunk/reactos/lib/ntdll/ldr/startup.c
--- trunk/reactos/lib/ntdll/ldr/startup.c	2005-08-11 19:44:36 UTC (rev 17296)
+++ trunk/reactos/lib/ntdll/ldr/startup.c	2005-08-11 19:46:39 UTC (rev 17297)
@@ -66,14 +66,35 @@
     NTSTATUS Status = STATUS_SUCCESS;
     ULONG Value = 0;
     UNICODE_STRING ValueString;
+    UNICODE_STRING ImageName;
+    UNICODE_STRING ImagePathName;
     WCHAR ValueBuffer[64];
     ULONG ValueSize;
 
     if (Peb->ProcessParameters &&
         Peb->ProcessParameters->ImagePathName.Length > 0)
       {
+        DPRINT("%wZ\n", &Peb->ProcessParameters->ImagePathName);
+
+        ImagePathName = Peb->ProcessParameters->ImagePathName;
+        ImageName.Buffer = ImagePathName.Buffer + ImagePathName.Length / sizeof(WCHAR);
+        ImageName.Length = 0;
+        while (ImagePathName.Buffer < ImageName.Buffer)
+        {
+            ImageName.Buffer--;
+            if (*ImageName.Buffer == L'\\')
+            {
+               ImageName.Buffer++;
+               break;
+            }
+        }
+        ImageName.Length = ImagePathName.Length - (ImageName.Buffer - ImagePathName.Buffer) * sizeof(WCHAR);
+        ImageName.MaximumLength = ImageName.Length + ImagePathName.MaximumLength - ImagePathName.Length;
+
+        DPRINT("%wZ\n", &ImageName);
+
         /* global flag */
-        Status = LdrQueryImageFileExecutionOptions (&Peb->ProcessParameters->ImagePathName,
+        Status = LdrQueryImageFileExecutionOptions (&ImageName,
 				                    L"GlobalFlag",
 				                    REG_SZ,
 						    (PVOID)ValueBuffer,
@@ -81,12 +102,15 @@
 						    &ValueSize);
         if (NT_SUCCESS(Status))
           {
-            ValueString.Buffer = ValueBuffer + 1;
-	    ValueString.Length = ValueSize - 2 * sizeof(WCHAR);
+            ValueString.Buffer = ValueBuffer;
+	    ValueString.Length = ValueSize - sizeof(WCHAR);
 	    ValueString.MaximumLength = sizeof(ValueBuffer);
-	    RtlUnicodeStringToInteger(&ValueString, 16, &Value);
-            Peb->NtGlobalFlag |= Value;
-	    DPRINT("GlobalFlag: Key='%S', Value=%08x\n", ValueBuffer, Value);
+	    Status = RtlUnicodeStringToInteger(&ValueString, 16, &Value);
+            if (NT_SUCCESS(Status))
+              {
+                Peb->NtGlobalFlag |= Value;
+	        DPRINT("GlobalFlag: Key='%S', Value=%08x\n", ValueBuffer, Value);
+              }
 	  }
         /*
 	 * FIXME: