source: Daodan/MSYS2/mingw32/i686-w64-mingw32/include/kcom.h

Last change on this file was 1166, checked in by rossy, 3 years ago

Daodan: Replace MinGW build env with an up-to-date MSYS2 env

File size: 5.7 KB
Line 
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(_KCOM_)
22#define _KCOM_
23
24#include <ks.h>
25
26#if defined(__cplusplus)
27extern "C" {
28#endif
29
30#define STATIC_KoCreateObject 0x72CF721C, 0x525A, 0x11D1, 0x9A, 0xA1, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96
31DEFINE_GUIDSTRUCT("72CF721C-525A-11D1-9AA1-00A0C9223196", KoCreateObject);
32#define KOSTRING_CreateObject L"{72CF721C-525A-11D1-9AA1-00A0C9223196}"
33
34#ifndef CLSCTX_KERNEL_SERVER
35#define CLSCTX_KERNEL_SERVER 0x00000200
36#endif
37
38#if !defined(__cplusplus) || _MSC_VER < 1100
39
40#define STATIC_IID_IKoInitializeParentDeviceObject 0x21B36996, 0x8DE3, 0x11D1, 0x8A, 0xE0, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96
41DEFINE_GUIDEX(IID_IKoInitializeParentDeviceObject);
42
43#else
44
45interface __declspec(uuid("21B36996-8DE3-11D1-8AE0-00A0C9223196")) IKoInitializeParentDeviceObject;
46
47#endif
48
49#ifndef COMDDKMETHOD
50#ifdef _COMDDK_
51#define COMDDKMETHOD
52#else
53#define COMDDKMETHOD DECLSPEC_IMPORT
54#endif
55#endif
56
57#ifdef _COMDDK_
58#define COMDDKAPI
59#else
60#define COMDDKAPI DECLSPEC_IMPORT
61#endif
62
63typedef
64NTSTATUS
65(*KoCreateObjectHandler)(
66 REFCLSID ClassId,
67 IUnknown* UnkOuter,
68 REFIID InterfaceId,
69 PVOID* Interface);
70
71#undef INTERFACE
72#define INTERFACE INonDelegatedUnknown
73DECLARE_INTERFACE(INonDelegatedUnknown) {
74 STDMETHOD(NonDelegatedQueryInterface)(
75 THIS_
76 REFIID InterfaceId,
77 PVOID* Interface
78 ) PURE;
79
80 STDMETHOD_(ULONG,NonDelegatedAddRef)(
81 THIS
82 ) PURE;
83
84 STDMETHOD_(ULONG,NonDelegatedRelease)(
85 THIS
86 ) PURE;
87};
88
89#undef INTERFACE
90#define INTERFACE IIndirectedUnknown
91DECLARE_INTERFACE(IIndirectedUnknown) {
92 STDMETHOD(IndirectedQueryInterface)(
93 THIS_
94 REFIID InterfaceId,
95 PVOID* Interface
96 ) PURE;
97
98 STDMETHOD_(ULONG,IndirectedAddRef)(
99 THIS
100 ) PURE;
101
102 STDMETHOD_(ULONG,IndirectedRelease)(
103 THIS
104 ) PURE;
105};
106
107#undef INTERFACE
108#define INTERFACE IKoInitializeParentDeviceObject
109DECLARE_INTERFACE_(IKoInitializeParentDeviceObject, IUnknown) {
110 STDMETHOD(SetParentDeviceObject)(
111 THIS_
112 PDEVICE_OBJECT ParentDeviceObject
113 ) PURE;
114};
115
116#if defined(__cplusplus)
117
118class CBaseUnknown : public INonDelegatedUnknown, public IIndirectedUnknown {
119 protected:
120 LONG m_RefCount;
121 private:
122 BOOLEAN m_UsingClassId;
123 CLSID m_ClassId;
124 protected:
125 IUnknown* m_UnknownOuter;
126 public:
127 COMDDKMETHOD CBaseUnknown (REFCLSID ClassId, IUnknown* UnknownOuter = NULL);
128 COMDDKMETHOD CBaseUnknown(IUnknown* UnknownOuter = NULL);
129 COMDDKMETHOD virtual ~CBaseUnknown();
130 COMDDKMETHOD STDMETHODIMP_(ULONG) NonDelegatedAddRef();
131 COMDDKMETHOD STDMETHODIMP_(ULONG) NonDelegatedRelease();
132 COMDDKMETHOD STDMETHODIMP NonDelegatedQueryInterface(REFIID InterfaceId, PVOID* Interface);
133 COMDDKMETHOD STDMETHODIMP_(ULONG) IndirectedAddRef();
134 COMDDKMETHOD STDMETHODIMP_(ULONG) IndirectedRelease();
135 COMDDKMETHOD STDMETHODIMP IndirectedQueryInterface(REFIID InterfaceId, PVOID* Interface);
136};
137
138#if !defined(DEFINE_ABSTRACT_UNKNOWN)
139#define DEFINE_ABSTRACT_UNKNOWN() \
140 STDMETHOD(QueryInterface)(THIS_ REFIID InterfaceId, PVOID* Interface) PURE; \
141 STDMETHOD_(ULONG,AddRef)(THIS) PURE; \
142 STDMETHOD_(ULONG,Release)(THIS) PURE;
143#endif
144
145#define DEFINE_STD_UNKNOWN() \
146 STDMETHODIMP NonDelegatedQueryInterface( REFIID InterfaceId, PVOID* Interface); \
147 STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); \
148 STDMETHODIMP_(ULONG) AddRef(); \
149 STDMETHODIMP_(ULONG) Release();
150
151#define IMPLEMENT_STD_UNKNOWN(Class) \
152 STDMETHODIMP Class::QueryInterface( REFIID InterfaceId, PVOID* Interface) { \
153 return m_UnknownOuter->QueryInterface(InterfaceId, Interface);\
154 } \
155 STDMETHODIMP_(ULONG) Class::AddRef() { \
156 return m_UnknownOuter->AddRef(); \
157 } \
158 STDMETHODIMP_(ULONG) Class::Release() { \
159 return m_UnknownOuter->Release(); \
160 }
161
162#else
163
164COMDDKAPI
165void
166NTAPI
167KoRelease(
168 REFCLSID ClassId);
169
170#endif /* !__cplusplus */
171
172COMDDKAPI
173NTSTATUS
174NTAPI
175KoCreateInstance(
176 REFCLSID ClassId,
177 IUnknown* UnkOuter,
178 ULONG ClsContext,
179 REFIID InterfaceId,
180 PVOID* Interface);
181
182COMDDKAPI
183NTSTATUS
184NTAPI
185KoDeviceInitialize(
186 PDEVICE_OBJECT DeviceObject);
187
188COMDDKAPI
189NTSTATUS
190NTAPI
191KoDriverInitialize(
192 PDRIVER_OBJECT DriverObject,
193 PUNICODE_STRING RegistryPathName,
194 KoCreateObjectHandler CreateObjectHandler);
195
196
197#if defined(__cplusplus)
198}
199#endif
200
201#ifdef __cplusplus
202
203#ifndef _NEW_DELETE_OPERATORS_
204#define _NEW_DELETE_OPERATORS_
205
206inline PVOID operator new(
207 size_t iSize,
208 POOL_TYPE poolType)
209{
210 PVOID result = ExAllocatePoolWithTag(poolType,iSize,'wNCK');
211 if (result) {
212 RtlZeroMemory(result,iSize);
213 }
214 return result;
215}
216
217inline PVOID operator new(
218 size_t iSize,
219 POOL_TYPE poolType,
220 ULONG tag)
221{
222 PVOID result = ExAllocatePoolWithTag(poolType,iSize,tag);
223 if (result) {
224 RtlZeroMemory(result,iSize);
225 }
226 return result;
227}
228
229inline void __cdecl operator delete(
230 PVOID pVoid)
231{
232 if (pVoid) ExFreePool(pVoid);
233}
234
235#endif /* _NEW_DELETE_OPERATORS_ */
236
237#if defined(_SYS_GUID_OPERATOR_EQ_)
238#define _GUID_OPERATORS_
239//#pragma message("WARNING: Using system operator==/!= for GUIDs")
240#endif
241
242#ifndef _GUID_OPERATORS_
243#define _GUID_OPERATORS_
244
245__inline WINBOOL operator==(const GUID& guidOne, const GUID& guidOther) {
246 return IsEqualGUIDAligned(guidOne,guidOther);
247}
248
249__inline WINBOOL operator!=(const GUID& guidOne, const GUID& guidOther) {
250 return !(guidOne == guidOther);
251}
252
253#endif /* _GUID_OPERATORS_ */
254
255#endif /* __cplusplus */
256
257#endif /* _KCOM_ */
Note: See TracBrowser for help on using the repository browser.