a couple bitwise nits in your first patch:
+#define HKCR_MASK 2 +#define IS_HKCR(hk) ((UINT_PTR)hk > 0 && ((UINT_PTR)hk & 3) == HKCR_MASK)
Typically a mask would define all the bits that could be set, and a flag would be the particular bit you want to test. Something like: #define SPECIAL_HKEY_MASK 3 #define HKCR_FLAG 2
Also, in the following expression: ((UINT_PTR)hk > 0 && ((UINT_PTR)hk & 3)
The second can never be true when the first is false, so you can just drop the first.
How? isn't 0x80000003 < 0 && 0x80000003 & 3? I just realized the UINT_PTR cast forces it to be >0 anyway.
These suggestions yield: #define IS_HKCR(hk) (((UINT_PTR)(hk) & SPECIAL_HKEY_MASK) == HKCR_FLAG)
Thanks.
--Juan