How to identify a stale handle?

Lets suppose you are keeping handles of all processes running in a system using OpenProcess, now it’s just normal that some processes may exit, but since you have a valid handle there is no way to tell whether the process is still running or whether it has exited. You cannot check for NULL since the […]
Continue reading…

 

Watching out for registry key changes using RegNotifyChangeKeyValue!

We can watch out for changes on a key in the registry using the function RegNotifyChangeKeyValue. Here is a demo on how to do this. 🙂 [sourcecode language=’cpp’]// Helper function void RegWatchOut( HANDLE& hEvent ) {    const DWORD dwEventFilter = REG_NOTIFY_CHANGE_NAME |                                REG_NOTIFY_CHANGE_ATTRIBUTES |                                REG_NOTIFY_CHANGE_LAST_SET |                                REG_NOTIFY_CHANGE_SECURITY;    RegNotifyChangeKeyValue( HKEY_LOCAL_MACHINE,                             […]
Continue reading…