Hmmm… IsBad*Ptr() functions are deprecated in Win32 API! Ok.. but what if you need it? Actually there is no reliable way to figure out if a pointer is valid or not. If you suffer such problem, it should be fixed at the caller side or the side where it prepared the pointer.
But.. what if you really need it even though you sufficiently considered that?
What if some external code gives you a bad pointer?
Here is a good blog post, “There is no point improving the implementation of a bad idea.”
There is a simple drop-in replacement and it’s.. reasonable.