microsoft / Detours

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

Is it safe to detach/attach multiple times? #253

Open R3uan3 opened 1 year ago

R3uan3 commented 1 year ago

Upon consecutive calls to 'DetourDetach' and 'DetourAttach' there is any chance to cause any kind of crash or error, into the hooked process? or is it considerable safe?

I'm asking in a scenario where you detach with the intention to pause the hooks, and then reenable them when needed. or should i create any kind of if else in each API hooked?

if (!hooksEnabled) 
    return 'the original function'
sylveon commented 1 year ago

Consecutive attach and detach works for me

sonyps5201314 commented 1 year ago

https://github.com/microsoft/Detours/pull/144 is a workload for this issue.