On Mon, 19 Sep 2011, Nikolay Sivov wrote: [...]
static inline BOOL is_valid(HIMAGELIST himl) {
- return himl&& himl->lpVtbl ==&ImageListImpl_Vtbl;
- BOOL valid;
- __TRY
- {
valid = himl&& himl->lpVtbl ==&ImageListImpl_Vtbl;
- }
- __EXCEPT_PAGE_FAULT
- {
valid = FALSE;
- }
- __ENDTRY
- return valid; }
Maybe use IsBadReadPtr() with sizeof(void*) is better? You need only vtable pointer to be accessible.
I prefer this construct as using IsBadReadPtr() would introduce a race in is_valid(). Of course calling is_valid() is in itself racy anyway. So I don't mind switching over if that's preferred (the code would have fewer lines).