Proposal: Introduce DetourUpdateAllOtherThreads#233
Proposal: Introduce DetourUpdateAllOtherThreads#233adams85 wants to merge 1 commit intomicrosoft:masterfrom
Conversation
src/detours.cpp
Outdated
| HANDLE hThread; | ||
| BOOL fCloseThreadHandleOnDestroy; | ||
|
|
||
| DetourThread() { |
| { | ||
| DetourThread * pNext; | ||
| HANDLE hThread; | ||
| BOOL fCloseThreadHandleOnDestroy; |
There was a problem hiding this comment.
If we're giving this class ownership semantics, delete the copy constructor and assignment operator.
|
|
||
| LONG WINAPI DetourUpdateAllOtherThreads() | ||
| { | ||
| _NtGetNextThread NtGetNextThread = (_NtGetNextThread)GetProcAddress(GetModuleHandle(TEXT("ntdll.dll")), "NtGetNextThread"); |
There was a problem hiding this comment.
Try avoiding undocumented APIs if possible: Windows 8.1 and up have PssCaptureSnapshot that you can dynamically query for. Using NtGetNextThread should be fine on older platforms.
| return NO_ERROR; | ||
| } | ||
|
|
||
| if (currentThreadId != GetThreadId(hThread)) { |
There was a problem hiding this comment.
GetThreadId was introduced in Vista but Detours supports XP. This won't compile. See #80.
b13666a to
4cfe39f
Compare
|
I've addressed the first two problems. The other two (regarding the Windows APIs used) would take more time than I can spare now... |
|
@adams85 I have already introduced the |
|
@sonyps5201314 My code is based on yours indeed. I just wanted to create a small and easy to follow PR which has a chance to be merged. Unfortunately I missed that this breaks XP compatibility. So I'm closing this PR in favor of yours. |
|
@adams85 |
Introduce a new public function which updates all threads apart from the current one in a single operation.
Microsoft Reviewers: Open in CodeFlow