Skip to content

Commit

Permalink
Merge pull request #36 from bb107/Session_0_Initialize
Browse files Browse the repository at this point in the history
#35 Fix initialization failure in session 0
  • Loading branch information
bb107 authored Oct 8, 2023
2 parents 5fb7f59 + 131699f commit b2e4ed4
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions MemoryModule/Initialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,12 +333,21 @@ NTSTATUS MmpAllocateGlobalData() {
SIZE_T ViewSize = 0;
PTEB teb = NtCurrentTeb();

swprintf_s(
buffer,
L"\\Sessions\\%d\\BaseNamedObjects\\MMPP*%p",
NtCurrentPeb()->SessionId,
(PVOID)(~(ULONG_PTR)teb->ClientId.UniqueProcess ^ (ULONG_PTR)teb->ProcessEnvironmentBlock->ProcessHeap)
);
if (NtCurrentPeb()->SessionId == 0) {
swprintf_s(
buffer,
L"\\BaseNamedObjects\\MMPP*%p",
(PVOID)(~(ULONG_PTR)teb->ClientId.UniqueProcess ^ (ULONG_PTR)teb->ProcessEnvironmentBlock->ProcessHeap)
);
}
else {
swprintf_s(
buffer,
L"\\Sessions\\%d\\BaseNamedObjects\\MMPP*%p",
NtCurrentPeb()->SessionId,
(PVOID)(~(ULONG_PTR)teb->ClientId.UniqueProcess ^ (ULONG_PTR)teb->ProcessEnvironmentBlock->ProcessHeap)
);
}

RtlInitUnicodeString(&us, buffer);
InitializeObjectAttributes(&oa, &us, 0, nullptr, nullptr);
Expand Down

0 comments on commit b2e4ed4

Please sign in to comment.