microsoft / Detours

Detours is a software package for monitoring and instrumenting API calls on Windows. It is distributed in source code form.
MIT License
5.02k stars 981 forks source link

Misleading/non-effective usage of DetourUpdateThread in samples #151

Open ohuseyinoglu opened 3 years ago

ohuseyinoglu commented 3 years ago

Describe the bug

As mentioned in the discussion b/w @sylveon and @bgianfo, passing GetCurrentThread() to DetourUpdateThread() is practically a NO-OP, however, probably all the samples, and the Using Detours wiki does use the API that way currently!

Command-line test case

N/A

Expected behavior

This is non-effective, and worse, misleading, giving users a false sense of security in their Detours usage. A better handling of threads should be provided at the API level (or at least more detailed code added to samples).

I haven't reviewed the code, but @sonyps5201314 has a closed PR suggesting a new API entry point (DetourUpdateAllOtherThreads). Something along those lines may be useful probably??

Detours version

Latest on master as of this issue's creation date: d8b8144

Additional context

I'll log another issue/question about the stability of the RIP changing after this. Please evaluate the issues together.

bgianfo commented 3 years ago

Thanks for creating an issue to track these.

As mentioned, I believe @sonyps5201314's PR is probably the best fix for this kind of issue.