From 092a09743c471f08fe9303a2b9ebee4176fbdf1a Mon Sep 17 00:00:00 2001 From: Ratin Gao Date: Fri, 20 Sep 2024 03:35:17 +0800 Subject: [PATCH] [3RDPARTY] Update KNSoft.NDK to 1.2.0-beta --- Source/Demo/Demo.vcxproj | 4 ++-- Source/Demo/packages.config | 2 +- Source/KNSoft.SlimDetours.vcxproj | 4 ++-- Source/SlimDetours/Memory.c | 2 +- Source/SlimDetours/SlimDetours.NDK.inl | 6 +++--- Source/SlimDetours/Thread.c | 4 ++-- Source/SlimDetours/Transaction.c | 12 ++++++------ Source/packages.config | 2 +- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Source/Demo/Demo.vcxproj b/Source/Demo/Demo.vcxproj index 7e86bd1..804894b 100644 --- a/Source/Demo/Demo.vcxproj +++ b/Source/Demo/Demo.vcxproj @@ -188,12 +188,12 @@ - + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + \ No newline at end of file diff --git a/Source/Demo/packages.config b/Source/Demo/packages.config index ac12d07..68d6cac 100644 --- a/Source/Demo/packages.config +++ b/Source/Demo/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/Source/KNSoft.SlimDetours.vcxproj b/Source/KNSoft.SlimDetours.vcxproj index 6b5cfa1..edc3006 100644 --- a/Source/KNSoft.SlimDetours.vcxproj +++ b/Source/KNSoft.SlimDetours.vcxproj @@ -220,12 +220,12 @@ - + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + \ No newline at end of file diff --git a/Source/SlimDetours/Memory.c b/Source/SlimDetours/Memory.c index 722749a..06a102d 100644 --- a/Source/SlimDetours/Memory.c +++ b/Source/SlimDetours/Memory.c @@ -76,7 +76,7 @@ detour_memory_init(VOID) NtdllLdrEntry = CONTAINING_RECORD(NtCurrentPeb()->Ldr->InInitializationOrderModuleList.Flink, LDR_DATA_TABLE_ENTRY, - InInitializationOrderModuleList); + InInitializationOrderLinks); s_ulSystemRegionLowUpperBound = (ULONG_PTR)NtdllLdrEntry->DllBase + NtdllLdrEntry->SizeOfImage - 1; s_ulSystemRegionLowLowerBound = s_ulSystemRegionLowUpperBound - _1GB + 1; if (s_ulSystemRegionLowLowerBound < SYSTEM_RESERVED_REGION_LOWEST) diff --git a/Source/SlimDetours/SlimDetours.NDK.inl b/Source/SlimDetours/SlimDetours.NDK.inl index fa5e14a..29a6c6f 100644 --- a/Source/SlimDetours/SlimDetours.NDK.inl +++ b/Source/SlimDetours/SlimDetours.NDK.inl @@ -74,9 +74,9 @@ #endif -#define NtGetCurrentProcessId() (NtCurrentTeb()->ClientId.UniqueProcess) -#define NtGetCurrentThreadId() (NtCurrentTeb()->ClientId.UniqueThread) +#define NtCurrentProcessId() ((HANDLE)ReadTeb(ClientId.UniqueProcess)) +#define NtCurrentThreadId() ((HANDLE)ReadTeb(ClientId.UniqueThread)) #define NtGetProcessHeap() (NtCurrentPeb()->ProcessHeap) -#define NtGetNtdllBase() (CONTAINING_RECORD(NtCurrentPeb()->Ldr->InInitializationOrderModuleList.Flink, LDR_DATA_TABLE_ENTRY, InInitializationOrderModuleList)->DllBase) +#define NtGetNtdllBase() (CONTAINING_RECORD(NtCurrentPeb()->Ldr->InInitializationOrderModuleList.Flink, LDR_DATA_TABLE_ENTRY, InInitializationOrderLinks)->DllBase) #endif diff --git a/Source/SlimDetours/Thread.c b/Source/SlimDetours/Thread.c index 767aaef..b134eb1 100644 --- a/Source/SlimDetours/Thread.c +++ b/Source/SlimDetours/Thread.c @@ -39,7 +39,7 @@ detour_thread_suspend( } /* Find current process and threads */ - CurrentPID = NtGetCurrentProcessId(); + CurrentPID = NtCurrentProcessId(); pCurrentSPI = pSPI; while (pCurrentSPI->UniqueProcessId != CurrentPID) { @@ -72,7 +72,7 @@ detour_thread_suspend( /* Suspend threads */ SuspendedCount = 0; - CurrentTID = NtGetCurrentThreadId(); + CurrentTID = NtCurrentThreadId(); for (i = 0; i < pCurrentSPI->NumberOfThreads; i++) { if (pSTI[i].ClientId.UniqueThread == CurrentTID || diff --git a/Source/SlimDetours/Transaction.c b/Source/SlimDetours/Transaction.c index 976687b..43552ff 100644 --- a/Source/SlimDetours/Transaction.c +++ b/Source/SlimDetours/Transaction.c @@ -58,7 +58,7 @@ SlimDetoursTransactionBegin(VOID) NTSTATUS Status; // Make sure only one thread can start a transaction. - if (_InterlockedCompareExchangePointer(&s_nPendingThreadId, NtGetCurrentThreadId(), 0) != 0) + if (_InterlockedCompareExchangePointer(&s_nPendingThreadId, NtCurrentThreadId(), 0) != 0) { return HRESULT_FROM_NT(STATUS_TRANSACTIONAL_CONFLICT); } @@ -99,7 +99,7 @@ SlimDetoursTransactionAbort(VOID) SIZE_T sMem; DWORD dwOld; - if (s_nPendingThreadId != NtGetCurrentThreadId()) + if (s_nPendingThreadId != NtCurrentThreadId()) { return HRESULT_FROM_NT(STATUS_TRANSACTIONAL_CONFLICT); } @@ -152,7 +152,7 @@ SlimDetoursTransactionCommit(VOID) BOOL freed = FALSE; ULONG i; - if (s_nPendingThreadId != NtGetCurrentThreadId()) + if (s_nPendingThreadId != NtCurrentThreadId()) { return HRESULT_FROM_NT(STATUS_TRANSACTIONAL_CONFLICT); } @@ -281,7 +281,7 @@ SlimDetoursAttach( SIZE_T sMem; DWORD dwOld; - if (s_nPendingThreadId != NtGetCurrentThreadId()) + if (s_nPendingThreadId != NtCurrentThreadId()) { return HRESULT_FROM_NT(STATUS_TRANSACTIONAL_CONFLICT); } @@ -484,7 +484,7 @@ SlimDetoursDetach( SIZE_T sMem; DWORD dwOld; - if (s_nPendingThreadId != NtGetCurrentThreadId()) + if (s_nPendingThreadId != NtCurrentThreadId()) { return HRESULT_FROM_NT(STATUS_TRANSACTIONAL_CONFLICT); } @@ -622,7 +622,7 @@ detour_dll_notify_proc( while (pAttach != NULL) { /* Match Dll name */ - if (!RtlEqualUnicodeString(&pAttach->usDllName, NotificationData->Loaded.BaseDllName, FALSE)) + if (!RtlEqualUnicodeString(&pAttach->usDllName, (PUNICODE_STRING)NotificationData->Loaded.BaseDllName, FALSE)) { pPrevAttach = pAttach; pAttach = pAttach->pNext; diff --git a/Source/packages.config b/Source/packages.config index ac12d07..68d6cac 100644 --- a/Source/packages.config +++ b/Source/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file