These are chat archives for EasyHook/EasyHook
Hi, in the documentation for the LocalHook Dispose method it says that a disposed hook will / may consume memory for the process life-time. In our scenario, we need to hook certain methods only for very short amounts of time. Up until now, we did this by always uninstalling (disposing) the hook after use and creating a new one on demany. However, now I'm thinking this might be an issue if hooks don't get disposed properly and may leak memory.
Is there a "correct" way to completely uninstall a hook in this scenario or do we need some sort of centralized hook management which actually keeps the hook alive and only disables it when we don't use it (i.e. using in inclusive ACL on a nonexistent thread id or something like that), which is most of the time?
In fact we are sandboxing things, or more precisely, we are being sandboxed. We're developing two separate plugins for the same host application which live in the same process but get loaded into different AppDomains by the host (something we have little to no control over). These two plugins will both need to hook the same native method and if we're keeping the hook alive for a long time and just using ACLs to disable it (as was suggested above), both addins will almost certainly be attempting to hold a hook to the method at the same time.
We could of course implement some synchronization via remoting between the AppDomains if that's required, but if EH supports two hooks to the same method in the same process we can keep our addins decoupled as they should be.