ReactOS  0.4.15-dev-3439-g2693a26
stdunk.cpp
Go to the documentation of this file.
1 /*
2  ReactOS Kernel-Mode COM
3  IUnknown implementations
4 
5  LICENSE
6  Please see COPYING in the top-level directory for license information.
7 
8  AUTHORS
9  Andrew Greenwood
10 */
11 
12 #include <stdunk.h>
13 
15 {
16  m_ref_count = 0;
17 
18  if ( outer_unknown )
19  m_outer_unknown = outer_unknown;
20  else
21  m_outer_unknown = PUNKNOWN(dynamic_cast<PNONDELEGATINGUNKNOWN>(this));
22 }
23 
24 CUnknown::~CUnknown()
25 {
26 }
27 
29 CUnknown::NonDelegatingAddRef()
30 {
32  return m_ref_count;
33 }
34 
36 CUnknown::NonDelegatingRelease()
37 {
38  if ( InterlockedDecrement(&m_ref_count) == 0 )
39  {
40  m_ref_count ++;
41  delete this;
42  return 0;
43  }
44 
45  return m_ref_count;
46 }
47 
49 CUnknown::NonDelegatingQueryInterface(
50  IN REFIID iid,
51  PVOID* ppVoid)
52 {
53  /* FIXME */
54  #if 0
55  if ( IsEqualGUID(iid, IID_IUnknown) ) /* TODO: Aligned? */
56  *ppVoid = PVOID(PUNKNOWN(this));
57  else
58  *ppVoid = NULL;
59  #endif
60 
61  if ( *ppVoid )
62  {
63  PUNKNOWN(*ppVoid)->AddRef();
64  return STATUS_SUCCESS;
65  }
66 
68 }
LONG m_ref_count
Definition: stdunk.h:119
#define IN
Definition: typedefs.h:39
#define STDMETHODIMP_(t)
Definition: basetyps.h:44
#define REFIID
Definition: guiddef.h:118
struct CUnknown CUnknown
Definition: stdunk.cpp:14
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
IUnknown * PUNKNOWN
Definition: com_apitest.h:45
LONG NTSTATUS
Definition: precomp.h:26
PUNKNOWN m_outer_unknown
Definition: stdunk.h:120
void * PVOID
Definition: retypes.h:9
const GUID IID_IUnknown
ULONG AddRef()
#define InterlockedDecrement
Definition: armddk.h:52
#define InterlockedIncrement
Definition: armddk.h:53
#define NULL
Definition: types.h:112
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
unsigned int ULONG
Definition: retypes.h:1
#define STATUS_SUCCESS
Definition: shellext.h:65