@@ -23,6 +23,7 @@ detour_thread_suspend(
23
23
HANDLE CurrentTID = (HANDLE )(ULONG_PTR )NtCurrentThreadId ();
24
24
BOOL ClosePrevThread = FALSE;
25
25
HANDLE ThreadHandle = NULL ;
26
+
26
27
while (TRUE)
27
28
{
28
29
HANDLE NextThreadHandle ;
@@ -44,21 +45,18 @@ detour_thread_suspend(
44
45
ThreadHandle = NextThreadHandle ;
45
46
ClosePrevThread = TRUE;
46
47
48
+ /* Skip the current thread */
47
49
if (!CurrentThreadSkipped )
48
50
{
49
51
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 )))
57
57
{
58
58
continue ;
59
59
}
60
-
61
- /* Skip the current thread */
62
60
if (BasicInformation .ClientId .UniqueThread == CurrentTID )
63
61
{
64
62
CurrentThreadSkipped = TRUE;
@@ -82,6 +80,10 @@ detour_thread_suspend(
82
80
if (Buffer == s_Handles )
83
81
{
84
82
p = (PHANDLE )detour_memory_alloc (BufferCapacity * sizeof (HANDLE ));
83
+ if (p )
84
+ {
85
+ RtlCopyMemory (p , Buffer , SuspendedCount * sizeof (HANDLE ));
86
+ }
85
87
} else
86
88
{
87
89
p = (PHANDLE )detour_memory_realloc (Buffer , BufferCapacity * sizeof (HANDLE ));
@@ -186,7 +188,7 @@ detour_thread_update(
186
188
bUpdateContext = FALSE;
187
189
for (o = PendingOperations ; o != NULL && !bUpdateContext ; o = o -> pNext )
188
190
{
189
- if (o -> fIsRemove )
191
+ if (o -> dwOperation == DETOUR_OPERATION_REMOVE )
190
192
{
191
193
if (cxt .CONTEXT_PC >= (ULONG_PTR )o -> pTrampoline -> rbCode &&
192
194
cxt .CONTEXT_PC < ((ULONG_PTR )o -> pTrampoline -> rbCode + RTL_FIELD_SIZE (DETOUR_TRAMPOLINE , rbCode )))
@@ -202,7 +204,7 @@ detour_thread_update(
202
204
bUpdateContext = TRUE;
203
205
}
204
206
#endif
205
- } else if (o -> fIsAdd )
207
+ } else if (o -> dwOperation == DETOUR_OPERATION_ADD )
206
208
{
207
209
if (cxt .CONTEXT_PC >= (ULONG_PTR )o -> pbTarget &&
208
210
cxt .CONTEXT_PC < ((ULONG_PTR )o -> pbTarget + o -> pTrampoline -> cbRestore ))
0 commit comments