Am 05.03.2019 um 23:16 schrieb Henri Verbeet hverbeet@gmail.com:
That's pretty ugly.
I know. But which part do you think could be improved in particular? Moving the extra checks out of impl_from_IDirectDrawClipper to keep it in line with the standard way we do COM objects?
Would it work to introduce a helper along the lines of the floowing?
static BOOL ddraw_clipper_is_valid(struct ddraw_clipper *clipper) { return !IsBadReadPtr(clipper, sizeof(*clipper)) && clipper->IDirectDrawClipper_iface.lpVtbl == &ddraw_clipper_vtbl; }
The vtable only matters for Release(), the rest of the methods don't care if you change the vtable, that's why I added the magic value.
If we only care about fixing Deus Ex for now I could set the vtable to NULL on release and add a try-catch around the clipper release in ddraw_surface_wined3d_object_destroyed. That would be less invasive, but we couldn't add the test because it would crash.