The problem is that currently, if the application requests a IDirectDrawSurface4 what it gets is a IDirectDrawSurface7. Which is (on the first look) not a issue, as the vtables are compatible (same functions with same signature at same offsets, except for IDirectDrawSurface7 having added some functions at the end), but on the second look, the IDirectDrawSurface7 vtable contains the pointer to the strict AddAttachedSurface, whereas the vtable for IDirectDraw4 must contain a pointer to a relaxed AddAttachedSurface. This we need two different vtables (You can query an IDirectDraw7 and an IDirectDraw4 surface on the same object, so a flag in the object does not do, probably[1]) to get the different behaviours. Two different vtables for the same object inherently is thunking.
Regards, Michael Karcher
[1] In fact, an API test is required. Strict or relaxed semantics might also depend on how the surface was created (from IDirectDraw4 or IDirectDraw7) instead of the interfaced used to add an attached surface. This would be strange IMO, as the idea about COM is that the interface describes semantics that work regardless how the object was created, but let's test that, nevertheless.
I wonder if there is an easy way to do an API abstraction of some sort... not with a flag perse but like you can in C++ with the different instanciations depending upon the parms passed. Then instead of thunking , which is inherently buggy and tends to be slow, you use the v7 structure and return it without the v7 specific items at the end. That way you store one table instead of 2. (again sorry if this is fuzzy I am working on no sleep here).