Skip to content

Commit dcf5f3c

Browse files
committed
Fix 32-bit compilation failure
1 parent a4bf943 commit dcf5f3c

4 files changed

Lines changed: 11 additions & 9 deletions

File tree

MemoryModule/BaseAddressIndex.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "stdafx.h"
22

3-
VOID RtlRbInsertNodeEx(
3+
VOID NTAPI RtlRbInsertNodeEx(
44
_In_ PRTL_RB_TREE Tree,
55
_In_ PRTL_BALANCED_NODE Parent,
66
_In_ BOOLEAN Right,
@@ -11,7 +11,7 @@ VOID RtlRbInsertNodeEx(
1111
return decltype(&RtlRbInsertNodeEx)(MmpGlobalDataPtr->MmpBaseAddressIndex->_RtlRbInsertNodeEx)(Tree, Parent, Right, Node);
1212
}
1313

14-
VOID RtlRbRemoveNode(
14+
VOID NTAPI RtlRbRemoveNode(
1515
_In_ PRTL_RB_TREE Tree,
1616
_In_ PRTL_BALANCED_NODE Node) {
1717
if (!MmpGlobalDataPtr->MmpBaseAddressIndex->_RtlRbRemoveNode)return;

MemoryModule/Initialize.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -291,19 +291,20 @@ VOID InitializeWindowsVersion() {
291291

292292
NTSTATUS MmpAllocateGlobalData() {
293293
NTSTATUS status;
294-
HANDLE hSection = nullptr;
295294
OBJECT_ATTRIBUTES oa;
296295
LARGE_INTEGER li;
296+
WCHAR buffer[128];
297+
HANDLE hSection = nullptr;
297298
UNICODE_STRING us{};
298299
PVOID BaseAddress = 0;
299300
SIZE_T ViewSize = 0;
300-
WCHAR buffer[128];
301+
PTEB teb = NtCurrentTeb();
301302

302303
swprintf_s(
303304
buffer,
304-
L"\\Sessions\\%d\\BaseNamedObjects\\MMPP*%08X",
305+
L"\\Sessions\\%d\\BaseNamedObjects\\MMPP*%p",
305306
NtCurrentPeb()->SessionId,
306-
(unsigned int)(ULONG_PTR)NtCurrentProcessId()
307+
(PVOID)(~(ULONG_PTR)teb->ClientId.UniqueProcess ^ (ULONG_PTR)teb->ProcessEnvironmentBlock->ProcessHeap)
307308
);
308309

309310
RtlInitUnicodeString(&us, buffer);

MemoryModule/MmpTls.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,9 @@ DWORD NTAPI MmpUserThreadStart(LPVOID lpThreadParameter) {
194194

195195
PTLS_ENTRY tls = CONTAINING_RECORD(entry, TLS_ENTRY, TlsEntryLinks);
196196
auto len = tls->TlsDirectory.EndAddressOfRawData - tls->TlsDirectory.StartAddressOfRawData;
197-
PVOID data = RtlAllocateHeap(RtlProcessHeap(), 0, len);
198-
if (!len) {
197+
PVOID data = len ? RtlAllocateHeap(RtlProcessHeap(), 0, len) : nullptr;
198+
if (!data) {
199+
RtlFreeHeap(RtlProcessHeap(), 0, data);
199200
success = false;
200201
break;
201202
}

MemoryModule/Utils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ SIZE_T NTAPI _RtlCompareMemory(
159159
const VOID* Source1,
160160
const VOID* Source2,
161161
SIZE_T Length) {
162-
return decltype(&_RtlCompareMemory)(RtlGetNtProcAddress("RtlCompareMemory"))(Source1, Source2, Length);
162+
return decltype(&_RtlCompareMemory)(GetProcAddress((HMODULE)MmpGlobalDataPtr->MmpBaseAddressIndex->NtdllLdrEntry->DllBase,"RtlCompareMemory"))(Source1, Source2, Length);
163163
}
164164
#define RtlCompareMemory _RtlCompareMemory
165165
#endif

0 commit comments

Comments
 (0)