我正在反转使用 DirectX 7 的旧 DirectDraw 游戏。
我有一个LPDIRECTDRAWSURFACE7 g_lpDDSBack
andg_lpDDSBack->BltFast
正在被调用,但这就是它在 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);
作为参考,这里是接口:
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 ...
因此,从 HexRays 代码中g_lpDDSBack->QueryInterface + 7
,我们可以看到它正在调用g_lpDDSBack->BltFast
. 但是HexRays为什么不直接调用BltFast
呢?