[dummy] Pass back the created PDO
[people/sha0/winvblock.git] / src / include / dummy.h
1 /**
2  * Copyright (C) 2010-2011, Shao Miller <shao.miller@yrdsb.edu.on.ca>.
3  *
4  * This file is part of WinVBlock, originally derived from WinAoE.
5  *
6  * WinVBlock is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * WinVBlock is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with WinVBlock.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 #ifndef WV_M_DUMMY_H_
20 #  define WV_M_DUMMY_H_
21
22 /**
23  * @file
24  *
25  * Dummy device specifics.
26  */
27
28 /* PnP IDs for a dummy device. */
29 typedef struct WV_DUMMY_IDS {
30     UINT32 DevOffset;
31     UINT32 DevLen;
32     UINT32 InstanceOffset;
33     UINT32 InstanceLen;
34     UINT32 HardwareOffset;
35     UINT32 HardwareLen;
36     UINT32 CompatOffset;
37     UINT32 CompatLen;
38     UINT32 Len;
39     const WCHAR * Ids;
40     WCHAR Text[1];
41   } WV_S_DUMMY_IDS, * WV_SP_DUMMY_IDS;
42
43 /* Macro support for dummy ID generation. */
44 #define WV_M_DUMMY_IDS_X_ENUM(prefix_, name_, literal_)           \
45   prefix_ ## name_ ## Offset_,                                    \
46   prefix_ ## name_ ## Len_ = sizeof (literal_) / sizeof (WCHAR),  \
47   prefix_ ## name_ ## End_ =                                      \
48     prefix_ ## name_ ## Offset_ + prefix_ ## name_ ## Len_ - 1,
49
50 #define WV_M_DUMMY_IDS_X_LITERALS(prefix_, name_, literal_) \
51   literal_ L"\0"
52
53 #define WV_M_DUMMY_IDS_X_FILL(prefix_, name_, literal_) \
54   prefix_ ## name_ ## Offset_,                          \
55   prefix_ ## name_ ## Len_,
56
57 /**
58  * Generate a static const WV_S_DUMMY_IDS object.
59  *
60  * @v DummyIds          The name of the desired object.  Also used as prefix.
61  * @v XMacro            The x-macro with the ID text.
62  *
63  * This macro will produce the following:
64  *   enum values:
65  *     [DummyIds]DevOffset_
66  *     [DummyIds]DevLen_
67  *     [DummyIds]DevEnd_
68  *     [DummyIds]InstanceOffset_
69  *     [DummyIds]InstanceLen_
70  *     [DummyIds]InstanceEnd_
71  *     [DummyIds]HardwareOffset_
72  *     [DummyIds]HardwareLen_
73  *     [DummyIds]HardwareEnd_
74  *     [DummyIds]CompatOffset_
75  *     [DummyIds]CompatLen_
76  *     [DummyIds]CompatEnd_
77  *     [DummyIds]Len_
78  *   WCHAR[]:
79  *     [DummyIds]String_
80  *   static const WV_S_DUMMY_IDS:
81  *     [DummyIds]
82  */
83 #define WV_M_DUMMY_ID_GEN(DummyIds, XMacro)     \
84                                                 \
85 enum {                                          \
86     XMacro(WV_M_DUMMY_IDS_X_ENUM, DummyIds)     \
87     DummyIds ## Len_                            \
88   };                                            \
89                                                 \
90 static const WCHAR DummyIds ## String_[] =      \
91   XMacro(WV_M_DUMMY_IDS_X_LITERALS, DummyIds);  \
92                                                 \
93 static const WV_S_DUMMY_IDS DummyIds = {        \
94     XMacro(WV_M_DUMMY_IDS_X_FILL, DummyIds)     \
95     DummyIds ## Len_,                           \
96     DummyIds ## String_                         \
97   }
98
99 extern WVL_M_LIB NTSTATUS STDCALL WvDummyAdd(
100     IN const WV_S_DUMMY_IDS *,
101     IN DEVICE_TYPE,
102     IN ULONG,
103     OUT PDEVICE_OBJECT *
104   );
105
106 #endif  /* WV_M_DUMMY_H_ */