[NTOSKRNL]
authorStefan Ginsberg <stefanginsberg@gmail.com>
Wed, 22 Feb 2012 21:18:56 +0000 (21:18 +0000)
committerStefan Ginsberg <stefanginsberg@gmail.com>
Wed, 22 Feb 2012 21:18:56 +0000 (21:18 +0000)
Some misc fixes to make kernel compile warning-free with /W3. Also fix a bug that completely broke the ProcessWx86Information case for NtQueryInformationProcess by missing to reference/dereference and acquiring the specified process' EPROCESS.

svn path=/trunk/; revision=55815

reactos/ntoskrnl/io/iomgr/deviface.c
reactos/ntoskrnl/io/iomgr/volume.c
reactos/ntoskrnl/io/pnpmgr/pnpmgr.c
reactos/ntoskrnl/mm/balance.c
reactos/ntoskrnl/mm/i386/page.c
reactos/ntoskrnl/mm/mminit.c
reactos/ntoskrnl/ps/query.c

index 9b40aab..4d89012 100644 (file)
@@ -737,7 +737,9 @@ IoGetDeviceInterfaces(IN CONST GUID *InterfaceClassGuid,
             {
                 PWSTR NewBuffer;
                 ReturnBuffer.MaximumLength = (USHORT)max(ReturnBuffer.MaximumLength * 2,
-                                                 ReturnBuffer.Length + KeyName.Length + 2 * sizeof(WCHAR));
+                                                         (USHORT)(ReturnBuffer.Length +
+                                                         KeyName.Length +
+                                                         2 * sizeof(WCHAR)));
                 NewBuffer = ExAllocatePool(PagedPool, ReturnBuffer.MaximumLength);
                 if (!NewBuffer)
                 {
index d336385..460302b 100644 (file)
@@ -1409,8 +1409,8 @@ IoVolumeDeviceToDosName(IN PVOID VolumeDeviceObject,
     }
 
     /* Set output string */
-    DosName->Length = VolumePathPtr->MultiSzLength;
-    DosName->MaximumLength = VolumePathPtr->MultiSzLength + sizeof(UNICODE_NULL);
+    DosName->Length = (USHORT)VolumePathPtr->MultiSzLength;
+    DosName->MaximumLength = (USHORT)VolumePathPtr->MultiSzLength + sizeof(UNICODE_NULL);
     /* Our MOUNTMGR_VOLUME_PATHS will be used as output buffer */
     DosName->Buffer = (PWSTR)VolumePathPtr;
     /* Move name at the begin, RtlMoveMemory is OK with overlapping */
index a688cf5..52d04b0 100644 (file)
@@ -199,7 +199,7 @@ IopInstallCriticalDevice(PDEVICE_NODE DeviceNode)
 
     while (*IdBuffer)
     {
-        ULONG StringLength = (ULONG)wcslen(IdBuffer) + 1, Index;
+        USHORT StringLength = (USHORT)wcslen(IdBuffer) + 1, Index;
         
         IopFixupDeviceId(IdBuffer);
         
@@ -247,7 +247,7 @@ IopInstallCriticalDevice(PDEVICE_NODE DeviceNode)
                 ChildIdNameU.Buffer = IdBuffer;
                 ChildIdNameU.MaximumLength = ChildIdNameU.Length = (StringLength - 1) * sizeof(WCHAR);
                 RegKeyNameU.Buffer = BasicInfo->Name;
-                RegKeyNameU.MaximumLength = RegKeyNameU.Length = BasicInfo->NameLength;
+                RegKeyNameU.MaximumLength = RegKeyNameU.Length = (USHORT)BasicInfo->NameLength;
 
                 if (RtlEqualUnicodeString(&ChildIdNameU, &RegKeyNameU, TRUE))
                 {
index b134095..829b123 100644 (file)
@@ -138,7 +138,7 @@ ULONG
 NTAPI
 MiTrimMemoryConsumer(ULONG Consumer, ULONG InitialTarget)
 {
-    LONG Target = InitialTarget;
+    ULONG Target = InitialTarget;
     ULONG NrFreedPages = 0;
     NTSTATUS Status;
 
index 12ef77e..9660d77 100644 (file)
@@ -217,7 +217,7 @@ MiSynchronizeSystemPde(PMMPDE PointerPde)
     KeMemoryBarrierWithoutFence();
 
     /* Return, if we had success */
-    return (BOOLEAN)SystemPde.u.Hard.Valid;
+    return SystemPde.u.Hard.Valid != 0;
 }
 
 NTSTATUS
@@ -549,7 +549,7 @@ Mmi386MakeKernelPageTableGlobal(PVOID Address)
     {
         if(!MiSynchronizeSystemPde(PointerPde))
             return FALSE;
-        return PointerPte->u.Hard.Valid;
+        return (BOOLEAN)PointerPte->u.Hard.Valid;
     }
     return FALSE;
 }
index c0ff60f..d943384 100644 (file)
@@ -262,7 +262,7 @@ MiDbgDumpAddressSpace(VOID)
     DPRINT1("          0x%p - 0x%p\t%s\n",
             MmNonPagedPoolStart,
             (ULONG_PTR)MmNonPagedPoolStart + MmSizeOfNonPagedPoolInBytes,
-            "ARM³ Non Paged Pool");
+            "ARM3 Non Paged Pool");
     DPRINT1("          0x%p - 0x%p\t%s\n",
             MiSystemViewStart,
             (ULONG_PTR)MiSystemViewStart + MmSystemViewSize,
@@ -283,7 +283,7 @@ MiDbgDumpAddressSpace(VOID)
     DPRINT1("          0x%p - 0x%p\t%s\n",
             MmPagedPoolStart,
             (ULONG_PTR)MmPagedPoolStart + MmSizeOfPagedPoolInBytes,
-            "ARM³ Paged Pool");
+            "ARM3 Paged Pool");
     DPRINT1("          0x%p - 0x%p\t%s\n",
             MmNonPagedSystemStart, MmNonPagedPoolExpansionStart,
             "System PTE Space");
index 9d308b4..308e983 100644 (file)
@@ -855,7 +855,7 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
             /* Protect write in SEH */
             _SEH2_TRY
             {
-                /* Return the count of handles */
+                /* Return debug port's handle */
                 *(PHANDLE)ProcessInformation = DebugPort;
             }
             _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
@@ -887,7 +887,7 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
             /* Protect write in SEH */
             _SEH2_TRY
             {
-                /* Return the count of handles */
+                /* Return FALSE -- we don't support this */
                 *(PULONG)ProcessInformation = FALSE;
             }
             _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
@@ -908,8 +908,14 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
                 break;
             }
 
-            /* Indicate success */
-            Status = STATUS_SUCCESS;
+            /* Reference the process */
+            Status = ObReferenceObjectByHandle(ProcessHandle,
+                                               PROCESS_QUERY_INFORMATION,
+                                               PsProcessType,
+                                               PreviousMode,
+                                               (PVOID*)&Process,
+                                               NULL);
+            if (!NT_SUCCESS(Status)) break;
 
             /* Protect write in SEH */
             _SEH2_TRY
@@ -923,6 +929,9 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
                 Status = _SEH2_GetExceptionCode();
             }
             _SEH2_END;
+
+            /* Dereference the process */
+            ObDereferenceObject(Process);
             break;
 
         case ProcessWow64Information:
@@ -1067,8 +1076,11 @@ NtSetInformationProcess(IN HANDLE ProcessHandle,
     PVOID ExceptionPort;
     ULONG Break;
     KAFFINITY ValidAffinity, Affinity = 0;
-    ULONG DefaultHardErrorMode = 0, BasePriority = 0, MemoryPriority = 0;
-    ULONG DisableBoost = 0, DebugFlags = 0, EnableFixup = 0, Boost = 0;
+    KPRIORITY BasePriority = 0;
+    UCHAR MemoryPriority = 0;
+    BOOLEAN DisableBoost = 0;
+    ULONG DefaultHardErrorMode = 0;
+    ULONG DebugFlags = 0, EnableFixup = 0, Boost = 0;
     ULONG NoExecute = 0, VdmPower = 0;
     BOOLEAN HasPrivilege;
     PLIST_ENTRY Next;
@@ -1448,7 +1460,7 @@ NtSetInformationProcess(IN HANDLE ProcessHandle,
             /* Enter SEH for direct buffer read */
             _SEH2_TRY
             {
-                BasePriority = *(PULONG)ProcessInformation;
+                BasePriority = *(KPRIORITY*)ProcessInformation;
             }
             _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
             {
@@ -1674,7 +1686,7 @@ NtSetInformationProcess(IN HANDLE ProcessHandle,
             /* Enter SEH for direct buffer read */
             _SEH2_TRY
             {
-                DisableBoost = *(PULONG)ProcessInformation;
+                DisableBoost = *(PBOOLEAN)ProcessInformation;
             }
             _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
             {
@@ -1814,6 +1826,8 @@ NtSetInformationProcess(IN HANDLE ProcessHandle,
             /* Only supported on x86 */
 #if defined (_X86_)
             Ke386SetIOPL();
+#else
+            Status = STATUS_NOT_IMPLEMENTED;
 #endif
             /* Done */
             break;