Author: greatlrd
Date: Wed Dec 24 05:14:44 2008
New Revision: 38326
URL:
http://svn.reactos.org/svn/reactos?rev=38326&view=rev
Log:
Rewrote
DllGetClassObject
DXDiagCF_LockServer
DXDiagCF_CreateInstance
DXDiagCF_Release
DXDiagCF_AddRef
DXDiagCF_QueryInterface
to make them more winodws NT compatible and the struct match better againts windows. If u
type cast the COM interface pointer to _INT struct you will access the internal data, even
overwrite function pointers to own.
Modified:
branches/reactx/reactos/dll/directx/dxdiagn/container.c
branches/reactx/reactos/dll/directx/dxdiagn/dxdiag_main.c
branches/reactx/reactos/dll/directx/dxdiagn/dxdiag_private.h
branches/reactx/reactos/dll/directx/dxdiagn/provider.c
Modified: branches/reactx/reactos/dll/directx/dxdiagn/container.c
URL:
http://svn.reactos.org/svn/reactos/branches/reactx/reactos/dll/directx/dxdi…
==============================================================================
--- branches/reactx/reactos/dll/directx/dxdiagn/container.c [iso-8859-1] (original)
+++ branches/reactx/reactos/dll/directx/dxdiagn/container.c [iso-8859-1] Wed Dec 24
05:14:44 2008
@@ -48,7 +48,7 @@
TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1);
- DXDIAGN_LockModule();
+ //DXDIAGN_LockModule();
return refCount;
}
@@ -63,7 +63,7 @@
HeapFree(GetProcessHeap(), 0, This);
}
- DXDIAGN_UnlockModule();
+ //DXDIAGN_UnlockModule();
return refCount;
}
Modified: branches/reactx/reactos/dll/directx/dxdiagn/dxdiag_main.c
URL:
http://svn.reactos.org/svn/reactos/branches/reactx/reactos/dll/directx/dxdi…
==============================================================================
--- branches/reactx/reactos/dll/directx/dxdiagn/dxdiag_main.c [iso-8859-1] (original)
+++ branches/reactx/reactos/dll/directx/dxdiagn/dxdiag_main.c [iso-8859-1] Wed Dec 24
05:14:44 2008
@@ -23,68 +23,15 @@
#include "dxdiag_private.h"
#include "wine/debug.h"
+#define INITGUID
+
+DWORD g_cComponents;
+DWORD g_cServerLocks;
+
WINE_DEFAULT_DEBUG_CHANNEL(dxdiag);
-LONG DXDIAGN_refCount = 0;
-
-/* At process attach */
-BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
-{
- TRACE("%p,%lx,%p\n", hInstDLL, fdwReason, lpvReserved);
- if (fdwReason == DLL_PROCESS_ATTACH) {
- DisableThreadLibraryCalls(hInstDLL);
- }
- return TRUE;
-}
-
-/*******************************************************************************
- * DXDiag ClassFactory
- */
-typedef struct {
- const IClassFactoryVtbl *lpVtbl;
- REFCLSID rclsid;
- HRESULT (*pfnCreateInstanceFactory)(LPCLASSFACTORY iface, LPUNKNOWN punkOuter, REFIID
riid, LPVOID *ppobj);
-} IClassFactoryImpl;
-
-static HRESULT WINAPI DXDiagCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID
*ppobj) {
- FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
-
- if (ppobj == NULL) return E_POINTER;
-
- return E_NOINTERFACE;
-}
-
-static ULONG WINAPI DXDiagCF_AddRef(LPCLASSFACTORY iface) {
- DXDIAGN_LockModule();
-
- return 2; /* non-heap based object */
-}
-
-static ULONG WINAPI DXDiagCF_Release(LPCLASSFACTORY iface) {
- DXDIAGN_UnlockModule();
-
- return 1; /* non-heap based object */
-}
-
-static HRESULT WINAPI DXDiagCF_CreateInstance(LPCLASSFACTORY iface,LPUNKNOWN
pOuter,REFIID riid,LPVOID *ppobj) {
- IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
- TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
-
- return This->pfnCreateInstanceFactory(iface, pOuter, riid, ppobj);
-}
-
-static HRESULT WINAPI DXDiagCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
- TRACE("(%d)\n", dolock);
-
- if (dolock)
- DXDIAGN_LockModule();
- else
- DXDIAGN_UnlockModule();
-
- return S_OK;
-}
-
-static const IClassFactoryVtbl DXDiagCF_Vtbl = {
+IClassFactoryVtbl DXDiagCF_Vtbl =
+{
DXDiagCF_QueryInterface,
DXDiagCF_AddRef,
DXDiagCF_Release,
@@ -92,17 +39,162 @@
DXDiagCF_LockServer
};
-static IClassFactoryImpl DXDiag_CFS[] = {
- { &DXDiagCF_Vtbl, &CLSID_DxDiagProvider, DXDiag_CreateDXDiagProvider },
- { NULL, NULL, NULL }
+IDxDiagProviderVtbl DxDiagProvider_Vtbl =
+{
+ IDxDiagProviderImpl_QueryInterface,
+ IDxDiagProviderImpl_AddRef,
+ IDxDiagProviderImpl_Release,
+ IDxDiagProviderImpl_Initialize,
+ IDxDiagProviderImpl_GetRootContainer
};
+
+IDxDiagProviderPrivateVtbl DxDiagProvider_PrivateVtbl =
+{
+ IDxDiagProviderImpl_QueryInterface,
+ IDxDiagProviderImpl_AddRef,
+ IDxDiagProviderImpl_Release,
+ IDxDiagProviderImpl_ExecMethod
+};
+
+/* At process attach */
+BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+ TRACE("%p,%lx,%p\n", hInstDLL, fdwReason, lpvReserved);
+ if (fdwReason == DLL_PROCESS_ATTACH) {
+ DisableThreadLibraryCalls(hInstDLL);
+ }
+ return TRUE;
+}
+
+/*******************************************************************************
+ * DXDiag ClassFactory
+ */
+
+HRESULT
+WINAPI
+DXDiagCF_QueryInterface(LPCLASSFACTORY iface, REFIID riid, LPVOID *ppobj)
+{
+ LPICLASSFACTORY_INT This = (LPICLASSFACTORY_INT) iface;
+ HRESULT retValue = S_OK;
+
+ if (ppobj == NULL)
+ {
+ retValue = E_INVALIDARG;
+ }
+ else
+ {
+ if ( ( IsEqualGUID( riid, &IID_IUnknown) ) ||
+ ( IsEqualGUID( riid, &IID_IClassFactory) ) )
+ {
+ *ppobj = This;
+ IClassFactory_AddRef( iface );
+ }
+ else
+ {
+ *ppobj = NULL;
+ retValue = E_NOINTERFACE;
+ }
+ }
+ return retValue;
+}
+
+ULONG
+WINAPI
+DXDiagCF_AddRef(LPCLASSFACTORY iface)
+{
+ LPICLASSFACTORY_INT This = (LPICLASSFACTORY_INT) iface;
+
+ return (ULONG) InterlockedIncrement( (LONG *) &This->RefCount );
+}
+
+ULONG
+WINAPI
+DXDiagCF_Release(LPCLASSFACTORY iface)
+{
+ LPICLASSFACTORY_INT This = (LPICLASSFACTORY_INT) iface;
+ ULONG RefCount = 0;
+
+ RefCount = InterlockedDecrement( (LONG *) &This->RefCount );
+
+ if (RefCount <= 0)
+ {
+ if (This->RefCount == 0)
+ {
+ HeapFree(GetProcessHeap(), 0, This);
+ }
+
+ RefCount = 0;
+ }
+
+ return RefCount;
+}
+
+
+HRESULT
+WINAPI
+DXDiagCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID
*ppobj)
+{
+ HRESULT retValue = S_OK;
+
+ if ( *ppobj != NULL )
+ {
+ *ppobj = NULL;
+ }
+
+ if ( pOuter == NULL )
+ {
+ if ( IsEqualGUID( riid, &CLSID_DxDiagProvider ) )
+ {
+
+ LPDXDIAGPROVIDER_INT myDxDiagProvider_int = (LPDXDIAGPROVIDER_INT)
HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(DXDIAGPROVIDER_INT));
+
+ if ( myDxDiagProvider_int == NULL)
+ {
+ *ppobj = NULL;
+ retValue = E_OUTOFMEMORY;
+ }
+ else
+ {
+ myDxDiagProvider_int->lpVbl = (LPVOID) &DxDiagProvider_Vtbl;
+ myDxDiagProvider_int->lpVbl_private = (LPVOID)
&DxDiagProvider_PrivateVtbl;
+ IDxDiagProviderImpl_AddRef( (LPDXDIAGPROVIDER) myDxDiagProvider_int );
+ InterlockedIncrement( (LONG *)&g_cComponents);
+ retValue = IDxDiagProvider_QueryInterface( (LPDXDIAGPROVIDER) myDxDiagProvider_int,
riid, ppobj );
+ IDxDiagProvider_Release( (LPDXDIAGPROVIDER) myDxDiagProvider_int );
+ *ppobj = (LPVOID) myDxDiagProvider_int;
+ }
+ }
+ else
+ {
+ retValue = CLASS_E_CLASSNOTAVAILABLE;
+ }
+ }
+
+ return retValue;
+}
+
+HRESULT
+WINAPI
+DXDiagCF_LockServer(LPCLASSFACTORY iface,BOOL dolock)
+{
+
+ if (dolock == TRUE)
+ {
+ InterlockedIncrement( (LONG *)&g_cServerLocks);
+ }
+
+ return S_OK;
+}
+
+
+
/***********************************************************************
* DllCanUnloadNow (DXDIAGN.@)
*/
HRESULT WINAPI DllCanUnloadNow(void)
{
- return DXDIAGN_refCount != 0 ? S_FALSE : S_OK;
+ return S_OK;
}
/***********************************************************************
@@ -110,18 +202,42 @@
*/
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
{
- int i = 0;
-
- TRACE("(%p,%p,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
- while (NULL != DXDiag_CFS[i].rclsid) {
- if (IsEqualGUID(rclsid, DXDiag_CFS[i].rclsid)) {
- DXDiagCF_AddRef((IClassFactory*) &DXDiag_CFS[i]);
- *ppv = &DXDiag_CFS[i];
- return S_OK;
- }
- ++i;
- }
-
- FIXME("(%p,%p,%p): no interface found.\n", debugstr_guid(rclsid),
debugstr_guid(riid), ppv);
- return CLASS_E_CLASSNOTAVAILABLE;
-}
+ HRESULT retValue = S_OK;
+ LPICLASSFACTORY_INT myIClassFactory_int;
+ LPCLASSFACTORY This;
+
+
+ if ( IsEqualGUID( rclsid, &CLSID_DxDiagProvider) )
+ {
+ myIClassFactory_int = (LPICLASSFACTORY_INT)
HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(ICLASSFACTORY_INT));
+
+ if (myIClassFactory_int != NULL)
+ {
+ myIClassFactory_int->lpVbl = (LPVOID) &DXDiagCF_Vtbl;
+
+ This = (LPCLASSFACTORY) myIClassFactory_int;
+
+ DXDiagCF_AddRef( This );
+
+ retValue = IClassFactory_QueryInterface( This, riid, ppv );
+
+ IClassFactory_AddRef( This );
+
+ *ppv = (LPVOID) This;
+ }
+ else
+ {
+ retValue = E_OUTOFMEMORY;
+ *ppv = NULL;
+ }
+
+ }
+ else
+ {
+ retValue = CLASS_E_CLASSNOTAVAILABLE;
+ *ppv = NULL;
+ }
+
+ return retValue;
+
+}
Modified: branches/reactx/reactos/dll/directx/dxdiagn/dxdiag_private.h
URL:
http://svn.reactos.org/svn/reactos/branches/reactx/reactos/dll/directx/dxdi…
==============================================================================
--- branches/reactx/reactos/dll/directx/dxdiagn/dxdiag_private.h [iso-8859-1] (original)
+++ branches/reactx/reactos/dll/directx/dxdiagn/dxdiag_private.h [iso-8859-1] Wed Dec 24
05:14:44 2008
@@ -21,16 +21,27 @@
#ifndef __WINE_DXDIAG_PRIVATE_H
#define __WINE_DXDIAG_PRIVATE_H
-#include <stdarg.h>
+#define COBJMACROS
-#include "windef.h"
-#include "winbase.h"
-#include "wingdi.h"
-#include "winuser.h"
-#include "objbase.h"
-#include "oleauto.h"
+#include <windows.h>
+#if defined(_WIN32) && !defined(_NO_COM )
+#define COM_NO_WINDOWS_H
-#include "dxdiag.h"
+#include <objbase.h>
+#else
+#define IUnknown void
+#if !defined(NT_BUILD_ENVIRONMENT) && !defined(WINNT)
+ #define CO_E_NOTINITIALIZED 0x800401F0
+#endif
+#endif
+
+
+
+
+
+
+
+#include <dxdiag.h>
/* DXDiag Interfaces: */
typedef struct IDxDiagProviderImpl IDxDiagProviderImpl;
@@ -43,15 +54,33 @@
/*****************************************************************************
* IDxDiagProvider implementation structure
*/
-struct IDxDiagProviderImpl {
- /* IUnknown fields */
- const IDxDiagProviderVtbl *lpVtbl;
- LONG ref;
- /* IDxDiagProvider fields */
- BOOL init;
- DXDIAG_INIT_PARAMS params;
- IDxDiagContainer* pRootContainer;
-};
+
+typedef struct _DXDIAGPROVIDER_INT
+{
+ /*0x00 */ LPVOID lpVbl;
+ /*0x04 */ LPVOID lpVbl_private;
+ /*0x08 */ DWORD Unkonwn1;
+ /*0x0C */ DWORD Unkonwn2;
+ /*0x10 */ DWORD RefCount;
+ /*0x0C */ DWORD Unkonwn3;
+ /*0x20 */ CHAR Unkonwn4;
+ /*0x21 */ CHAR Unkonwn5;
+ /*0x22 */ CHAR Unkonwn6;
+ /*0x23 */ CHAR Unkonwn7;
+ /*0x24 */ CHAR Unkonwn8;
+ /*0x25 */ CHAR Unkonwn9;
+ /*0x26 */ CHAR Unkonwn10;
+ /*0x27 */ CHAR Unkonwn11;
+ /*0x28 */ CHAR Unkonwn12;
+ /*0x29 */ CHAR Unkonwn13;
+ /*0x2A */ CHAR Unkonwn14;
+ /*0x2C */ CHAR Unkonwn15;
+ /* wine */
+ /* IDxDiagProvider fields */
+ BOOL init;
+ DXDIAG_INIT_PARAMS params;
+ IDxDiagContainer* pRootContainer;
+} DXDIAGPROVIDER_INT, *LPDXDIAGPROVIDER_INT;
/* IUnknown: */
extern HRESULT WINAPI IDxDiagProviderImpl_QueryInterface(PDXDIAGPROVIDER iface, REFIID
riid, LPVOID *ppobj);
@@ -101,10 +130,6 @@
extern HRESULT WINAPI IDxDiagContainerImpl_AddProp(PDXDIAGCONTAINER iface, LPCWSTR
pwszPropName, VARIANT* pVarProp);
extern HRESULT WINAPI IDxDiagContainerImpl_AddChildContainer(PDXDIAGCONTAINER iface,
LPCWSTR pszContName, PDXDIAGCONTAINER pSubCont);
-/**
- * factories
- */
-extern HRESULT DXDiag_CreateDXDiagProvider(LPCLASSFACTORY iface, LPUNKNOWN punkOuter,
REFIID riid, LPVOID *ppobj);
/** internal factory */
extern HRESULT DXDiag_CreateDXDiagContainer(REFIID riid, LPVOID *ppobj);
@@ -113,8 +138,61 @@
/**********************************************************************
* Dll lifetime tracking declaration for dxdiagn.dll
*/
-extern LONG DXDIAGN_refCount;
-static inline void DXDIAGN_LockModule(void) { InterlockedIncrement( &DXDIAGN_refCount
); }
-static inline void DXDIAGN_UnlockModule(void) { InterlockedDecrement(
&DXDIAGN_refCount ); }
+
+
+
+
+/*****************************************************************************
+ * IClassFactoryImpl implementation structure
+ */
+
+
+HRESULT WINAPI DXDiagCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj);
+ULONG WINAPI DXDiagCF_AddRef(LPCLASSFACTORY iface);
+ULONG WINAPI DXDiagCF_Release(LPCLASSFACTORY iface);
+HRESULT WINAPI DXDiagCF_CreateInstance(LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID
riid,LPVOID *ppobj);
+HRESULT WINAPI DXDiagCF_LockServer(LPCLASSFACTORY iface,BOOL dolock);
+
+
+
+typedef struct _ICLASSFACTORY_INT
+{
+ LPVOID lpVbl;
+ DWORD RefCount;
+ LPVOID Unknown1;
+ LPVOID Unknown2;
+} ICLASSFACTORY_INT, *LPICLASSFACTORY_INT;
+
+
+
+ULONG WINAPI IDxDiagProviderImpl_ExecMethod(PDXDIAGPROVIDER iface);
+
+#if defined( _WIN32 ) && !defined( _NO_COM )
+ #undef INTERFACE
+ #define INTERFACE IDxDiagProviderPrivate
+
+ DECLARE_INTERFACE_( IDxDiagProviderPrivate, IUnknown )
+ {
+ STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE;
+ STDMETHOD_(ULONG,AddRef) (THIS) PURE;
+ STDMETHOD_(ULONG,Release) (THIS) PURE;
+ STDMETHOD_(ULONG,ExecMethod) (THIS) PURE;
+
+ };
+ #if !defined(__cplusplus) || defined(CINTERFACE)
+ #define IDxDiagProviderPrivate_QueryInterface(p, a, b)
(p)->lpVtbl->QueryInterface(p, a, b)
+ #define IDxDiagProviderPrivate_AddRef(p)
(p)->lpVtbl->AddRef(p)
+ #define IDxDiagProviderPrivate_Release(p)
(p)->lpVtbl->Release(p)
+ #define IDxDiagProviderPrivate_ExecMethod(p)
(p)->lpVtbl->ExecMethod(p)
+ #else
+ #define IDxDiagProviderPrivate_QueryInterface(p, a, b)
(p)->QueryInterface(a, b)
+ #define IDxDiagProviderPrivate_AddRef(p) (p)->AddRef()
+ #define IDxDiagProviderPrivate_Release(p)
(p)->Release()
+ #define IDxDiagProviderPrivate_ExecMethod(p) (p)->ExecMethod()
+ #endif
+#endif
+
+typedef struct IDxDiagProviderPrivateVtbl DXDIAGPROVIDERPRIVARECALLBACK;
+typedef DXDIAGPROVIDERPRIVARECALLBACK *LPDXDIAGPROVIDERPRIVARECALLBACK;
#endif
Modified: branches/reactx/reactos/dll/directx/dxdiagn/provider.c
URL:
http://svn.reactos.org/svn/reactos/branches/reactx/reactos/dll/directx/dxdi…
==============================================================================
--- branches/reactx/reactos/dll/directx/dxdiagn/provider.c [iso-8859-1] (original)
+++ branches/reactx/reactos/dll/directx/dxdiagn/provider.c [iso-8859-1] Wed Dec 24
05:14:44 2008
@@ -42,24 +42,29 @@
}
ULONG WINAPI IDxDiagProviderImpl_AddRef(PDXDIAGPROVIDER iface) {
- IDxDiagProviderImpl *This = (IDxDiagProviderImpl *)iface;
- TRACE("(%p) : AddRef from %ld\n", This, This->ref);
- return ++(This->ref);
+ LPDXDIAGPROVIDER_INT This = (LPDXDIAGPROVIDER_INT) iface;
+ TRACE("(%p) : AddRef from %ld\n", This, This->RefCount);
+ return ++(This->RefCount);
}
ULONG WINAPI IDxDiagProviderImpl_Release(PDXDIAGPROVIDER iface) {
- IDxDiagProviderImpl *This = (IDxDiagProviderImpl *)iface;
- ULONG ref = --This->ref;
- TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
+ LPDXDIAGPROVIDER_INT This = (LPDXDIAGPROVIDER_INT) iface;
+ ULONG ref = --This->RefCount;
+ TRACE("(%p) : ReleaseRef to %ld\n", This, This->RefCount);
if (ref == 0) {
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
+ULONG WINAPI IDxDiagProviderImpl_ExecMethod(PDXDIAGPROVIDER iface) {
+ return 0;
+}
+
+
/* IDxDiagProvider Interface follow: */
HRESULT WINAPI IDxDiagProviderImpl_Initialize(PDXDIAGPROVIDER iface, DXDIAG_INIT_PARAMS*
pParams) {
- IDxDiagProviderImpl *This = (IDxDiagProviderImpl *)iface;
+ LPDXDIAGPROVIDER_INT This = (LPDXDIAGPROVIDER_INT) iface;
TRACE("(%p,%p)\n", iface, pParams);
if (NULL == pParams) {
@@ -76,7 +81,7 @@
HRESULT WINAPI IDxDiagProviderImpl_GetRootContainer(PDXDIAGPROVIDER iface,
IDxDiagContainer** ppInstance) {
HRESULT hr = S_OK;
- IDxDiagProviderImpl *This = (IDxDiagProviderImpl *)iface;
+ LPDXDIAGPROVIDER_INT This = (LPDXDIAGPROVIDER_INT) iface;
TRACE("(%p,%p)\n", iface, ppInstance);
if (NULL == ppInstance) {
@@ -94,26 +99,5 @@
return IDxDiagContainerImpl_QueryInterface((PDXDIAGCONTAINER)This->pRootContainer,
&IID_IDxDiagContainer, (void**) ppInstance);
}
-IDxDiagProviderVtbl DxDiagProvider_Vtbl =
-{
- IDxDiagProviderImpl_QueryInterface,
- IDxDiagProviderImpl_AddRef,
- IDxDiagProviderImpl_Release,
- IDxDiagProviderImpl_Initialize,
- IDxDiagProviderImpl_GetRootContainer
-};
-HRESULT DXDiag_CreateDXDiagProvider(LPCLASSFACTORY iface, LPUNKNOWN punkOuter, REFIID
riid, LPVOID *ppobj) {
- IDxDiagProviderImpl* provider;
- TRACE("(%p, %s, %p)\n", punkOuter, debugstr_guid(riid), ppobj);
-
- provider = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDxDiagProviderImpl));
- if (NULL == provider) {
- *ppobj = NULL;
- return E_OUTOFMEMORY;
- }
- provider->lpVtbl = &DxDiagProvider_Vtbl;
- provider->ref = 0; /* will be inited with QueryInterface */
- return IDxDiagProviderImpl_QueryInterface ((PDXDIAGPROVIDER)provider, riid, ppobj);
-}