ReactOS 0.4.15-dev-7942-gd23573b
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)
29extern "C" {
30#endif
31
32#define STATIC_KoCreateObject 0x72CF721CL, 0x525A, 0x11D1, {0x9A, 0xA1, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}
33DEFINE_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
43DEFINE_GUIDEX(IID_IKoInitializeParentDeviceObject);
44
45#else
46
47interface __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
65typedef
68 IN REFCLSID ClassId,
69 IN IUnknown* UnkOuter OPTIONAL,
70 IN REFIID InterfaceId,
72
73#undef INTERFACE
74#define INTERFACE INonDelegatedUnknown
75DECLARE_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
93DECLARE_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
111DECLARE_INTERFACE_(IKoInitializeParentDeviceObject, IUnknown) {
112 STDMETHOD(SetParentDeviceObject)(
113 THIS_
114 IN PDEVICE_OBJECT ParentDeviceObject
115 ) PURE;
116};
117
118#if defined(__cplusplus)
119
120class 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
167void
168NTAPI
170 IN REFCLSID ClassId);
171
172#endif /* !__cplusplus */
173
176NTAPI
178 IN REFCLSID ClassId,
179 IN IUnknown* UnkOuter OPTIONAL,
180 IN ULONG ClsContext,
181 IN REFIID InterfaceId,
183
186NTAPI
189
192NTAPI
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
208inline 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
219inline 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
231inline void __cdecl operator delete(
232 PVOID pVoid)
233{
234 if (pVoid) ExFreePool(pVoid);
235}
236
237inline 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_ */
unsigned char BOOLEAN
bool _STLP_CALL operator!=(const allocator< _T1 > &, const allocator< _T2 > &) _STLP_NOTHROW
Definition: _alloc.h:384
#define __cdecl
Definition: accygwin.h:79
LONG NTSTATUS
Definition: precomp.h:26
#define DECLARE_INTERFACE_(i, b)
Definition: basetyps.h:78
#define PURE
Definition: basetyps.h:64
#define THIS_
Definition: basetyps.h:65
#define THIS
Definition: basetyps.h:66
#define STDMETHODIMP
Definition: basetyps.h:43
#define STDMETHOD_(t, m)
Definition: basetyps.h:63
#define STDMETHOD(m)
Definition: basetyps.h:62
#define DECLARE_INTERFACE(i)
Definition: basetyps.h:73
#define STDMETHODIMP_(t)
Definition: basetyps.h:44
#define NULL
Definition: types.h:112
#define NTSTATUS
Definition: precomp.h:21
#define DEFINE_GUIDEX(name)
Definition: dmksctrl.h:28
__declspec(noinline) int TestFunc(int
Definition: ehthrow.cxx:232
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint64EXT * result
Definition: glext.h:11304
Definition: msctf.idl:550
COMDDKAPI NTSTATUS NTAPI KoDeviceInitialize(IN PDEVICE_OBJECT DeviceObject)
Definition: api.c:1513
NTSTATUS(* KoCreateObjectHandler)(IN REFCLSID ClassId, IN IUnknown *UnkOuter OPTIONAL, IN REFIID InterfaceId, OUT PVOID *Interface)
Definition: kcom.h:67
COMDDKAPI void NTAPI KoRelease(IN REFCLSID ClassId)
Definition: api.c:1575
#define COMDDKAPI
Definition: kcom.h:62
COMDDKAPI NTSTATUS NTAPI KoDriverInitialize(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPathName, IN KoCreateObjectHandler CreateObjectHandler)
Definition: api.c:1530
#define COMDDKMETHOD
Definition: kcom.h:55
COMDDKAPI NTSTATUS NTAPI KoCreateInstance(IN REFCLSID ClassId, IN IUnknown *UnkOuter OPTIONAL, IN ULONG ClsContext, IN REFIID InterfaceId, OUT PVOID *Interface)
Definition: kcom.c:19
#define DEFINE_GUIDSTRUCT(guid, name)
Definition: ks.h:98
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
long LONG
Definition: pedump.c:60
#define REFIID
Definition: guiddef.h:118
#define REFCLSID
Definition: guiddef.h:117
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
Definition: ecma_167.h:138
bool operator==(const TKeyDef &t1, const TKeyDef &t2)
Definition: tkeydef.cpp:122
#define OPTIONAL
Definition: typedefs.h:41
INT POOL_TYPE
Definition: typedefs.h:78
#define NTAPI
Definition: typedefs.h:36
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE Interface
Definition: wdffdo.h:465
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:235