Fixed code formatting

This commit is contained in:
Boring
2023-04-17 10:52:39 +08:00
parent 4b493a7469
commit e829adb154
5 changed files with 112 additions and 27 deletions
+1 -3
View File
@@ -53,8 +53,6 @@ NTSTATUS NTAPI RtlInsertModuleBaseAddressIndexNode(
}
NTSTATUS NTAPI RtlRemoveModuleBaseAddressIndexNode(_In_ PLDR_DATA_TABLE_ENTRY DataTableEntry) {
static auto tree{ MmpGlobalDataPtr->MmpBaseAddressIndex->LdrpModuleBaseAddressIndex };
if (!tree->Root)return STATUS_UNSUCCESSFUL;
RtlRbRemoveNode(tree, &PLDR_DATA_TABLE_ENTRY_WIN8(DataTableEntry)->BaseAddressIndexNode);
RtlRbRemoveNode(MmpGlobalDataPtr->MmpBaseAddressIndex->LdrpModuleBaseAddressIndex, &PLDR_DATA_TABLE_ENTRY_WIN8(DataTableEntry)->BaseAddressIndexNode);
return STATUS_SUCCESS;
}
+2 -2
View File
@@ -6,7 +6,7 @@ static NTSTATUS RtlFreeDependencies(_In_ PLDR_DATA_TABLE_ENTRY_WIN10 LdrEntry) {
PLDR_DATA_TABLE_ENTRY_WIN10 ModuleEntry = nullptr;
_LDRP_CSLIST* head = (decltype(head))LdrEntry->DdagNode->Dependencies, * entry = head;
HANDLE heap = NtCurrentPeb()->ProcessHeap;
const static bool IsWin8 = RtlIsWindowsVersionInScope(6, 2, 0, 6, 3, -1);
BOOL IsWin8 = RtlIsWindowsVersionInScope(6, 2, 0, 6, 3, -1);
if (!LdrEntry->DdagNode->Dependencies)return STATUS_SUCCESS;
//find all dependencies and free
@@ -134,7 +134,7 @@ BOOL NTAPI RtlInitializeLdrDataTableEntry(
case WINDOWS_VERSION::win8:
case WINDOWS_VERSION::winBlue: {
auto entry = (PLDR_DATA_TABLE_ENTRY_WIN8)LdrEntry;
const static bool IsWin8 = RtlIsWindowsVersionInScope(6, 2, 0, 6, 3, -1);
BOOL IsWin8 = RtlIsWindowsVersionInScope(6, 2, 0, 6, 3, -1);
NtQuerySystemTime(&entry->LoadTime);
entry->OriginalBase = headers->OptionalHeader.ImageBase;
entry->BaseNameHashValue = LdrHashEntry(DllBaseName, false);
+13 -12
View File
@@ -197,20 +197,20 @@ DWORD NTAPI MmpUserThreadStart(LPVOID lpThreadParameter) {
goto __skip_tls;
}
//
// Check if we have already initialized
//
EnterCriticalSection(&MmpGlobalDataPtr->MmpTls->MmpTlspLock);
record = MmpFindTlspRecordLockHeld();
LeaveCriticalSection(&MmpGlobalDataPtr->MmpTls->MmpTlspLock);
if (!!record)goto __skip_tls;
//
// Allocate and replace ThreadLocalStoragePointer for new thread
//
EnterCriticalSection(&MmpGlobalDataPtr->MmpTls->MmpTlspLock);
//
// Check if we have already initialized
//
record = MmpFindTlspRecordLockHeld();
if (!!record) {
LeaveCriticalSection(&MmpGlobalDataPtr->MmpTls->MmpTlspLock);
goto __skip_tls;
}
record = PMMP_TLSP_RECORD(RtlAllocateHeap(RtlProcessHeap(), 0, sizeof(MMP_TLSP_RECORD)));
if (record) {
record->TlspLdrBlock = (PVOID*)NtCurrentTeb()->ThreadLocalStoragePointer;
@@ -276,9 +276,7 @@ DWORD NTAPI MmpUserThreadStart(LPVOID lpThreadParameter) {
return ERROR_NOT_ENOUGH_MEMORY;
}
EnterCriticalSection(&MmpGlobalDataPtr->MmpTls->MmpTlspLock);
++MmpGlobalDataPtr->MmpTls->MmpActiveThreadCount;
LeaveCriticalSection(&MmpGlobalDataPtr->MmpTls->MmpTlspLock);
InterlockedIncrement(&MmpGlobalDataPtr->MmpTls->MmpActiveThreadCount);
__skip_tls:
return Context.ThreadStartRoutine(Context.ThreadParameter);
@@ -369,6 +367,9 @@ VOID NTAPI HookLdrShutdownThread(VOID) {
}
RtlFreeHeap(RtlProcessHeap(), 0, TlspMmpBlock);
RtlFreeHeap(RtlProcessHeap(), 0, record);
RtlFreeHeap(RtlProcessHeap(), 0, record);
RtlFreeHeap(RtlProcessHeap(), 0, record);
}
else {
if (MmpGlobalDataPtr->MmpTls->MmpTlsList.Flink != &MmpGlobalDataPtr->MmpTls->MmpTlsList) {
+2
View File
@@ -11,7 +11,9 @@
//
// Determine whether to use MmpTls(1) or LdrpTls(0)
//
#ifndef MMPP_USE_TLS
#define MMPP_USE_TLS 1
#endif
// offsetof()
#include <cstddef>