1 /*
2 * Copyright 2012 Hans Leidekker for CodeWeavers
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19 #define COBJMACROS
20 #define NONAMELESSUNION
21 #define NONAMELESSSTRUCT
22
23 #include <stdarg.h>
24 #ifdef __REACTOS__
25 #include <wchar.h>
26 #endif
27
28 #include "ntstatus.h"
29 #define WIN32_NO_STATUS
30 #include "windef.h"
31 #include "winbase.h"
32 #include "winsock2.h"
33 #include "ws2tcpip.h"
34 #include "initguid.h"
35 #include "wbemcli.h"
36 #include "wbemprov.h"
37 #include "iphlpapi.h"
38 #include "netioapi.h"
39 #include "tlhelp32.h"
40 #ifndef __REACTOS__
41 #include "d3d10.h"
42 #endif
43 #include "winternl.h"
44 #include "winioctl.h"
45 #include "winsvc.h"
46 #include "winver.h"
47 #include "sddl.h"
48 #include "ntsecapi.h"
49 #ifdef __REACTOS__
50 #include <wingdi.h>
51 #include <winreg.h>
52 #endif
53 #include "winspool.h"
54 #include "setupapi.h"
55
56 #include "wine/asm.h"
57 #include "wine/debug.h"
58 #include "wbemprox_private.h"
59
60 WINE_DEFAULT_DEBUG_CHANNEL(wbemprox);
61
62 static const WCHAR class_associatorsW[] =
63 {'_','_','A','S','S','O','C','I','A','T','O','R','S',0};
64 static const WCHAR class_baseboardW[] =
65 {'W','i','n','3','2','_','B','a','s','e','B','o','a','r','d',0};
66 static const WCHAR class_biosW[] =
67 {'W','i','n','3','2','_','B','I','O','S',0};
68 static const WCHAR class_cdromdriveW[] =
69 {'W','i','n','3','2','_','C','D','R','O','M','D','r','i','v','e',0};
70 static const WCHAR class_compsysW[] =
71 {'W','i','n','3','2','_','C','o','m','p','u','t','e','r','S','y','s','t','e','m',0};
72 static const WCHAR class_compsysproductW[] =
73 {'W','i','n','3','2','_','C','o','m','p','u','t','e','r','S','y','s','t','e','m','P','r','o','d','u','c','t',0};
74 static const WCHAR class_datafileW[] =
75 {'C','I','M','_','D','a','t','a','F','i','l','e',0};
76 static const WCHAR class_desktopmonitorW[] =
77 {'W','i','n','3','2','_','D','e','s','k','t','o','p','M','o','n','i','t','o','r',0};
78 static const WCHAR class_directoryW[] =
79 {'W','i','n','3','2','_','D','i','r','e','c','t','o','r','y',0};
80 static const WCHAR class_diskdriveW[] =
81 {'W','i','n','3','2','_','D','i','s','k','D','r','i','v','e',0};
82 static const WCHAR class_diskdrivetodiskpartitionW[] =
83 {'W','i','n','3','2','_','D','i','s','k','D','r','i','v','e','T','o','D','i','s','k','P','a','r','t','i','t','i','o','n',0};
84 static const WCHAR class_diskpartitionW[] =
85 {'W','i','n','3','2','_','D','i','s','k','P','a','r','t','i','t','i','o','n',0};
86 static const WCHAR class_displaycontrollerconfigW[] =
87 {'W','i','n','3','2','_','D','i','s','p','l','a','y','C','o','n','t','r','o','l','l','e','r',
88 'C','o','n','f','i','g','u','r','a','t','i','o','n',0};
89 static const WCHAR class_ip4routetableW[] =
90 {'W','i','n','3','2','_','I','P','4','R','o','u','t','e','T','a','b','l','e',0};
91 static const WCHAR class_logicaldiskW[] =
92 {'W','i','n','3','2','_','L','o','g','i','c','a','l','D','i','s','k',0};
93 static const WCHAR class_logicaldisk2W[] =
94 {'C','I','M','_','L','o','g','i','c','a','l','D','i','s','k',0};
95 static const WCHAR class_logicaldisktopartitionW[] =
96 {'W','i','n','3','2','_','L','o','g','i','c','a','l','D','i','s','k','T','o','P','a','r','t','i','t','i','o','n',0};
97 static const WCHAR class_networkadapterW[] =
98 {'W','i','n','3','2','_','N','e','t','w','o','r','k','A','d','a','p','t','e','r',0};
99 static const WCHAR class_networkadapterconfigW[] =
100 {'W','i','n','3','2','_','N','e','t','w','o','r','k','A','d','a','p','t','e','r',
101 'C','o','n','f','i','g','u','r','a','t','i','o','n',0};
102 static const WCHAR class_operatingsystemW[] =
103 {'W','i','n','3','2','_','O','p','e','r','a','t','i','n','g','S','y','s','t','e','m',0};
104 static const WCHAR class_paramsW[] =
105 {'_','_','P','A','R','A','M','E','T','E','R','S',0};
106 static const WCHAR class_physicalmediaW[] =
107 {'W','i','n','3','2','_','P','h','y','s','i','c','a','l','M','e','d','i','a',0};
108 static const WCHAR class_physicalmemoryW[] =
109 {'W','i','n','3','2','_','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
110 static const WCHAR class_pnpentityW[] =
111 {'W','i','n','3','2','_','P','n','P','E','n','t','i','t','y',0};
112 static const WCHAR class_printerW[] =
113 {'W','i','n','3','2','_','P','r','i','n','t','e','r',0};
114 static const WCHAR class_process_getowner_outW[] =
115 {'_','_','W','I','N','3','2','_','P','R','O','C','E','S','S','_','G','E','T','O','W',
116 'N','E','R','_','O','U','T',0};
117 static const WCHAR class_processorW[] =
118 {'W','i','n','3','2','_','P','r','o','c','e','s','s','o','r',0};
119 static const WCHAR class_processor2W[] =
120 {'C','I','M','_','P','r','o','c','e','s','s','o','r',0};
121 static const WCHAR class_qualifiersW[] =
122 {'_','_','Q','U','A','L','I','F','I','E','R','S',0};
123 static const WCHAR class_quickfixengineeringW[] =
124 {'W','i','n','3','2','_','Q','u','i','c','k','F','i','x','E','n','g','i','n','e','e','r','i','n','g',0};
125 static const WCHAR class_sidW[] =
126 {'W','i','n','3','2','_','S','I','D',0};
127 static const WCHAR class_sounddeviceW[] =
128 {'W','i','n','3','2','_','S','o','u','n','d','D','e','v','i','c','e',0};
129 static const WCHAR class_systemenclosureW[] =
130 {'W','i','n','3','2','_','S','y','s','t','e','m','E','n','c','l','o','s','u','r','e',0};
131 #ifndef __REACTOS__
132 static const WCHAR class_videocontrollerW[] =
133 {'W','i','n','3','2','_','V','i','d','e','o','C','o','n','t','r','o','l','l','e','r',0};
134 #endif
135 static const WCHAR class_winsatW[] =
136 {'W','i','n','3','2','_','W','i','n','S','A','T',0};
137
138 static const WCHAR prop_accountnameW[] =
139 {'A','c','c','o','u','n','t','N','a','m','e',0};
140 static const WCHAR prop_acceptpauseW[] =
141 {'A','c','c','e','p','t','P','a','u','s','e',0};
142 static const WCHAR prop_acceptstopW[] =
143 {'A','c','c','e','p','t','S','t','o','p',0};
144 static const WCHAR prop_accessmaskW[] =
145 {'A','c','c','e','s','s','M','a','s','k',0};
146 #ifndef __REACTOS__
147 static const WCHAR prop_adapterdactypeW[] =
148 {'A','d','a','p','t','e','r','D','A','C','T','y','p','e',0};
149 static const WCHAR prop_adapterramW[] =
150 {'A','d','a','p','t','e','r','R','A','M',0};
151 #endif
152 static const WCHAR prop_adaptertypeW[] =
153 {'A','d','a','p','t','e','r','T','y','p','e',0};
154 static const WCHAR prop_adaptertypeidW[] =
155 {'A','d','a','p','t','e','r','T','y','p','e','I','D',0};
156 static const WCHAR prop_addresswidthW[] =
157 {'A','d','d','r','e','s','s','W','i','d','t','h',0};
158 static const WCHAR prop_antecedentW[] =
159 {'A','n','t','e','c','e','d','e','n','t',0};
160 static const WCHAR prop_architectureW[] =
161 {'A','r','c','h','i','t','e','c','t','u','r','e',0};
162 static const WCHAR prop_assocclassW[] =
163 {'A','s','s','o','c','C','l','a','s','s',0};
164 static const WCHAR prop_associatorW[] =
165 {'A','s','s','o','c','i','a','t','o','r',0};
166 static const WCHAR prop_attributesW[] =
167 {'A','t','t','r','i','b','u','t','e','s',0};
168 #ifndef __REACTOS__
169 static const WCHAR prop_availabilityW[] =
170 {'A','v','a','i','l','a','b','i','l','i','t','y',0};
171 #endif
172 static const WCHAR prop_binaryrepresentationW[] =
173 {'B','i','n','a','r','y','R','e','p','r','e','s','e','n','t','a','t','i','o','n',0};
174 static const WCHAR prop_bitsperpixelW[] =
175 {'B','i','t','s','P','e','r','P','i','x','e','l',0};
176 static const WCHAR prop_boolvalueW[] =
177 {'B','o','o','l','V','a','l','u','e',0};
178 static const WCHAR prop_bootableW[] =
179 {'B','o','o','t','a','b','l','e',0};
180 static const WCHAR prop_bootpartitionW[] =
181 {'B','o','o','t','P','a','r','t','i','t','i','o','n',0};
182 static const WCHAR prop_buildnumberW[] =
183 {'B','u','i','l','d','N','u','m','b','e','r',0};
184 static const WCHAR prop_capacityW[] =
185 {'C','a','p','a','c','i','t','y',0};
186 static const WCHAR prop_captionW[] =
187 {'C','a','p','t','i','o','n',0};
188 static const WCHAR prop_chassistypesW[] =
189 {'C','h','a','s','s','i','s','T','y','p','e','s',0};
190 static const WCHAR prop_classW[] =
191 {'C','l','a','s','s',0};
192 static const WCHAR prop_codesetW[] =
193 {'C','o','d','e','S','e','t',0};
194 static const WCHAR prop_commandlineW[] =
195 {'C','o','m','m','a','n','d','L','i','n','e',0};
196 static const WCHAR prop_configmanagererrorcodeW[] =
197 {'C','o','n','f','i','g','M','a','n','a','g','e','r','E','r','r','o','r','C','o','d','e',0};
198 static const WCHAR prop_configuredclockspeedW[] =
199 {'C','o','n','f','i','g','u','r','e','d','C','l','o','c','k','S','p','e','e','d',0};
200 static const WCHAR prop_countrycodeW[] =
201 {'C','o','u','n','t','r','y','C','o','d','e',0};
202 static const WCHAR prop_cpuscoreW[] =
203 {'C','P','U','S','c','o','r','e',0};
204 static const WCHAR prop_cpustatusW[] =
205 {'C','p','u','S','t','a','t','u','s',0};
206 static const WCHAR prop_csdversionW[] =
207 {'C','S','D','V','e','r','s','i','o','n',0};
208 static const WCHAR prop_csnameW[] =
209 {'C','S','N','a','m','e',0};
210 #ifndef __REACTOS__
211 static const WCHAR prop_currentbitsperpixelW[] =
212 {'C','u','r','r','e','n','t','B','i','t','s','P','e','r','P','i','x','e','l',0};
213 #endif
214 static const WCHAR prop_currentclockspeedW[] =
215 {'C','u','r','r','e','n','t','C','l','o','c','k','S','p','e','e','d',0};
216 static const WCHAR prop_currenthorizontalresW[] =
217 {'C','u','r','r','e','n','t','H','o','r','i','z','o','n','t','a','l','R','e','s','o','l','u','t','i','o','n',0};
218 static const WCHAR prop_currentlanguageW[] =
219 {'C','u','r','r','e','n','t','L','a','n','g','u','a','g','e',0};
220 static const WCHAR prop_currentrefreshrateW[] =
221 {'C','u','r','r','e','n','t','R','e','f','r','e','s','h','R','a','t','e',0};
222 static const WCHAR prop_currentscanmodeW[] =
223 {'C','u','r','r','e','n','t','S','c','a','n','M','o','d','e',0};
224 static const WCHAR prop_currenttimezoneW[] =
225 {'C','u','r','r','e','n','t','T','i','m','e','Z','o','n','e',0};
226 static const WCHAR prop_currentverticalresW[] =
227 {'C','u','r','r','e','n','t','V','e','r','t','i','c','a','l','R','e','s','o','l','u','t','i','o','n',0};
228 static const WCHAR prop_d3dscoreW[] =
229 {'D','3','D','S','c','o','r','e',0};
230 static const WCHAR prop_datawidthW[] =
231 {'D','a','t','a','W','i','d','t','h',0};
232 static const WCHAR prop_defaultipgatewayW[] =
233 {'D','e','f','a','u','l','t','I','P','G','a','t','e','w','a','y',0};
234 static const WCHAR prop_defaultvalueW[] =
235 {'D','e','f','a','u','l','t','V','a','l','u','e',0};
236 static const WCHAR prop_dependentW[] =
237 {'D','e','p','e','n','d','e','n','t',0};
238 static const WCHAR prop_descriptionW[] =
239 {'D','e','s','c','r','i','p','t','i','o','n',0};
240 static const WCHAR prop_destinationW[] =
241 {'D','e','s','t','i','n','a','t','i','o','n',0};
242 static const WCHAR prop_deviceidW[] =
243 {'D','e','v','i','c','e','I','d',0};
244 static const WCHAR prop_devicelocatorW[] =
245 {'D','e','v','i','c','e','L','o','c','a','t','o','r',0};
246 static const WCHAR prop_dhcpenabledW[] =
247 {'D','H','C','P','E','n','a','b','l','e','d',0};
248 static const WCHAR prop_directionW[] =
249 {'D','i','r','e','c','t','i','o','n',0};
250 static const WCHAR prop_diskscoreW[] =
251 {'D','i','s','k','S','c','o','r','e',0};
252 static const WCHAR prop_displaynameW[] =
253 {'D','i','s','p','l','a','y','N','a','m','e',0};
254 static const WCHAR prop_diskindexW[] =
255 {'D','i','s','k','I','n','d','e','x',0};
256 static const WCHAR prop_dnshostnameW[] =
257 {'D','N','S','H','o','s','t','N','a','m','e',0};
258 static const WCHAR prop_dnsserversearchorderW[] =
259 {'D','N','S','S','e','r','v','e','r','S','e','a','r','c','h','O','r','d','e','r',0};
260 static const WCHAR prop_domainW[] =
261 {'D','o','m','a','i','n',0};
262 static const WCHAR prop_domainroleW[] =
263 {'D','o','m','a','i','n','R','o','l','e',0};
264 static const WCHAR prop_driveW[] =
265 {'D','r','i','v','e',0};
266 static const WCHAR prop_driverdateW[] =
267 {'D','r','i','v','e','r','D','a','t','e',0};
268 static const WCHAR prop_drivernameW[] =
269 {'D','r','i','v','e','r','N','a','m','e',0};
270 #ifndef __REACTOS__
271 static const WCHAR prop_driverversionW[] =
272 {'D','r','i','v','e','r','V','e','r','s','i','o','n',0};
273 #endif
274 static const WCHAR prop_drivetypeW[] =
275 {'D','r','i','v','e','T','y','p','e',0};
276 static const WCHAR prop_familyW[] =
277 {'F','a','m','i','l','y',0};
278 static const WCHAR prop_filesystemW[] =
279 {'F','i','l','e','S','y','s','t','e','m',0};
280 static const WCHAR prop_flavorW[] =
281 {'F','l','a','v','o','r',0};
282 static const WCHAR prop_freespaceW[] =
283 {'F','r','e','e','S','p','a','c','e',0};
284 static const WCHAR prop_freephysicalmemoryW[] =
285 {'F','r','e','e','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
286 static const WCHAR prop_handleW[] =
287 {'H','a','n','d','l','e',0};
288 static const WCHAR prop_graphicsscoreW[] =
289 {'G','r','a','p','h','i','c','s','S','c','o','r','e',0};
290 static const WCHAR prop_horizontalresolutionW[] =
291 {'H','o','r','i','z','o','n','t','a','l','R','e','s','o','l','u','t','i','o','n',0};
292 static const WCHAR prop_hotfixidW[] =
293 {'H','o','t','F','i','x','I','D',0};
294 static const WCHAR prop_idW[] =
295 {'I','D',0};
296 static const WCHAR prop_identificationcodeW[] =
297 {'I','d','e','n','t','i','f','i','c','a','t','i','o','n','C','o','d','e',0};
298 static const WCHAR prop_identifyingnumberW[] =
299 {'I','d','e','n','t','i','f','y','i','n','g','N','u','m','b','e','r',0};
300 static const WCHAR prop_indexW[] =
301 {'I','n','d','e','x',0};
302 static const WCHAR prop_installdateW[] =
303 {'I','n','s','t','a','l','l','D','a','t','e',0};
304 static const WCHAR prop_installeddisplaydriversW[]=
305 {'I','n','s','t','a','l','l','e','d','D','i','s','p','l','a','y','D','r','i','v','e','r','s',0};
306 static const WCHAR prop_interfaceindexW[] =
307 {'I','n','t','e','r','f','a','c','e','I','n','d','e','x',0};
308 static const WCHAR prop_interfacetypeW[] =
309 {'I','n','t','e','r','f','a','c','e','T','y','p','e',0};
310 static const WCHAR prop_intvalueW[] =
311 {'I','n','t','e','g','e','r','V','a','l','u','e',0};
312 static const WCHAR prop_ipaddressW[] =
313 {'I','P','A','d','d','r','e','s','s',0};
314 static const WCHAR prop_ipconnectionmetricW[] =
315 {'I','P','C','o','n','n','e','c','t','i','o','n','M','e','t','r','i','c',0};
316 static const WCHAR prop_ipenabledW[] =
317 {'I','P','E','n','a','b','l','e','d',0};
318 static const WCHAR prop_ipsubnet[] =
319 {'I','P','S','u','b','n','e','t',0};
320 static const WCHAR prop_lastbootuptimeW[] =
321 {'L','a','s','t','B','o','o','t','U','p','T','i','m','e',0};
322 static const WCHAR prop_levelW[] =
323 {'L','e','v','e','l',0};
324 static const WCHAR prop_localW[] =
325 {'L','o','c','a','l',0};
326 static const WCHAR prop_localdatetimeW[] =
327 {'L','o','c','a','l','D','a','t','e','T','i','m','e',0};
328 static const WCHAR prop_localeW[] =
329 {'L','o','c','a','l','e',0};
330 static const WCHAR prop_locationW[] =
331 {'L','o','c','a','t','i','o','n',0};
332 static const WCHAR prop_lockpresentW[] =
333 {'L','o','c','k','P','r','e','s','e','n','t',0};
334 static const WCHAR prop_macaddressW[] =
335 {'M','A','C','A','d','d','r','e','s','s',0};
336 static const WCHAR prop_manufacturerW[] =
337 {'M','a','n','u','f','a','c','t','u','r','e','r',0};
338 static const WCHAR prop_maxclockspeedW[] =
339 {'M','a','x','C','l','o','c','k','S','p','e','e','d',0};
340 static const WCHAR prop_mediatypeW[] =
341 {'M','e','d','i','a','T','y','p','e',0};
342 static const WCHAR prop_memberW[] =
343 {'M','e','m','b','e','r',0};
344 static const WCHAR prop_memoryscoreW[] =
345 {'M','e','m','o','r','y','S','c','o','r','e',0};
346 static const WCHAR prop_memorytypeW[] =
347 {'M','e','m','o','r','y','T','y','p','e',0};
348 static const WCHAR prop_methodW[] =
349 {'M','e','t','h','o','d',0};
350 static const WCHAR prop_modelW[] =
351 {'M','o','d','e','l',0};
352 static const WCHAR prop_netconnectionstatusW[] =
353 {'N','e','t','C','o','n','n','e','c','t','i','o','n','S','t','a','t','u','s',0};
354 static const WCHAR prop_networkW[] =
355 {'N','e','t','w','o','r','k',0};
356 static const WCHAR prop_nexthopW[] =
357 {'N','e','x','t','H','o','p',0};
358 static const WCHAR prop_numcoresW[] =
359 {'N','u','m','b','e','r','O','f','C','o','r','e','s',0};
360 static const WCHAR prop_numlogicalprocessorsW[] =
361 {'N','u','m','b','e','r','O','f','L','o','g','i','c','a','l','P','r','o','c','e','s','s','o','r','s',0};
362 static const WCHAR prop_numprocessorsW[] =
363 {'N','u','m','b','e','r','O','f','P','r','o','c','e','s','s','o','r','s',0};
364 static const WCHAR prop_operatingsystemskuW[] =
365 {'O','p','e','r','a','t','i','n','g','S','y','s','t','e','m','S','K','U',0};
366 static const WCHAR prop_osarchitectureW[] =
367 {'O','S','A','r','c','h','i','t','e','c','t','u','r','e',0};
368 static const WCHAR prop_oslanguageW[] =
369 {'O','S','L','a','n','g','u','a','g','e',0};
370 static const WCHAR prop_osproductsuiteW[] =
371 {'O','S','P','r','o','d','u','c','t','S','u','i','t','e',0};
372 static const WCHAR prop_ostypeW[] =
373 {'O','S','T','y','p','e',0};
374 static const WCHAR prop_parameterW[] =
375 {'P','a','r','a','m','e','t','e','r',0};
376 static const WCHAR prop_partnumberW[] =
377 {'P','a','r','t','N','u','m','b','e','r',0};
378 static const WCHAR prop_physicaladapterW[] =
379 {'P','h','y','s','i','c','a','l','A','d','a','p','t','e','r',0};
380 static const WCHAR prop_pixelsperxlogicalinchW[] =
381 {'P','i','x','e','l','s','P','e','r','X','L','o','g','i','c','a','l','I','n','c','h',0};
382 static const WCHAR prop_pnpdeviceidW[] =
383 {'P','N','P','D','e','v','i','c','e','I','D',0};
384 static const WCHAR prop_portnameW[] =
385 {'P','o','r','t','N','a','m','e',0};
386 static const WCHAR prop_pprocessidW[] =
387 {'P','a','r','e','n','t','P','r','o','c','e','s','s','I','D',0};
388 static const WCHAR prop_primaryW[] =
389 {'P','r','i','m','a','r','y',0};
390 static const WCHAR prop_processidW[] =
391 {'P','r','o','c','e','s','s','I','D',0};
392 static const WCHAR prop_processoridW[] =
393 {'P','r','o','c','e','s','s','o','r','I','d',0};
394 static const WCHAR prop_processortypeW[] =
395 {'P','r','o','c','e','s','s','o','r','T','y','p','e',0};
396 static const WCHAR prop_productW[] =
397 {'P','r','o','d','u','c','t',0};
398 static const WCHAR prop_productnameW[] =
399 {'P','r','o','d','u','c','t','N','a','m','e',0};
400 static const WCHAR prop_referenceddomainnameW[] =
401 {'R','e','f','e','r','e','n','c','e','d','D','o','m','a','i','n','N','a','m','e',0};
402 static const WCHAR prop_releasedateW[] =
403 {'R','e','l','e','a','s','e','D','a','t','e',0};
404 static const WCHAR prop_revisionW[] =
405 {'R','e','v','i','s','i','o','n',0};
406 static const WCHAR prop_serialnumberW[] =
407 {'S','e','r','i','a','l','N','u','m','b','e','r',0};
408 static const WCHAR prop_servicepackmajorW[] =
409 {'S','e','r','v','i','c','e','P','a','c','k','M','a','j','o','r','V','e','r','s','i','o','n',0};
410 static const WCHAR prop_servicepackminorW[] =
411 {'S','e','r','v','i','c','e','P','a','c','k','M','i','n','o','r','V','e','r','s','i','o','n',0};
412 static const WCHAR prop_servicetypeW[] =
413 {'S','e','r','v','i','c','e','T','y','p','e',0};
414 static const WCHAR prop_settingidW[] =
415 {'S','e','t','t','i','n','g','I','D',0};
416 static const WCHAR prop_skunumberW[] =
417 {'S','K','U','N','u','m','b','e','r',0};
418 static const WCHAR prop_smbiosbiosversionW[] =
419 {'S','M','B','I','O','S','B','I','O','S','V','e','r','s','i','o','n',0};
420 static const WCHAR prop_smbiosmajorversionW[] =
421 {'S','M','B','I','O','S','M','a','j','o','r','V','e','r','s','i','o','n',0};
422 static const WCHAR prop_smbiosminorversionW[] =
423 {'S','M','B','I','O','S','M','i','n','o','r','V','e','r','s','i','o','n',0};
424 static const WCHAR prop_startmodeW[] =
425 {'S','t','a','r','t','M','o','d','e',0};
426 static const WCHAR prop_sidW[] =
427 {'S','I','D',0};
428 static const WCHAR prop_sidlengthW[] =
429 {'S','i','d','L','e','n','g','t','h',0};
430 static const WCHAR prop_sizeW[] =
431 {'S','i','z','e',0};
432 static const WCHAR prop_speedW[] =
433 {'S','p','e','e','d',0};
434 static const WCHAR prop_startingoffsetW[] =
435 {'S','t','a','r','t','i','n','g','O','f','f','s','e','t',0};
436 static const WCHAR prop_stateW[] =
437 {'S','t','a','t','e',0};
438 static const WCHAR prop_statusW[] =
439 {'S','t','a','t','u','s',0};
440 static const WCHAR prop_statusinfoW[] =
441 {'S','t','a','t','u','s','I','n','f','o',0};
442 static const WCHAR prop_strvalueW[] =
443 {'S','t','r','i','n','g','V','a','l','u','e',0};
444 static const WCHAR prop_suitemaskW[] =
445 {'S','u','i','t','e','M','a','s','k',0};
446 static const WCHAR prop_systemdirectoryW[] =
447 {'S','y','s','t','e','m','D','i','r','e','c','t','o','r','y',0};
448 static const WCHAR prop_systemdriveW[] =
449 {'S','y','s','t','e','m','D','r','i','v','e',0};
450 static const WCHAR prop_systemnameW[] =
451 {'S','y','s','t','e','m','N','a','m','e',0};
452 static const WCHAR prop_tagW[] =
453 {'T','a','g',0};
454 static const WCHAR prop_threadcountW[] =
455 {'T','h','r','e','a','d','C','o','u','n','t',0};
456 static const WCHAR prop_timetakenW[] =
457 {'T','i','m','e','T','a','k','e','n',0};
458 static const WCHAR prop_totalphysicalmemoryW[] =
459 {'T','o','t','a','l','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
460 static const WCHAR prop_totalvirtualmemorysizeW[] =
461 {'T','o','t','a','l','V','i','r','t','u','a','l','M','e','m','o','r','y','S','i','z','e',0};
462 static const WCHAR prop_totalvisiblememorysizeW[] =
463 {'T','o','t','a','l','V','i','s','i','b','l','e','M','e','m','o','r','y','S','i','z','e',0};
464 static const WCHAR prop_typeW[] =
465 {'T','y','p','e',0};
466 static const WCHAR prop_uniqueidW[] =
467 {'U','n','i','q','u','e','I','d',0};
468 static const WCHAR prop_usernameW[] =
469 {'U','s','e','r','N','a','m','e',0};
470 static const WCHAR prop_uuidW[] =
471 {'U','U','I','D',0};
472 static const WCHAR prop_vendorW[] =
473 {'V','e','n','d','o','r',0};
474 static const WCHAR prop_versionW[] =
475 {'V','e','r','s','i','o','n',0};
476 static const WCHAR prop_verticalresolutionW[] =
477 {'V','e','r','t','i','c','a','l','R','e','s','o','l','u','t','i','o','n',0};
478 #ifndef __REACTOS__
479 static const WCHAR prop_videoarchitectureW[] =
480 {'V','i','d','e','o','A','r','c','h','i','t','e','c','t','u','r','e',0};
481 static const WCHAR prop_videomemorytypeW[] =
482 {'V','i','d','e','o','M','e','m','o','r','y','T','y','p','e',0};
483 static const WCHAR prop_videomodedescriptionW[] =
484 {'V','i','d','e','o','M','o','d','e','D','e','s','c','r','i','p','t','i','o','n',0};
485 static const WCHAR prop_videoprocessorW[] =
486 {'V','i','d','e','o','P','r','o','c','e','s','s','o','r',0};
487 #endif /* !__REACTOS__ */
488 static const WCHAR prop_volumenameW[] =
489 {'V','o','l','u','m','e','N','a','m','e',0};
490 static const WCHAR prop_volumeserialnumberW[] =
491 {'V','o','l','u','m','e','S','e','r','i','a','l','N','u','m','b','e','r',0};
492 static const WCHAR prop_winsatassessmentstateW[] =
493 {'W','i','n','S','A','T','A','s','s','e','s','s','m','e','n','t','S','t','a','t','e',0};
494 static const WCHAR prop_winsprlevelW[] =
495 {'W','i','n','S','P','R','L','e','v','e','l',0};
496 static const WCHAR prop_workingsetsizeW[] =
497 {'W','o','r','k','i','n','g','S','e','t','S','i','z','e',0};
498
499 /* column definitions must be kept in sync with record structures below */
500 static const struct column col_associator[] =
501 {
502 { prop_assocclassW, CIM_STRING },
503 { prop_classW, CIM_STRING },
504 { prop_associatorW, CIM_STRING }
505 };
506 static const struct column col_baseboard[] =
507 {
508 { prop_manufacturerW, CIM_STRING|COL_FLAG_DYNAMIC },
509 { prop_modelW, CIM_STRING },
510 { prop_nameW, CIM_STRING },
511 { prop_productW, CIM_STRING|COL_FLAG_DYNAMIC },
512 { prop_serialnumberW, CIM_STRING|COL_FLAG_DYNAMIC },
513 { prop_tagW, CIM_STRING|COL_FLAG_KEY },
514 { prop_versionW, CIM_STRING|COL_FLAG_DYNAMIC }
515 };
516 static const struct column col_bios[] =
517 {
518 { prop_currentlanguageW, CIM_STRING },
519 { prop_descriptionW, CIM_STRING },
520 { prop_identificationcodeW, CIM_STRING },
521 { prop_manufacturerW, CIM_STRING|COL_FLAG_DYNAMIC },
522 { prop_nameW, CIM_STRING },
523 { prop_releasedateW, CIM_DATETIME|COL_FLAG_DYNAMIC },
524 { prop_serialnumberW, CIM_STRING },
525 { prop_smbiosbiosversionW, CIM_STRING|COL_FLAG_DYNAMIC },
526 { prop_smbiosmajorversionW, CIM_UINT16 },
527 { prop_smbiosminorversionW, CIM_UINT16 },
528 { prop_versionW, CIM_STRING|COL_FLAG_KEY }
529 };
530 static const struct column col_cdromdrive[] =
531 {
532 { prop_deviceidW, CIM_STRING|COL_FLAG_KEY },
533 { prop_driveW, CIM_STRING|COL_FLAG_DYNAMIC },
534 { prop_mediatypeW, CIM_STRING },
535 { prop_nameW, CIM_STRING },
536 { prop_pnpdeviceidW, CIM_STRING }
537 };
538 static const struct column col_compsys[] =
539 {
540 { prop_descriptionW, CIM_STRING },
541 { prop_domainW, CIM_STRING },
542 { prop_domainroleW, CIM_UINT16 },
543 { prop_manufacturerW, CIM_STRING },
544 { prop_modelW, CIM_STRING },
545 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
546 { prop_numlogicalprocessorsW, CIM_UINT32 },
547 { prop_numprocessorsW, CIM_UINT32 },
548 { prop_totalphysicalmemoryW, CIM_UINT64 },
549 { prop_usernameW, CIM_STRING|COL_FLAG_DYNAMIC }
550 };
551 static const struct column col_compsysproduct[] =
552 {
553 { prop_identifyingnumberW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
554 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
555 { prop_skunumberW, CIM_STRING },
556 { prop_uuidW, CIM_STRING|COL_FLAG_DYNAMIC },
557 { prop_vendorW, CIM_STRING|COL_FLAG_DYNAMIC },
558 { prop_versionW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY }
559 };
560 static const struct column col_datafile[] =
561 {
562 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
563 { prop_versionW, CIM_STRING|COL_FLAG_DYNAMIC }
564 };
565 static const struct column col_desktopmonitor[] =
566 {
567 { prop_pixelsperxlogicalinchW, CIM_UINT32 }
568 };
569 static const struct column col_directory[] =
570 {
571 { prop_accessmaskW, CIM_UINT32 },
572 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY }
573 };
574 static const struct column col_diskdrive[] =
575 {
576 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
577 { prop_indexW, CIM_UINT32 },
578 { prop_interfacetypeW, CIM_STRING },
579 { prop_manufacturerW, CIM_STRING },
580 { prop_mediatypeW, CIM_STRING },
581 { prop_modelW, CIM_STRING },
582 { prop_pnpdeviceidW, CIM_STRING },
583 { prop_serialnumberW, CIM_STRING },
584 { prop_sizeW, CIM_UINT64 }
585 };
586 static const struct column col_diskdrivetodiskpartition[] =
587 {
588 { prop_antecedentW, CIM_REFERENCE|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
589 { prop_dependentW, CIM_REFERENCE|COL_FLAG_DYNAMIC|COL_FLAG_KEY }
590 };
591 static const struct column col_diskpartition[] =
592 {
593 { prop_bootableW, CIM_BOOLEAN },
594 { prop_bootpartitionW, CIM_BOOLEAN },
595 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
596 { prop_diskindexW, CIM_UINT32 },
597 { prop_indexW, CIM_UINT32 },
598 { prop_pnpdeviceidW, CIM_STRING|COL_FLAG_DYNAMIC },
599 { prop_sizeW, CIM_UINT64 },
600 { prop_startingoffsetW, CIM_UINT64 },
601 { prop_typeW, CIM_STRING|COL_FLAG_DYNAMIC }
602 };
603 static const struct column col_displaycontrollerconfig[] =
604 {
605 { prop_bitsperpixelW, CIM_UINT32 },
606 { prop_captionW, CIM_STRING },
607 { prop_horizontalresolutionW, CIM_UINT32 },
608 { prop_nameW, CIM_STRING|COL_FLAG_KEY },
609 { prop_verticalresolutionW, CIM_UINT32 }
610 };
611 static const struct column col_ip4routetable[] =
612 {
613 { prop_destinationW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
614 { prop_interfaceindexW, CIM_SINT32|COL_FLAG_KEY },
615 { prop_nexthopW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
616 };
617 static const struct column col_logicaldisk[] =
618 {
619 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
620 { prop_drivetypeW, CIM_UINT32 },
621 { prop_filesystemW, CIM_STRING|COL_FLAG_DYNAMIC },
622 { prop_freespaceW, CIM_UINT64 },
623 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
624 { prop_sizeW, CIM_UINT64 },
625 { prop_volumenameW, CIM_STRING|COL_FLAG_DYNAMIC },
626 { prop_volumeserialnumberW, CIM_STRING|COL_FLAG_DYNAMIC }
627 };
628 static const struct column col_logicaldisktopartition[] =
629 {
630 { prop_antecedentW, CIM_REFERENCE|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
631 { prop_dependentW, CIM_REFERENCE|COL_FLAG_DYNAMIC|COL_FLAG_KEY }
632 };
633 static const struct column col_networkadapter[] =
634 {
635 { prop_adaptertypeW, CIM_STRING },
636 { prop_adaptertypeidW, CIM_UINT16 },
637 { prop_descriptionW, CIM_STRING|COL_FLAG_DYNAMIC },
638 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
639 { prop_indexW, CIM_UINT32 },
640 { prop_interfaceindexW, CIM_UINT32 },
641 { prop_macaddressW, CIM_STRING|COL_FLAG_DYNAMIC },
642 { prop_manufacturerW, CIM_STRING },
643 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
644 { prop_netconnectionstatusW, CIM_UINT16 },
645 { prop_physicaladapterW, CIM_BOOLEAN },
646 { prop_pnpdeviceidW, CIM_STRING },
647 { prop_speedW, CIM_UINT64 }
648 };
649 static const struct column col_networkadapterconfig[] =
650 {
651 { prop_defaultipgatewayW, CIM_STRING|CIM_FLAG_ARRAY|COL_FLAG_DYNAMIC },
652 { prop_descriptionW, CIM_STRING|COL_FLAG_DYNAMIC },
653 { prop_dhcpenabledW, CIM_BOOLEAN },
654 { prop_dnshostnameW, CIM_STRING|COL_FLAG_DYNAMIC },
655 { prop_dnsserversearchorderW, CIM_STRING|CIM_FLAG_ARRAY|COL_FLAG_DYNAMIC },
656 { prop_indexW, CIM_UINT32|COL_FLAG_KEY },
657 { prop_ipaddressW, CIM_STRING|CIM_FLAG_ARRAY|COL_FLAG_DYNAMIC },
658 { prop_ipconnectionmetricW, CIM_UINT32 },
659 { prop_ipenabledW, CIM_BOOLEAN },
660 { prop_ipsubnet, CIM_STRING|CIM_FLAG_ARRAY|COL_FLAG_DYNAMIC },
661 { prop_macaddressW, CIM_STRING|COL_FLAG_DYNAMIC },
662 { prop_settingidW, CIM_STRING|COL_FLAG_DYNAMIC }
663 };
664 static const struct column col_operatingsystem[] =
665 {
666 { prop_buildnumberW, CIM_STRING|COL_FLAG_DYNAMIC },
667 { prop_captionW, CIM_STRING|COL_FLAG_DYNAMIC },
668 { prop_codesetW, CIM_STRING|COL_FLAG_DYNAMIC },
669 { prop_countrycodeW, CIM_STRING|COL_FLAG_DYNAMIC },
670 { prop_csdversionW, CIM_STRING|COL_FLAG_DYNAMIC },
671 { prop_csnameW, CIM_STRING|COL_FLAG_DYNAMIC },
672 { prop_currenttimezoneW, CIM_SINT16 },
673 { prop_freephysicalmemoryW, CIM_UINT64 },
674 { prop_installdateW, CIM_DATETIME },
675 { prop_lastbootuptimeW, CIM_DATETIME|COL_FLAG_DYNAMIC },
676 { prop_localdatetimeW, CIM_DATETIME|COL_FLAG_DYNAMIC },
677 { prop_localeW, CIM_STRING|COL_FLAG_DYNAMIC },
678 { prop_manufacturerW, CIM_STRING },
679 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
680 { prop_operatingsystemskuW, CIM_UINT32 },
681 { prop_osarchitectureW, CIM_STRING },
682 { prop_oslanguageW, CIM_UINT32 },
683 { prop_osproductsuiteW, CIM_UINT32 },
684 { prop_ostypeW, CIM_UINT16 },
685 { prop_primaryW, CIM_BOOLEAN },
686 { prop_serialnumberW, CIM_STRING },
687 { prop_servicepackmajorW, CIM_UINT16 },
688 { prop_servicepackminorW, CIM_UINT16 },
689 { prop_suitemaskW, CIM_UINT32 },
690 { prop_systemdirectoryW, CIM_STRING|COL_FLAG_DYNAMIC },
691 { prop_systemdriveW, CIM_STRING|COL_FLAG_DYNAMIC },
692 { prop_totalvirtualmemorysizeW, CIM_UINT64 },
693 { prop_totalvisiblememorysizeW, CIM_UINT64 },
694 { prop_versionW, CIM_STRING|COL_FLAG_DYNAMIC }
695 };
696 static const struct column col_param[] =
697 {
698 { prop_classW, CIM_STRING },
699 { prop_methodW, CIM_STRING },
700 { prop_directionW, CIM_SINT32 },
701 { prop_parameterW, CIM_STRING },
702 { prop_typeW, CIM_UINT32 },
703 { prop_defaultvalueW, CIM_UINT32 }
704 };
705 static const struct column col_physicalmedia[] =
706 {
707 { prop_serialnumberW, CIM_STRING },
708 { prop_tagW, CIM_STRING }
709 };
710 static const struct column col_physicalmemory[] =
711 {
712 { prop_capacityW, CIM_UINT64 },
713 { prop_configuredclockspeedW, CIM_UINT32 },
714 { prop_devicelocatorW, CIM_STRING },
715 { prop_memorytypeW, CIM_UINT16 },
716 { prop_partnumberW, CIM_STRING }
717 };
718 static const struct column col_pnpentity[] =
719 {
720 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC },
721 };
722 static const struct column col_printer[] =
723 {
724 { prop_attributesW, CIM_UINT32 },
725 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
726 { prop_drivernameW, CIM_STRING|COL_FLAG_DYNAMIC },
727 { prop_horizontalresolutionW, CIM_UINT32 },
728 { prop_localW, CIM_BOOLEAN },
729 { prop_locationW, CIM_STRING|COL_FLAG_DYNAMIC },
730 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
731 { prop_networkW, CIM_BOOLEAN },
732 { prop_portnameW, CIM_STRING|COL_FLAG_DYNAMIC },
733 };
734 static const struct column col_process[] =
735 {
736 { prop_captionW, CIM_STRING|COL_FLAG_DYNAMIC },
737 { prop_commandlineW, CIM_STRING|COL_FLAG_DYNAMIC },
738 { prop_descriptionW, CIM_STRING|COL_FLAG_DYNAMIC },
739 { prop_handleW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
740 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
741 { prop_pprocessidW, CIM_UINT32 },
742 { prop_processidW, CIM_UINT32 },
743 { prop_threadcountW, CIM_UINT32 },
744 { prop_workingsetsizeW, CIM_UINT64 },
745 /* methods */
746 { method_getownerW, CIM_FLAG_ARRAY|COL_FLAG_METHOD }
747 };
748 static const struct column col_processor[] =
749 {
750 { prop_addresswidthW, CIM_UINT16 },
751 { prop_architectureW, CIM_UINT16 },
752 { prop_captionW, CIM_STRING|COL_FLAG_DYNAMIC },
753 { prop_cpustatusW, CIM_UINT16 },
754 { prop_currentclockspeedW, CIM_UINT32 },
755 { prop_datawidthW, CIM_UINT16 },
756 { prop_descriptionW, CIM_STRING|COL_FLAG_DYNAMIC },
757 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
758 { prop_familyW, CIM_UINT16 },
759 { prop_levelW, CIM_UINT16 },
760 { prop_manufacturerW, CIM_STRING|COL_FLAG_DYNAMIC },
761 { prop_maxclockspeedW, CIM_UINT32 },
762 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
763 { prop_numcoresW, CIM_UINT32 },
764 { prop_numlogicalprocessorsW, CIM_UINT32 },
765 { prop_processoridW, CIM_STRING|COL_FLAG_DYNAMIC },
766 { prop_processortypeW, CIM_UINT16 },
767 { prop_revisionW, CIM_UINT16 },
768 { prop_uniqueidW, CIM_STRING },
769 { prop_versionW, CIM_STRING|COL_FLAG_DYNAMIC }
770 };
771 static const struct column col_qualifier[] =
772 {
773 { prop_classW, CIM_STRING },
774 { prop_memberW, CIM_STRING },
775 { prop_typeW, CIM_UINT32 },
776 { prop_flavorW, CIM_SINT32 },
777 { prop_nameW, CIM_STRING },
778 { prop_intvalueW, CIM_SINT32 },
779 { prop_strvalueW, CIM_STRING },
780 { prop_boolvalueW, CIM_BOOLEAN }
781 };
782 static const struct column col_quickfixengineering[] =
783 {
784 { prop_captionW, CIM_STRING },
785 { prop_hotfixidW, CIM_STRING|COL_FLAG_KEY }
786 };
787 static const struct column col_service[] =
788 {
789 { prop_acceptpauseW, CIM_BOOLEAN },
790 { prop_acceptstopW, CIM_BOOLEAN },
791 { prop_displaynameW, CIM_STRING|COL_FLAG_DYNAMIC },
792 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
793 { prop_processidW, CIM_UINT32 },
794 { prop_servicetypeW, CIM_STRING },
795 { prop_startmodeW, CIM_STRING },
796 { prop_stateW, CIM_STRING },
797 { prop_systemnameW, CIM_STRING|COL_FLAG_DYNAMIC },
798 /* methods */
799 { method_pauseserviceW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
800 { method_resumeserviceW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
801 { method_startserviceW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
802 { method_stopserviceW, CIM_FLAG_ARRAY|COL_FLAG_METHOD }
803 };
804 static const struct column col_sid[] =
805 {
806 { prop_accountnameW, CIM_STRING|COL_FLAG_DYNAMIC },
807 { prop_binaryrepresentationW, CIM_UINT8|CIM_FLAG_ARRAY|COL_FLAG_DYNAMIC },
808 { prop_referenceddomainnameW, CIM_STRING|COL_FLAG_DYNAMIC },
809 { prop_sidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
810 { prop_sidlengthW, CIM_UINT32 }
811 };
812 static const struct column col_sounddevice[] =
813 {
814 { prop_nameW, CIM_STRING },
815 { prop_productnameW, CIM_STRING },
816 { prop_statusinfoW, CIM_UINT16 }
817 };
818 static const struct column col_stdregprov[] =
819 {
820 { method_createkeyW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
821 { method_enumkeyW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
822 { method_enumvaluesW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
823 { method_getstringvalueW, CIM_FLAG_ARRAY|COL_FLAG_METHOD }
824 };
825 static const struct column col_systemenclosure[] =
826 {
827 { prop_captionW, CIM_STRING },
828 { prop_chassistypesW, CIM_UINT16|CIM_FLAG_ARRAY|COL_FLAG_DYNAMIC },
829 { prop_descriptionW, CIM_STRING },
830 { prop_lockpresentW, CIM_BOOLEAN },
831 { prop_manufacturerW, CIM_STRING|COL_FLAG_DYNAMIC },
832 { prop_nameW, CIM_STRING },
833 { prop_tagW, CIM_STRING },
834 };
835 static const struct column col_systemsecurity[] =
836 {
837 { method_getsdW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
838 { method_setsdW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
839 };
840
841 #ifndef __REACTOS__
842 static const struct column col_videocontroller[] =
843 {
844 { prop_adapterdactypeW, CIM_STRING },
845 { prop_adapterramW, CIM_UINT32 },
846 { prop_availabilityW, CIM_UINT16 },
847 { prop_captionW, CIM_STRING|COL_FLAG_DYNAMIC },
848 { prop_configmanagererrorcodeW, CIM_UINT32 },
849 { prop_currentbitsperpixelW, CIM_UINT32 },
850 { prop_currenthorizontalresW, CIM_UINT32 },
851 { prop_currentrefreshrateW, CIM_UINT32 },
852 { prop_currentscanmodeW, CIM_UINT16 },
853 { prop_currentverticalresW, CIM_UINT32 },
854 { prop_descriptionW, CIM_STRING|COL_FLAG_DYNAMIC },
855 { prop_deviceidW, CIM_STRING|COL_FLAG_KEY },
856 { prop_driverdateW, CIM_DATETIME },
857 { prop_driverversionW, CIM_STRING },
858 { prop_installeddisplaydriversW,CIM_STRING },
859 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
860 { prop_pnpdeviceidW, CIM_STRING|COL_FLAG_DYNAMIC },
861 { prop_statusW, CIM_STRING },
862 { prop_videoarchitectureW, CIM_UINT16 },
863 { prop_videomemorytypeW, CIM_UINT16 },
864 { prop_videomodedescriptionW, CIM_STRING|COL_FLAG_DYNAMIC },
865 { prop_videoprocessorW, CIM_STRING|COL_FLAG_DYNAMIC },
866 };
867 #endif
868
869 static const struct column col_winsat[] =
870 {
871 { prop_cpuscoreW, CIM_REAL32 },
872 { prop_d3dscoreW, CIM_REAL32 },
873 { prop_diskscoreW, CIM_REAL32 },
874 { prop_graphicsscoreW, CIM_REAL32 },
875 { prop_memoryscoreW, CIM_REAL32 },
876 { prop_timetakenW, CIM_STRING|COL_FLAG_KEY },
877 { prop_winsatassessmentstateW, CIM_UINT32 },
878 { prop_winsprlevelW, CIM_REAL32 },
879 };
880
881
882 static const WCHAR baseboard_manufacturerW[] =
883 {'I','n','t','e','l',' ','C','o','r','p','o','r','a','t','i','o','n',0};
884 static const WCHAR baseboard_serialnumberW[] =
885 {'N','o','n','e',0};
886 static const WCHAR baseboard_tagW[] =
887 {'B','a','s','e',' ','B','o','a','r','d',0};
888 static const WCHAR baseboard_versionW[] =
889 {'1','.','0',0};
890 static const WCHAR bios_descriptionW[] =
891 {'D','e','f','a','u','l','t',' ','S','y','s','t','e','m',' ','B','I','O','S',0};
892 static const WCHAR bios_manufacturerW[] =
893 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
894 static const WCHAR bios_releasedateW[] =
895 {'2','0','1','2','0','6','0','8','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
896 static const WCHAR bios_serialnumberW[] =
897 {'0',0};
898 static const WCHAR bios_smbiosbiosversionW[] =
899 {'W','i','n','e',0};
900 static const WCHAR bios_versionW[] =
901 {'W','I','N','E',' ',' ',' ','-',' ','1',0};
902 static const WCHAR cdromdrive_mediatypeW[] =
903 {'C','D','-','R','O','M',0};
904 static const WCHAR cdromdrive_nameW[] =
905 {'W','i','n','e',' ','C','D','-','R','O','M',' ','A','T','A',' ','D','e','v','i','c','e',0};
906 static const WCHAR cdromdrive_pnpdeviceidW[]=
907 {'I','D','E','\\','C','D','R','O','M','W','I','N','E','_','C','D','-','R','O','M',
908 '_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_',
909 '_','_','_','_','_','_','_','1','.','0','_','_','_','_','_','\\','5','&','3','A','2',
910 'A','5','8','5','4','&','0','&','1','.','0','.','0',0};
911 static const WCHAR compsys_descriptionW[] =
912 {'A','T','/','A','T',' ','C','O','M','P','A','T','I','B','L','E',0};
913 static const WCHAR compsys_domainW[] =
914 {'W','O','R','K','G','R','O','U','P',0};
915 static const WCHAR compsys_manufacturerW[] =
916 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
917 static const WCHAR compsys_modelW[] =
918 {'W','i','n','e',0};
919 static const WCHAR compsysproduct_identifyingnumberW[] =
920 {'0',0};
921 static const WCHAR compsysproduct_nameW[] =
922 {'W','i','n','e',0};
923 static const WCHAR compsysproduct_uuidW[] =
924 {'d','e','a','d','d','e','a','d','-','d','e','a','d','-','d','e','a','d','-','d','e','a','d','-',
925 'd','e','a','d','d','e','a','d','d','e','a','d',0};
926 static const WCHAR compsysproduct_vendorW[] =
927 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
928 static const WCHAR compsysproduct_versionW[] =
929 {'1','.','0',0};
930 static const WCHAR diskdrive_interfacetypeW[] =
931 {'I','D','E',0};
932 static const WCHAR diskdrive_manufacturerW[] =
933 {'(','S','t','a','n','d','a','r','d',' ','d','i','s','k',' ','d','r','i','v','e','s',')',0};
934 static const WCHAR diskdrive_mediatype_fixedW[] =
935 {'F','i','x','e','d',' ','h','a','r','d',' ','d','i','s','k',0};
936 static const WCHAR diskdrive_mediatype_removableW[] =
937 {'R','e','m','o','v','a','b','l','e',' ','m','e','d','i','a',0};
938 static const WCHAR diskdrive_modelW[] =
939 {'W','i','n','e',' ','D','i','s','k',' ','D','r','i','v','e',0};
940 static const WCHAR diskdrive_pnpdeviceidW[] =
941 {'I','D','E','\\','D','i','s','k','\\','V','E','N','_','W','I','N','E',0};
942 static const WCHAR diskdrive_serialW[] =
943 {'W','I','N','E','H','D','I','S','K',0};
944 static const WCHAR networkadapter_pnpdeviceidW[]=
945 {'P','C','I','\\','V','E','N','_','8','0','8','6','&','D','E','V','_','1','0','0','E','&',
946 'S','U','B','S','Y','S','_','0','0','1','E','8','0','8','6','&','R','E','V','_','0','2','\\',
947 '3','&','2','6','7','A','6','1','6','A','&','1','&','1','8',0};
948 static const WCHAR os_32bitW[] =
949 {'3','2','-','b','i','t',0};
950 static const WCHAR os_64bitW[] =
951 {'6','4','-','b','i','t',0};
952 static const WCHAR os_installdateW[] =
953 {'2','0','1','4','0','1','0','1','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
954 static const WCHAR os_serialnumberW[] =
955 {'1','2','3','4','5','-','O','E','M','-','1','2','3','4','5','6','7','-','1','2','3','4','5',0};
956 static const WCHAR physicalmedia_tagW[] =
957 {'\\','\\','.','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','0',0};
958 static const WCHAR quickfixengineering_captionW[] =
959 {'h','t','t','p',':','/','/','w','i','n','e','h','q','.','o','r','g',0};
960 static const WCHAR quickfixengineering_hotfixidW[] =
961 {'K','B','1','2','3','4','5','6','7',0};
962 static const WCHAR sounddevice_productnameW[] =
963 {'W','i','n','e',' ','A','u','d','i','o',' ','D','e','v','i','c','e',0};
964 static const WCHAR systemenclosure_systemenclosureW[] =
965 {'S','y','s','t','e','m',' ','E','n','c','l','o','s','u','r','e',0};
966 static const WCHAR systemenclosure_tagW[] =
967 {'S','y','s','t','e','m',' ','E','n','c','l','o','s','u','r','e',' ','0',0};
968 static const WCHAR systemenclosure_manufacturerW[] =
969 {'W','i','n','e',0};
970 static const WCHAR videocontroller_dactypeW[] =
971 {'I','n','t','e','g','r','a','t','e','d',' ','R','A','M','D','A','C',0};
972 static const WCHAR videocontroller_deviceidW[] =
973 {'V','i','d','e','o','C','o','n','t','r','o','l','l','e','r','1',0};
974 static const WCHAR videocontroller_driverdateW[] =
975 {'2','0','1','7','0','1','0','1','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
976 static const WCHAR videocontroller_driverversionW[] =
977 {'1','.','0',0};
978 static const WCHAR videocontroller_statusW[] =
979 {'O','K',0};
980 static const WCHAR winsat_timetakenW[] =
981 {'M','o','s','t','R','e','c','e','n','t','A','s','s','e','s','s','m','e','n','t',0};
982
983 #include "pshpack1.h"
984 struct record_associator
985 {
986 const WCHAR *assocclass;
987 const WCHAR *class;
988 const WCHAR *associator;
989 };
990 struct record_baseboard
991 {
992 const WCHAR *manufacturer;
993 const WCHAR *model;
994 const WCHAR *name;
995 const WCHAR *product;
996 const WCHAR *serialnumber;
997 const WCHAR *tag;
998 const WCHAR *version;
999 };
1000 struct record_bios
1001 {
1002 const WCHAR *currentlanguage;
1003 const WCHAR *description;
1004 const WCHAR *identificationcode;
1005 const WCHAR *manufacturer;
1006 const WCHAR *name;
1007 const WCHAR *releasedate;
1008 const WCHAR *serialnumber;
1009 const WCHAR *smbiosbiosversion;
1010 UINT16 smbiosmajorversion;
1011 UINT16 smbiosminorversion;
1012 const WCHAR *version;
1013 };
1014 struct record_cdromdrive
1015 {
1016 const WCHAR *device_id;
1017 const WCHAR *drive;
1018 const WCHAR *mediatype;
1019 const WCHAR *name;
1020 const WCHAR *pnpdevice_id;
1021 };
1022 struct record_computersystem
1023 {
1024 const WCHAR *description;
1025 const WCHAR *domain;
1026 UINT16 domainrole;
1027 const WCHAR *manufacturer;
1028 const WCHAR *model;
1029 const WCHAR *name;
1030 UINT32 num_logical_processors;
1031 UINT32 num_processors;
1032 UINT64 total_physical_memory;
1033 const WCHAR *username;
1034 };
1035 struct record_computersystemproduct
1036 {
1037 const WCHAR *identifyingnumber;
1038 const WCHAR *name;
1039 const WCHAR *skunumber;
1040 const WCHAR *uuid;
1041 const WCHAR *vendor;
1042 const WCHAR *version;
1043 };
1044 struct record_datafile
1045 {
1046 const WCHAR *name;
1047 const WCHAR *version;
1048 };
1049 struct record_desktopmonitor
1050 {
1051 UINT32 pixelsperxlogicalinch;
1052 };
1053 struct record_directory
1054 {
1055 UINT32 accessmask;
1056 const WCHAR *name;
1057 };
1058 struct record_diskdrive
1059 {
1060 const WCHAR *device_id;
1061 UINT32 index;
1062 const WCHAR *interfacetype;
1063 const WCHAR *manufacturer;
1064 const WCHAR *mediatype;
1065 const WCHAR *model;
1066 const WCHAR *pnpdevice_id;
1067 const WCHAR *serialnumber;
1068 UINT64 size;
1069 };
1070 struct record_diskdrivetodiskpartition
1071 {
1072 const WCHAR *antecedent;
1073 const WCHAR *dependent;
1074 };
1075 struct record_diskpartition
1076 {
1077 int bootable;
1078 int bootpartition;
1079 const WCHAR *device_id;
1080 UINT32 diskindex;
1081 UINT32 index;
1082 const WCHAR *pnpdevice_id;
1083 UINT64 size;
1084 UINT64 startingoffset;
1085 const WCHAR *type;
1086 };
1087 struct record_displaycontrollerconfig
1088 {
1089 UINT32 bitsperpixel;
1090 const WCHAR *caption;
1091 UINT32 horizontalresolution;
1092 const WCHAR *name;
1093 UINT32 verticalresolution;
1094 };
1095 struct record_ip4routetable
1096 {
1097 const WCHAR *destination;
1098 INT32 interfaceindex;
1099 const WCHAR *nexthop;
1100 };
1101 struct record_logicaldisk
1102 {
1103 const WCHAR *device_id;
1104 UINT32 drivetype;
1105 const WCHAR *filesystem;
1106 UINT64 freespace;
1107 const WCHAR *name;
1108 UINT64 size;
1109 const WCHAR *volumename;
1110 const WCHAR *volumeserialnumber;
1111 };
1112 struct record_logicaldisktopartition
1113 {
1114 const WCHAR *antecedent;
1115 const WCHAR *dependent;
1116 };
1117 struct record_networkadapter
1118 {
1119 const WCHAR *adaptertype;
1120 UINT16 adaptertypeid;
1121 const WCHAR *description;
1122 const WCHAR *device_id;
1123 UINT32 index;
1124 UINT32 interface_index;
1125 const WCHAR *mac_address;
1126 const WCHAR *manufacturer;
1127 const WCHAR *name;
1128 UINT16 netconnection_status;
1129 int physicaladapter;
1130 const WCHAR *pnpdevice_id;
1131 UINT64 speed;
1132 };
1133 struct record_networkadapterconfig
1134 {
1135 const struct array *defaultipgateway;
1136 const WCHAR *description;
1137 int dhcpenabled;
1138 const WCHAR *dnshostname;
1139 const struct array *dnsserversearchorder;
1140 UINT32 index;
1141 const struct array *ipaddress;
1142 UINT32 ipconnectionmetric;
1143 int ipenabled;
1144 const struct array *ipsubnet;
1145 const WCHAR *mac_address;
1146 const WCHAR *settingid;
1147 };
1148 struct record_operatingsystem
1149 {
1150 const WCHAR *buildnumber;
1151 const WCHAR *caption;
1152 const WCHAR *codeset;
1153 const WCHAR *countrycode;
1154 const WCHAR *csdversion;
1155 const WCHAR *csname;
1156 INT16 currenttimezone;
1157 UINT64 freephysicalmemory;
1158 const WCHAR *installdate;
1159 const WCHAR *lastbootuptime;
1160 const WCHAR *localdatetime;
1161 const WCHAR *locale;
1162 const WCHAR *manufacturer;
1163 const WCHAR *name;
1164 UINT32 operatingsystemsku;
1165 const WCHAR *osarchitecture;
1166 UINT32 oslanguage;
1167 UINT32 osproductsuite;
1168 UINT16 ostype;
1169 int primary;
1170 const WCHAR *serialnumber;
1171 UINT16 servicepackmajor;
1172 UINT16 servicepackminor;
1173 UINT32 suitemask;
1174 const WCHAR *systemdirectory;
1175 const WCHAR *systemdrive;
1176 UINT64 totalvirtualmemorysize;
1177 UINT64 totalvisiblememorysize;
1178 const WCHAR *version;
1179 };
1180 struct record_param
1181 {
1182 const WCHAR *class;
1183 const WCHAR *method;
1184 INT32 direction;
1185 const WCHAR *parameter;
1186 UINT32 type;
1187 UINT32 defaultvalue;
1188 };
1189 struct record_physicalmedia
1190 {
1191 const WCHAR *serialnumber;
1192 const WCHAR *tag;
1193 };
1194 struct record_physicalmemory
1195 {
1196 UINT64 capacity;
1197 UINT32 configuredclockspeed;
1198 const WCHAR *devicelocator;
1199 UINT16 memorytype;
1200 const WCHAR *partnumber;
1201 };
1202 struct record_pnpentity
1203 {
1204 const WCHAR *device_id;
1205 };
1206 struct record_printer
1207 {
1208 UINT32 attributes;
1209 const WCHAR *device_id;
1210 const WCHAR *drivername;
1211 UINT32 horizontalresolution;
1212 int local;
1213 const WCHAR *location;
1214 const WCHAR *name;
1215 int network;
1216 const WCHAR *portname;
1217 };
1218 struct record_process
1219 {
1220 const WCHAR *caption;
1221 const WCHAR *commandline;
1222 const WCHAR *description;
1223 const WCHAR *handle;
1224 const WCHAR *name;
1225 UINT32 pprocess_id;
1226 UINT32 process_id;
1227 UINT32 thread_count;
1228 UINT64 workingsetsize;
1229 /* methods */
1230 class_method *get_owner;
1231 };
1232 struct record_processor
1233 {
1234 UINT16 addresswidth;
1235 UINT16 architecture;
1236 const WCHAR *caption;
1237 UINT16 cpu_status;
1238 UINT32 currentclockspeed;
1239 UINT16 datawidth;
1240 const WCHAR *description;
1241 const WCHAR *device_id;
1242 UINT16 family;
1243 UINT16 level;
1244 const WCHAR *manufacturer;
1245 UINT32 maxclockspeed;
1246 const WCHAR *name;
1247 UINT32 num_cores;
1248 UINT32 num_logical_processors;
1249 const WCHAR *processor_id;
1250 UINT16 processortype;
1251 UINT16 revision;
1252 const WCHAR *unique_id;
1253 const WCHAR *version;
1254 };
1255 struct record_qualifier
1256 {
1257 const WCHAR *class;
1258 const WCHAR *member;
1259 UINT32 type;
1260 INT32 flavor;
1261 const WCHAR *name;
1262 INT32 intvalue;
1263 const WCHAR *strvalue;
1264 int boolvalue;
1265 };
1266 struct record_quickfixengineering
1267 {
1268 const WCHAR *caption;
1269 const WCHAR *hotfixid;
1270 };
1271 struct record_service
1272 {
1273 int accept_pause;
1274 int accept_stop;
1275 const WCHAR *displayname;
1276 const WCHAR *name;
1277 UINT32 process_id;
1278 const WCHAR *servicetype;
1279 const WCHAR *startmode;
1280 const WCHAR *state;
1281 const WCHAR *systemname;
1282 /* methods */
1283 class_method *pause_service;
1284 class_method *resume_service;
1285 class_method *start_service;
1286 class_method *stop_service;
1287 };
1288 struct record_sid
1289 {
1290 const WCHAR *accountname;
1291 const struct array *binaryrepresentation;
1292 const WCHAR *referenceddomainname;
1293 const WCHAR *sid;
1294 UINT32 sidlength;
1295 };
1296 struct record_sounddevice
1297 {
1298 const WCHAR *name;
1299 const WCHAR *productname;
1300 UINT16 statusinfo;
1301 };
1302 struct record_stdregprov
1303 {
1304 class_method *createkey;
1305 class_method *enumkey;
1306 class_method *enumvalues;
1307 class_method *getstringvalue;
1308 };
1309 struct record_systemsecurity
1310 {
1311 class_method *getsd;
1312 class_method *setsd;
1313 };
1314 struct record_systemenclosure
1315 {
1316 const WCHAR *caption;
1317 const struct array *chassistypes;
1318 const WCHAR *description;
1319 int lockpresent;
1320 const WCHAR *manufacturer;
1321 const WCHAR *name;
1322 const WCHAR *tag;
1323 };
1324 struct record_videocontroller
1325 {
1326 const WCHAR *adapter_dactype;
1327 UINT32 adapter_ram;
1328 UINT16 availability;
1329 const WCHAR *caption;
1330 UINT32 config_errorcode;
1331 UINT32 current_bitsperpixel;
1332 UINT32 current_horizontalres;
1333 UINT32 current_refreshrate;
1334 UINT16 current_scanmode;
1335 UINT32 current_verticalres;
1336 const WCHAR *description;
1337 const WCHAR *device_id;
1338 const WCHAR *driverdate;
1339 const WCHAR *driverversion;
1340 const WCHAR *installeddriver;
1341 const WCHAR *name;
1342 const WCHAR *pnpdevice_id;
1343 const WCHAR *status;
1344 UINT16 videoarchitecture;
1345 UINT16 videomemorytype;
1346 const WCHAR *videomodedescription;
1347 const WCHAR *videoprocessor;
1348 };
1349 struct record_winsat
1350 {
1351 FLOAT cpuscore;
1352 FLOAT d3dscore;
1353 FLOAT diskscrore;
1354 FLOAT graphicsscore;
1355 FLOAT memoryscore;
1356 const WCHAR *timetaken;
1357 UINT32 winsatassessmentstate;
1358 FLOAT winsprlevel;
1359 };
1360 #include "poppack.h"
1361
1362 static const struct record_associator data_associator[] =
1363 {
1364 { class_diskdrivetodiskpartitionW, class_diskpartitionW, class_diskdriveW },
1365 { class_logicaldisktopartitionW, class_logicaldiskW, class_diskpartitionW },
1366 };
1367 static const struct record_param data_param[] =
1368 {
1369 { class_processW, method_getownerW, -1, param_returnvalueW, CIM_UINT32 },
1370 { class_processW, method_getownerW, -1, param_userW, CIM_STRING },
1371 { class_processW, method_getownerW, -1, param_domainW, CIM_STRING },
1372 { class_serviceW, method_pauseserviceW, -1, param_returnvalueW, CIM_UINT32 },
1373 { class_serviceW, method_resumeserviceW, -1, param_returnvalueW, CIM_UINT32 },
1374 { class_serviceW, method_startserviceW, -1, param_returnvalueW, CIM_UINT32 },
1375 { class_serviceW, method_stopserviceW, -1, param_returnvalueW, CIM_UINT32 },
1376 { class_stdregprovW, method_createkeyW, 1, param_defkeyW, CIM_SINT32, 0x80000002 },
1377 { class_stdregprovW, method_createkeyW, 1, param_subkeynameW, CIM_STRING },
1378 { class_stdregprovW, method_createkeyW, -1, param_returnvalueW, CIM_UINT32 },
1379 { class_stdregprovW, method_enumkeyW, 1, param_defkeyW, CIM_SINT32, 0x80000002 },
1380 { class_stdregprovW, method_enumkeyW, 1, param_subkeynameW, CIM_STRING },
1381 { class_stdregprovW, method_enumkeyW, -1, param_returnvalueW, CIM_UINT32 },
1382 { class_stdregprovW, method_enumkeyW, -1, param_namesW, CIM_STRING|CIM_FLAG_ARRAY },
1383 { class_stdregprovW, method_enumvaluesW, 1, param_defkeyW, CIM_SINT32, 0x80000002 },
1384 { class_stdregprovW, method_enumvaluesW, 1, param_subkeynameW, CIM_STRING },
1385 { class_stdregprovW, method_enumvaluesW, -1, param_returnvalueW, CIM_UINT32 },
1386 { class_stdregprovW, method_enumvaluesW, -1, param_namesW, CIM_STRING|CIM_FLAG_ARRAY },
1387 { class_stdregprovW, method_enumvaluesW, -1, param_typesW, CIM_SINT32|CIM_FLAG_ARRAY },
1388 { class_stdregprovW, method_getstringvalueW, 1, param_defkeyW, CIM_SINT32, 0x80000002 },
1389 { class_stdregprovW, method_getstringvalueW, 1, param_subkeynameW, CIM_STRING },
1390 { class_stdregprovW, method_getstringvalueW, 1, param_valuenameW, CIM_STRING },
1391 { class_stdregprovW, method_getstringvalueW, -1, param_returnvalueW, CIM_UINT32 },
1392 { class_stdregprovW, method_getstringvalueW, -1, param_valueW, CIM_STRING },
1393 { class_systemsecurityW, method_getsdW, -1, param_returnvalueW, CIM_UINT32 },
1394 { class_systemsecurityW, method_getsdW, -1, param_sdW, CIM_UINT8|CIM_FLAG_ARRAY },
1395 { class_systemsecurityW, method_setsdW, 1, param_sdW, CIM_UINT8|CIM_FLAG_ARRAY },
1396 { class_systemsecurityW, method_setsdW, -1, param_returnvalueW, CIM_UINT32 },
1397 };
1398
1399 #define FLAVOR_ID (WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE | WBEM_FLAVOR_NOT_OVERRIDABLE |\
1400 WBEM_FLAVOR_ORIGIN_PROPAGATED)
1401
1402 static const struct record_physicalmedia data_physicalmedia[] =
1403 {
1404 { diskdrive_serialW, physicalmedia_tagW }
1405 };
1406 static const struct record_qualifier data_qualifier[] =
1407 {
1408 { class_process_getowner_outW, param_userW, CIM_SINT32, FLAVOR_ID, prop_idW, 0 },
1409 { class_process_getowner_outW, param_domainW, CIM_SINT32, FLAVOR_ID, prop_idW, 1 }
1410 };
1411 static const struct record_quickfixengineering data_quickfixengineering[] =
1412 {
1413 { quickfixengineering_captionW, quickfixengineering_hotfixidW },
1414 };
1415 static const struct record_sounddevice data_sounddevice[] =
1416 {
1417 { sounddevice_productnameW, sounddevice_productnameW, 3 /* enabled */ }
1418 };
1419 static const struct record_stdregprov data_stdregprov[] =
1420 {
1421 { reg_create_key, reg_enum_key, reg_enum_values, reg_get_stringvalue }
1422 };
1423 static UINT16 systemenclosure_chassistypes[] =
1424 {
1425 1,
1426 };
1427 static const struct array systemenclosure_chassistypes_array =
1428 {
1429 sizeof(*systemenclosure_chassistypes),
1430 ARRAY_SIZE(systemenclosure_chassistypes),
1431 &systemenclosure_chassistypes
1432 };
1433 static const struct record_systemsecurity data_systemsecurity[] =
1434 {
1435 { security_get_sd, security_set_sd }
1436 };
1437 static const struct record_winsat data_winsat[] =
1438 {
1439 { 8.0f, 8.0f, 8.0f, 8.0f, 8.0f, winsat_timetakenW, 1 /* Valid */, 8.0f },
1440 };
1441
1442 /* check if row matches condition and update status */
match_row(const struct table * table,UINT row,const struct expr * cond,enum fill_status * status)1443 static BOOL match_row( const struct table *table, UINT row, const struct expr *cond, enum fill_status *status )
1444 {
1445 LONGLONG val;
1446 UINT type;
1447
1448 if (!cond)
1449 {
1450 *status = FILL_STATUS_UNFILTERED;
1451 return TRUE;
1452 }
1453 if (eval_cond( table, row, cond, &val, &type ) != S_OK)
1454 {
1455 *status = FILL_STATUS_FAILED;
1456 return FALSE;
1457 }
1458 *status = FILL_STATUS_FILTERED;
1459 return val != 0;
1460 }
1461
resize_table(struct table * table,UINT row_count,UINT row_size)1462 static BOOL resize_table( struct table *table, UINT row_count, UINT row_size )
1463 {
1464 if (!table->num_rows_allocated)
1465 {
1466 if (!(table->data = heap_alloc( row_count * row_size ))) return FALSE;
1467 table->num_rows_allocated = row_count;
1468 return TRUE;
1469 }
1470 if (row_count > table->num_rows_allocated)
1471 {
1472 BYTE *data;
1473 UINT count = max( row_count, table->num_rows_allocated * 2 );
1474 if (!(data = heap_realloc( table->data, count * row_size ))) return FALSE;
1475 table->data = data;
1476 table->num_rows_allocated = count;
1477 }
1478 return TRUE;
1479 }
1480
1481 #include "pshpack1.h"
1482 struct smbios_prologue
1483 {
1484 BYTE calling_method;
1485 BYTE major_version;
1486 BYTE minor_version;
1487 BYTE revision;
1488 DWORD length;
1489 };
1490
1491 enum smbios_type
1492 {
1493 SMBIOS_TYPE_BIOS,
1494 SMBIOS_TYPE_SYSTEM,
1495 SMBIOS_TYPE_BASEBOARD,
1496 SMBIOS_TYPE_CHASSIS,
1497 };
1498
1499 struct smbios_header
1500 {
1501 BYTE type;
1502 BYTE length;
1503 WORD handle;
1504 };
1505
1506 struct smbios_baseboard
1507 {
1508 struct smbios_header hdr;
1509 BYTE vendor;
1510 BYTE product;
1511 BYTE version;
1512 BYTE serial;
1513 };
1514
1515 struct smbios_bios
1516 {
1517 struct smbios_header hdr;
1518 BYTE vendor;
1519 BYTE version;
1520 WORD start;
1521 BYTE date;
1522 BYTE size;
1523 UINT64 characteristics;
1524 };
1525
1526 struct smbios_chassis
1527 {
1528 struct smbios_header hdr;
1529 BYTE vendor;
1530 BYTE type;
1531 BYTE version;
1532 BYTE serial;
1533 BYTE asset_tag;
1534 };
1535
1536 struct smbios_system
1537 {
1538 struct smbios_header hdr;
1539 BYTE vendor;
1540 BYTE product;
1541 BYTE version;
1542 BYTE serial;
1543 BYTE uuid[16];
1544 };
1545 #include "poppack.h"
1546
1547 #define RSMB (('R' << 24) | ('S' << 16) | ('M' << 8) | 'B')
1548
find_smbios_entry(enum smbios_type type,const char * buf,UINT len)1549 static const struct smbios_header *find_smbios_entry( enum smbios_type type, const char *buf, UINT len )
1550 {
1551 const char *ptr, *start;
1552 const struct smbios_prologue *prologue;
1553 const struct smbios_header *hdr;
1554
1555 if (len < sizeof(struct smbios_prologue)) return NULL;
1556 prologue = (const struct smbios_prologue *)buf;
1557 if (prologue->length > len - sizeof(*prologue) || prologue->length < sizeof(*hdr)) return NULL;
1558
1559 start = (const char *)(prologue + 1);
1560 hdr = (const struct smbios_header *)start;
1561
1562 for (;;)
1563 {
1564 if ((const char *)hdr - start >= prologue->length - sizeof(*hdr)) return NULL;
1565
1566 if (!hdr->length)
1567 {
1568 WARN( "invalid entry\n" );
1569 return NULL;
1570 }
1571
1572 if (hdr->type == type)
1573 {
1574 if ((const char *)hdr - start + hdr->length > prologue->length) return NULL;
1575 break;
1576 }
1577 else /* skip other entries and their strings */
1578 {
1579 for (ptr = (const char *)hdr + hdr->length; ptr - buf < len && *ptr; ptr++)
1580 {
1581 for (; ptr - buf < len; ptr++) if (!*ptr) break;
1582 }
1583 if (ptr == (const char *)hdr + hdr->length) ptr++;
1584 hdr = (const struct smbios_header *)(ptr + 1);
1585 }
1586 }
1587
1588 return hdr;
1589 }
1590
get_smbios_string(BYTE id,const char * buf,UINT offset,UINT buflen)1591 static WCHAR *get_smbios_string( BYTE id, const char *buf, UINT offset, UINT buflen )
1592 {
1593 const char *ptr = buf + offset;
1594 UINT i = 0;
1595
1596 if (!id || offset >= buflen) return NULL;
1597 for (ptr = buf + offset; ptr - buf < buflen && *ptr; ptr++)
1598 {
1599 if (++i == id) return heap_strdupAW( ptr );
1600 for (; ptr - buf < buflen; ptr++) if (!*ptr) break;
1601 }
1602 return NULL;
1603 }
1604
get_baseboard_string(BYTE id,const char * buf,UINT len)1605 static WCHAR *get_baseboard_string( BYTE id, const char *buf, UINT len )
1606 {
1607 const struct smbios_header *hdr;
1608 const struct smbios_baseboard *baseboard;
1609 UINT offset;
1610
1611 if (!(hdr = find_smbios_entry( SMBIOS_TYPE_BASEBOARD, buf, len ))) return NULL;
1612
1613 baseboard = (const struct smbios_baseboard *)hdr;
1614 offset = (const char *)baseboard - buf + baseboard->hdr.length;
1615 return get_smbios_string( id, buf, offset, len );
1616 }
1617
get_baseboard_manufacturer(const char * buf,UINT len)1618 static WCHAR *get_baseboard_manufacturer( const char *buf, UINT len )
1619 {
1620 WCHAR *ret = get_baseboard_string( 1, buf, len );
1621 if (!ret) return heap_strdupW( baseboard_manufacturerW );
1622 return ret;
1623 }
1624
get_baseboard_product(const char * buf,UINT len)1625 static WCHAR *get_baseboard_product( const char *buf, UINT len )
1626 {
1627 WCHAR *ret = get_baseboard_string( 2, buf, len );
1628 if (!ret) return heap_strdupW( baseboard_tagW );
1629 return ret;
1630 }
1631
get_baseboard_serialnumber(const char * buf,UINT len)1632 static WCHAR *get_baseboard_serialnumber( const char *buf, UINT len )
1633 {
1634 WCHAR *ret = get_baseboard_string( 4, buf, len );
1635 if (!ret) return heap_strdupW( baseboard_serialnumberW );
1636 return ret;
1637 }
1638
get_baseboard_version(const char * buf,UINT len)1639 static WCHAR *get_baseboard_version( const char *buf, UINT len )
1640 {
1641 WCHAR *ret = get_baseboard_string( 3, buf, len );
1642 if (!ret) return heap_strdupW( baseboard_versionW );
1643 return ret;
1644 }
1645
fill_baseboard(struct table * table,const struct expr * cond)1646 static enum fill_status fill_baseboard( struct table *table, const struct expr *cond )
1647 {
1648 struct record_baseboard *rec;
1649 enum fill_status status = FILL_STATUS_UNFILTERED;
1650 UINT row = 0, len;
1651 char *buf;
1652
1653 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1654
1655 len = GetSystemFirmwareTable( RSMB, 0, NULL, 0 );
1656 if (!(buf = heap_alloc( len ))) return FILL_STATUS_FAILED;
1657 GetSystemFirmwareTable( RSMB, 0, buf, len );
1658
1659 rec = (struct record_baseboard *)table->data;
1660 rec->manufacturer = get_baseboard_manufacturer( buf, len );
1661 rec->model = baseboard_tagW;
1662 rec->name = baseboard_tagW;
1663 rec->product = get_baseboard_product( buf, len );
1664 rec->serialnumber = get_baseboard_serialnumber( buf, len );
1665 rec->tag = baseboard_tagW;
1666 rec->version = get_baseboard_version( buf, len );
1667 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
1668 else row++;
1669
1670 heap_free( buf );
1671
1672 TRACE("created %u rows\n", row);
1673 table->num_rows = row;
1674 return status;
1675 }
1676
get_bios_smbiosmajorversion(const char * buf,UINT len)1677 static UINT16 get_bios_smbiosmajorversion( const char *buf, UINT len )
1678 {
1679 const struct smbios_prologue *prologue = (const struct smbios_prologue *)buf;
1680 if (len < sizeof(*prologue)) return 2;
1681 return prologue->major_version;
1682 }
1683
get_bios_smbiosminorversion(const char * buf,UINT len)1684 static UINT16 get_bios_smbiosminorversion( const char *buf, UINT len )
1685 {
1686 const struct smbios_prologue *prologue = (const struct smbios_prologue *)buf;
1687 if (len < sizeof(*prologue)) return 0;
1688 return prologue->minor_version;
1689 }
1690
get_bios_string(BYTE id,const char * buf,UINT len)1691 static WCHAR *get_bios_string( BYTE id, const char *buf, UINT len )
1692 {
1693 const struct smbios_header *hdr;
1694 const struct smbios_bios *bios;
1695 UINT offset;
1696
1697 if (!(hdr = find_smbios_entry( SMBIOS_TYPE_BIOS, buf, len ))) return NULL;
1698
1699 bios = (const struct smbios_bios *)hdr;
1700 offset = (const char *)bios - buf + bios->hdr.length;
1701 return get_smbios_string( id, buf, offset, len );
1702 }
1703
get_bios_manufacturer(const char * buf,UINT len)1704 static WCHAR *get_bios_manufacturer( const char *buf, UINT len )
1705 {
1706 WCHAR *ret = get_bios_string( 1, buf, len );
1707 if (!ret) return heap_strdupW( bios_manufacturerW );
1708 return ret;
1709 }
1710
convert_bios_date(const WCHAR * str)1711 static WCHAR *convert_bios_date( const WCHAR *str )
1712 {
1713 static const WCHAR fmtW[] =
1714 {'%','0','4','u','%','0','2','u','%','0','2','u','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
1715 UINT year, month, day, len = lstrlenW( str );
1716 const WCHAR *p = str, *q;
1717 WCHAR *ret;
1718
1719 while (len && iswspace( *p )) { p++; len--; }
1720 while (len && iswspace( p[len - 1] )) { len--; }
1721
1722 q = p;
1723 while (len && iswdigit( *q )) { q++; len--; };
1724 if (q - p != 2 || !len || *q != '/') return NULL;
1725 month = (p[0] - '0') * 10 + p[1] - '0';
1726
1727 p = ++q; len--;
1728 while (len && iswdigit( *q )) { q++; len--; };
1729 if (q - p != 2 || !len || *q != '/') return NULL;
1730 day = (p[0] - '0') * 10 + p[1] - '0';
1731
1732 p = ++q; len--;
1733 while (len && iswdigit( *q )) { q++; len--; };
1734 if (q - p == 4) year = (p[0] - '0') * 1000 + (p[1] - '0') * 100 + (p[2] - '0') * 10 + p[3] - '0';
1735 else if (q - p == 2) year = 1900 + (p[0] - '0') * 10 + p[1] - '0';
1736 else return NULL;
1737
1738 if (!(ret = heap_alloc( sizeof(fmtW) ))) return NULL;
1739 swprintf( ret, fmtW, year, month, day );
1740 return ret;
1741 }
1742
get_bios_releasedate(const char * buf,UINT len)1743 static WCHAR *get_bios_releasedate( const char *buf, UINT len )
1744 {
1745 WCHAR *ret, *date = get_bios_string( 3, buf, len );
1746 if (!date || !(ret = convert_bios_date( date ))) ret = heap_strdupW( bios_releasedateW );
1747 heap_free( date );
1748 return ret;
1749 }
1750
get_bios_smbiosbiosversion(const char * buf,UINT len)1751 static WCHAR *get_bios_smbiosbiosversion( const char *buf, UINT len )
1752 {
1753 WCHAR *ret = get_bios_string( 2, buf, len );
1754 if (!ret) return heap_strdupW( bios_smbiosbiosversionW );
1755 return ret;
1756 }
1757
fill_bios(struct table * table,const struct expr * cond)1758 static enum fill_status fill_bios( struct table *table, const struct expr *cond )
1759 {
1760 struct record_bios *rec;
1761 enum fill_status status = FILL_STATUS_UNFILTERED;
1762 UINT row = 0, len;
1763 char *buf;
1764
1765 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1766
1767 len = GetSystemFirmwareTable( RSMB, 0, NULL, 0 );
1768 if (!(buf = heap_alloc( len ))) return FILL_STATUS_FAILED;
1769 GetSystemFirmwareTable( RSMB, 0, buf, len );
1770
1771 rec = (struct record_bios *)table->data;
1772 rec->currentlanguage = NULL;
1773 rec->description = bios_descriptionW;
1774 rec->identificationcode = NULL;
1775 rec->manufacturer = get_bios_manufacturer( buf, len );
1776 rec->name = bios_descriptionW;
1777 rec->releasedate = get_bios_releasedate( buf, len );
1778 rec->serialnumber = bios_serialnumberW;
1779 rec->smbiosbiosversion = get_bios_smbiosbiosversion( buf, len );
1780 rec->smbiosmajorversion = get_bios_smbiosmajorversion( buf, len );
1781 rec->smbiosminorversion = get_bios_smbiosminorversion( buf, len );
1782 rec->version = bios_versionW;
1783 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
1784 else row++;
1785
1786 heap_free( buf );
1787
1788 TRACE("created %u rows\n", row);
1789 table->num_rows = row;
1790 return status;
1791 }
1792
fill_cdromdrive(struct table * table,const struct expr * cond)1793 static enum fill_status fill_cdromdrive( struct table *table, const struct expr *cond )
1794 {
1795 static const WCHAR fmtW[] = {'%','c',':',0};
1796 WCHAR drive[3], root[] = {'A',':','\\',0};
1797 struct record_cdromdrive *rec;
1798 UINT i, row = 0, offset = 0;
1799 DWORD drives = GetLogicalDrives();
1800 enum fill_status status = FILL_STATUS_UNFILTERED;
1801
1802 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1803
1804 for (i = 0; i < 26; i++)
1805 {
1806 if (drives & (1 << i))
1807 {
1808 root[0] = 'A' + i;
1809 if (GetDriveTypeW( root ) != DRIVE_CDROM)
1810 continue;
1811
1812 if (!resize_table( table, row + 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1813
1814 rec = (struct record_cdromdrive *)(table->data + offset);
1815 rec->device_id = cdromdrive_pnpdeviceidW;
1816 swprintf( drive, fmtW, 'A' + i );
1817 rec->drive = heap_strdupW( drive );
1818 rec->mediatype = cdromdrive_mediatypeW;
1819 rec->name = cdromdrive_nameW;
1820 rec->pnpdevice_id = cdromdrive_pnpdeviceidW;
1821 if (!match_row( table, row, cond, &status ))
1822 {
1823 free_row_values( table, row );
1824 continue;
1825 }
1826 offset += sizeof(*rec);
1827 row++;
1828 }
1829 }
1830 TRACE("created %u rows\n", row);
1831 table->num_rows = row;
1832 return status;
1833 }
1834
get_processor_count(void)1835 static UINT get_processor_count(void)
1836 {
1837 SYSTEM_BASIC_INFORMATION info;
1838
1839 if (NtQuerySystemInformation( SystemBasicInformation, &info, sizeof(info), NULL )) return 1;
1840 return info.NumberOfProcessors;
1841 }
1842
1843 #ifdef __REACTOS__
get_logical_processor_count(UINT * num_cores)1844 static UINT get_logical_processor_count( UINT *num_cores )
1845 {
1846 SYSTEM_LOGICAL_PROCESSOR_INFORMATION *info;
1847 UINT i, j, count = 0;
1848 NTSTATUS status;
1849 ULONG len;
1850
1851 if (num_cores) *num_cores = get_processor_count();
1852 status = NtQuerySystemInformation( SystemLogicalProcessorInformation, NULL, 0, &len );
1853 if (status != STATUS_INFO_LENGTH_MISMATCH) return get_processor_count();
1854
1855 if (!(info = heap_alloc( len ))) return get_processor_count();
1856 status = NtQuerySystemInformation( SystemLogicalProcessorInformation, info, len, &len );
1857 if (status != STATUS_SUCCESS)
1858 {
1859 heap_free( info );
1860 return get_processor_count();
1861 }
1862 if (num_cores) *num_cores = 0;
1863 for (i = 0; i < len / sizeof(*info); i++)
1864 {
1865 if (info[i].Relationship == RelationProcessorCore)
1866 {
1867 for (j = 0; j < sizeof(ULONG_PTR); j++) if (info[i].ProcessorMask & (1 << j)) count++;
1868 }
1869 else if (info[i].Relationship == RelationProcessorPackage && num_cores)
1870 {
1871 for (j = 0; j < sizeof(ULONG_PTR); j++) if (info[i].ProcessorMask & (1 << j)) (*num_cores)++;
1872 }
1873 }
1874 heap_free( info );
1875 return count;
1876 }
1877 #else
get_logical_processor_count(UINT * num_physical,UINT * num_packages)1878 static UINT get_logical_processor_count( UINT *num_physical, UINT *num_packages )
1879 {
1880 SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *buf, *entry;
1881 UINT core_relation_count = 0, package_relation_count = 0;
1882 NTSTATUS status;
1883 ULONG len, offset = 0;
1884 BOOL smt_enabled = FALSE;
1885 DWORD all = RelationAll;
1886
1887 if (num_packages) *num_packages = 1;
1888 status = NtQuerySystemInformationEx( SystemLogicalProcessorInformationEx, &all, sizeof(all), NULL, 0, &len );
1889 if (status != STATUS_INFO_LENGTH_MISMATCH) return get_processor_count();
1890
1891 if (!(buf = heap_alloc( len ))) return get_processor_count();
1892 status = NtQuerySystemInformationEx( SystemLogicalProcessorInformationEx, &all, sizeof(all), buf, len, NULL );
1893 if (status != STATUS_SUCCESS)
1894 {
1895 heap_free( buf );
1896 return get_processor_count();
1897 }
1898
1899 while (offset < len)
1900 {
1901 entry = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *)((char *)buf + offset);
1902
1903 if (entry->Relationship == RelationProcessorCore)
1904 {
1905 core_relation_count++;
1906 if (entry->u.Processor.Flags & LTP_PC_SMT) smt_enabled = TRUE;
1907 }
1908 else if (entry->Relationship == RelationProcessorPackage)
1909 {
1910 package_relation_count++;
1911 }
1912 offset += entry->Size;
1913 }
1914
1915 heap_free( buf );
1916 if (num_physical) *num_physical = core_relation_count;
1917 if (num_packages) *num_packages = package_relation_count;
1918 return smt_enabled ? core_relation_count * 2 : core_relation_count;
1919 }
1920 #endif
1921
get_total_physical_memory(void)1922 static UINT64 get_total_physical_memory(void)
1923 {
1924 MEMORYSTATUSEX status;
1925
1926 status.dwLength = sizeof(status);
1927 if (!GlobalMemoryStatusEx( &status )) return 1024 * 1024 * 1024;
1928 return status.ullTotalPhys;
1929 }
1930
get_available_physical_memory(void)1931 static UINT64 get_available_physical_memory(void)
1932 {
1933 MEMORYSTATUSEX status;
1934
1935 status.dwLength = sizeof(status);
1936 if (!GlobalMemoryStatusEx( &status )) return 1024 * 1024 * 1024;
1937 return status.ullAvailPhys;
1938 }
1939
get_computername(void)1940 static WCHAR *get_computername(void)
1941 {
1942 WCHAR *ret;
1943 DWORD size = MAX_COMPUTERNAME_LENGTH + 1;
1944
1945 if (!(ret = heap_alloc( size * sizeof(WCHAR) ))) return NULL;
1946 GetComputerNameW( ret, &size );
1947 return ret;
1948 }
1949
get_username(void)1950 static WCHAR *get_username(void)
1951 {
1952 WCHAR *ret;
1953 DWORD compsize, usersize;
1954 DWORD size;
1955
1956 compsize = 0;
1957 GetComputerNameW( NULL, &compsize );
1958 usersize = 0;
1959 GetUserNameW( NULL, &usersize );
1960 size = compsize + usersize; /* two null terminators account for the \ */
1961 if (!(ret = heap_alloc( size * sizeof(WCHAR) ))) return NULL;
1962 GetComputerNameW( ret, &compsize );
1963 ret[compsize] = '\\';
1964 GetUserNameW( ret + compsize + 1, &usersize );
1965 return ret;
1966 }
1967
fill_compsys(struct table * table,const struct expr * cond)1968 static enum fill_status fill_compsys( struct table *table, const struct expr *cond )
1969 {
1970 struct record_computersystem *rec;
1971 enum fill_status status = FILL_STATUS_UNFILTERED;
1972 UINT row = 0;
1973
1974 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1975
1976 rec = (struct record_computersystem *)table->data;
1977 rec->description = compsys_descriptionW;
1978 rec->domain = compsys_domainW;
1979 rec->domainrole = 0; /* standalone workstation */
1980 rec->manufacturer = compsys_manufacturerW;
1981 rec->model = compsys_modelW;
1982 rec->name = get_computername();
1983 #ifdef __REACTOS__
1984 rec->num_logical_processors = get_logical_processor_count( NULL );
1985 rec->num_processors = get_processor_count();
1986 #else
1987 rec->num_logical_processors = get_logical_processor_count( NULL, &rec->num_processors );
1988 #endif
1989 rec->total_physical_memory = get_total_physical_memory();
1990 rec->username = get_username();
1991 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
1992 else row++;
1993
1994 TRACE("created %u rows\n", row);
1995 table->num_rows = row;
1996 return status;
1997 }
1998
get_compsysproduct_string(BYTE id,const char * buf,UINT len)1999 static WCHAR *get_compsysproduct_string( BYTE id, const char *buf, UINT len )
2000 {
2001 const struct smbios_header *hdr;
2002 const struct smbios_system *system;
2003 UINT offset;
2004
2005 if (!(hdr = find_smbios_entry( SMBIOS_TYPE_SYSTEM, buf, len ))) return NULL;
2006
2007 system = (const struct smbios_system *)hdr;
2008 offset = (const char *)system - buf + system->hdr.length;
2009 return get_smbios_string( id, buf, offset, len );
2010 }
2011
get_compsysproduct_identifyingnumber(const char * buf,UINT len)2012 static WCHAR *get_compsysproduct_identifyingnumber( const char *buf, UINT len )
2013 {
2014 WCHAR *ret = get_compsysproduct_string( 4, buf, len );
2015 if (!ret) return heap_strdupW( compsysproduct_identifyingnumberW );
2016 return ret;
2017 }
2018
get_compsysproduct_name(const char * buf,UINT len)2019 static WCHAR *get_compsysproduct_name( const char *buf, UINT len )
2020 {
2021 WCHAR *ret = get_compsysproduct_string( 2, buf, len );
2022 if (!ret) return heap_strdupW( compsysproduct_nameW );
2023 return ret;
2024 }
2025
get_compsysproduct_uuid(const char * buf,UINT len)2026 static WCHAR *get_compsysproduct_uuid( const char *buf, UINT len )
2027 {
2028 static const WCHAR fmtW[] =
2029 {'%','0','2','X','%','0','2','X','%','0','2','X','%','0','2','X','-','%','0','2','X','%','0','2','X','-',
2030 '%','0','2','X','%','0','2','X','-','%','0','2','X','%','0','2','X','-','%','0','2','X','%','0','2','X',
2031 '%','0','2','X','%','0','2','X','%','0','2','X','%','0','2','X',0};
2032 static const BYTE none[] = {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
2033 const struct smbios_header *hdr;
2034 const struct smbios_system *system;
2035 const BYTE *ptr;
2036 WCHAR *ret = NULL;
2037
2038 if (!(hdr = find_smbios_entry( SMBIOS_TYPE_SYSTEM, buf, len )) || hdr->length < sizeof(*system)) goto done;
2039 system = (const struct smbios_system *)hdr;
2040 if (!memcmp( system->uuid, none, sizeof(none) ) || !(ret = heap_alloc( 37 * sizeof(WCHAR) ))) goto done;
2041
2042 ptr = system->uuid;
2043 swprintf( ret, fmtW, ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5], ptr[6], ptr[7], ptr[8], ptr[9],
2044 ptr[10], ptr[11], ptr[12], ptr[13], ptr[14], ptr[15] );
2045
2046 done:
2047 if (!ret) ret = heap_strdupW( compsysproduct_uuidW );
2048 return ret;
2049 }
2050
get_compsysproduct_vendor(const char * buf,UINT len)2051 static WCHAR *get_compsysproduct_vendor( const char *buf, UINT len )
2052 {
2053 WCHAR *ret = get_compsysproduct_string( 1, buf, len );
2054 if (!ret) return heap_strdupW( compsysproduct_vendorW );
2055 return ret;
2056 }
2057
get_compsysproduct_version(const char * buf,UINT len)2058 static WCHAR *get_compsysproduct_version( const char *buf, UINT len )
2059 {
2060 WCHAR *ret = get_compsysproduct_string( 3, buf, len );
2061 if (!ret) return heap_strdupW( compsysproduct_versionW );
2062 return ret;
2063 }
2064
fill_compsysproduct(struct table * table,const struct expr * cond)2065 static enum fill_status fill_compsysproduct( struct table *table, const struct expr *cond )
2066 {
2067 struct record_computersystemproduct *rec;
2068 enum fill_status status = FILL_STATUS_UNFILTERED;
2069 UINT row = 0, len;
2070 char *buf;
2071
2072 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
2073
2074 len = GetSystemFirmwareTable( RSMB, 0, NULL, 0 );
2075 if (!(buf = heap_alloc( len ))) return FILL_STATUS_FAILED;
2076 GetSystemFirmwareTable( RSMB, 0, buf, len );
2077
2078 rec = (struct record_computersystemproduct *)table->data;
2079 rec->identifyingnumber = get_compsysproduct_identifyingnumber( buf, len );
2080 rec->name = get_compsysproduct_name( buf, len );
2081 rec->skunumber = NULL;
2082 rec->uuid = get_compsysproduct_uuid( buf, len );
2083 rec->vendor = get_compsysproduct_vendor( buf, len );
2084 rec->version = get_compsysproduct_version( buf, len );
2085 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
2086 else row++;
2087
2088 heap_free( buf );
2089
2090 TRACE("created %u rows\n", row);
2091 table->num_rows = row;
2092 return status;
2093 }
2094
2095 struct dirstack
2096 {
2097 WCHAR **dirs;
2098 UINT *len_dirs;
2099 UINT num_dirs;
2100 UINT num_allocated;
2101 };
2102
alloc_dirstack(UINT size)2103 static struct dirstack *alloc_dirstack( UINT size )
2104 {
2105 struct dirstack *dirstack;
2106
2107 if (!(dirstack = heap_alloc( sizeof(*dirstack) ))) return NULL;
2108 if (!(dirstack->dirs = heap_alloc( sizeof(WCHAR *) * size )))
2109 {
2110 heap_free( dirstack );
2111 return NULL;
2112 }
2113 if (!(dirstack->len_dirs = heap_alloc( sizeof(UINT) * size )))
2114 {
2115 heap_free( dirstack->dirs );
2116 heap_free( dirstack );
2117 return NULL;
2118 }
2119 dirstack->num_dirs = 0;
2120 dirstack->num_allocated = size;
2121 return dirstack;
2122 }
2123
clear_dirstack(struct dirstack * dirstack)2124 static void clear_dirstack( struct dirstack *dirstack )
2125 {
2126 UINT i;
2127 for (i = 0; i < dirstack->num_dirs; i++) heap_free( dirstack->dirs[i] );
2128 dirstack->num_dirs = 0;
2129 }
2130
free_dirstack(struct dirstack * dirstack)2131 static void free_dirstack( struct dirstack *dirstack )
2132 {
2133 clear_dirstack( dirstack );
2134 heap_free( dirstack->dirs );
2135 heap_free( dirstack->len_dirs );
2136 heap_free( dirstack );
2137 }
2138
push_dir(struct dirstack * dirstack,WCHAR * dir,UINT len)2139 static BOOL push_dir( struct dirstack *dirstack, WCHAR *dir, UINT len )
2140 {
2141 UINT size, i = dirstack->num_dirs;
2142
2143 if (!dir) return FALSE;
2144
2145 if (i == dirstack->num_allocated)
2146 {
2147 WCHAR **tmp;
2148 UINT *len_tmp;
2149
2150 size = dirstack->num_allocated * 2;
2151 if (!(tmp = heap_realloc( dirstack->dirs, size * sizeof(WCHAR *) ))) return FALSE;
2152 dirstack->dirs = tmp;
2153 if (!(len_tmp = heap_realloc( dirstack->len_dirs, size * sizeof(UINT) ))) return FALSE;
2154 dirstack->len_dirs = len_tmp;
2155 dirstack->num_allocated = size;
2156 }
2157 dirstack->dirs[i] = dir;
2158 dirstack->len_dirs[i] = len;
2159 dirstack->num_dirs++;
2160 return TRUE;
2161 }
2162
pop_dir(struct dirstack * dirstack,UINT * len)2163 static WCHAR *pop_dir( struct dirstack *dirstack, UINT *len )
2164 {
2165 if (!dirstack->num_dirs)
2166 {
2167 *len = 0;
2168 return NULL;
2169 }
2170 dirstack->num_dirs--;
2171 *len = dirstack->len_dirs[dirstack->num_dirs];
2172 return dirstack->dirs[dirstack->num_dirs];
2173 }
2174
peek_dir(struct dirstack * dirstack)2175 static const WCHAR *peek_dir( struct dirstack *dirstack )
2176 {
2177 if (!dirstack->num_dirs) return NULL;
2178 return dirstack->dirs[dirstack->num_dirs - 1];
2179 }
2180
build_glob(WCHAR drive,const WCHAR * path,UINT len)2181 static WCHAR *build_glob( WCHAR drive, const WCHAR *path, UINT len )
2182 {
2183 UINT i = 0;
2184 WCHAR *ret;
2185
2186 if (!(ret = heap_alloc( (len + 6) * sizeof(WCHAR) ))) return NULL;
2187 ret[i++] = drive;
2188 ret[i++] = ':';
2189 ret[i++] = '\\';
2190 if (path && len)
2191 {
2192 memcpy( ret + i, path, len * sizeof(WCHAR) );
2193 i += len;
2194 ret[i++] = '\\';
2195 }
2196 ret[i++] = '*';
2197 ret[i] = 0;
2198 return ret;
2199 }
2200
build_name(WCHAR drive,const WCHAR * path)2201 static WCHAR *build_name( WCHAR drive, const WCHAR *path )
2202 {
2203 UINT i = 0, len = 0;
2204 const WCHAR *p;
2205 WCHAR *ret;
2206
2207 for (p = path; *p; p++)
2208 {
2209 if (*p == '\\') len += 2;
2210 else len++;
2211 };
2212 if (!(ret = heap_alloc( (len + 5) * sizeof(WCHAR) ))) return NULL;
2213 ret[i++] = drive;
2214 ret[i++] = ':';
2215 ret[i++] = '\\';
2216 ret[i++] = '\\';
2217 for (p = path; *p; p++)
2218 {
2219 if (*p != '\\') ret[i++] = *p;
2220 else
2221 {
2222 ret[i++] = '\\';
2223 ret[i++] = '\\';
2224 }
2225 }
2226 ret[i] = 0;
2227 return ret;
2228 }
2229
build_dirname(const WCHAR * path,UINT * ret_len)2230 static WCHAR *build_dirname( const WCHAR *path, UINT *ret_len )
2231 {
2232 const WCHAR *p = path, *start;
2233 UINT len, i;
2234 WCHAR *ret;
2235
2236 if (!iswalpha( p[0] ) || p[1] != ':' || p[2] != '\\' || p[3] != '\\' || !p[4]) return NULL;
2237 start = path + 4;
2238 len = lstrlenW( start );
2239 p = start + len - 1;
2240 if (*p == '\\') return NULL;
2241
2242 while (p >= start && *p != '\\') { len--; p--; };
2243 while (p >= start && *p == '\\') { len--; p--; };
2244
2245 if (!(ret = heap_alloc( (len + 1) * sizeof(WCHAR) ))) return NULL;
2246 for (i = 0, p = start; p < start + len; p++)
2247 {
2248 if (p[0] == '\\' && p[1] == '\\')
2249 {
2250 ret[i++] = '\\';
2251 p++;
2252 }
2253 else ret[i++] = *p;
2254 }
2255 ret[i] = 0;
2256 *ret_len = i;
2257 return ret;
2258 }
2259
seen_dir(struct dirstack * dirstack,const WCHAR * path)2260 static BOOL seen_dir( struct dirstack *dirstack, const WCHAR *path )
2261 {
2262 UINT i;
2263 for (i = 0; i < dirstack->num_dirs; i++) if (!wcscmp( dirstack->dirs[i], path )) return TRUE;
2264 return FALSE;
2265 }
2266
2267 /* optimize queries of the form WHERE Name='...' [OR Name='...']* */
seed_dirs(struct dirstack * dirstack,const struct expr * cond,WCHAR root,UINT * count)2268 static UINT seed_dirs( struct dirstack *dirstack, const struct expr *cond, WCHAR root, UINT *count )
2269 {
2270 const struct expr *left, *right;
2271
2272 if (!cond || cond->type != EXPR_COMPLEX) return *count = 0;
2273
2274 left = cond->u.expr.left;
2275 right = cond->u.expr.right;
2276 if (cond->u.expr.op == OP_EQ)
2277 {
2278 UINT len;
2279 WCHAR *path;
2280 const WCHAR *str = NULL;
2281
2282 if (left->type == EXPR_PROPVAL && right->type == EXPR_SVAL &&
2283 !wcscmp( left->u.propval->name, prop_nameW ) &&
2284 towupper( right->u.sval[0] ) == towupper( root ))
2285 {
2286 str = right->u.sval;
2287 }
2288 else if (left->type == EXPR_SVAL && right->type == EXPR_PROPVAL &&
2289 !wcscmp( right->u.propval->name, prop_nameW ) &&
2290 towupper( left->u.sval[0] ) == towupper( root ))
2291 {
2292 str = left->u.sval;
2293 }
2294 if (str && (path = build_dirname( str, &len )))
2295 {
2296 if (seen_dir( dirstack, path ))
2297 {
2298 heap_free( path );
2299 return ++*count;
2300 }
2301 else if (push_dir( dirstack, path, len )) return ++*count;
2302 heap_free( path );
2303 return *count = 0;
2304 }
2305 }
2306 else if (cond->u.expr.op == OP_OR)
2307 {
2308 UINT left_count = 0, right_count = 0;
2309
2310 if (!(seed_dirs( dirstack, left, root, &left_count ))) return *count = 0;
2311 if (!(seed_dirs( dirstack, right, root, &right_count ))) return *count = 0;
2312 return *count += left_count + right_count;
2313 }
2314 return *count = 0;
2315 }
2316
append_path(const WCHAR * path,const WCHAR * segment,UINT * len)2317 static WCHAR *append_path( const WCHAR *path, const WCHAR *segment, UINT *len )
2318 {
2319 UINT len_path = 0, len_segment = lstrlenW( segment );
2320 WCHAR *ret;
2321
2322 *len = 0;
2323 if (path) len_path = lstrlenW( path );
2324 if (!(ret = heap_alloc( (len_path + len_segment + 2) * sizeof(WCHAR) ))) return NULL;
2325 if (path && len_path)
2326 {
2327 memcpy( ret, path, len_path * sizeof(WCHAR) );
2328 ret[len_path] = '\\';
2329 *len += len_path + 1;
2330 }
2331 memcpy( ret + *len, segment, len_segment * sizeof(WCHAR) );
2332 *len += len_segment;
2333 ret[*len] = 0;
2334 return ret;
2335 }
2336
get_file_version(const WCHAR * filename)2337 static WCHAR *get_file_version( const WCHAR *filename )
2338 {
2339 static const WCHAR slashW[] = {'\\',0}, fmtW[] = {'%','u','.','%','u','.','%','u','.','%','u',0};
2340 VS_FIXEDFILEINFO *info;
2341 DWORD size, len = 4 * 5 + ARRAY_SIZE( fmtW );
2342 void *block;
2343 WCHAR *ret;
2344
2345 if (!(ret = heap_alloc( len * sizeof(WCHAR) ))) return NULL;
2346 if (!(size = GetFileVersionInfoSizeW( filename, NULL )) || !(block = heap_alloc( size )))
2347 {
2348 heap_free( ret );
2349 return NULL;
2350 }
2351 if (!GetFileVersionInfoW( filename, 0, size, block ) ||
2352 !VerQueryValueW( block, slashW, (void **)&info, &size ))
2353 {
2354 heap_free( block );
2355 heap_free( ret );
2356 return NULL;
2357 }
2358 swprintf( ret, fmtW, info->dwFileVersionMS >> 16, info->dwFileVersionMS & 0xffff,
2359 info->dwFileVersionLS >> 16, info->dwFileVersionLS & 0xffff );
2360 heap_free( block );
2361 return ret;
2362 }
2363
fill_datafile(struct table * table,const struct expr * cond)2364 static enum fill_status fill_datafile( struct table *table, const struct expr *cond )
2365 {
2366 static const WCHAR dotW[] = {'.',0}, dotdotW[] = {'.','.',0};
2367 struct record_datafile *rec;
2368 UINT i, len, row = 0, offset = 0, num_expected_rows;
2369 WCHAR *glob = NULL, *path = NULL, *new_path, root[] = {'A',':','\\',0};
2370 DWORD drives = GetLogicalDrives();
2371 WIN32_FIND_DATAW data;
2372 HANDLE handle;
2373 struct dirstack *dirstack;
2374 enum fill_status status = FILL_STATUS_UNFILTERED;
2375
2376 if (!resize_table( table, 8, sizeof(*rec) )) return FILL_STATUS_FAILED;
2377
2378 dirstack = alloc_dirstack(2);
2379
2380 for (i = 0; i < 26; i++)
2381 {
2382 if (!(drives & (1 << i))) continue;
2383
2384 root[0] = 'A' + i;
2385 if (GetDriveTypeW( root ) != DRIVE_FIXED) continue;
2386
2387 num_expected_rows = 0;
2388 if (!seed_dirs( dirstack, cond, root[0], &num_expected_rows )) clear_dirstack( dirstack );
2389
2390 for (;;)
2391 {
2392 heap_free( glob );
2393 heap_free( path );
2394 path = pop_dir( dirstack, &len );
2395 if (!(glob = build_glob( root[0], path, len )))
2396 {
2397 status = FILL_STATUS_FAILED;
2398 goto done;
2399 }
2400 if ((handle = FindFirstFileW( glob, &data )) != INVALID_HANDLE_VALUE)
2401 {
2402 do
2403 {
2404 if (!resize_table( table, row + 1, sizeof(*rec) ))
2405 {
2406 status = FILL_STATUS_FAILED;
2407 FindClose( handle );
2408 goto done;
2409 }
2410 if (!wcscmp( data.cFileName, dotW ) || !wcscmp( data.cFileName, dotdotW )) continue;
2411
2412 if (!(new_path = append_path( path, data.cFileName, &len )))
2413 {
2414 status = FILL_STATUS_FAILED;
2415 FindClose( handle );
2416 goto done;
2417 }
2418
2419 if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
2420 {
2421 if (push_dir( dirstack, new_path, len )) continue;
2422 heap_free( new_path );
2423 FindClose( handle );
2424 status = FILL_STATUS_FAILED;
2425 goto done;
2426 }
2427 rec = (struct record_datafile *)(table->data + offset);
2428 rec->name = build_name( root[0], new_path );
2429 rec->version = get_file_version( rec->name );
2430 heap_free( new_path );
2431 if (!match_row( table, row, cond, &status ))
2432 {
2433 free_row_values( table, row );
2434 continue;
2435 }
2436 else if (num_expected_rows && row == num_expected_rows - 1)
2437 {
2438 row++;
2439 FindClose( handle );
2440 status = FILL_STATUS_FILTERED;
2441 goto done;
2442 }
2443 offset += sizeof(*rec);
2444 row++;
2445 }
2446 while (FindNextFileW( handle, &data ));
2447 FindClose( handle );
2448 }
2449 if (!peek_dir( dirstack )) break;
2450 }
2451 }
2452
2453 done:
2454 free_dirstack( dirstack );
2455 heap_free( glob );
2456 heap_free( path );
2457
2458 TRACE("created %u rows\n", row);
2459 table->num_rows = row;
2460 return status;
2461 }
2462
get_pixelsperxlogicalinch(void)2463 static UINT32 get_pixelsperxlogicalinch(void)
2464 {
2465 HDC hdc = GetDC( NULL );
2466 UINT32 ret;
2467
2468 if (!hdc) return 96;
2469 ret = GetDeviceCaps( hdc, LOGPIXELSX );
2470 ReleaseDC( NULL, hdc );
2471 return ret;
2472 }
2473
fill_desktopmonitor(struct table * table,const struct expr * cond)2474 static enum fill_status fill_desktopmonitor( struct table *table, const struct expr *cond )
2475 {
2476 struct record_desktopmonitor *rec;
2477 enum fill_status status = FILL_STATUS_UNFILTERED;
2478 UINT row = 0;
2479
2480 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
2481
2482 rec = (struct record_desktopmonitor *)table->data;
2483 rec->pixelsperxlogicalinch = get_pixelsperxlogicalinch();
2484
2485 if (match_row( table, row, cond, &status )) row++;
2486
2487 TRACE("created %u rows\n", row);
2488 table->num_rows = row;
2489 return status;
2490 }
2491
fill_directory(struct table * table,const struct expr * cond)2492 static enum fill_status fill_directory( struct table *table, const struct expr *cond )
2493 {
2494 static const WCHAR dotW[] = {'.',0}, dotdotW[] = {'.','.',0};
2495 struct record_directory *rec;
2496 UINT i, len, row = 0, offset = 0, num_expected_rows;
2497 WCHAR *glob = NULL, *path = NULL, *new_path, root[] = {'A',':','\\',0};
2498 DWORD drives = GetLogicalDrives();
2499 WIN32_FIND_DATAW data;
2500 HANDLE handle;
2501 struct dirstack *dirstack;
2502 enum fill_status status = FILL_STATUS_UNFILTERED;
2503
2504 if (!resize_table( table, 4, sizeof(*rec) )) return FILL_STATUS_FAILED;
2505
2506 dirstack = alloc_dirstack(2);
2507
2508 for (i = 0; i < 26; i++)
2509 {
2510 if (!(drives & (1 << i))) continue;
2511
2512 root[0] = 'A' + i;
2513 if (GetDriveTypeW( root ) != DRIVE_FIXED) continue;
2514
2515 num_expected_rows = 0;
2516 if (!seed_dirs( dirstack, cond, root[0], &num_expected_rows )) clear_dirstack( dirstack );
2517
2518 for (;;)
2519 {
2520 heap_free( glob );
2521 heap_free( path );
2522 path = pop_dir( dirstack, &len );
2523 if (!(glob = build_glob( root[0], path, len )))
2524 {
2525 status = FILL_STATUS_FAILED;
2526 goto done;
2527 }
2528 if ((handle = FindFirstFileW( glob, &data )) != INVALID_HANDLE_VALUE)
2529 {
2530 do
2531 {
2532 if (!resize_table( table, row + 1, sizeof(*rec) ))
2533 {
2534 FindClose( handle );
2535 status = FILL_STATUS_FAILED;
2536 goto done;
2537 }
2538 if (!(data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ||
2539 !wcscmp( data.cFileName, dotW ) || !wcscmp( data.cFileName, dotdotW ))
2540 continue;
2541
2542 if (!(new_path = append_path( path, data.cFileName, &len )))
2543 {
2544 FindClose( handle );
2545 status = FILL_STATUS_FAILED;
2546 goto done;
2547 }
2548
2549 if (!(push_dir( dirstack, new_path, len )))
2550 {
2551 heap_free( new_path );
2552 FindClose( handle );
2553 status = FILL_STATUS_FAILED;
2554 goto done;
2555 }
2556 rec = (struct record_directory *)(table->data + offset);
2557 rec->accessmask = FILE_ALL_ACCESS;
2558 rec->name = build_name( root[0], new_path );
2559 heap_free( new_path );
2560 if (!match_row( table, row, cond, &status ))
2561 {
2562 free_row_values( table, row );
2563 continue;
2564 }
2565 else if (num_expected_rows && row == num_expected_rows - 1)
2566 {
2567 row++;
2568 FindClose( handle );
2569 status = FILL_STATUS_FILTERED;
2570 goto done;
2571 }
2572 offset += sizeof(*rec);
2573 row++;
2574 }
2575 while (FindNextFileW( handle, &data ));
2576 FindClose( handle );
2577 }
2578 if (!peek_dir( dirstack )) break;
2579 }
2580 }
2581
2582 done:
2583 free_dirstack( dirstack );
2584 heap_free( glob );
2585 heap_free( path );
2586
2587 TRACE("created %u rows\n", row);
2588 table->num_rows = row;
2589 return status;
2590 }
2591
get_freespace(const WCHAR * dir,UINT64 * disksize)2592 static UINT64 get_freespace( const WCHAR *dir, UINT64 *disksize )
2593 {
2594 WCHAR root[] = {'\\','\\','.','\\','A',':',0};
2595 ULARGE_INTEGER free;
2596 DISK_GEOMETRY_EX info;
2597 HANDLE handle;
2598 DWORD bytes_returned;
2599
2600 free.QuadPart = 512 * 1024 * 1024;
2601 GetDiskFreeSpaceExW( dir, NULL, NULL, &free );
2602
2603 root[4] = dir[0];
2604 handle = CreateFileW( root, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0 );
2605 if (handle != INVALID_HANDLE_VALUE)
2606 {
2607 if (DeviceIoControl( handle, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, NULL, 0, &info, sizeof(info), &bytes_returned, NULL ))
2608 *disksize = info.DiskSize.QuadPart;
2609 CloseHandle( handle );
2610 }
2611 return free.QuadPart;
2612 }
2613
fill_diskdrive(struct table * table,const struct expr * cond)2614 static enum fill_status fill_diskdrive( struct table *table, const struct expr *cond )
2615 {
2616 static const WCHAR fmtW[] =
2617 {'\\','\\','\\','\\','.','\\','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','%','u',0};
2618 WCHAR device_id[ARRAY_SIZE( fmtW ) + 10], root[] = {'A',':','\\',0};
2619 struct record_diskdrive *rec;
2620 UINT i, row = 0, offset = 0, index = 0, type;
2621 UINT64 size = 1024 * 1024 * 1024;
2622 DWORD drives = GetLogicalDrives();
2623 enum fill_status status = FILL_STATUS_UNFILTERED;
2624
2625 if (!resize_table( table, 2, sizeof(*rec) )) return FILL_STATUS_FAILED;
2626
2627 for (i = 0; i < 26; i++)
2628 {
2629 if (drives & (1 << i))
2630 {
2631 root[0] = 'A' + i;
2632 type = GetDriveTypeW( root );
2633 if (type != DRIVE_FIXED && type != DRIVE_REMOVABLE)
2634 continue;
2635
2636 if (!resize_table( table, row + 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
2637
2638 rec = (struct record_diskdrive *)(table->data + offset);
2639 swprintf( device_id, fmtW, index );
2640 rec->device_id = heap_strdupW( device_id );
2641 rec->index = index++;
2642 rec->interfacetype = diskdrive_interfacetypeW;
2643 rec->manufacturer = diskdrive_manufacturerW;
2644 rec->mediatype = (type == DRIVE_FIXED) ? diskdrive_mediatype_fixedW : diskdrive_mediatype_removableW;
2645 rec->model = diskdrive_modelW;
2646 rec->pnpdevice_id = diskdrive_pnpdeviceidW;
2647 rec->serialnumber = diskdrive_serialW;
2648 get_freespace( root, &size );
2649 rec->size = size;
2650 if (!match_row( table, row, cond, &status ))
2651 {
2652 free_row_values( table, row );
2653 continue;
2654 }
2655 offset += sizeof(*rec);
2656 row++;
2657 }
2658 }
2659 TRACE("created %u rows\n", row);
2660 table->num_rows = row;
2661 return status;
2662 }
2663
2664 struct association
2665 {
2666 WCHAR *ref;
2667 WCHAR *ref2;
2668 };
2669
free_assocations(struct association * assoc,UINT count)2670 static void free_assocations( struct association *assoc, UINT count )
2671 {
2672 UINT i;
2673 if (!assoc) return;
2674 for (i = 0; i < count; i++)
2675 {
2676 heap_free( assoc[i].ref );
2677 heap_free( assoc[i].ref2 );
2678 }
2679 heap_free( assoc );
2680 }
2681
get_diskdrivetodiskpartition_pairs(UINT * count)2682 static struct association *get_diskdrivetodiskpartition_pairs( UINT *count )
2683 {
2684 static const WCHAR pathW[] =
2685 {'_','_','P','A','T','H',0};
2686 static const WCHAR selectW[] =
2687 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','W','i','n','3','2','_',
2688 'D','i','s','k','D','r','i','v','e',0};
2689 static const WCHAR select2W[] =
2690 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','W','i','n','3','2','_',
2691 'D','i','s','k','P','a','r','t','i','t','i','o','n',0};
2692 struct association *ret = NULL;
2693 struct query *query, *query2 = NULL;
2694 VARIANT val;
2695 HRESULT hr;
2696 UINT i;
2697
2698 if (!(query = create_query())) return NULL;
2699 if ((hr = parse_query( selectW, &query->view, &query->mem )) != S_OK) goto done;
2700 if ((hr = execute_view( query->view )) != S_OK) goto done;
2701
2702 if (!(query2 = create_query())) return FALSE;
2703 if ((hr = parse_query( select2W, &query2->view, &query2->mem )) != S_OK) goto done;
2704 if ((hr = execute_view( query2->view )) != S_OK) goto done;
2705
2706 if (!(ret = heap_alloc_zero( query->view->result_count * sizeof(*ret) ))) goto done;
2707
2708 for (i = 0; i < query->view->result_count; i++)
2709 {
2710 if ((hr = get_propval( query->view, i, pathW, &val, NULL, NULL )) != S_OK) goto done;
2711 if (!(ret[i].ref = heap_strdupW( V_BSTR(&val) ))) goto done;
2712 VariantClear( &val );
2713
2714 if ((hr = get_propval( query2->view, i, pathW, &val, NULL, NULL )) != S_OK) goto done;
2715 if (!(ret[i].ref2 = heap_strdupW( V_BSTR(&val) ))) goto done;
2716 VariantClear( &val );
2717 }
2718
2719 *count = query->view->result_count;
2720
2721 done:
2722 if (!ret) free_assocations( ret, query->view->result_count );
2723 free_query( query );
2724 free_query( query2 );
2725 return ret;
2726 }
2727
fill_diskdrivetodiskpartition(struct table * table,const struct expr * cond)2728 static enum fill_status fill_diskdrivetodiskpartition( struct table *table, const struct expr *cond )
2729 {
2730 struct record_diskdrivetodiskpartition *rec;
2731 UINT i, row = 0, offset = 0, count = 0;
2732 enum fill_status status = FILL_STATUS_UNFILTERED;
2733 struct association *assoc;
2734
2735 if (!(assoc = get_diskdrivetodiskpartition_pairs( &count ))) return FILL_STATUS_FAILED;
2736 if (!count)
2737 {
2738 free_assocations( assoc, count );
2739 return FILL_STATUS_UNFILTERED;
2740 }
2741 if (!resize_table( table, count, sizeof(*rec) ))
2742 {
2743 free_assocations( assoc, count );
2744 return FILL_STATUS_FAILED;
2745 }
2746
2747 for (i = 0; i < count; i++)
2748 {
2749 rec = (struct record_diskdrivetodiskpartition *)(table->data + offset);
2750 rec->antecedent = assoc[i].ref;
2751 rec->dependent = assoc[i].ref2;
2752 if (!match_row( table, row, cond, &status ))
2753 {
2754 free_row_values( table, row );
2755 continue;
2756 }
2757 offset += sizeof(*rec);
2758 row++;
2759 }
2760
2761 heap_free( assoc );
2762
2763 TRACE("created %u rows\n", row);
2764 table->num_rows = row;
2765 return status;
2766 }
2767
get_filesystem(const WCHAR * root)2768 static WCHAR *get_filesystem( const WCHAR *root )
2769 {
2770 static const WCHAR ntfsW[] = {'N','T','F','S',0};
2771 WCHAR buffer[MAX_PATH + 1];
2772
2773 if (GetVolumeInformationW( root, NULL, 0, NULL, NULL, NULL, buffer, MAX_PATH + 1 ))
2774 return heap_strdupW( buffer );
2775 return heap_strdupW( ntfsW );
2776 }
2777
fill_diskpartition(struct table * table,const struct expr * cond)2778 static enum fill_status fill_diskpartition( struct table *table, const struct expr *cond )
2779 {
2780 static const WCHAR fmtW[] =
2781 {'D','i','s','k',' ','#','%','u',',',' ','P','a','r','t','i','t','i','o','n',' ','#','0',0};
2782 WCHAR device_id[32], root[] = {'A',':','\\',0};
2783 struct record_diskpartition *rec;
2784 UINT i, row = 0, offset = 0, type, index = 0;
2785 UINT64 size = 1024 * 1024 * 1024;
2786 DWORD drives = GetLogicalDrives();
2787 enum fill_status status = FILL_STATUS_UNFILTERED;
2788
2789 if (!resize_table( table, 4, sizeof(*rec) )) return FILL_STATUS_FAILED;
2790
2791 for (i = 0; i < 26; i++)
2792 {
2793 if (drives & (1 << i))
2794 {
2795 root[0] = 'A' + i;
2796 type = GetDriveTypeW( root );
2797 if (type != DRIVE_FIXED && type != DRIVE_REMOVABLE)
2798 continue;
2799
2800 if (!resize_table( table, row + 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
2801
2802 rec = (struct record_diskpartition *)(table->data + offset);
2803 rec->bootable = (i == 2) ? -1 : 0;
2804 rec->bootpartition = (i == 2) ? -1 : 0;
2805 swprintf( device_id, fmtW, index );
2806 rec->device_id = heap_strdupW( device_id );
2807 rec->diskindex = index++;
2808 rec->index = 0;
2809 rec->pnpdevice_id = heap_strdupW( device_id );
2810 get_freespace( root, &size );
2811 rec->size = size;
2812 rec->startingoffset = 0;
2813 rec->type = get_filesystem( root );
2814 if (!match_row( table, row, cond, &status ))
2815 {
2816 free_row_values( table, row );
2817 continue;
2818 }
2819 offset += sizeof(*rec);
2820 row++;
2821 }
2822 }
2823 TRACE("created %u rows\n", row);
2824 table->num_rows = row;
2825 return status;
2826 }
2827
get_bitsperpixel(UINT * hres,UINT * vres)2828 static UINT32 get_bitsperpixel( UINT *hres, UINT *vres )
2829 {
2830 HDC hdc = GetDC( NULL );
2831 UINT32 ret;
2832
2833 if (!hdc) return 32;
2834 ret = GetDeviceCaps( hdc, BITSPIXEL );
2835 *hres = GetDeviceCaps( hdc, HORZRES );
2836 *vres = GetDeviceCaps( hdc, VERTRES );
2837 ReleaseDC( NULL, hdc );
2838 return ret;
2839 }
2840
fill_displaycontrollerconfig(struct table * table,const struct expr * cond)2841 static enum fill_status fill_displaycontrollerconfig( struct table *table, const struct expr *cond )
2842 {
2843 struct record_displaycontrollerconfig *rec;
2844 UINT row = 0, hres = 1024, vres = 768;
2845 enum fill_status status = FILL_STATUS_UNFILTERED;
2846
2847 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
2848
2849 rec = (struct record_displaycontrollerconfig *)table->data;
2850 rec->bitsperpixel = get_bitsperpixel( &hres, &vres );
2851 rec->caption = videocontroller_deviceidW;
2852 rec->horizontalresolution = hres;
2853 rec->name = videocontroller_deviceidW;
2854 rec->verticalresolution = vres;
2855 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
2856 else row++;
2857
2858 TRACE("created %u rows\n", row);
2859 table->num_rows = row;
2860 return status;
2861 }
2862
get_ip4_string(DWORD addr)2863 static WCHAR *get_ip4_string( DWORD addr )
2864 {
2865 static const WCHAR fmtW[] = {'%','u','.','%','u','.','%','u','.','%','u',0};
2866 DWORD len = sizeof("ddd.ddd.ddd.ddd");
2867 WCHAR *ret;
2868
2869 if (!(ret = heap_alloc( len * sizeof(WCHAR) ))) return NULL;
2870 swprintf( ret, fmtW, (addr >> 24) & 0xff, (addr >> 16) & 0xff, (addr >> 8) & 0xff, addr & 0xff );
2871 return ret;
2872 }
2873
fill_ip4routetable(struct table * table,const struct expr * cond)2874 static enum fill_status fill_ip4routetable( struct table *table, const struct expr *cond )
2875 {
2876 struct record_ip4routetable *rec;
2877 UINT i, row = 0, offset = 0, size = 0;
2878 MIB_IPFORWARDTABLE *forwards;
2879 enum fill_status status = FILL_STATUS_UNFILTERED;
2880
2881 if (GetIpForwardTable( NULL, &size, TRUE ) != ERROR_INSUFFICIENT_BUFFER) return FILL_STATUS_FAILED;
2882 if (!(forwards = heap_alloc( size ))) return FILL_STATUS_FAILED;
2883 if (GetIpForwardTable( forwards, &size, TRUE ))
2884 {
2885 heap_free( forwards );
2886 return FILL_STATUS_FAILED;
2887 }
2888 if (!resize_table( table, max(forwards->dwNumEntries, 1), sizeof(*rec) ))
2889 {
2890 heap_free( forwards );
2891 return FILL_STATUS_FAILED;
2892 }
2893
2894 for (i = 0; i < forwards->dwNumEntries; i++)
2895 {
2896 rec = (struct record_ip4routetable *)(table->data + offset);
2897
2898 rec->destination = get_ip4_string( ntohl(forwards->table[i].dwForwardDest) );
2899 rec->interfaceindex = forwards->table[i].dwForwardIfIndex;
2900 rec->nexthop = get_ip4_string( ntohl(forwards->table[i].dwForwardNextHop) );
2901
2902 if (!match_row( table, row, cond, &status ))
2903 {
2904 free_row_values( table, row );
2905 continue;
2906 }
2907 offset += sizeof(*rec);
2908 row++;
2909 }
2910 TRACE("created %u rows\n", row);
2911 table->num_rows = row;
2912
2913 heap_free( forwards );
2914 return status;
2915 }
2916
get_volumename(const WCHAR * root)2917 static WCHAR *get_volumename( const WCHAR *root )
2918 {
2919 WCHAR buf[MAX_PATH + 1] = {0};
2920 GetVolumeInformationW( root, buf, ARRAY_SIZE( buf ), NULL, NULL, NULL, NULL, 0 );
2921 return heap_strdupW( buf );
2922 }
get_volumeserialnumber(const WCHAR * root)2923 static WCHAR *get_volumeserialnumber( const WCHAR *root )
2924 {
2925 static const WCHAR fmtW[] = {'%','0','8','X',0};
2926 DWORD serial = 0;
2927 WCHAR buffer[9];
2928
2929 GetVolumeInformationW( root, NULL, 0, &serial, NULL, NULL, NULL, 0 );
2930 swprintf( buffer, fmtW, serial );
2931 return heap_strdupW( buffer );
2932 }
2933
fill_logicaldisk(struct table * table,const struct expr * cond)2934 static enum fill_status fill_logicaldisk( struct table *table, const struct expr *cond )
2935 {
2936 static const WCHAR fmtW[] = {'%','c',':',0};
2937 WCHAR device_id[3], root[] = {'A',':','\\',0};
2938 struct record_logicaldisk *rec;
2939 UINT i, row = 0, offset = 0, type;
2940 UINT64 size = 1024 * 1024 * 1024;
2941 DWORD drives = GetLogicalDrives();
2942 enum fill_status status = FILL_STATUS_UNFILTERED;
2943
2944 if (!resize_table( table, 4, sizeof(*rec) )) return FILL_STATUS_FAILED;
2945
2946 for (i = 0; i < 26; i++)
2947 {
2948 if (drives & (1 << i))
2949 {
2950 root[0] = 'A' + i;
2951 type = GetDriveTypeW( root );
2952 if (type != DRIVE_FIXED && type != DRIVE_CDROM && type != DRIVE_REMOVABLE)
2953 continue;
2954
2955 if (!resize_table( table, row + 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
2956
2957 rec = (struct record_logicaldisk *)(table->data + offset);
2958 swprintf( device_id, fmtW, 'A' + i );
2959 rec->device_id = heap_strdupW( device_id );
2960 rec->drivetype = type;
2961 rec->filesystem = get_filesystem( root );
2962 rec->freespace = get_freespace( root, &size );
2963 rec->name = heap_strdupW( device_id );
2964 rec->size = size;
2965 rec->volumename = get_volumename( root );
2966 rec->volumeserialnumber = get_volumeserialnumber( root );
2967 if (!match_row( table, row, cond, &status ))
2968 {
2969 free_row_values( table, row );
2970 continue;
2971 }
2972 offset += sizeof(*rec);
2973 row++;
2974 }
2975 }
2976 TRACE("created %u rows\n", row);
2977 table->num_rows = row;
2978 return status;
2979 }
2980
get_logicaldisktopartition_pairs(UINT * count)2981 static struct association *get_logicaldisktopartition_pairs( UINT *count )
2982 {
2983 static const WCHAR pathW[] =
2984 {'_','_','P','A','T','H',0};
2985 static const WCHAR selectW[] =
2986 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','W','i','n','3','2','_',
2987 'D','i','s','k','P','a','r','t','i','t','i','o','n',0};
2988 static const WCHAR select2W[] =
2989 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','W','i','n','3','2','_',
2990 'L','o','g','i','c','a','l','D','i','s','k',' ','W','H','E','R','E',' ',
2991 'D','r','i','v','e','T','y','p','e','=','2',' ','O','R',' ','D','r','i','v','e','T','y','p','e','=','3',0};
2992 struct association *ret = NULL;
2993 struct query *query, *query2 = NULL;
2994 VARIANT val;
2995 HRESULT hr;
2996 UINT i;
2997
2998 if (!(query = create_query())) return NULL;
2999 if ((hr = parse_query( selectW, &query->view, &query->mem )) != S_OK) goto done;
3000 if ((hr = execute_view( query->view )) != S_OK) goto done;
3001
3002 if (!(query2 = create_query())) return FALSE;
3003 if ((hr = parse_query( select2W, &query2->view, &query2->mem )) != S_OK) goto done;
3004 if ((hr = execute_view( query2->view )) != S_OK) goto done;
3005
3006 if (!(ret = heap_alloc_zero( query->view->result_count * sizeof(*ret) ))) goto done;
3007
3008 /* assume fixed and removable disks are enumerated in the same order as partitions */
3009 for (i = 0; i < query->view->result_count; i++)
3010 {
3011 if ((hr = get_propval( query->view, i, pathW, &val, NULL, NULL )) != S_OK) goto done;
3012 if (!(ret[i].ref = heap_strdupW( V_BSTR(&val) ))) goto done;
3013 VariantClear( &val );
3014
3015 if ((hr = get_propval( query2->view, i, pathW, &val, NULL, NULL )) != S_OK) goto done;
3016 if (!(ret[i].ref2 = heap_strdupW( V_BSTR(&val) ))) goto done;
3017 VariantClear( &val );
3018 }
3019
3020 *count = query->view->result_count;
3021
3022 done:
3023 if (!ret) free_assocations( ret, query->view->result_count );
3024 free_query( query );
3025 free_query( query2 );
3026 return ret;
3027 }
3028
fill_logicaldisktopartition(struct table * table,const struct expr * cond)3029 static enum fill_status fill_logicaldisktopartition( struct table *table, const struct expr *cond )
3030 {
3031 struct record_logicaldisktopartition *rec;
3032 UINT i, row = 0, offset = 0, count = 0;
3033 enum fill_status status = FILL_STATUS_UNFILTERED;
3034 struct association *assoc;
3035
3036 if (!(assoc = get_logicaldisktopartition_pairs( &count ))) return FILL_STATUS_FAILED;
3037 if (!count)
3038 {
3039 free_assocations( assoc, count );
3040 return FILL_STATUS_UNFILTERED;
3041 }
3042 if (!resize_table( table, count, sizeof(*rec) ))
3043 {
3044 free_assocations( assoc, count );
3045 return FILL_STATUS_FAILED;
3046 }
3047
3048 for (i = 0; i < count; i++)
3049 {
3050 rec = (struct record_logicaldisktopartition *)(table->data + offset);
3051 rec->antecedent = assoc[i].ref;
3052 rec->dependent = assoc[i].ref2;
3053 if (!match_row( table, row, cond, &status ))
3054 {
3055 free_row_values( table, row );
3056 continue;
3057 }
3058 offset += sizeof(*rec);
3059 row++;
3060 }
3061
3062 heap_free( assoc );
3063
3064 TRACE("created %u rows\n", row);
3065 table->num_rows = row;
3066 return status;
3067 }
3068
get_connection_status(IF_OPER_STATUS status)3069 static UINT16 get_connection_status( IF_OPER_STATUS status )
3070 {
3071 switch (status)
3072 {
3073 case IfOperStatusDown:
3074 return 0; /* Disconnected */
3075 case IfOperStatusUp:
3076 return 2; /* Connected */
3077 default:
3078 ERR("unhandled status %u\n", status);
3079 break;
3080 }
3081 return 0;
3082 }
get_mac_address(const BYTE * addr,DWORD len)3083 static WCHAR *get_mac_address( const BYTE *addr, DWORD len )
3084 {
3085 static const WCHAR fmtW[] =
3086 {'%','0','2','x',':','%','0','2','x',':','%','0','2','x',':',
3087 '%','0','2','x',':','%','0','2','x',':','%','0','2','x',0};
3088 WCHAR *ret;
3089
3090 if (len != 6 || !(ret = heap_alloc( 18 * sizeof(WCHAR) ))) return NULL;
3091 swprintf( ret, fmtW, addr[0], addr[1], addr[2], addr[3], addr[4], addr[5] );
3092 return ret;
3093 }
get_adaptertype(DWORD type,int * id,int * physical)3094 static const WCHAR *get_adaptertype( DWORD type, int *id, int *physical )
3095 {
3096 static const WCHAR ethernetW[] = {'E','t','h','e','r','n','e','t',' ','8','0','2','.','3',0};
3097 static const WCHAR wirelessW[] = {'W','i','r','e','l','e','s','s',0};
3098 static const WCHAR firewireW[] = {'1','3','9','4',0};
3099 static const WCHAR tunnelW[] = {'T','u','n','n','e','l',0};
3100
3101 switch (type)
3102 {
3103 case IF_TYPE_ETHERNET_CSMACD:
3104 *id = 0;
3105 *physical = -1;
3106 return ethernetW;
3107 case IF_TYPE_IEEE80211:
3108 *id = 9;
3109 *physical = -1;
3110 return wirelessW;
3111 case IF_TYPE_IEEE1394:
3112 *id = 13;
3113 *physical = -1;
3114 return firewireW;
3115 case IF_TYPE_TUNNEL:
3116 *id = 15;
3117 *physical = 0;
3118 return tunnelW;
3119 default:
3120 *id = -1;
3121 *physical = 0;
3122 return NULL;
3123 }
3124 }
3125
fill_networkadapter(struct table * table,const struct expr * cond)3126 static enum fill_status fill_networkadapter( struct table *table, const struct expr *cond )
3127 {
3128 static const WCHAR fmtW[] = {'%','u',0};
3129 WCHAR device_id[11];
3130 struct record_networkadapter *rec;
3131 IP_ADAPTER_ADDRESSES *aa, *buffer;
3132 UINT row = 0, offset = 0, count = 0;
3133 DWORD size = 0, ret;
3134 int adaptertypeid, physical;
3135 enum fill_status status = FILL_STATUS_UNFILTERED;
3136
3137 ret = GetAdaptersAddresses( AF_UNSPEC, 0, NULL, NULL, &size );
3138 if (ret != ERROR_BUFFER_OVERFLOW) return FILL_STATUS_FAILED;
3139
3140 if (!(buffer = heap_alloc( size ))) return FILL_STATUS_FAILED;
3141 if (GetAdaptersAddresses( AF_UNSPEC, 0, NULL, buffer, &size ))
3142 {
3143 heap_free( buffer );
3144 return FILL_STATUS_FAILED;
3145 }
3146 for (aa = buffer; aa; aa = aa->Next)
3147 {
3148 if (aa->IfType != IF_TYPE_SOFTWARE_LOOPBACK) count++;
3149 }
3150 if (!resize_table( table, count, sizeof(*rec) ))
3151 {
3152 heap_free( buffer );
3153 return FILL_STATUS_FAILED;
3154 }
3155 for (aa = buffer; aa; aa = aa->Next)
3156 {
3157 if (aa->IfType == IF_TYPE_SOFTWARE_LOOPBACK) continue;
3158
3159 rec = (struct record_networkadapter *)(table->data + offset);
3160 swprintf( device_id, fmtW, aa->u.s.IfIndex );
3161 rec->adaptertype = get_adaptertype( aa->IfType, &adaptertypeid, &physical );
3162 rec->adaptertypeid = adaptertypeid;
3163 rec->description = heap_strdupW( aa->Description );
3164 rec->device_id = heap_strdupW( device_id );
3165 rec->index = aa->u.s.IfIndex;
3166 rec->interface_index = aa->u.s.IfIndex;
3167 rec->mac_address = get_mac_address( aa->PhysicalAddress, aa->PhysicalAddressLength );
3168 rec->manufacturer = compsys_manufacturerW;
3169 rec->name = heap_strdupW( aa->FriendlyName );
3170 rec->netconnection_status = get_connection_status( aa->OperStatus );
3171 rec->physicaladapter = physical;
3172 rec->pnpdevice_id = networkadapter_pnpdeviceidW;
3173 rec->speed = 1000000;
3174 if (!match_row( table, row, cond, &status ))
3175 {
3176 free_row_values( table, row );
3177 continue;
3178 }
3179 offset += sizeof(*rec);
3180 row++;
3181 }
3182 TRACE("created %u rows\n", row);
3183 table->num_rows = row;
3184
3185 heap_free( buffer );
3186 return status;
3187 }
3188
get_dnshostname(IP_ADAPTER_UNICAST_ADDRESS * addr)3189 static WCHAR *get_dnshostname( IP_ADAPTER_UNICAST_ADDRESS *addr )
3190 {
3191 const SOCKET_ADDRESS *sa = &addr->Address;
3192 WCHAR buf[NI_MAXHOST];
3193
3194 if (!addr) return NULL;
3195 if (GetNameInfoW( sa->lpSockaddr, sa->iSockaddrLength, buf, ARRAY_SIZE( buf ), NULL,
3196 0, NI_NAMEREQD )) return NULL;
3197 return heap_strdupW( buf );
3198 }
get_defaultipgateway(IP_ADAPTER_GATEWAY_ADDRESS * list)3199 static struct array *get_defaultipgateway( IP_ADAPTER_GATEWAY_ADDRESS *list )
3200 {
3201 IP_ADAPTER_GATEWAY_ADDRESS *gateway;
3202 struct array *ret;
3203 ULONG buflen, i = 0, count = 0;
3204 WCHAR **ptr, buf[54]; /* max IPv6 address length */
3205
3206 if (!list) return NULL;
3207 for (gateway = list; gateway; gateway = gateway->Next) count++;
3208
3209 if (!(ret = heap_alloc( sizeof(*ret) ))) return NULL;
3210 if (!(ptr = heap_alloc( sizeof(*ptr) * count )))
3211 {
3212 heap_free( ret );
3213 return NULL;
3214 }
3215 for (gateway = list; gateway; gateway = gateway->Next)
3216 {
3217 buflen = ARRAY_SIZE( buf );
3218 if (WSAAddressToStringW( gateway->Address.lpSockaddr, gateway->Address.iSockaddrLength,
3219 NULL, buf, &buflen) || !(ptr[i++] = heap_strdupW( buf )))
3220 {
3221 for (; i > 0; i--) heap_free( ptr[i - 1] );
3222 heap_free( ptr );
3223 heap_free( ret );
3224 return NULL;
3225 }
3226 }
3227 ret->elem_size = sizeof(*ptr);
3228 ret->count = count;
3229 ret->ptr = ptr;
3230 return ret;
3231 }
get_dnsserversearchorder(IP_ADAPTER_DNS_SERVER_ADDRESS * list)3232 static struct array *get_dnsserversearchorder( IP_ADAPTER_DNS_SERVER_ADDRESS *list )
3233 {
3234 IP_ADAPTER_DNS_SERVER_ADDRESS *server;
3235 struct array *ret;
3236 ULONG buflen, i = 0, count = 0;
3237 WCHAR **ptr, *p, buf[54]; /* max IPv6 address length */
3238
3239 if (!list) return NULL;
3240 for (server = list; server; server = server->Next) count++;
3241
3242 if (!(ret = heap_alloc( sizeof(*ret) ))) return NULL;
3243 if (!(ptr = heap_alloc( sizeof(*ptr) * count )))
3244 {
3245 heap_free( ret );
3246 return NULL;
3247 }
3248 for (server = list; server; server = server->Next)
3249 {
3250 buflen = ARRAY_SIZE( buf );
3251 if (WSAAddressToStringW( server->Address.lpSockaddr, server->Address.iSockaddrLength,
3252 NULL, buf, &buflen) || !(ptr[i++] = heap_strdupW( buf )))
3253 {
3254 for (; i > 0; i--) heap_free( ptr[i - 1] );
3255 heap_free( ptr );
3256 heap_free( ret );
3257 return NULL;
3258 }
3259 if ((p = wcsrchr( ptr[i - 1], ':' ))) *p = 0;
3260 }
3261 ret->elem_size = sizeof(*ptr);
3262 ret->count = count;
3263 ret->ptr = ptr;
3264 return ret;
3265 }
3266
3267 #ifndef __REACTOS__
3268
get_ipaddress(IP_ADAPTER_UNICAST_ADDRESS_LH * list)3269 static struct array *get_ipaddress( IP_ADAPTER_UNICAST_ADDRESS_LH *list )
3270 {
3271 IP_ADAPTER_UNICAST_ADDRESS_LH *address;
3272 struct array *ret;
3273 ULONG buflen, i = 0, count = 0;
3274 WCHAR **ptr, buf[54]; /* max IPv6 address length */
3275
3276 if (!list) return NULL;
3277 for (address = list; address; address = address->Next) count++;
3278
3279 if (!(ret = heap_alloc( sizeof(*ret) ))) return NULL;
3280 if (!(ptr = heap_alloc( sizeof(*ptr) * count )))
3281 {
3282 heap_free( ret );
3283 return NULL;
3284 }
3285 for (address = list; address; address = address->Next)
3286 {
3287 buflen = ARRAY_SIZE( buf );
3288 if (WSAAddressToStringW( address->Address.lpSockaddr, address->Address.iSockaddrLength,
3289 NULL, buf, &buflen) || !(ptr[i++] = heap_strdupW( buf )))
3290 {
3291 for (; i > 0; i--) heap_free( ptr[i - 1] );
3292 heap_free( ptr );
3293 heap_free( ret );
3294 return NULL;
3295 }
3296 }
3297 ret->elem_size = sizeof(*ptr);
3298 ret->count = count;
3299 ret->ptr = ptr;
3300 return ret;
3301 }
get_ipsubnet(IP_ADAPTER_UNICAST_ADDRESS_LH * list)3302 static struct array *get_ipsubnet( IP_ADAPTER_UNICAST_ADDRESS_LH *list )
3303 {
3304 IP_ADAPTER_UNICAST_ADDRESS_LH *address;
3305 struct array *ret;
3306 ULONG i = 0, count = 0;
3307 WCHAR **ptr;
3308
3309 if (!list) return NULL;
3310 for (address = list; address; address = address->Next) count++;
3311
3312 if (!(ret = heap_alloc( sizeof(*ret) ))) return NULL;
3313 if (!(ptr = heap_alloc( sizeof(*ptr) * count )))
3314 {
3315 heap_free( ret );
3316 return NULL;
3317 }
3318 for (address = list; address; address = address->Next)
3319 {
3320 if (address->Address.lpSockaddr->sa_family == AF_INET)
3321 {
3322 WCHAR buf[INET_ADDRSTRLEN];
3323 SOCKADDR_IN addr;
3324 ULONG buflen = ARRAY_SIZE( buf );
3325
3326 memset( &addr, 0, sizeof(addr) );
3327 addr.sin_family = AF_INET;
3328 if (ConvertLengthToIpv4Mask( address->OnLinkPrefixLength, &addr.sin_addr.S_un.S_addr ) != NO_ERROR
3329 || WSAAddressToStringW( (SOCKADDR*)&addr, sizeof(addr), NULL, buf, &buflen))
3330 ptr[i] = NULL;
3331 else
3332 ptr[i] = heap_strdupW( buf );
3333 }
3334 else
3335 {
3336 static const WCHAR fmtW[] = {'%','u',0};
3337 WCHAR buf[11];
3338
3339 swprintf( buf, fmtW, address->OnLinkPrefixLength );
3340 ptr[i] = heap_strdupW( buf );
3341 }
3342 if (!ptr[i++])
3343 {
3344 for (; i > 0; i--) heap_free( ptr[i - 1] );
3345 heap_free( ptr );
3346 heap_free( ret );
3347 return NULL;
3348 }
3349 }
3350 ret->elem_size = sizeof(*ptr);
3351 ret->count = count;
3352 ret->ptr = ptr;
3353 return ret;
3354 }
3355
3356 #endif /* !__REACTOS__ */
3357
get_settingid(UINT32 index)3358 static WCHAR *get_settingid( UINT32 index )
3359 {
3360 GUID guid;
3361 WCHAR *ret, *str;
3362 memset( &guid, 0, sizeof(guid) );
3363 guid.Data1 = index;
3364 UuidToStringW( &guid, &str );
3365 ret = heap_strdupW( str );
3366 RpcStringFreeW( &str );
3367 return ret;
3368 }
3369
fill_networkadapterconfig(struct table * table,const struct expr * cond)3370 static enum fill_status fill_networkadapterconfig( struct table *table, const struct expr *cond )
3371 {
3372 struct record_networkadapterconfig *rec;
3373 IP_ADAPTER_ADDRESSES *aa, *buffer;
3374 UINT row = 0, offset = 0, count = 0;
3375 DWORD size = 0, ret;
3376 enum fill_status status = FILL_STATUS_UNFILTERED;
3377
3378 ret = GetAdaptersAddresses( AF_UNSPEC, GAA_FLAG_INCLUDE_ALL_GATEWAYS, NULL, NULL, &size );
3379 if (ret != ERROR_BUFFER_OVERFLOW) return FILL_STATUS_FAILED;
3380
3381 if (!(buffer = heap_alloc( size ))) return FILL_STATUS_FAILED;
3382 if (GetAdaptersAddresses( AF_UNSPEC, GAA_FLAG_INCLUDE_ALL_GATEWAYS, NULL, buffer, &size ))
3383 {
3384 heap_free( buffer );
3385 return FILL_STATUS_FAILED;
3386 }
3387 for (aa = buffer; aa; aa = aa->Next)
3388 {
3389 if (aa->IfType != IF_TYPE_SOFTWARE_LOOPBACK) count++;
3390 }
3391 if (!resize_table( table, count, sizeof(*rec) ))
3392 {
3393 heap_free( buffer );
3394 return FILL_STATUS_FAILED;
3395 }
3396 for (aa = buffer; aa; aa = aa->Next)
3397 {
3398 if (aa->IfType == IF_TYPE_SOFTWARE_LOOPBACK) continue;
3399
3400 rec = (struct record_networkadapterconfig *)(table->data + offset);
3401 rec->defaultipgateway = get_defaultipgateway( aa->FirstGatewayAddress );
3402 rec->description = heap_strdupW( aa->Description );
3403 rec->dhcpenabled = -1;
3404 rec->dnshostname = get_dnshostname( aa->FirstUnicastAddress );
3405 rec->dnsserversearchorder = get_dnsserversearchorder( aa->FirstDnsServerAddress );
3406 rec->index = aa->u.s.IfIndex;
3407 #ifndef __REACTOS__
3408 rec->ipaddress = get_ipaddress( aa->FirstUnicastAddress );
3409 #endif
3410 rec->ipconnectionmetric = 20;
3411 rec->ipenabled = -1;
3412 #ifndef __REACTOS__
3413 rec->ipsubnet = get_ipsubnet( aa->FirstUnicastAddress );
3414 #endif
3415 rec->mac_address = get_mac_address( aa->PhysicalAddress, aa->PhysicalAddressLength );
3416 rec->settingid = get_settingid( rec->index );
3417 if (!match_row( table, row, cond, &status ))
3418 {
3419 free_row_values( table, row );
3420 continue;
3421 }
3422 offset += sizeof(*rec);
3423 row++;
3424 }
3425 TRACE("created %u rows\n", row);
3426 table->num_rows = row;
3427
3428 heap_free( buffer );
3429 return status;
3430 }
3431
fill_physicalmemory(struct table * table,const struct expr * cond)3432 static enum fill_status fill_physicalmemory( struct table *table, const struct expr *cond )
3433 {
3434 static const WCHAR dimm0W[] = {'D','I','M','M',' ','0',0};
3435 struct record_physicalmemory *rec;
3436 enum fill_status status = FILL_STATUS_UNFILTERED;
3437 UINT row = 0;
3438
3439 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
3440
3441 rec = (struct record_physicalmemory *)table->data;
3442 rec->capacity = get_total_physical_memory();
3443 rec->configuredclockspeed = 0;
3444 rec->devicelocator = dimm0W;
3445 rec->memorytype = 9; /* RAM */
3446 rec->partnumber = NULL;
3447 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
3448 else row++;
3449
3450 TRACE("created %u rows\n", row);
3451 table->num_rows = row;
3452 return status;
3453 }
3454
fill_pnpentity(struct table * table,const struct expr * cond)3455 static enum fill_status fill_pnpentity( struct table *table, const struct expr *cond )
3456 {
3457 struct record_pnpentity *rec;
3458 enum fill_status status = FILL_STATUS_UNFILTERED;
3459 HDEVINFO device_info_set;
3460 SP_DEVINFO_DATA devinfo = {0};
3461 DWORD idx;
3462
3463 device_info_set = SetupDiGetClassDevsW( NULL, NULL, NULL, DIGCF_ALLCLASSES|DIGCF_PRESENT );
3464
3465 devinfo.cbSize = sizeof(devinfo);
3466
3467 idx = 0;
3468 while (SetupDiEnumDeviceInfo( device_info_set, idx++, &devinfo ))
3469 {
3470 /* noop */
3471 }
3472
3473 resize_table( table, idx, sizeof(*rec) );
3474 table->num_rows = 0;
3475 rec = (struct record_pnpentity *)table->data;
3476
3477 idx = 0;
3478 while (SetupDiEnumDeviceInfo( device_info_set, idx++, &devinfo ))
3479 {
3480 WCHAR device_id[MAX_PATH];
3481 if (SetupDiGetDeviceInstanceIdW( device_info_set, &devinfo, device_id,
3482 ARRAY_SIZE(device_id), NULL ))
3483 {
3484 rec->device_id = heap_strdupW( device_id );
3485
3486 table->num_rows++;
3487 if (!match_row( table, table->num_rows - 1, cond, &status ))
3488 {
3489 free_row_values( table, table->num_rows - 1 );
3490 table->num_rows--;
3491 }
3492 else
3493 rec++;
3494 }
3495 }
3496
3497 SetupDiDestroyDeviceInfoList( device_info_set );
3498
3499 return status;
3500 }
3501
fill_printer(struct table * table,const struct expr * cond)3502 static enum fill_status fill_printer( struct table *table, const struct expr *cond )
3503 {
3504 static const WCHAR fmtW[] = {'P','r','i','n','t','e','r','%','d',0};
3505 struct record_printer *rec;
3506 enum fill_status status = FILL_STATUS_UNFILTERED;
3507 PRINTER_INFO_2W *info;
3508 DWORD i, offset = 0, count = 0, size = 0, num_rows = 0;
3509 WCHAR id[20];
3510
3511 EnumPrintersW( PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &size, &count );
3512 if (!count) return FILL_STATUS_UNFILTERED;
3513
3514 if (!(info = heap_alloc( size ))) return FILL_STATUS_FAILED;
3515 if (!EnumPrintersW( PRINTER_ENUM_LOCAL, NULL, 2, (BYTE *)info, size, &size, &count ))
3516 {
3517 heap_free( info );
3518 return FILL_STATUS_FAILED;
3519 }
3520 if (!resize_table( table, count, sizeof(*rec) ))
3521 {
3522 heap_free( info );
3523 return FILL_STATUS_FAILED;
3524 }
3525
3526 for (i = 0; i < count; i++)
3527 {
3528 rec = (struct record_printer *)(table->data + offset);
3529 rec->attributes = info[i].Attributes;
3530 swprintf( id, fmtW, i );
3531 rec->device_id = heap_strdupW( id );
3532 rec->drivername = heap_strdupW( info[i].pDriverName );
3533 rec->horizontalresolution = info[i].pDevMode->u1.s1.dmPrintQuality;
3534 rec->local = -1;
3535 rec->location = heap_strdupW( info[i].pLocation );
3536 rec->name = heap_strdupW( info[i].pPrinterName );
3537 rec->network = 0;
3538 rec->portname = heap_strdupW( info[i].pPortName );
3539 if (!match_row( table, i, cond, &status ))
3540 {
3541 free_row_values( table, i );
3542 continue;
3543 }
3544 offset += sizeof(*rec);
3545 num_rows++;
3546 }
3547 TRACE("created %u rows\n", num_rows);
3548 table->num_rows = num_rows;
3549
3550 heap_free( info );
3551 return status;
3552 }
3553
get_cmdline(DWORD process_id)3554 static WCHAR *get_cmdline( DWORD process_id )
3555 {
3556 if (process_id == GetCurrentProcessId()) return heap_strdupW( GetCommandLineW() );
3557 return NULL; /* FIXME handle different process case */
3558 }
3559
fill_process(struct table * table,const struct expr * cond)3560 static enum fill_status fill_process( struct table *table, const struct expr *cond )
3561 {
3562 static const WCHAR fmtW[] = {'%','u',0};
3563 WCHAR handle[11];
3564 struct record_process *rec;
3565 PROCESSENTRY32W entry;
3566 HANDLE snap;
3567 enum fill_status status = FILL_STATUS_FAILED;
3568 UINT row = 0, offset = 0;
3569
3570 snap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
3571 if (snap == INVALID_HANDLE_VALUE) return FILL_STATUS_FAILED;
3572
3573 entry.dwSize = sizeof(entry);
3574 if (!Process32FirstW( snap, &entry )) goto done;
3575 if (!resize_table( table, 8, sizeof(*rec) )) goto done;
3576
3577 do
3578 {
3579 if (!resize_table( table, row + 1, sizeof(*rec) ))
3580 {
3581 status = FILL_STATUS_FAILED;
3582 goto done;
3583 }
3584
3585 rec = (struct record_process *)(table->data + offset);
3586 rec->caption = heap_strdupW( entry.szExeFile );
3587 rec->commandline = get_cmdline( entry.th32ProcessID );
3588 rec->description = heap_strdupW( entry.szExeFile );
3589 swprintf( handle, fmtW, entry.th32ProcessID );
3590 rec->handle = heap_strdupW( handle );
3591 rec->name = heap_strdupW( entry.szExeFile );
3592 rec->process_id = entry.th32ProcessID;
3593 rec->pprocess_id = entry.th32ParentProcessID;
3594 rec->thread_count = entry.cntThreads;
3595 rec->workingsetsize = 0;
3596 rec->get_owner = process_get_owner;
3597 if (!match_row( table, row, cond, &status ))
3598 {
3599 free_row_values( table, row );
3600 continue;
3601 }
3602 offset += sizeof(*rec);
3603 row++;
3604 } while (Process32NextW( snap, &entry ));
3605
3606 TRACE("created %u rows\n", row);
3607 table->num_rows = row;
3608
3609 done:
3610 CloseHandle( snap );
3611 return status;
3612 }
3613
3614 extern void do_cpuid( unsigned int ax, unsigned int *p );
3615 #if defined(_MSC_VER)
do_cpuid(unsigned int ax,unsigned int * p)3616 void do_cpuid( unsigned int ax, unsigned int *p )
3617 {
3618 __cpuid( p, ax );
3619 }
3620 #elif defined(__i386__)
3621 __ASM_GLOBAL_FUNC( do_cpuid,
3622 "pushl %esi\n\t"
3623 "pushl %ebx\n\t"
3624 "movl 12(%esp),%eax\n\t"
3625 "movl 16(%esp),%esi\n\t"
3626 "cpuid\n\t"
3627 "movl %eax,(%esi)\n\t"
3628 "movl %ebx,4(%esi)\n\t"
3629 "movl %ecx,8(%esi)\n\t"
3630 "movl %edx,12(%esi)\n\t"
3631 "popl %ebx\n\t"
3632 "popl %esi\n\t"
3633 "ret" )
3634 #elif defined(__x86_64__)
3635 __ASM_GLOBAL_FUNC( do_cpuid,
3636 "pushq %rsi\n\t"
3637 "pushq %rbx\n\t"
3638 "movq %rcx,%rax\n\t"
3639 "movq %rdx,%rsi\n\t"
3640 "cpuid\n\t"
3641 "movl %eax,(%rsi)\n\t"
3642 "movl %ebx,4(%rsi)\n\t"
3643 "movl %ecx,8(%rsi)\n\t"
3644 "movl %edx,12(%rsi)\n\t"
3645 "popq %rbx\n\t"
3646 "popq %rsi\n\t"
3647 "ret" )
3648 #else
3649 void do_cpuid( unsigned int ax, unsigned int *p )
3650 {
3651 FIXME("\n");
3652 }
3653 #endif
3654
get_processor_model(unsigned int reg0,unsigned int * stepping,unsigned int * family)3655 static unsigned int get_processor_model( unsigned int reg0, unsigned int *stepping, unsigned int *family )
3656 {
3657 unsigned int model, family_id = (reg0 & (0x0f << 8)) >> 8;
3658
3659 model = (reg0 & (0x0f << 4)) >> 4;
3660 if (family_id == 6 || family_id == 15) model |= (reg0 & (0x0f << 16)) >> 12;
3661 if (family)
3662 {
3663 *family = family_id;
3664 if (family_id == 15) *family += (reg0 & (0xff << 20)) >> 20;
3665 }
3666 *stepping = reg0 & 0x0f;
3667 return model;
3668 }
regs_to_str(unsigned int * regs,unsigned int len,WCHAR * buffer)3669 static void regs_to_str( unsigned int *regs, unsigned int len, WCHAR *buffer )
3670 {
3671 unsigned int i;
3672 unsigned char *p = (unsigned char *)regs;
3673
3674 for (i = 0; i < len; i++) { buffer[i] = *p++; }
3675 buffer[i] = 0;
3676 }
get_processor_manufacturer(WCHAR * manufacturer,UINT len)3677 static void get_processor_manufacturer( WCHAR *manufacturer, UINT len )
3678 {
3679 unsigned int tmp, regs[4] = {0, 0, 0, 0};
3680
3681 do_cpuid( 0, regs );
3682 tmp = regs[2]; /* swap edx and ecx */
3683 regs[2] = regs[3];
3684 regs[3] = tmp;
3685
3686 regs_to_str( regs + 1, min( 12, len ), manufacturer );
3687 }
get_osarchitecture(void)3688 static const WCHAR *get_osarchitecture(void)
3689 {
3690 SYSTEM_INFO info;
3691 GetNativeSystemInfo( &info );
3692 if (info.u.s.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) return os_64bitW;
3693 return os_32bitW;
3694 }
get_processor_caption(WCHAR * caption,UINT len)3695 static void get_processor_caption( WCHAR *caption, UINT len )
3696 {
3697 static const WCHAR fmtW[] =
3698 {'%','s',' ','F','a','m','i','l','y',' ','%','u',' ',
3699 'M','o','d','e','l',' ','%','u',' ','S','t','e','p','p','i','n','g',' ','%','u',0};
3700 static const WCHAR x86W[] = {'x','8','6',0};
3701 static const WCHAR intel64W[] = {'I','n','t','e','l','6','4',0};
3702 static const WCHAR amd64W[] = {'A','M','D','6','4',0};
3703 static const WCHAR authenticamdW[] = {'A','u','t','h','e','n','t','i','c','A','M','D',0};
3704 const WCHAR *arch;
3705 WCHAR manufacturer[13];
3706 unsigned int regs[4] = {0, 0, 0, 0}, family, model, stepping;
3707
3708 get_processor_manufacturer( manufacturer, ARRAY_SIZE( manufacturer ) );
3709 if (get_osarchitecture() == os_32bitW) arch = x86W;
3710 else if (!wcscmp( manufacturer, authenticamdW )) arch = amd64W;
3711 else arch = intel64W;
3712
3713 do_cpuid( 1, regs );
3714
3715 model = get_processor_model( regs[0], &stepping, &family );
3716 swprintf( caption, fmtW, arch, family, model, stepping );
3717 }
get_processor_version(WCHAR * version,UINT len)3718 static void get_processor_version( WCHAR *version, UINT len )
3719 {
3720 static const WCHAR fmtW[] =
3721 {'M','o','d','e','l',' ','%','u',',',' ','S','t','e','p','p','i','n','g',' ','%','u',0};
3722 unsigned int regs[4] = {0, 0, 0, 0}, model, stepping;
3723
3724 do_cpuid( 1, regs );
3725
3726 model = get_processor_model( regs[0], &stepping, NULL );
3727 swprintf( version, fmtW, model, stepping );
3728 }
get_processor_revision(void)3729 static UINT16 get_processor_revision(void)
3730 {
3731 unsigned int regs[4] = {0, 0, 0, 0};
3732 do_cpuid( 1, regs );
3733 return regs[0];
3734 }
get_processor_id(WCHAR * processor_id,UINT len)3735 static void get_processor_id( WCHAR *processor_id, UINT len )
3736 {
3737 static const WCHAR fmtW[] = {'%','0','8','X','%','0','8','X',0};
3738 unsigned int regs[4] = {0, 0, 0, 0};
3739
3740 do_cpuid( 1, regs );
3741 swprintf( processor_id, fmtW, regs[3], regs[0] );
3742 }
get_processor_name(WCHAR * name)3743 static void get_processor_name( WCHAR *name )
3744 {
3745 unsigned int regs[4] = {0, 0, 0, 0};
3746 int i;
3747
3748 do_cpuid( 0x80000000, regs );
3749 if (regs[0] >= 0x80000004)
3750 {
3751 do_cpuid( 0x80000002, regs );
3752 regs_to_str( regs, 16, name );
3753 do_cpuid( 0x80000003, regs );
3754 regs_to_str( regs, 16, name + 16 );
3755 do_cpuid( 0x80000004, regs );
3756 regs_to_str( regs, 16, name + 32 );
3757 }
3758 for (i = lstrlenW(name) - 1; i >= 0 && name[i] == ' '; i--) name[i] = 0;
3759 }
get_processor_currentclockspeed(UINT index)3760 static UINT get_processor_currentclockspeed( UINT index )
3761 {
3762 PROCESSOR_POWER_INFORMATION *info;
3763 UINT ret = 1000, size = get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION);
3764 NTSTATUS status;
3765
3766 if ((info = heap_alloc( size )))
3767 {
3768 status = NtPowerInformation( ProcessorInformation, NULL, 0, info, size );
3769 if (!status) ret = info[index].CurrentMhz;
3770 heap_free( info );
3771 }
3772 return ret;
3773 }
get_processor_maxclockspeed(UINT index)3774 static UINT get_processor_maxclockspeed( UINT index )
3775 {
3776 PROCESSOR_POWER_INFORMATION *info;
3777 UINT ret = 1000, size = get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION);
3778 NTSTATUS status;
3779
3780 if ((info = heap_alloc( size )))
3781 {
3782 status = NtPowerInformation( ProcessorInformation, NULL, 0, info, size );
3783 if (!status) ret = info[index].MaxMhz;
3784 heap_free( info );
3785 }
3786 return ret;
3787 }
3788
fill_processor(struct table * table,const struct expr * cond)3789 static enum fill_status fill_processor( struct table *table, const struct expr *cond )
3790 {
3791 static const WCHAR fmtW[] = {'C','P','U','%','u',0};
3792 WCHAR caption[100], device_id[14], processor_id[17], manufacturer[13], name[49] = {0}, version[50];
3793 struct record_processor *rec;
3794 #ifdef __REACTOS__
3795 UINT i, offset = 0, num_rows = 0, num_cores, num_logical_processors, count = get_processor_count();
3796 #else
3797 UINT i, offset = 0, num_rows = 0, num_logical, num_physical, num_packages;
3798 #endif
3799 enum fill_status status = FILL_STATUS_UNFILTERED;
3800
3801 #ifdef __REACTOS__
3802 if (!resize_table( table, count, sizeof(*rec) )) return FILL_STATUS_FAILED;
3803 #else
3804 num_logical = get_logical_processor_count( &num_physical, &num_packages );
3805
3806 if (!resize_table( table, num_packages, sizeof(*rec) )) return FILL_STATUS_FAILED;
3807 #endif
3808
3809 get_processor_caption( caption, ARRAY_SIZE( caption ) );
3810 get_processor_id( processor_id, ARRAY_SIZE( processor_id ) );
3811 get_processor_manufacturer( manufacturer, ARRAY_SIZE( manufacturer ) );
3812 get_processor_name( name );
3813 get_processor_version( version, ARRAY_SIZE( version ) );
3814
3815 #ifdef __REACTOS__
3816 num_logical_processors = get_logical_processor_count( &num_cores ) / count;
3817 num_cores /= count;
3818
3819 for (i = 0; i < count; i++)
3820 #else
3821 for (i = 0; i < num_packages; i++)
3822 #endif
3823 {
3824 rec = (struct record_processor *)(table->data + offset);
3825 rec->addresswidth = get_osarchitecture() == os_32bitW ? 32 : 64;
3826 rec->architecture = get_osarchitecture() == os_32bitW ? 0 : 9;
3827 rec->caption = heap_strdupW( caption );
3828 rec->cpu_status = 1; /* CPU Enabled */
3829 rec->currentclockspeed = get_processor_currentclockspeed( i );
3830 rec->datawidth = get_osarchitecture() == os_32bitW ? 32 : 64;
3831 rec->description = heap_strdupW( caption );
3832 swprintf( device_id, fmtW, i );
3833 rec->device_id = heap_strdupW( device_id );
3834 rec->family = 2; /* Unknown */
3835 rec->level = 15;
3836 rec->manufacturer = heap_strdupW( manufacturer );
3837 rec->maxclockspeed = get_processor_maxclockspeed( i );
3838 rec->name = heap_strdupW( name );
3839 #ifdef __REACTOS__
3840 rec->num_cores = num_cores;
3841 rec->num_logical_processors = num_logical_processors;
3842 #else
3843 rec->num_cores = num_physical / num_packages;
3844 rec->num_logical_processors = num_logical / num_packages;
3845 #endif
3846 rec->processor_id = heap_strdupW( processor_id );
3847 rec->processortype = 3; /* central processor */
3848 rec->revision = get_processor_revision();
3849 rec->unique_id = NULL;
3850 rec->version = heap_strdupW( version );
3851 if (!match_row( table, i, cond, &status ))
3852 {
3853 free_row_values( table, i );
3854 continue;
3855 }
3856 offset += sizeof(*rec);
3857 num_rows++;
3858 }
3859
3860 TRACE("created %u rows\n", num_rows);
3861 table->num_rows = num_rows;
3862 return status;
3863 }
3864
get_lastbootuptime(void)3865 static WCHAR *get_lastbootuptime(void)
3866 {
3867 static const WCHAR fmtW[] =
3868 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
3869 '.','%','0','6','u','+','0','0','0',0};
3870 SYSTEM_TIMEOFDAY_INFORMATION ti;
3871 TIME_FIELDS tf;
3872 WCHAR *ret;
3873
3874 if (!(ret = heap_alloc( 26 * sizeof(WCHAR) ))) return NULL;
3875
3876 NtQuerySystemInformation( SystemTimeOfDayInformation, &ti, sizeof(ti), NULL );
3877 RtlTimeToTimeFields( &ti.liKeBootTime, &tf );
3878 swprintf( ret, fmtW, tf.Year, tf.Month, tf.Day, tf.Hour, tf.Minute, tf.Second, tf.Milliseconds * 1000 );
3879 return ret;
3880 }
get_localdatetime(void)3881 static WCHAR *get_localdatetime(void)
3882 {
3883 static const WCHAR fmtW[] =
3884 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
3885 '.','%','0','6','u','%','+','0','3','d',0};
3886 TIME_ZONE_INFORMATION tzi;
3887 SYSTEMTIME st;
3888 WCHAR *ret;
3889 DWORD Status;
3890 LONG Bias;
3891
3892 Status = GetTimeZoneInformation(&tzi);
3893
3894 if(Status == TIME_ZONE_ID_INVALID) return NULL;
3895 Bias = tzi.Bias;
3896 if(Status == TIME_ZONE_ID_DAYLIGHT)
3897 Bias+= tzi.DaylightBias;
3898 else
3899 Bias+= tzi.StandardBias;
3900 if (!(ret = heap_alloc( 26 * sizeof(WCHAR) ))) return NULL;
3901
3902 GetLocalTime(&st);
3903 swprintf( ret, fmtW, st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds * 1000, -Bias );
3904 return ret;
3905 }
get_systemdirectory(void)3906 static WCHAR *get_systemdirectory(void)
3907 {
3908 void *redir;
3909 WCHAR *ret;
3910
3911 if (!(ret = heap_alloc( MAX_PATH * sizeof(WCHAR) ))) return NULL;
3912 Wow64DisableWow64FsRedirection( &redir );
3913 GetSystemDirectoryW( ret, MAX_PATH );
3914 Wow64RevertWow64FsRedirection( redir );
3915 return ret;
3916 }
get_systemdrive(void)3917 static WCHAR *get_systemdrive(void)
3918 {
3919 WCHAR *ret = heap_alloc( 3 * sizeof(WCHAR) ); /* "c:" */
3920 if (ret && GetEnvironmentVariableW( prop_systemdriveW, ret, 3 )) return ret;
3921 heap_free( ret );
3922 return NULL;
3923 }
get_codeset(void)3924 static WCHAR *get_codeset(void)
3925 {
3926 static const WCHAR fmtW[] = {'%','u',0};
3927 WCHAR *ret = heap_alloc( 11 * sizeof(WCHAR) );
3928 if (ret) swprintf( ret, fmtW, GetACP() );
3929 return ret;
3930 }
get_countrycode(void)3931 static WCHAR *get_countrycode(void)
3932 {
3933 WCHAR *ret = heap_alloc( 6 * sizeof(WCHAR) );
3934 if (ret) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT, LOCALE_ICOUNTRY, ret, 6 );
3935 return ret;
3936 }
get_locale(void)3937 static WCHAR *get_locale(void)
3938 {
3939 WCHAR *ret = heap_alloc( 5 * sizeof(WCHAR) );
3940 if (ret) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT, LOCALE_ILANGUAGE, ret, 5 );
3941 return ret;
3942 }
get_osbuildnumber(OSVERSIONINFOEXW * ver)3943 static WCHAR *get_osbuildnumber( OSVERSIONINFOEXW *ver )
3944 {
3945 static const WCHAR fmtW[] = {'%','u',0};
3946 WCHAR *ret = heap_alloc( 11 * sizeof(WCHAR) );
3947 if (ret) swprintf( ret, fmtW, ver->dwBuildNumber );
3948 return ret;
3949 }
get_oscaption(OSVERSIONINFOEXW * ver)3950 static WCHAR *get_oscaption( OSVERSIONINFOEXW *ver )
3951 {
3952 static const WCHAR windowsW[] =
3953 {'M','i','c','r','o','s','o','f','t',' ','W','i','n','d','o','w','s',' '};
3954 static const WCHAR win2000W[] =
3955 {'2','0','0','0',' ','P','r','o','f','e','s','s','i','o','n','a','l',0};
3956 static const WCHAR win2003W[] =
3957 {'S','e','r','v','e','r',' ','2','0','0','3',' ','S','t','a','n','d','a','r','d',' ','E','d','i','t','i','o','n',0};
3958 static const WCHAR winxpW[] =
3959 {'X','P',' ','P','r','o','f','e','s','s','i','o','n','a','l',0};
3960 static const WCHAR winxp64W[] =
3961 {'X','P',' ','P','r','o','f','e','s','s','i','o','n','a','l',' ','x','6','4',' ','E','d','i','t','i','o','n',0};
3962 static const WCHAR vistaW[] =
3963 {'V','i','s','t','a',' ','U','l','t','i','m','a','t','e',0};
3964 static const WCHAR win2008W[] =
3965 {'S','e','r','v','e','r',' ','2','0','0','8',' ','S','t','a','n','d','a','r','d',0};
3966 static const WCHAR win7W[] =
3967 {'7',' ','P','r','o','f','e','s','s','i','o','n','a','l',0};
3968 static const WCHAR win2008r2W[] =
3969 {'S','e','r','v','e','r',' ','2','0','0','8',' ','R','2',' ','S','t','a','n','d','a','r','d',0};
3970 static const WCHAR win8W[] =
3971 {'8',' ','P','r','o',0};
3972 static const WCHAR win81W[] =
3973 {'8','.','1',' ','P','r','o',0};
3974 static const WCHAR win10W[] =
3975 {'1','0',' ','P','r','o',0};
3976 int len = ARRAY_SIZE( windowsW );
3977 WCHAR *ret;
3978
3979 if (!(ret = heap_alloc( len * sizeof(WCHAR) + sizeof(win2003W) ))) return NULL;
3980 memcpy( ret, windowsW, sizeof(windowsW) );
3981 if (ver->dwMajorVersion == 10 && ver->dwMinorVersion == 0) memcpy( ret + len, win10W, sizeof(win10W) );
3982 else if (ver->dwMajorVersion == 6 && ver->dwMinorVersion == 3) memcpy( ret + len, win8W, sizeof(win8W) );
3983 else if (ver->dwMajorVersion == 6 && ver->dwMinorVersion == 2) memcpy( ret + len, win81W, sizeof(win81W) );
3984 else if (ver->dwMajorVersion == 6 && ver->dwMinorVersion == 1)
3985 {
3986 if (ver->wProductType == VER_NT_WORKSTATION) memcpy( ret + len, win7W, sizeof(win7W) );
3987 else memcpy( ret + len, win2008r2W, sizeof(win2008r2W) );
3988 }
3989 else if (ver->dwMajorVersion == 6 && ver->dwMinorVersion == 0)
3990 {
3991 if (ver->wProductType == VER_NT_WORKSTATION) memcpy( ret + len, vistaW, sizeof(vistaW) );
3992 else memcpy( ret + len, win2008W, sizeof(win2008W) );
3993 }
3994 else if (ver->dwMajorVersion == 5 && ver->dwMinorVersion == 2)
3995 {
3996 if (ver->wProductType == VER_NT_WORKSTATION) memcpy( ret + len, winxp64W, sizeof(winxp64W) );
3997 else memcpy( ret + len, win2003W, sizeof(win2003W) );
3998 }
3999 else if (ver->dwMajorVersion == 5 && ver->dwMinorVersion == 1) memcpy( ret + len, winxpW, sizeof(winxpW) );
4000 else memcpy( ret + len, win2000W, sizeof(win2000W) );
4001 return ret;
4002 }
get_osname(const WCHAR * caption)4003 static WCHAR *get_osname( const WCHAR *caption )
4004 {
4005 static const WCHAR partitionW[] =
4006 {'|','C',':','\\','W','I','N','D','O','W','S','|','\\','D','e','v','i','c','e','\\',
4007 'H','a','r','d','d','i','s','k','0','\\','P','a','r','t','i','t','i','o','n','1',0};
4008 int len = lstrlenW( caption );
4009 WCHAR *ret;
4010
4011 if (!(ret = heap_alloc( len * sizeof(WCHAR) + sizeof(partitionW) ))) return NULL;
4012 memcpy( ret, caption, len * sizeof(WCHAR) );
4013 memcpy( ret + len, partitionW, sizeof(partitionW) );
4014 return ret;
4015 }
get_osversion(OSVERSIONINFOEXW * ver)4016 static WCHAR *get_osversion( OSVERSIONINFOEXW *ver )
4017 {
4018 static const WCHAR fmtW[] = {'%','u','.','%','u','.','%','u',0};
4019 WCHAR *ret = heap_alloc( 33 * sizeof(WCHAR) );
4020 if (ret) swprintf( ret, fmtW, ver->dwMajorVersion, ver->dwMinorVersion, ver->dwBuildNumber );
4021 return ret;
4022 }
4023 #ifndef __REACTOS__
get_operatingsystemsku(void)4024 static DWORD get_operatingsystemsku(void)
4025 {
4026 DWORD ret = PRODUCT_UNDEFINED;
4027 GetProductInfo( 6, 0, 0, 0, &ret );
4028 return ret;
4029 }
4030 #endif
get_currenttimezone(void)4031 static INT16 get_currenttimezone(void)
4032 {
4033 TIME_ZONE_INFORMATION info;
4034 DWORD status = GetTimeZoneInformation( &info );
4035 if (status == TIME_ZONE_ID_INVALID) return 0;
4036 if (status == TIME_ZONE_ID_DAYLIGHT) return -(info.Bias + info.DaylightBias);
4037 return -(info.Bias + info.StandardBias);
4038 }
4039
fill_operatingsystem(struct table * table,const struct expr * cond)4040 static enum fill_status fill_operatingsystem( struct table *table, const struct expr *cond )
4041 {
4042 static const WCHAR wineprojectW[] = {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
4043 struct record_operatingsystem *rec;
4044 enum fill_status status = FILL_STATUS_UNFILTERED;
4045 OSVERSIONINFOEXW ver;
4046 UINT row = 0;
4047
4048 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
4049
4050 ver.dwOSVersionInfoSize = sizeof(ver);
4051 GetVersionExW( (OSVERSIONINFOW *)&ver );
4052
4053 rec = (struct record_operatingsystem *)table->data;
4054 rec->buildnumber = get_osbuildnumber( &ver );
4055 rec->caption = get_oscaption( &ver );
4056 rec->codeset = get_codeset();
4057 rec->countrycode = get_countrycode();
4058 rec->csdversion = ver.szCSDVersion[0] ? heap_strdupW( ver.szCSDVersion ) : NULL;
4059 rec->csname = get_computername();
4060 rec->currenttimezone = get_currenttimezone();
4061 rec->freephysicalmemory = get_available_physical_memory() / 1024;
4062 rec->installdate = os_installdateW;
4063 rec->lastbootuptime = get_lastbootuptime();
4064 rec->localdatetime = get_localdatetime();
4065 rec->locale = get_locale();
4066 rec->manufacturer = wineprojectW;
4067 rec->name = get_osname( rec->caption );
4068 #ifndef __REACTOS__
4069 rec->operatingsystemsku = get_operatingsystemsku();
4070 #endif
4071 rec->osarchitecture = get_osarchitecture();
4072 rec->oslanguage = GetSystemDefaultLangID();
4073 rec->osproductsuite = 2461140; /* Windows XP Professional */
4074 rec->ostype = 18; /* WINNT */
4075 rec->primary = -1;
4076 rec->serialnumber = os_serialnumberW;
4077 rec->servicepackmajor = ver.wServicePackMajor;
4078 rec->servicepackminor = ver.wServicePackMinor;
4079 rec->suitemask = 272; /* Single User + Terminal */
4080 rec->systemdirectory = get_systemdirectory();
4081 rec->systemdrive = get_systemdrive();
4082 rec->totalvirtualmemorysize = get_total_physical_memory() / 1024;
4083 rec->totalvisiblememorysize = rec->totalvirtualmemorysize;
4084 rec->version = get_osversion( &ver );
4085 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
4086 else row++;
4087
4088 TRACE("created %u rows\n", row);
4089 table->num_rows = row;
4090 return status;
4091 }
4092
get_service_type(DWORD type)4093 static const WCHAR *get_service_type( DWORD type )
4094 {
4095 static const WCHAR filesystem_driverW[] =
4096 {'F','i','l','e',' ','S','y','s','t','e','m',' ','D','r','i','v','e','r',0};
4097 static const WCHAR kernel_driverW[] =
4098 {'K','e','r','n','e','l',' ','D','r','i','v','e','r',0};
4099 static const WCHAR own_processW[] =
4100 {'O','w','n',' ','P','r','o','c','e','s','s',0};
4101 static const WCHAR share_processW[] =
4102 {'S','h','a','r','e',' ','P','r','o','c','e','s','s',0};
4103
4104 if (type & SERVICE_KERNEL_DRIVER) return kernel_driverW;
4105 else if (type & SERVICE_FILE_SYSTEM_DRIVER) return filesystem_driverW;
4106 else if (type & SERVICE_WIN32_OWN_PROCESS) return own_processW;
4107 else if (type & SERVICE_WIN32_SHARE_PROCESS) return share_processW;
4108 else ERR("unhandled type 0x%08x\n", type);
4109 return NULL;
4110 }
get_service_state(DWORD state)4111 static const WCHAR *get_service_state( DWORD state )
4112 {
4113 static const WCHAR runningW[] =
4114 {'R','u','n','n','i','n','g',0};
4115 static const WCHAR start_pendingW[] =
4116 {'S','t','a','r','t',' ','P','e','n','d','i','n','g',0};
4117 static const WCHAR stop_pendingW[] =
4118 {'S','t','o','p',' ','P','e','n','d','i','n','g',0};
4119 static const WCHAR stoppedW[] =
4120 {'S','t','o','p','p','e','d',0};
4121 static const WCHAR unknownW[] =
4122 {'U','n','k','n','o','w','n',0};
4123
4124 switch (state)
4125 {
4126 case SERVICE_STOPPED: return stoppedW;
4127 case SERVICE_START_PENDING: return start_pendingW;
4128 case SERVICE_STOP_PENDING: return stop_pendingW;
4129 case SERVICE_RUNNING: return runningW;
4130 default:
4131 ERR("unknown state %u\n", state);
4132 return unknownW;
4133 }
4134 }
get_service_startmode(DWORD mode)4135 static const WCHAR *get_service_startmode( DWORD mode )
4136 {
4137 static const WCHAR bootW[] = {'B','o','o','t',0};
4138 static const WCHAR systemW[] = {'S','y','s','t','e','m',0};
4139 static const WCHAR autoW[] = {'A','u','t','o',0};
4140 static const WCHAR manualW[] = {'M','a','n','u','a','l',0};
4141 static const WCHAR disabledW[] = {'D','i','s','a','b','l','e','d',0};
4142 static const WCHAR unknownW[] = {'U','n','k','n','o','w','n',0};
4143
4144 switch (mode)
4145 {
4146 case SERVICE_BOOT_START: return bootW;
4147 case SERVICE_SYSTEM_START: return systemW;
4148 case SERVICE_AUTO_START: return autoW;
4149 case SERVICE_DEMAND_START: return manualW;
4150 case SERVICE_DISABLED: return disabledW;
4151 default:
4152 ERR("unknown mode 0x%x\n", mode);
4153 return unknownW;
4154 }
4155 }
query_service_config(SC_HANDLE manager,const WCHAR * name)4156 static QUERY_SERVICE_CONFIGW *query_service_config( SC_HANDLE manager, const WCHAR *name )
4157 {
4158 QUERY_SERVICE_CONFIGW *config = NULL;
4159 SC_HANDLE service;
4160 DWORD size;
4161
4162 if (!(service = OpenServiceW( manager, name, SERVICE_QUERY_CONFIG ))) return NULL;
4163 QueryServiceConfigW( service, NULL, 0, &size );
4164 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) goto done;
4165 if (!(config = heap_alloc( size ))) goto done;
4166 if (QueryServiceConfigW( service, config, size, &size )) goto done;
4167 heap_free( config );
4168 config = NULL;
4169
4170 done:
4171 CloseServiceHandle( service );
4172 return config;
4173 }
4174
fill_service(struct table * table,const struct expr * cond)4175 static enum fill_status fill_service( struct table *table, const struct expr *cond )
4176 {
4177 struct record_service *rec;
4178 SC_HANDLE manager;
4179 ENUM_SERVICE_STATUS_PROCESSW *tmp, *services = NULL;
4180 SERVICE_STATUS_PROCESS *status;
4181 WCHAR sysnameW[MAX_COMPUTERNAME_LENGTH + 1];
4182 DWORD len = ARRAY_SIZE( sysnameW );
4183 UINT i, row = 0, offset = 0, size = 256, needed, count;
4184 enum fill_status fill_status = FILL_STATUS_FAILED;
4185 BOOL ret;
4186
4187 if (!(manager = OpenSCManagerW( NULL, NULL, SC_MANAGER_ENUMERATE_SERVICE ))) return FILL_STATUS_FAILED;
4188 if (!(services = heap_alloc( size ))) goto done;
4189
4190 ret = EnumServicesStatusExW( manager, SC_ENUM_PROCESS_INFO, SERVICE_TYPE_ALL,
4191 SERVICE_STATE_ALL, (BYTE *)services, size, &needed,
4192 &count, NULL, NULL );
4193 if (!ret)
4194 {
4195 if (GetLastError() != ERROR_MORE_DATA) goto done;
4196 size = needed;
4197 if (!(tmp = heap_realloc( services, size ))) goto done;
4198 services = tmp;
4199 ret = EnumServicesStatusExW( manager, SC_ENUM_PROCESS_INFO, SERVICE_TYPE_ALL,
4200 SERVICE_STATE_ALL, (BYTE *)services, size, &needed,
4201 &count, NULL, NULL );
4202 if (!ret) goto done;
4203 }
4204 if (!resize_table( table, count, sizeof(*rec) )) goto done;
4205
4206 GetComputerNameW( sysnameW, &len );
4207 fill_status = FILL_STATUS_UNFILTERED;
4208
4209 for (i = 0; i < count; i++)
4210 {
4211 QUERY_SERVICE_CONFIGW *config;
4212
4213 if (!(config = query_service_config( manager, services[i].lpServiceName ))) continue;
4214
4215 status = &services[i].ServiceStatusProcess;
4216 rec = (struct record_service *)(table->data + offset);
4217 rec->accept_pause = (status->dwControlsAccepted & SERVICE_ACCEPT_PAUSE_CONTINUE) ? -1 : 0;
4218 rec->accept_stop = (status->dwControlsAccepted & SERVICE_ACCEPT_STOP) ? -1 : 0;
4219 rec->displayname = heap_strdupW( services[i].lpDisplayName );
4220 rec->name = heap_strdupW( services[i].lpServiceName );
4221 rec->process_id = status->dwProcessId;
4222 rec->servicetype = get_service_type( status->dwServiceType );
4223 rec->startmode = get_service_startmode( config->dwStartType );
4224 rec->state = get_service_state( status->dwCurrentState );
4225 rec->systemname = heap_strdupW( sysnameW );
4226 rec->pause_service = service_pause_service;
4227 rec->resume_service = service_resume_service;
4228 rec->start_service = service_start_service;
4229 rec->stop_service = service_stop_service;
4230 heap_free( config );
4231 if (!match_row( table, row, cond, &fill_status ))
4232 {
4233 free_row_values( table, row );
4234 continue;
4235 }
4236 offset += sizeof(*rec);
4237 row++;
4238 }
4239
4240 TRACE("created %u rows\n", row);
4241 table->num_rows = row;
4242
4243 done:
4244 CloseServiceHandle( manager );
4245 heap_free( services );
4246 return fill_status;
4247 }
4248
get_accountname(LSA_TRANSLATED_NAME * name)4249 static WCHAR *get_accountname( LSA_TRANSLATED_NAME *name )
4250 {
4251 if (!name || !name->Name.Buffer) return NULL;
4252 return heap_strdupW( name->Name.Buffer );
4253 }
get_binaryrepresentation(PSID sid,UINT len)4254 static struct array *get_binaryrepresentation( PSID sid, UINT len )
4255 {
4256 struct array *ret;
4257 UINT8 *ptr;
4258
4259 if (!(ret = heap_alloc( sizeof(*ret) ))) return NULL;
4260 if (!(ptr = heap_alloc( len )))
4261 {
4262 heap_free( ret );
4263 return NULL;
4264 }
4265 memcpy( ptr, sid, len );
4266 ret->elem_size = sizeof(*ptr);
4267 ret->count = len;
4268 ret->ptr = ptr;
4269 return ret;
4270 }
get_referenceddomainname(LSA_REFERENCED_DOMAIN_LIST * domain)4271 static WCHAR *get_referenceddomainname( LSA_REFERENCED_DOMAIN_LIST *domain )
4272 {
4273 if (!domain || !domain->Domains || !domain->Domains->Name.Buffer) return NULL;
4274 return heap_strdupW( domain->Domains->Name.Buffer );
4275 }
find_sid_str(const struct expr * cond)4276 static const WCHAR *find_sid_str( const struct expr *cond )
4277 {
4278 const struct expr *left, *right;
4279 const WCHAR *ret = NULL;
4280
4281 if (!cond || cond->type != EXPR_COMPLEX || cond->u.expr.op != OP_EQ) return NULL;
4282
4283 left = cond->u.expr.left;
4284 right = cond->u.expr.right;
4285 if (left->type == EXPR_PROPVAL && right->type == EXPR_SVAL && !wcsicmp( left->u.propval->name, prop_sidW ))
4286 {
4287 ret = right->u.sval;
4288 }
4289 else if (left->type == EXPR_SVAL && right->type == EXPR_PROPVAL && !wcsicmp( right->u.propval->name, prop_sidW ))
4290 {
4291 ret = left->u.sval;
4292 }
4293 return ret;
4294 }
4295
fill_sid(struct table * table,const struct expr * cond)4296 static enum fill_status fill_sid( struct table *table, const struct expr *cond )
4297 {
4298 PSID sid;
4299 LSA_REFERENCED_DOMAIN_LIST *domain;
4300 LSA_TRANSLATED_NAME *name;
4301 LSA_HANDLE handle;
4302 LSA_OBJECT_ATTRIBUTES attrs;
4303 const WCHAR *str;
4304 struct record_sid *rec;
4305 UINT len;
4306
4307 if (!(str = find_sid_str( cond ))) return FILL_STATUS_FAILED;
4308 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
4309
4310 if (!ConvertStringSidToSidW( str, &sid )) return FILL_STATUS_FAILED;
4311 len = GetLengthSid( sid );
4312
4313 memset( &attrs, 0, sizeof(attrs) );
4314 attrs.Length = sizeof(attrs);
4315 if (LsaOpenPolicy( NULL, &attrs, POLICY_ALL_ACCESS, &handle ))
4316 {
4317 LocalFree( sid );
4318 return FILL_STATUS_FAILED;
4319 }
4320 if (LsaLookupSids( handle, 1, &sid, &domain, &name ))
4321 {
4322 LocalFree( sid );
4323 LsaClose( handle );
4324 return FILL_STATUS_FAILED;
4325 }
4326
4327 rec = (struct record_sid *)table->data;
4328 rec->accountname = get_accountname( name );
4329 rec->binaryrepresentation = get_binaryrepresentation( sid, len );
4330 rec->referenceddomainname = get_referenceddomainname( domain );
4331 rec->sid = heap_strdupW( str );
4332 rec->sidlength = len;
4333
4334 TRACE("created 1 row\n");
4335 table->num_rows = 1;
4336
4337 LsaFreeMemory( domain );
4338 LsaFreeMemory( name );
4339 LocalFree( sid );
4340 LsaClose( handle );
4341 return FILL_STATUS_FILTERED;
4342 }
4343
get_systemenclosure_string(BYTE id,const char * buf,UINT len)4344 static WCHAR *get_systemenclosure_string( BYTE id, const char *buf, UINT len )
4345 {
4346 const struct smbios_header *hdr;
4347 const struct smbios_chassis *chassis;
4348 UINT offset;
4349
4350 if (!(hdr = find_smbios_entry( SMBIOS_TYPE_CHASSIS, buf, len ))) return NULL;
4351
4352 chassis = (const struct smbios_chassis *)hdr;
4353 offset = (const char *)chassis - buf + chassis->hdr.length;
4354 return get_smbios_string( id, buf, offset, len );
4355 }
4356
get_systemenclosure_manufacturer(const char * buf,UINT len)4357 static WCHAR *get_systemenclosure_manufacturer( const char *buf, UINT len )
4358 {
4359 WCHAR *ret = get_systemenclosure_string( 1, buf, len );
4360 if (!ret) return heap_strdupW( systemenclosure_manufacturerW );
4361 return ret;
4362 }
4363
get_systemenclosure_lockpresent(const char * buf,UINT len)4364 static int get_systemenclosure_lockpresent( const char *buf, UINT len )
4365 {
4366 const struct smbios_header *hdr;
4367 const struct smbios_chassis *chassis;
4368
4369 if (!(hdr = find_smbios_entry( SMBIOS_TYPE_CHASSIS, buf, len )) || hdr->length < sizeof(*chassis)) return 0;
4370
4371 chassis = (const struct smbios_chassis *)hdr;
4372 return (chassis->type & 0x80) ? -1 : 0;
4373 }
4374
dup_array(const struct array * src)4375 static struct array *dup_array( const struct array *src )
4376 {
4377 struct array *dst;
4378 if (!(dst = heap_alloc( sizeof(*dst) ))) return NULL;
4379 if (!(dst->ptr = heap_alloc( src->count * src->elem_size )))
4380 {
4381 heap_free( dst );
4382 return NULL;
4383 }
4384 memcpy( dst->ptr, src->ptr, src->count * src->elem_size );
4385 dst->elem_size = src->elem_size;
4386 dst->count = src->count;
4387 return dst;
4388 }
4389
get_systemenclosure_chassistypes(const char * buf,UINT len)4390 static struct array *get_systemenclosure_chassistypes( const char *buf, UINT len )
4391 {
4392 const struct smbios_header *hdr;
4393 const struct smbios_chassis *chassis;
4394 struct array *ret = NULL;
4395 UINT16 *types;
4396
4397 if (!(hdr = find_smbios_entry( SMBIOS_TYPE_CHASSIS, buf, len )) || hdr->length < sizeof(*chassis)) goto done;
4398 chassis = (const struct smbios_chassis *)hdr;
4399
4400 if (!(ret = heap_alloc( sizeof(*ret) ))) goto done;
4401 if (!(types = heap_alloc( sizeof(*types) )))
4402 {
4403 heap_free( ret );
4404 return NULL;
4405 }
4406 types[0] = chassis->type & ~0x80;
4407
4408 ret->elem_size = sizeof(*types);
4409 ret->count = 1;
4410 ret->ptr = types;
4411
4412 done:
4413 if (!ret) ret = dup_array( &systemenclosure_chassistypes_array );
4414 return ret;
4415 }
4416
fill_systemenclosure(struct table * table,const struct expr * cond)4417 static enum fill_status fill_systemenclosure( struct table *table, const struct expr *cond )
4418 {
4419 struct record_systemenclosure *rec;
4420 enum fill_status status = FILL_STATUS_UNFILTERED;
4421 UINT row = 0, len;
4422 char *buf;
4423
4424 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
4425
4426 len = GetSystemFirmwareTable( RSMB, 0, NULL, 0 );
4427 if (!(buf = heap_alloc( len ))) return FILL_STATUS_FAILED;
4428 GetSystemFirmwareTable( RSMB, 0, buf, len );
4429
4430 rec = (struct record_systemenclosure *)table->data;
4431 rec->caption = systemenclosure_systemenclosureW;
4432 rec->chassistypes = get_systemenclosure_chassistypes( buf, len );
4433 rec->description = systemenclosure_systemenclosureW;
4434 rec->lockpresent = get_systemenclosure_lockpresent( buf, len );
4435 rec->manufacturer = get_systemenclosure_manufacturer( buf, len );
4436 rec->name = systemenclosure_systemenclosureW;
4437 rec->tag = systemenclosure_tagW;
4438 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
4439 else row++;
4440
4441 heap_free( buf );
4442
4443 TRACE("created %u rows\n", row);
4444 table->num_rows = row;
4445 return status;
4446 }
4447
4448 #ifndef __REACTOS__
get_pnpdeviceid(DXGI_ADAPTER_DESC * desc)4449 static WCHAR *get_pnpdeviceid( DXGI_ADAPTER_DESC *desc )
4450 {
4451 static const WCHAR fmtW[] =
4452 {'P','C','I','\\','V','E','N','_','%','0','4','X','&','D','E','V','_','%','0','4','X',
4453 '&','S','U','B','S','Y','S','_','%','0','8','X','&','R','E','V','_','%','0','2','X','\\',
4454 '0','&','D','E','A','D','B','E','E','F','&','0','&','D','E','A','D',0};
4455 UINT len = sizeof(fmtW) + 2;
4456 WCHAR *ret;
4457
4458 if (!(ret = heap_alloc( len * sizeof(WCHAR) ))) return NULL;
4459 swprintf( ret, fmtW, desc->VendorId, desc->DeviceId, desc->SubSysId, desc->Revision );
4460 return ret;
4461 }
4462 #endif
4463
4464 #define HW_VENDOR_AMD 0x1002
4465 #define HW_VENDOR_NVIDIA 0x10de
4466 #define HW_VENDOR_VMWARE 0x15ad
4467 #define HW_VENDOR_INTEL 0x8086
4468
4469 #ifndef __REACTOS__
4470
get_installeddriver(UINT vendorid)4471 static const WCHAR *get_installeddriver( UINT vendorid )
4472 {
4473 static const WCHAR driver_amdW[] = {'a','t','i','c','f','x','3','2','.','d','l','l',0};
4474 static const WCHAR driver_intelW[] = {'i','g','d','u','m','d','i','m','3','2','.','d','l','l',0};
4475 static const WCHAR driver_nvidiaW[] = {'n','v','d','3','d','u','m','.','d','l','l',0};
4476 static const WCHAR driver_wineW[] = {'w','i','n','e','.','d','l','l',0};
4477
4478 /* FIXME: wined3d has a better table, but we cannot access this information through dxgi */
4479
4480 if (vendorid == HW_VENDOR_AMD)
4481 return driver_amdW;
4482 else if (vendorid == HW_VENDOR_NVIDIA)
4483 return driver_nvidiaW;
4484 else if (vendorid == HW_VENDOR_INTEL)
4485 return driver_intelW;
4486 return driver_wineW;
4487 }
4488
fill_videocontroller(struct table * table,const struct expr * cond)4489 static enum fill_status fill_videocontroller( struct table *table, const struct expr *cond )
4490 {
4491 static const WCHAR fmtW[] = {'%','u',' ','x',' ','%','u',' ','x',' ','%','I','6','4','u',' ','c','o','l','o','r','s',0};
4492 struct record_videocontroller *rec;
4493 HRESULT hr;
4494 IDXGIFactory *factory = NULL;
4495 IDXGIAdapter *adapter = NULL;
4496 DXGI_ADAPTER_DESC desc;
4497 UINT row = 0, hres = 1024, vres = 768, vidmem = 512 * 1024 * 1024;
4498 const WCHAR *name = videocontroller_deviceidW;
4499 enum fill_status status = FILL_STATUS_UNFILTERED;
4500 WCHAR mode[44];
4501
4502 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
4503
4504 memset (&desc, 0, sizeof(desc));
4505 hr = CreateDXGIFactory( &IID_IDXGIFactory, (void **)&factory );
4506 if (FAILED(hr)) goto done;
4507
4508 hr = IDXGIFactory_EnumAdapters( factory, 0, &adapter );
4509 if (FAILED(hr)) goto done;
4510
4511 hr = IDXGIAdapter_GetDesc( adapter, &desc );
4512 if (SUCCEEDED(hr))
4513 {
4514 vidmem = desc.DedicatedVideoMemory;
4515 name = desc.Description;
4516 }
4517
4518 done:
4519 rec = (struct record_videocontroller *)table->data;
4520 rec->adapter_dactype = videocontroller_dactypeW;
4521 rec->adapter_ram = vidmem;
4522 rec->availability = 3; /* Running or Full Power */
4523 rec->config_errorcode = 0; /* no error */
4524 rec->caption = heap_strdupW( name );
4525 rec->current_bitsperpixel = get_bitsperpixel( &hres, &vres );
4526 rec->current_horizontalres = hres;
4527 rec->current_refreshrate = 0; /* default refresh rate */
4528 rec->current_scanmode = 2; /* Unknown */
4529 rec->current_verticalres = vres;
4530 rec->description = heap_strdupW( name );
4531 rec->device_id = videocontroller_deviceidW;
4532 rec->driverdate = videocontroller_driverdateW;
4533 rec->driverversion = videocontroller_driverversionW;
4534 rec->installeddriver = get_installeddriver( desc.VendorId );
4535 rec->name = heap_strdupW( name );
4536 rec->pnpdevice_id = get_pnpdeviceid( &desc );
4537 rec->status = videocontroller_statusW;
4538 rec->videoarchitecture = 2; /* Unknown */
4539 rec->videomemorytype = 2; /* Unknown */
4540 swprintf( mode, fmtW, hres, vres, (UINT64)1 << rec->current_bitsperpixel );
4541 rec->videomodedescription = heap_strdupW( mode );
4542 rec->videoprocessor = heap_strdupW( name );
4543 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
4544 else row++;
4545
4546 TRACE("created %u rows\n", row);
4547 table->num_rows = row;
4548
4549 if (adapter) IDXGIAdapter_Release( adapter );
4550 if (factory) IDXGIFactory_Release( factory );
4551 return status;
4552 }
4553
4554 #endif /* !__REACTOS__ */
4555
4556 #define C(c) sizeof(c)/sizeof(c[0]), c
4557 #define D(d) sizeof(d)/sizeof(d[0]), 0, (BYTE *)d
4558 static struct table builtin_classes[] =
4559 {
4560 { class_associatorsW, C(col_associator), D(data_associator) },
4561 { class_baseboardW, C(col_baseboard), 0, 0, NULL, fill_baseboard },
4562 { class_biosW, C(col_bios), 0, 0, NULL, fill_bios },
4563 { class_cdromdriveW, C(col_cdromdrive), 0, 0, NULL, fill_cdromdrive },
4564 { class_compsysW, C(col_compsys), 0, 0, NULL, fill_compsys },
4565 { class_compsysproductW, C(col_compsysproduct), 0, 0, NULL, fill_compsysproduct },
4566 { class_datafileW, C(col_datafile), 0, 0, NULL, fill_datafile },
4567 { class_desktopmonitorW, C(col_desktopmonitor), 0, 0, NULL, fill_desktopmonitor },
4568 { class_directoryW, C(col_directory), 0, 0, NULL, fill_directory },
4569 { class_diskdriveW, C(col_diskdrive), 0, 0, NULL, fill_diskdrive },
4570 { class_diskdrivetodiskpartitionW, C(col_diskdrivetodiskpartition), 0, 0, NULL, fill_diskdrivetodiskpartition },
4571 { class_diskpartitionW, C(col_diskpartition), 0, 0, NULL, fill_diskpartition },
4572 { class_displaycontrollerconfigW, C(col_displaycontrollerconfig), 0, 0, NULL, fill_displaycontrollerconfig },
4573 { class_ip4routetableW, C(col_ip4routetable), 0, 0, NULL, fill_ip4routetable },
4574 { class_logicaldiskW, C(col_logicaldisk), 0, 0, NULL, fill_logicaldisk },
4575 { class_logicaldisk2W, C(col_logicaldisk), 0, 0, NULL, fill_logicaldisk },
4576 { class_logicaldisktopartitionW, C(col_logicaldisktopartition), 0, 0, NULL, fill_logicaldisktopartition },
4577 { class_networkadapterW, C(col_networkadapter), 0, 0, NULL, fill_networkadapter },
4578 { class_networkadapterconfigW, C(col_networkadapterconfig), 0, 0, NULL, fill_networkadapterconfig },
4579 { class_operatingsystemW, C(col_operatingsystem), 0, 0, NULL, fill_operatingsystem },
4580 { class_paramsW, C(col_param), D(data_param) },
4581 { class_physicalmediaW, C(col_physicalmedia), D(data_physicalmedia) },
4582 { class_physicalmemoryW, C(col_physicalmemory), 0, 0, NULL, fill_physicalmemory },
4583 { class_pnpentityW, C(col_pnpentity), 0, 0, NULL, fill_pnpentity },
4584 { class_printerW, C(col_printer), 0, 0, NULL, fill_printer },
4585 { class_processW, C(col_process), 0, 0, NULL, fill_process },
4586 { class_processorW, C(col_processor), 0, 0, NULL, fill_processor },
4587 { class_processor2W, C(col_processor), 0, 0, NULL, fill_processor },
4588 { class_qualifiersW, C(col_qualifier), D(data_qualifier) },
4589 { class_quickfixengineeringW, C(col_quickfixengineering), D(data_quickfixengineering) },
4590 { class_serviceW, C(col_service), 0, 0, NULL, fill_service },
4591 { class_sidW, C(col_sid), 0, 0, NULL, fill_sid },
4592 { class_sounddeviceW, C(col_sounddevice), D(data_sounddevice) },
4593 { class_stdregprovW, C(col_stdregprov), D(data_stdregprov) },
4594 { class_systemsecurityW, C(col_systemsecurity), D(data_systemsecurity) },
4595 { class_systemenclosureW, C(col_systemenclosure), 0, 0, NULL, fill_systemenclosure },
4596 #ifndef __REACTOS__
4597 /* Requires dxgi.dll */
4598 { class_videocontrollerW, C(col_videocontroller), 0, 0, NULL, fill_videocontroller },
4599 #endif
4600 { class_winsatW, C(col_winsat), D(data_winsat) },
4601 };
4602 #undef C
4603 #undef D
4604
init_table_list(void)4605 void init_table_list( void )
4606 {
4607 static struct list tables = LIST_INIT( tables );
4608 UINT i;
4609
4610 for (i = 0; i < ARRAY_SIZE(builtin_classes); i++) list_add_tail( &tables, &builtin_classes[i].entry );
4611 table_list = &tables;
4612 }
4613