| 1 | /* | 
|---|
| 2 | * An implementation of IUnknown. | 
|---|
| 3 | * | 
|---|
| 4 | * hidenori@a2.ctktv.ne.jp | 
|---|
| 5 | */ | 
|---|
| 6 |  | 
|---|
| 7 | #ifndef WINE_DSHOW_IUNK_H | 
|---|
| 8 | #define WINE_DSHOW_IUNK_H | 
|---|
| 9 |  | 
|---|
| 10 | /* | 
|---|
| 11 | To avoid implementing IUnknown for all interfaces, | 
|---|
| 12 |  | 
|---|
| 13 | 1) To give a method to get rel-offset of IUnknown. | 
|---|
| 14 | 2) The IUnknown knows all IIDs and offsets of interfaces. | 
|---|
| 15 |  | 
|---|
| 16 | So each implementation must have following two members | 
|---|
| 17 | with the following order: | 
|---|
| 18 |  | 
|---|
| 19 | typedef struct IDispatchImpl | 
|---|
| 20 | { | 
|---|
| 21 | ICOM_VFIELD(IDispatch);     <-pointer of the interface. | 
|---|
| 22 | size_t      ofsIUnknown;    <-ofs<IDispatchImpl> - ofs<QUARTZ_IUnkImpl> | 
|---|
| 23 | }; | 
|---|
| 24 |  | 
|---|
| 25 | */ | 
|---|
| 26 |  | 
|---|
| 27 | /* for InterlockedExchangeAdd. */ | 
|---|
| 28 | #include <pshpack4.h> | 
|---|
| 29 |  | 
|---|
| 30 | typedef struct QUARTZ_IFEntry | 
|---|
| 31 | { | 
|---|
| 32 | const IID*      piid;           /* interface ID. */ | 
|---|
| 33 | size_t          ofsVTPtr;       /* offset from IUnknown. */ | 
|---|
| 34 | } QUARTZ_IFEntry; | 
|---|
| 35 |  | 
|---|
| 36 | typedef struct QUARTZ_IFDelegation | 
|---|
| 37 | { | 
|---|
| 38 | struct QUARTZ_IFDelegation*     pNext; | 
|---|
| 39 | HRESULT (*pOnQueryInterface)( | 
|---|
| 40 | IUnknown* punk, const IID* piid, void** ppobj ); | 
|---|
| 41 | } QUARTZ_IFDelegation; | 
|---|
| 42 |  | 
|---|
| 43 | typedef struct QUARTZ_IUnkImpl | 
|---|
| 44 | { | 
|---|
| 45 | /* pointer of IUnknown interface. */ | 
|---|
| 46 | ICOM_VFIELD(IUnknown); | 
|---|
| 47 |  | 
|---|
| 48 | /* array of supported IIDs and offsets. */ | 
|---|
| 49 | const QUARTZ_IFEntry*   pEntries; | 
|---|
| 50 | DWORD   dwEntries; | 
|---|
| 51 | /* list of delegation handlers. */ | 
|---|
| 52 | QUARTZ_IFDelegation*    pDelegationFirst; | 
|---|
| 53 | /* called on final release. */ | 
|---|
| 54 | void (*pOnFinalRelease)(IUnknown* punk); | 
|---|
| 55 |  | 
|---|
| 56 | /* IUnknown fields. */ | 
|---|
| 57 | LONG    ref; | 
|---|
| 58 | IUnknown*       punkControl; | 
|---|
| 59 | } QUARTZ_IUnkImpl; | 
|---|
| 60 |  | 
|---|
| 61 | #include <poppack.h> | 
|---|
| 62 |  | 
|---|
| 63 |  | 
|---|
| 64 | void QUARTZ_IUnkInit( QUARTZ_IUnkImpl* pImpl, IUnknown* punkOuter ); | 
|---|
| 65 | void QUARTZ_IUnkAddDelegation( | 
|---|
| 66 | QUARTZ_IUnkImpl* pImpl, QUARTZ_IFDelegation* pDelegation ); | 
|---|
| 67 |  | 
|---|
| 68 |  | 
|---|
| 69 | #endif  /* WINE_DSHOW_IUNK_H */ | 
|---|