From f85759bcc9c58af2d2c020ca0e4b5f59097dcd99 Mon Sep 17 00:00:00 2001 From: Lionel Ulmer Date: Mon, 13 Jan 2003 18:30:47 +0000 Subject: [PATCH] Update the 'DIRECTDRAW7' flag according to the interface initialized. --- dlls/ddraw/ddraw/hal.c | 2 +- dlls/ddraw/ddraw/thunks.c | 46 ++++++++++++++++++++++++++------------- dlls/ddraw/main.c | 33 +++++++++++++++++++++------- 3 files changed, 57 insertions(+), 24 deletions(-) diff --git a/dlls/ddraw/ddraw/hal.c b/dlls/ddraw/ddraw/hal.c index 06042cc2f85..cf69316f9d2 100644 --- a/dlls/ddraw/ddraw/hal.c +++ b/dlls/ddraw/ddraw/hal.c @@ -335,7 +335,7 @@ HRESULT HAL_DirectDraw_Construct(IDirectDrawImpl *This, BOOL ex) { HRESULT hr; - TRACE("(%p)\n", This); + TRACE("(%p,%d)\n", This, ex); hr = User_DirectDraw_Construct(This, ex); if (FAILED(hr)) return hr; diff --git a/dlls/ddraw/ddraw/thunks.c b/dlls/ddraw/ddraw/thunks.c index 9bb7a8ca407..f3f3d2e2d76 100644 --- a/dlls/ddraw/ddraw/thunks.c +++ b/dlls/ddraw/ddraw/thunks.c @@ -698,32 +698,48 @@ IDirectDraw4Impl_GetVerticalBlankStatus(LPDIRECTDRAW4 This, LPBOOL lpbIsInVB) } static HRESULT WINAPI -IDirectDrawImpl_Initialize(LPDIRECTDRAW This, LPGUID pGUID) +IDirectDrawImpl_Initialize(LPDIRECTDRAW iface, LPGUID pGUID) { - return IDirectDraw7_Initialize(COM_INTERFACE_CAST(IDirectDrawImpl, - IDirectDraw, - IDirectDraw7, This), - pGUID); + ICOM_THIS_FROM(IDirectDrawImpl, IDirectDraw, iface); + HRESULT ret_value; + + ret_value = IDirectDraw7_Initialize(ICOM_INTERFACE(This, IDirectDraw7), pGUID); + + /* Overwrite the falsely set 'DIRECTDRAW7' flag */ + This->local.dwLocalFlags &= ~DDRAWILCL_DIRECTDRAW7; + + return ret_value; } static HRESULT WINAPI -IDirectDraw2Impl_Initialize(LPDIRECTDRAW2 This, LPGUID pGUID) +IDirectDraw2Impl_Initialize(LPDIRECTDRAW2 iface, LPGUID pGUID) { - return IDirectDraw7_Initialize(COM_INTERFACE_CAST(IDirectDrawImpl, - IDirectDraw2, - IDirectDraw7, This), - pGUID); + ICOM_THIS_FROM(IDirectDrawImpl, IDirectDraw2, iface); + HRESULT ret_value; + + ret_value = IDirectDraw7_Initialize(ICOM_INTERFACE(This, IDirectDraw7), pGUID); + + /* Overwrite the falsely set 'DIRECTDRAW7' flag */ + This->local.dwLocalFlags &= ~DDRAWILCL_DIRECTDRAW7; + + return ret_value; } static HRESULT WINAPI -IDirectDraw4Impl_Initialize(LPDIRECTDRAW4 This, LPGUID pGUID) +IDirectDraw4Impl_Initialize(LPDIRECTDRAW4 iface, LPGUID pGUID) { - return IDirectDraw7_Initialize(COM_INTERFACE_CAST(IDirectDrawImpl, - IDirectDraw4, - IDirectDraw7, This), - pGUID); + ICOM_THIS_FROM(IDirectDrawImpl, IDirectDraw4, iface); + HRESULT ret_value; + + ret_value = IDirectDraw7_Initialize(ICOM_INTERFACE(This, IDirectDraw7), pGUID); + + /* Overwrite the falsely set 'DIRECTDRAW7' flag */ + This->local.dwLocalFlags &= ~DDRAWILCL_DIRECTDRAW7; + + return ret_value; } + static HRESULT WINAPI IDirectDrawImpl_RestoreDisplayMode(LPDIRECTDRAW This) { diff --git a/dlls/ddraw/main.c b/dlls/ddraw/main.c index 7b98266f03e..5e41e3b8887 100644 --- a/dlls/ddraw/main.c +++ b/dlls/ddraw/main.c @@ -241,6 +241,8 @@ static HRESULT DDRAW_Create( LPDIRECTDRAW7 pDD; HRESULT hr; + TRACE("(%s,%p,%p,%d)\n", debugstr_guid(lpGUID), lplpDD, pUnkOuter, ex); + if (DDRAW_num_drivers == 0) { WARN("no DirectDraw drivers registered\n"); @@ -251,8 +253,6 @@ static HRESULT DDRAW_Create( || lpGUID == (LPGUID)DDCREATE_HARDWAREONLY) lpGUID = NULL; - TRACE("(%s,%p,%p)\n",debugstr_guid(lpGUID),lplpDD,pUnkOuter); - if (pUnkOuter != NULL) return DDERR_INVALIDPARAMS; /* CLASS_E_NOAGGREGATION? */ @@ -277,7 +277,8 @@ static HRESULT DDRAW_Create( HRESULT WINAPI DirectDrawCreate( LPGUID lpGUID, LPDIRECTDRAW* lplpDD, LPUNKNOWN pUnkOuter ) { - return DDRAW_Create(lpGUID,(LPVOID*)lplpDD,pUnkOuter,&IID_IDirectDraw,FALSE); + TRACE("(%s,%p,%p)\n", debugstr_guid(lpGUID), lplpDD, pUnkOuter); + return DDRAW_Create(lpGUID, (LPVOID*) lplpDD, pUnkOuter, &IID_IDirectDraw, FALSE); } /*********************************************************************** @@ -290,10 +291,12 @@ HRESULT WINAPI DirectDrawCreate( HRESULT WINAPI DirectDrawCreateEx( LPGUID lpGUID, LPVOID* lplpDD, REFIID iid, LPUNKNOWN pUnkOuter ) { + TRACE("(%s,%p,%s,%p)\n", debugstr_guid(lpGUID), lplpDD, debugstr_guid(iid), pUnkOuter); + if (!IsEqualGUID(iid, &IID_IDirectDraw7)) return DDERR_INVALIDPARAMS; - return DDRAW_Create(lpGUID, lplpDD, pUnkOuter, iid, TRUE); + return DDRAW_Create(lpGUID, lplpDD, pUnkOuter, iid, TRUE); } extern HRESULT Uninit_DirectDraw_Create(const GUID*, LPDIRECTDRAW7*, @@ -305,8 +308,17 @@ static HRESULT DDRAW_CreateDirectDraw(IUnknown* pUnkOuter, REFIID iid, { LPDIRECTDRAW7 pDD; HRESULT hr; + BOOL ex; - hr = Uninit_DirectDraw_Create(NULL, &pDD, pUnkOuter, TRUE); /* ex? */ + TRACE("(%p,%s,%p)\n", pUnkOuter, debugstr_guid(iid), ppObj); + + /* This is a mighty hack :-) */ + if (IsEqualGUID(iid, &IID_IDirectDraw7)) + ex = TRUE; + else + ex = FALSE; + + hr = Uninit_DirectDraw_Create(NULL, &pDD, pUnkOuter, ex); if (FAILED(hr)) return hr; hr = IDirectDraw7_QueryInterface(pDD, iid, ppObj); @@ -349,6 +361,8 @@ DDCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) { ICOM_THIS(IClassFactoryImpl,iface); + TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), ppobj); + if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IClassFactory)) { @@ -363,18 +377,21 @@ DDCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) static ULONG WINAPI DDCF_AddRef(LPCLASSFACTORY iface) { ICOM_THIS(IClassFactoryImpl,iface); + + TRACE("(%p)->() incrementing from %ld.\n", This, This->ref); + return ++(This->ref); } static ULONG WINAPI DDCF_Release(LPCLASSFACTORY iface) { ICOM_THIS(IClassFactoryImpl,iface); - ULONG ref = --This->ref; + TRACE("(%p)->() decrementing from %ld.\n", This, This->ref); - if (ref == 0) + if (--This->ref == 0) HeapFree(GetProcessHeap(), 0, This); - return ref; + return This->ref; }