ReactOS  0.4.13-dev-563-g0561610
kcom.h
Go to the documentation of this file.
1 /*
2  * kcom.h
3  *
4  * This file is part of the ReactOS PSDK package.
5  *
6  * Contributors:
7  * Created by Andrew Greenwood.
8  *
9  * THIS SOFTWARE IS NOT COPYRIGHTED
10  *
11  * This source code is offered for use in the public domain. You may
12  * use, modify or distribute it freely.
13  *
14  * This code is distributed in the hope that it will be useful but
15  * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
16  * DISCLAIMED. This includes but is not limited to warranties of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18  *
19  */
20 
21 #if !defined(_KS_)
22 #error KS.H must be included before KCOM.H
23 #endif
24 
25 #if !defined(_KCOM_)
26 #define _KCOM_
27 
28 #if defined(__cplusplus)
29 extern "C" {
30 #endif
31 
32 #define STATIC_KoCreateObject 0x72CF721CL, 0x525A, 0x11D1, {0x9A, 0xA1, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}
33 DEFINE_GUIDSTRUCT("72CF721C-525A-11D1-9AA1-00A0C9223196", KoCreateObject);
34 #define KOSTRING_CreateObject L"{72CF721C-525A-11D1-9AA1-00A0C9223196}"
35 
36 #ifndef CLSCTX_KERNEL_SERVER
37 #define CLSCTX_KERNEL_SERVER 0x00000200
38 #endif
39 
40 #if !defined(__cplusplus) || _MSC_VER < 1100
41 
42 #define STATIC_IID_IKoInitializeParentDeviceObject 0x21B36996, 0x8DE3, 0x11D1, 0x8A, 0xE0, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96
43 DEFINE_GUIDEX(IID_IKoInitializeParentDeviceObject);
44 
45 #else
46 
47 interface __declspec(uuid("21B36996-8DE3-11D1-8AE0-00A0C9223196")) IKoInitializeParentDeviceObject;
48 
49 #endif
50 
51 #ifndef COMDDKMETHOD
52 #ifdef _COMDDK_
53 #define COMDDKMETHOD
54 #else
55 #define COMDDKMETHOD DECLSPEC_IMPORT
56 #endif
57 #endif
58 
59 #ifdef _COMDDK_
60 #define COMDDKAPI
61 #else
62 #define COMDDKAPI DECLSPEC_IMPORT
63 #endif
64 
65 typedef
68  IN REFCLSID ClassId,
69  IN IUnknown* UnkOuter OPTIONAL,
70  IN REFIID InterfaceId,
72 
73 #undef INTERFACE
74 #define INTERFACE INonDelegatedUnknown
75 DECLARE_INTERFACE(INonDelegatedUnknown) {
76  STDMETHOD(NonDelegatedQueryInterface)(
77  THIS_
78  IN REFIID InterfaceId,
80  ) PURE;
81 
82  STDMETHOD_(ULONG,NonDelegatedAddRef)(
83  THIS
84  ) PURE;
85 
86  STDMETHOD_(ULONG,NonDelegatedRelease)(
87  THIS
88  ) PURE;
89 };
90 
91 #undef INTERFACE
92 #define INTERFACE IIndirectedUnknown
93 DECLARE_INTERFACE(IIndirectedUnknown) {
94  STDMETHOD(IndirectedQueryInterface)(
95  THIS_
96  IN REFIID InterfaceId,
98  ) PURE;
99 
100  STDMETHOD_(ULONG,IndirectedAddRef)(
101  THIS
102  ) PURE;
103 
104  STDMETHOD_(ULONG,IndirectedRelease)(
105  THIS
106  ) PURE;
107 };
108 
109 #undef INTERFACE
110 #define INTERFACE IKoInitializeParentDeviceObject
111 DECLARE_INTERFACE_(IKoInitializeParentDeviceObject, IUnknown) {
112  STDMETHOD(SetParentDeviceObject)(
113  THIS_
114  IN PDEVICE_OBJECT ParentDeviceObject
115  ) PURE;
116 };
117 
118 #if defined(__cplusplus)
119 
120 class CBaseUnknown : public INonDelegatedUnknown, public IIndirectedUnknown {
121  protected:
122  LONG m_RefCount;
123  private:
124  BOOLEAN m_UsingClassId;
125  CLSID m_ClassId;
126  protected:
127  IUnknown* m_UnknownOuter;
128  public:
129  COMDDKMETHOD CBaseUnknown (IN REFCLSID ClassId, IN IUnknown* UnknownOuter OPTIONAL = NULL);
130  COMDDKMETHOD CBaseUnknown(IN IUnknown* UnknownOuter OPTIONAL = NULL);
131  COMDDKMETHOD virtual ~CBaseUnknown();
132  COMDDKMETHOD STDMETHODIMP_(ULONG) NonDelegatedAddRef();
133  COMDDKMETHOD STDMETHODIMP_(ULONG) NonDelegatedRelease();
134  COMDDKMETHOD STDMETHODIMP NonDelegatedQueryInterface(IN REFIID InterfaceId,OUT PVOID* Interface);
135  COMDDKMETHOD STDMETHODIMP_(ULONG) IndirectedAddRef();
136  COMDDKMETHOD STDMETHODIMP_(ULONG) IndirectedRelease();
137  COMDDKMETHOD STDMETHODIMP IndirectedQueryInterface(IN REFIID InterfaceId, OUT PVOID* Interface);
138 };
139 
140 #if !defined(DEFINE_ABSTRACT_UNKNOWN)
141 #define DEFINE_ABSTRACT_UNKNOWN() \
142  STDMETHOD(QueryInterface)(THIS_ REFIID InterfaceId, PVOID* Interface) PURE; \
143  STDMETHOD_(ULONG,AddRef)(THIS) PURE; \
144  STDMETHOD_(ULONG,Release)(THIS) PURE;
145 #endif
146 
147 #define DEFINE_STD_UNKNOWN() \
148  STDMETHODIMP NonDelegatedQueryInterface( REFIID InterfaceId, PVOID* Interface); \
149  STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); \
150  STDMETHODIMP_(ULONG) AddRef(); \
151  STDMETHODIMP_(ULONG) Release();
152 
153 #define IMPLEMENT_STD_UNKNOWN(Class) \
154  STDMETHODIMP Class::QueryInterface( REFIID InterfaceId, PVOID* Interface) { \
155  return m_UnknownOuter->QueryInterface(InterfaceId, Interface);\
156  } \
157  STDMETHODIMP_(ULONG) Class::AddRef() { \
158  return m_UnknownOuter->AddRef(); \
159  } \
160  STDMETHODIMP_(ULONG) Class::Release() { \
161  return m_UnknownOuter->Release(); \
162  }
163 
164 #else
165 
166 COMDDKAPI
167 void
168 NTAPI
169 KoRelease(
170  IN REFCLSID ClassId);
171 
172 #endif /* !__cplusplus */
173 
174 COMDDKAPI
175 NTSTATUS
176 NTAPI
178  IN REFCLSID ClassId,
179  IN IUnknown* UnkOuter OPTIONAL,
180  IN ULONG ClsContext,
181  IN REFIID InterfaceId,
182  OUT PVOID* Interface);
183 
184 COMDDKAPI
185 NTSTATUS
186 NTAPI
189 
190 COMDDKAPI
191 NTSTATUS
192 NTAPI
195  IN PUNICODE_STRING RegistryPathName,
196  IN KoCreateObjectHandler CreateObjectHandler);
197 
198 
199 #if defined(__cplusplus)
200 }
201 #endif
202 
203 #ifdef __cplusplus
204 
205 #ifndef _NEW_DELETE_OPERATORS_
206 #define _NEW_DELETE_OPERATORS_
207 
208 inline PVOID operator new(
209  size_t iSize,
210  POOL_TYPE poolType)
211 {
212  PVOID result = ExAllocatePoolWithTag(poolType,iSize,'wNCK');
213  if (result) {
214  RtlZeroMemory(result,iSize);
215  }
216  return result;
217 }
218 
219 inline PVOID operator new(
220  size_t iSize,
221  POOL_TYPE poolType,
222  ULONG tag)
223 {
224  PVOID result = ExAllocatePoolWithTag(poolType,iSize,tag);
225  if (result) {
226  RtlZeroMemory(result,iSize);
227  }
228  return result;
229 }
230 
231 inline void __cdecl operator delete(
232  PVOID pVoid)
233 {
234  if (pVoid) ExFreePool(pVoid);
235 }
236 
237 inline void __cdecl operator delete(
238  PVOID pVoid, UINT_PTR)
239 {
240  if (pVoid) ExFreePool(pVoid);
241 }
242 
243 #endif /* _NEW_DELETE_OPERATORS_ */
244 
245 #if defined(_SYS_GUID_OPERATOR_EQ_)
246 #define _GUID_OPERATORS_
247 //#pragma message("WARNING: Using system operator==/!= for GUIDs")
248 #endif
249 
250 #ifndef _GUID_OPERATORS_
251 #define _GUID_OPERATORS_
252 
253 __inline BOOL operator==(const GUID& guidOne, const GUID& guidOther) {
254  return IsEqualGUIDAligned(guidOne,guidOther);
255 }
256 
257 __inline BOOL operator!=(const GUID& guidOne, const GUID& guidOther) {
258  return !(guidOne == guidOther);
259 }
260 
261 #endif /* _GUID_OPERATORS_ */
262 
263 #endif /* __cplusplus */
264 
265 #endif /* _KCOM_ */
COMDDKAPI NTSTATUS NTAPI KoCreateInstance(IN REFCLSID ClassId, IN IUnknown *UnkOuter OPTIONAL, IN ULONG ClsContext, IN REFIID InterfaceId, OUT PVOID *Interface)
Definition: kcom.c:19
bool _STLP_CALL operator!=(const allocator< _T1 > &, const allocator< _T2 > &) _STLP_NOTHROW
Definition: _alloc.h:384
unsigned __int3264 UINT_PTR
Definition: activex.cpp:275
#define IN
Definition: typedefs.h:38
#define STDMETHODIMP_(t)
Definition: basetyps.h:44
#define REFIID
Definition: guiddef.h:113
DEFINE_GUIDEX(IID_IKoInitializeParentDeviceObject)
NTSTATUS(* KoCreateObjectHandler)(IN REFCLSID ClassId, IN IUnknown *UnkOuter OPTIONAL, IN REFIID InterfaceId, OUT PVOID *Interface)
Definition: kcom.h:67
#define THIS_
Definition: basetyps.h:65
#define __cdecl
Definition: accygwin.h:79
#define THIS
Definition: basetyps.h:66
#define REFCLSID
Definition: guiddef.h:112
#define COMDDKAPI
Definition: kcom.h:62
LONG NTSTATUS
Definition: precomp.h:26
COMDDKAPI NTSTATUS NTAPI KoDriverInitialize(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPathName, IN KoCreateObjectHandler CreateObjectHandler)
Definition: api.c:1530
Definition: ecma_167.h:138
struct _EXCEPTION_POINTERS *_CRTIMP __declspec(noreturn) void __cdecl terminate(void)
Definition: eh.h:27
#define STDMETHOD(m)
Definition: basetyps.h:62
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:233
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
#define STDMETHODIMP
Definition: basetyps.h:43
unsigned char BOOLEAN
DECLARE_INTERFACE(INonDelegatedUnknown)
Definition: kcom.h:75
smooth NULL
Definition: ftsmooth.c:416
#define COMDDKMETHOD
Definition: kcom.h:55
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
COMDDKAPI void NTAPI KoRelease(IN REFCLSID ClassId)
Definition: api.c:1575
IN PVOID IN PVOID IN USHORT IN USHORT IN PINTERFACE Interface
Definition: pci.h:359
INT POOL_TYPE
Definition: typedefs.h:76
COMDDKAPI NTSTATUS NTAPI KoDeviceInitialize(IN PDEVICE_OBJECT DeviceObject)
Definition: api.c:1513
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
bool operator==(const TKeyDef &t1, const TKeyDef &t2)
Definition: tkeydef.cpp:122
#define NTSTATUS
Definition: precomp.h:20
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define OPTIONAL
Definition: typedefs.h:40
#define PURE
Definition: basetyps.h:64
DECLARE_INTERFACE_(IKoInitializeParentDeviceObject, IUnknown)
Definition: kcom.h:111
#define OUT
Definition: typedefs.h:39
Definition: msctf.idl:510
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
DEFINE_GUIDSTRUCT("72CF721C-525A-11D1-9AA1-00A0C9223196", KoCreateObject)
#define STDMETHOD_(t, m)
Definition: basetyps.h:63
GLuint64EXT * result
Definition: glext.h:11304
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
char * tag
Definition: main.c:59