开发者

prevent hook dll loading

Is there a way to way set process security permissions or some other way to disable Windows from loading global window hook dlls? I don't want to disable SetWindowsHookEx, I just want to disabl开发者_StackOverflowe the hook dll from loading in my process.


You might be able to disable all hooks by installing your own hook and then not calling CallNextHookEx() from your hook. To do this correctly you will want to make sure that your hook will be the first hook that's going to be called.

The order the hooks are being called doesn't seem to be documented but it's easy enough to check by trial and error. Just install several hooks from different processes and see which is called first. The most likely cases are

  • The first hook that's installed is the first being called. This is the easy option. Just make sure to install your hook as soon as possible.
  • The first hook called is the only installed last. This one is more tricky. You'll have to make sure at all times that your's is the last hook that was installed. a hackish way to do this is to create a thread that every second or so removes the hook and adds it again.

This solution is far from perfect and, considering that the order is not documented, it may conceivably change at some point in the future. it is also possible that the hook invocation order is completely random, in which case this solution will not do you much good.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜