Skip to content

Commit 3b78ca2

Browse files
committed
[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
1 parent ad547c9 commit 3b78ca2

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

ntoskrnl/mm/ARM3/section.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1923,11 +1923,12 @@ MiQueryMemorySectionName(IN HANDLE ProcessHandle,
19231923
{
19241924
_SEH2_TRY
19251925
{
1926-
RtlInitUnicodeString(&SectionName->SectionFileName, SectionName->NameBuffer);
1927-
SectionName->SectionFileName.MaximumLength = (USHORT)MemoryInformationLength;
1926+
RtlInitEmptyUnicodeString(&SectionName->SectionFileName,
1927+
(PWSTR)(SectionName + 1),
1928+
MemoryInformationLength - sizeof(MEMORY_SECTION_NAME));
19281929
RtlCopyUnicodeString(&SectionName->SectionFileName, &ModuleFileName);
19291930

1930-
if (ReturnLength) *ReturnLength = ModuleFileName.Length;
1931+
if (ReturnLength) *ReturnLength = ModuleFileName.Length + sizeof(MEMORY_SECTION_NAME);
19311932

19321933
}
19331934
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
@@ -1938,11 +1939,12 @@ MiQueryMemorySectionName(IN HANDLE ProcessHandle,
19381939
}
19391940
else
19401941
{
1941-
RtlInitUnicodeString(&SectionName->SectionFileName, SectionName->NameBuffer);
1942-
SectionName->SectionFileName.MaximumLength = (USHORT)MemoryInformationLength;
1942+
RtlInitEmptyUnicodeString(&SectionName->SectionFileName,
1943+
(PWSTR)(SectionName + 1),
1944+
MemoryInformationLength - sizeof(MEMORY_SECTION_NAME));
19431945
RtlCopyUnicodeString(&SectionName->SectionFileName, &ModuleFileName);
19441946

1945-
if (ReturnLength) *ReturnLength = ModuleFileName.Length;
1947+
if (ReturnLength) *ReturnLength = ModuleFileName.Length + sizeof(MEMORY_SECTION_NAME);
19461948

19471949
}
19481950

0 commit comments

Comments
 (0)