[NTOS:MM] Fix MmGetFileNameForAddress() callers. (#1723)
authorSerge Gautherie <32623169+SergeGautherie@users.noreply.github.com>
Sat, 13 Jul 2019 22:32:23 +0000 (00:32 +0200)
committerHermès BÉLUSCA - MAÏTO <hermes.belusca-maito@reactos.org>
Sat, 13 Jul 2019 22:32:23 +0000 (00:32 +0200)
MmGetFileNameForAddress() calls RtlCreateUnicodeString().
This also fixes a leak in MiQueryMemorySectionName().

ntoskrnl/dbgk/dbgkobj.c
ntoskrnl/mm/ARM3/section.c

index 3f03e9b..c8126fe 100644 (file)
@@ -558,7 +558,7 @@ DbgkpPostFakeModuleMessages(IN PEPROCESS Process,
                 if (!NT_SUCCESS(Status)) LoadDll->FileHandle = NULL;
 
                 /* Free the name now */
-                ExFreePool(ModuleName.Buffer);
+                RtlFreeUnicodeString(&ModuleName);
             }
 
             /* Send the fake module load message */
index fdda46d..e50aa51 100644 (file)
@@ -1897,7 +1897,6 @@ MiQueryMemorySectionName(IN HANDLE ProcessHandle,
 {
     PEPROCESS Process;
     NTSTATUS Status;
-    WCHAR ModuleFileNameBuffer[MAX_PATH] = {0};
     UNICODE_STRING ModuleFileName;
     PMEMORY_SECTION_NAME SectionName = NULL;
     KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
@@ -1915,7 +1914,6 @@ MiQueryMemorySectionName(IN HANDLE ProcessHandle,
         return Status;
     }
 
-    RtlInitEmptyUnicodeString(&ModuleFileName, ModuleFileNameBuffer, sizeof(ModuleFileNameBuffer));
     Status = MmGetFileNameForAddress(BaseAddress, &ModuleFileName);
 
     if (NT_SUCCESS(Status))
@@ -1947,6 +1945,8 @@ MiQueryMemorySectionName(IN HANDLE ProcessHandle,
             if (ReturnLength) *ReturnLength = ModuleFileName.Length;
 
         }
+
+        RtlFreeUnicodeString(&ModuleFileName);
     }
     ObDereferenceObject(Process);
     return Status;