Windows has some available pointer functions you can use:
IsBadWritePtr IsBadWritePtr function
IsBadReadPtr IsBadReadPtr function
which you can condense with your own macro:
Code:#define IsBadPtr(ptr,sz) (IsBadReadPtr((LPVOID)(ptr),(sz)) || IsBadWritePtr((LPVOID)(ptr),(sz)))