I'm reversing an old DirectDraw game that uses DirectX 7.
I have a LPDIRECTDRAWSURFACE7 g_lpDDSBack
and g_lpDDSBack->BltFast
is being called but this is how it is decompiled in HexRays:
(*(int (__stdcall **)(struct IDirectDrawSurface7Vtbl *, int, int, LPDIRECTDRAWSURFACE7, RECT *, MACRO_DDBLTFAST))((int (__stdcall **)(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD))g_lpDDSBack->QueryInterface + 7))(
g_lpDDSBack,
x,
y,
pgf2->lpDDSrcSurface,
&pgf2->rect,
DDBLTFAST_SRCCOLORKEY);
For reference, here is the interface:
DECLARE_INTERFACE_( IDirectDrawSurface7, IUnknown )
{
/*** IUnknown methods ***/
STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; // 0
STDMETHOD_(ULONG,AddRef) (THIS) PURE; // 1
STDMETHOD_(ULONG,Release) (THIS) PURE; // 2
/*** IDirectDrawSurface methods ***/
STDMETHOD(AddAttachedSurface)(THIS_ LPDIRECTDRAWSURFACE7) PURE; // 3
STDMETHOD(AddOverlayDirtyRect)(THIS_ LPRECT) PURE; // 4
STDMETHOD(Blt)(THIS_ LPRECT,LPDIRECTDRAWSURFACE7, LPRECT,DWORD, LPDDBLTFX) PURE; // 5
STDMETHOD(BltBatch)(THIS_ LPDDBLTBATCH, DWORD, DWORD ) PURE; // 6
STDMETHOD(BltFast)(THIS_ DWORD,DWORD,LPDIRECTDRAWSURFACE7, LPRECT,DWORD) PURE; // 7
// etc ...
So from the HexRays code g_lpDDSBack->QueryInterface + 7
, we can see it's calling g_lpDDSBack->BltFast
. But why doesn't HexRays directly call BltFast
?