@@ -23,6 +23,7 @@ detour_thread_suspend(
2323 HANDLE CurrentTID = (HANDLE )(ULONG_PTR )NtCurrentThreadId ();
2424 BOOL ClosePrevThread = FALSE;
2525 HANDLE ThreadHandle = NULL ;
26+
2627 while (TRUE)
2728 {
2829 HANDLE NextThreadHandle ;
@@ -44,21 +45,18 @@ detour_thread_suspend(
4445 ThreadHandle = NextThreadHandle ;
4546 ClosePrevThread = TRUE;
4647
48+ /* Skip the current thread */
4749 if (!CurrentThreadSkipped )
4850 {
4951 THREAD_BASIC_INFORMATION BasicInformation ;
50- if (!NT_SUCCESS (NtQueryInformationThread (
51- ThreadHandle ,
52- ThreadBasicInformation ,
53- & BasicInformation ,
54- sizeof (BasicInformation ),
55- NULL
56- )))
52+ if (!NT_SUCCESS (NtQueryInformationThread (ThreadHandle ,
53+ ThreadBasicInformation ,
54+ & BasicInformation ,
55+ sizeof (BasicInformation ),
56+ NULL )))
5757 {
5858 continue ;
5959 }
60-
61- /* Skip the current thread */
6260 if (BasicInformation .ClientId .UniqueThread == CurrentTID )
6361 {
6462 CurrentThreadSkipped = TRUE;
@@ -82,6 +80,10 @@ detour_thread_suspend(
8280 if (Buffer == s_Handles )
8381 {
8482 p = (PHANDLE )detour_memory_alloc (BufferCapacity * sizeof (HANDLE ));
83+ if (p )
84+ {
85+ RtlCopyMemory (p , Buffer , SuspendedCount * sizeof (HANDLE ));
86+ }
8587 } else
8688 {
8789 p = (PHANDLE )detour_memory_realloc (Buffer , BufferCapacity * sizeof (HANDLE ));
@@ -186,7 +188,7 @@ detour_thread_update(
186188 bUpdateContext = FALSE;
187189 for (o = PendingOperations ; o != NULL && !bUpdateContext ; o = o -> pNext )
188190 {
189- if (o -> fIsRemove )
191+ if (o -> dwOperation == DETOUR_OPERATION_REMOVE )
190192 {
191193 if (cxt .CONTEXT_PC >= (ULONG_PTR )o -> pTrampoline -> rbCode &&
192194 cxt .CONTEXT_PC < ((ULONG_PTR )o -> pTrampoline -> rbCode + RTL_FIELD_SIZE (DETOUR_TRAMPOLINE , rbCode )))
@@ -202,7 +204,7 @@ detour_thread_update(
202204 bUpdateContext = TRUE;
203205 }
204206#endif
205- } else if (o -> fIsAdd )
207+ } else if (o -> dwOperation == DETOUR_OPERATION_ADD )
206208 {
207209 if (cxt .CONTEXT_PC >= (ULONG_PTR )o -> pbTarget &&
208210 cxt .CONTEXT_PC < ((ULONG_PTR )o -> pbTarget + o -> pTrampoline -> cbRestore ))
0 commit comments