Skip to content

Commit b2e4ed4

Browse files
authored
Merge pull request #36 from bb107/Session_0_Initialize
#35 Fix initialization failure in session 0
2 parents 5fb7f59 + 131699f commit b2e4ed4

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

MemoryModule/Initialize.cpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -333,12 +333,21 @@ NTSTATUS MmpAllocateGlobalData() {
333333
SIZE_T ViewSize = 0;
334334
PTEB teb = NtCurrentTeb();
335335

336-
swprintf_s(
337-
buffer,
338-
L"\\Sessions\\%d\\BaseNamedObjects\\MMPP*%p",
339-
NtCurrentPeb()->SessionId,
340-
(PVOID)(~(ULONG_PTR)teb->ClientId.UniqueProcess ^ (ULONG_PTR)teb->ProcessEnvironmentBlock->ProcessHeap)
341-
);
336+
if (NtCurrentPeb()->SessionId == 0) {
337+
swprintf_s(
338+
buffer,
339+
L"\\BaseNamedObjects\\MMPP*%p",
340+
(PVOID)(~(ULONG_PTR)teb->ClientId.UniqueProcess ^ (ULONG_PTR)teb->ProcessEnvironmentBlock->ProcessHeap)
341+
);
342+
}
343+
else {
344+
swprintf_s(
345+
buffer,
346+
L"\\Sessions\\%d\\BaseNamedObjects\\MMPP*%p",
347+
NtCurrentPeb()->SessionId,
348+
(PVOID)(~(ULONG_PTR)teb->ClientId.UniqueProcess ^ (ULONG_PTR)teb->ProcessEnvironmentBlock->ProcessHeap)
349+
);
350+
}
342351

343352
RtlInitUnicodeString(&us, buffer);
344353
InitializeObjectAttributes(&oa, &us, 0, nullptr, nullptr);

0 commit comments

Comments
 (0)