August 7, 2017
There are some common scenarios that benefit from the ability to hook operations. The canonical example is hooking Windows API functions for debugging purposes, or for malware detection. In this scenario, some DLL is injected into a target process and then hooks relevant functions. There are several ways to do that, but that is not the focus of this post; the interested reader can search the web for more information.
In the Component Object Model (COM) world, things are not so easy. Since COM is object based, it's not generally possible to get the address of a COM interface method,...
One of the nice features of C++ 11 is scoped enums ("enum class"). This solves a few issues with the classic C++ enums:
Scoped enums don't "leak" into the enclosing scope as classic C++ enums do.
Scoped enums don't automatically convert to integers, helping with type safety.
Scoped enums can be declared with the size of the underlying integer.
However, there is one feature that I believe was overlooked, or at least deemed unimportant to get into the standard: the automatic support for bitwise operations.
For example, suppose I'm writing a class called Process that wraps a Windows process handle and provides convenient access...