Need help in debugging a stack corruption
Robert Shearman
rob at codeweavers.com
Sat Jan 7 08:38:26 CST 2006
Stefan Dösinger wrote:
>IDirectDraw7Vtbl IDirectDraw7_Vtbl = {
> /* IUnknown */
> ...
> /* IDirectDraw7 */
> ...
> IDirectDrawImpl_SetCooperativeLevel,
> IDirectDrawImpl_SetDisplayMode,
> ...
>}
>
>IDirectDraw4Vtbl IDirectDraw4_Vtbl = {
> /* IUnknown */
> ...
> /* IDirectDraw4 */
> ...
> ( void * ) IDirectDrawImpl_SetCooperativeLevel,
> ( void * ) IDirectDrawImpl_SetDisplayMode,
> ...
>}
>
>
You can't do this. In order to access the object that the vtable is part
of you need to subtract an offset from the vtable pointer. If you use
the same function for two vtables then which offset do you use? The
answer: both or neither - it is impossible. Therefore, even though the
implementation of SetCooperativeLevel may be the same for the second
vtable, you still need to implement another function for it, even if it
just forwards to the true implementation.
You should never cast function pointers in vtables. The risks are just
too great.
--
Rob Shearman
More information about the wine-devel
mailing list