https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3b78ca210ef49c020e34321ba9206c83340f26c0

commit 3b78ca210ef49c020e34321ba9206c83340f26c0
Author:     Pierre Schweitzer <[email protected]>
AuthorDate: Sun Sep 29 14:16:44 2019 +0200
Commit:     Pierre Schweitzer <[email protected]>
CommitDate: Sun Sep 29 14:16:44 2019 +0200

    [NTOSKRNL] Simplify buffer definition in MiQueryMemorySectionName().
    Also take into account the UNICODE_STRING structure while computing whole 
size
    This is based on Thomas' patch.
    
    CORE-12043
---
 ntoskrnl/mm/ARM3/section.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/ntoskrnl/mm/ARM3/section.c b/ntoskrnl/mm/ARM3/section.c
index e50aa518e5d..6bc1a6ef8db 100644
--- a/ntoskrnl/mm/ARM3/section.c
+++ b/ntoskrnl/mm/ARM3/section.c
@@ -1923,11 +1923,12 @@ MiQueryMemorySectionName(IN HANDLE ProcessHandle,
         {
             _SEH2_TRY
             {
-                RtlInitUnicodeString(&SectionName->SectionFileName, 
SectionName->NameBuffer);
-                SectionName->SectionFileName.MaximumLength = 
(USHORT)MemoryInformationLength;
+                RtlInitEmptyUnicodeString(&SectionName->SectionFileName,
+                                          (PWSTR)(SectionName + 1),
+                                          MemoryInformationLength - 
sizeof(MEMORY_SECTION_NAME));
                 RtlCopyUnicodeString(&SectionName->SectionFileName, 
&ModuleFileName);
 
-                if (ReturnLength) *ReturnLength = ModuleFileName.Length;
+                if (ReturnLength) *ReturnLength = ModuleFileName.Length + 
sizeof(MEMORY_SECTION_NAME);
 
             }
             _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
@@ -1938,11 +1939,12 @@ MiQueryMemorySectionName(IN HANDLE ProcessHandle,
         }
         else
         {
-            RtlInitUnicodeString(&SectionName->SectionFileName, 
SectionName->NameBuffer);
-            SectionName->SectionFileName.MaximumLength = 
(USHORT)MemoryInformationLength;
+            RtlInitEmptyUnicodeString(&SectionName->SectionFileName,
+                                      (PWSTR)(SectionName + 1),
+                                      MemoryInformationLength - 
sizeof(MEMORY_SECTION_NAME));
             RtlCopyUnicodeString(&SectionName->SectionFileName, 
&ModuleFileName);
 
-            if (ReturnLength) *ReturnLength = ModuleFileName.Length;
+            if (ReturnLength) *ReturnLength = ModuleFileName.Length + 
sizeof(MEMORY_SECTION_NAME);
 
         }
 

Reply via email to