-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: Introduce DetourUpdateAllOtherThreads #233
Proposal: Introduce DetourUpdateAllOtherThreads #233
Conversation
src/detours.cpp
Outdated
@@ -1524,6 +1524,24 @@ struct DetourThread | |||
{ | |||
DetourThread * pNext; | |||
HANDLE hThread; | |||
BOOL fCloseThreadHandleOnDestroy; | |||
|
|||
DetourThread() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allman braces
@@ -1524,6 +1524,24 @@ struct DetourThread | |||
{ | |||
DetourThread * pNext; | |||
HANDLE hThread; | |||
BOOL fCloseThreadHandleOnDestroy; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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