ReactOS 0.4.15-dev-5666-gc548b97
builtin.c
Go to the documentation of this file.
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
61
62static const WCHAR class_associatorsW[] =
63 {'_','_','A','S','S','O','C','I','A','T','O','R','S',0};
64static const WCHAR class_baseboardW[] =
65 {'W','i','n','3','2','_','B','a','s','e','B','o','a','r','d',0};
66static const WCHAR class_biosW[] =
67 {'W','i','n','3','2','_','B','I','O','S',0};
68static const WCHAR class_cdromdriveW[] =
69 {'W','i','n','3','2','_','C','D','R','O','M','D','r','i','v','e',0};
70static 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};
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};
74static const WCHAR class_datafileW[] =
75 {'C','I','M','_','D','a','t','a','F','i','l','e',0};
77 {'W','i','n','3','2','_','D','e','s','k','t','o','p','M','o','n','i','t','o','r',0};
78static const WCHAR class_directoryW[] =
79 {'W','i','n','3','2','_','D','i','r','e','c','t','o','r','y',0};
80static const WCHAR class_diskdriveW[] =
81 {'W','i','n','3','2','_','D','i','s','k','D','r','i','v','e',0};
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};
85 {'W','i','n','3','2','_','D','i','s','k','P','a','r','t','i','t','i','o','n',0};
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};
90 {'W','i','n','3','2','_','I','P','4','R','o','u','t','e','T','a','b','l','e',0};
91static const WCHAR class_logicaldiskW[] =
92 {'W','i','n','3','2','_','L','o','g','i','c','a','l','D','i','s','k',0};
93static const WCHAR class_logicaldisk2W[] =
94 {'C','I','M','_','L','o','g','i','c','a','l','D','i','s','k',0};
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};
98 {'W','i','n','3','2','_','N','e','t','w','o','r','k','A','d','a','p','t','e','r',0};
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};
103 {'W','i','n','3','2','_','O','p','e','r','a','t','i','n','g','S','y','s','t','e','m',0};
104static const WCHAR class_paramsW[] =
105 {'_','_','P','A','R','A','M','E','T','E','R','S',0};
107 {'W','i','n','3','2','_','P','h','y','s','i','c','a','l','M','e','d','i','a',0};
109 {'W','i','n','3','2','_','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
110static const WCHAR class_pnpentityW[] =
111 {'W','i','n','3','2','_','P','n','P','E','n','t','i','t','y',0};
112static const WCHAR class_printerW[] =
113 {'W','i','n','3','2','_','P','r','i','n','t','e','r',0};
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};
117static const WCHAR class_processorW[] =
118 {'W','i','n','3','2','_','P','r','o','c','e','s','s','o','r',0};
119static const WCHAR class_processor2W[] =
120 {'C','I','M','_','P','r','o','c','e','s','s','o','r',0};
121static const WCHAR class_qualifiersW[] =
122 {'_','_','Q','U','A','L','I','F','I','E','R','S',0};
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};
125static const WCHAR class_sidW[] =
126 {'W','i','n','3','2','_','S','I','D',0};
127static const WCHAR class_sounddeviceW[] =
128 {'W','i','n','3','2','_','S','o','u','n','d','D','e','v','i','c','e',0};
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__
133 {'W','i','n','3','2','_','V','i','d','e','o','C','o','n','t','r','o','l','l','e','r',0};
134#endif
135static const WCHAR class_winsatW[] =
136 {'W','i','n','3','2','_','W','i','n','S','A','T',0};
137
138static const WCHAR prop_accountnameW[] =
139 {'A','c','c','o','u','n','t','N','a','m','e',0};
140static const WCHAR prop_acceptpauseW[] =
141 {'A','c','c','e','p','t','P','a','u','s','e',0};
142static const WCHAR prop_acceptstopW[] =
143 {'A','c','c','e','p','t','S','t','o','p',0};
144static const WCHAR prop_accessmaskW[] =
145 {'A','c','c','e','s','s','M','a','s','k',0};
146#ifndef __REACTOS__
148 {'A','d','a','p','t','e','r','D','A','C','T','y','p','e',0};
149static const WCHAR prop_adapterramW[] =
150 {'A','d','a','p','t','e','r','R','A','M',0};
151#endif
152static const WCHAR prop_adaptertypeW[] =
153 {'A','d','a','p','t','e','r','T','y','p','e',0};
155 {'A','d','a','p','t','e','r','T','y','p','e','I','D',0};
156static const WCHAR prop_addresswidthW[] =
157 {'A','d','d','r','e','s','s','W','i','d','t','h',0};
158static const WCHAR prop_antecedentW[] =
159 {'A','n','t','e','c','e','d','e','n','t',0};
160static const WCHAR prop_architectureW[] =
161 {'A','r','c','h','i','t','e','c','t','u','r','e',0};
162static const WCHAR prop_assocclassW[] =
163 {'A','s','s','o','c','C','l','a','s','s',0};
164static const WCHAR prop_associatorW[] =
165 {'A','s','s','o','c','i','a','t','o','r',0};
166static const WCHAR prop_attributesW[] =
167 {'A','t','t','r','i','b','u','t','e','s',0};
168#ifndef __REACTOS__
169static const WCHAR prop_availabilityW[] =
170 {'A','v','a','i','l','a','b','i','l','i','t','y',0};
171#endif
173 {'B','i','n','a','r','y','R','e','p','r','e','s','e','n','t','a','t','i','o','n',0};
174static const WCHAR prop_bitsperpixelW[] =
175 {'B','i','t','s','P','e','r','P','i','x','e','l',0};
176static const WCHAR prop_boolvalueW[] =
177 {'B','o','o','l','V','a','l','u','e',0};
178static const WCHAR prop_bootableW[] =
179 {'B','o','o','t','a','b','l','e',0};
181 {'B','o','o','t','P','a','r','t','i','t','i','o','n',0};
182static const WCHAR prop_buildnumberW[] =
183 {'B','u','i','l','d','N','u','m','b','e','r',0};
184static const WCHAR prop_capacityW[] =
185 {'C','a','p','a','c','i','t','y',0};
186static const WCHAR prop_captionW[] =
187 {'C','a','p','t','i','o','n',0};
188static const WCHAR prop_chassistypesW[] =
189 {'C','h','a','s','s','i','s','T','y','p','e','s',0};
190static const WCHAR prop_classW[] =
191 {'C','l','a','s','s',0};
192static const WCHAR prop_codesetW[] =
193 {'C','o','d','e','S','e','t',0};
194static const WCHAR prop_commandlineW[] =
195 {'C','o','m','m','a','n','d','L','i','n','e',0};
197 {'C','o','n','f','i','g','M','a','n','a','g','e','r','E','r','r','o','r','C','o','d','e',0};
199 {'C','o','n','f','i','g','u','r','e','d','C','l','o','c','k','S','p','e','e','d',0};
200static const WCHAR prop_countrycodeW[] =
201 {'C','o','u','n','t','r','y','C','o','d','e',0};
202static const WCHAR prop_cpuscoreW[] =
203 {'C','P','U','S','c','o','r','e',0};
204static const WCHAR prop_cpustatusW[] =
205 {'C','p','u','S','t','a','t','u','s',0};
206static const WCHAR prop_csdversionW[] =
207 {'C','S','D','V','e','r','s','i','o','n',0};
208static const WCHAR prop_csnameW[] =
209 {'C','S','N','a','m','e',0};
210#ifndef __REACTOS__
212 {'C','u','r','r','e','n','t','B','i','t','s','P','e','r','P','i','x','e','l',0};
213#endif
215 {'C','u','r','r','e','n','t','C','l','o','c','k','S','p','e','e','d',0};
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};
219 {'C','u','r','r','e','n','t','L','a','n','g','u','a','g','e',0};
221 {'C','u','r','r','e','n','t','R','e','f','r','e','s','h','R','a','t','e',0};
223 {'C','u','r','r','e','n','t','S','c','a','n','M','o','d','e',0};
225 {'C','u','r','r','e','n','t','T','i','m','e','Z','o','n','e',0};
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};
228static const WCHAR prop_d3dscoreW[] =
229 {'D','3','D','S','c','o','r','e',0};
230static const WCHAR prop_datawidthW[] =
231 {'D','a','t','a','W','i','d','t','h',0};
233 {'D','e','f','a','u','l','t','I','P','G','a','t','e','w','a','y',0};
234static const WCHAR prop_defaultvalueW[] =
235 {'D','e','f','a','u','l','t','V','a','l','u','e',0};
236static const WCHAR prop_dependentW[] =
237 {'D','e','p','e','n','d','e','n','t',0};
238static const WCHAR prop_descriptionW[] =
239 {'D','e','s','c','r','i','p','t','i','o','n',0};
240static const WCHAR prop_destinationW[] =
241 {'D','e','s','t','i','n','a','t','i','o','n',0};
242static const WCHAR prop_deviceidW[] =
243 {'D','e','v','i','c','e','I','d',0};
245 {'D','e','v','i','c','e','L','o','c','a','t','o','r',0};
246static const WCHAR prop_dhcpenabledW[] =
247 {'D','H','C','P','E','n','a','b','l','e','d',0};
248static const WCHAR prop_directionW[] =
249 {'D','i','r','e','c','t','i','o','n',0};
250static const WCHAR prop_diskscoreW[] =
251 {'D','i','s','k','S','c','o','r','e',0};
252static const WCHAR prop_displaynameW[] =
253 {'D','i','s','p','l','a','y','N','a','m','e',0};
254static const WCHAR prop_diskindexW[] =
255 {'D','i','s','k','I','n','d','e','x',0};
256static const WCHAR prop_dnshostnameW[] =
257 {'D','N','S','H','o','s','t','N','a','m','e',0};
259 {'D','N','S','S','e','r','v','e','r','S','e','a','r','c','h','O','r','d','e','r',0};
260static const WCHAR prop_domainW[] =
261 {'D','o','m','a','i','n',0};
262static const WCHAR prop_domainroleW[] =
263 {'D','o','m','a','i','n','R','o','l','e',0};
264static const WCHAR prop_driveW[] =
265 {'D','r','i','v','e',0};
266static const WCHAR prop_driverdateW[] =
267 {'D','r','i','v','e','r','D','a','t','e',0};
268static const WCHAR prop_drivernameW[] =
269 {'D','r','i','v','e','r','N','a','m','e',0};
270#ifndef __REACTOS__
272 {'D','r','i','v','e','r','V','e','r','s','i','o','n',0};
273#endif
274static const WCHAR prop_drivetypeW[] =
275 {'D','r','i','v','e','T','y','p','e',0};
276static const WCHAR prop_familyW[] =
277 {'F','a','m','i','l','y',0};
278static const WCHAR prop_filesystemW[] =
279 {'F','i','l','e','S','y','s','t','e','m',0};
280static const WCHAR prop_flavorW[] =
281 {'F','l','a','v','o','r',0};
282static const WCHAR prop_freespaceW[] =
283 {'F','r','e','e','S','p','a','c','e',0};
285 {'F','r','e','e','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
286static const WCHAR prop_handleW[] =
287 {'H','a','n','d','l','e',0};
289 {'G','r','a','p','h','i','c','s','S','c','o','r','e',0};
291 {'H','o','r','i','z','o','n','t','a','l','R','e','s','o','l','u','t','i','o','n',0};
292static const WCHAR prop_hotfixidW[] =
293 {'H','o','t','F','i','x','I','D',0};
294static const WCHAR prop_idW[] =
295 {'I','D',0};
297 {'I','d','e','n','t','i','f','i','c','a','t','i','o','n','C','o','d','e',0};
299 {'I','d','e','n','t','i','f','y','i','n','g','N','u','m','b','e','r',0};
300static const WCHAR prop_indexW[] =
301 {'I','n','d','e','x',0};
302static const WCHAR prop_installdateW[] =
303 {'I','n','s','t','a','l','l','D','a','t','e',0};
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};
307 {'I','n','t','e','r','f','a','c','e','I','n','d','e','x',0};
309 {'I','n','t','e','r','f','a','c','e','T','y','p','e',0};
310static const WCHAR prop_intvalueW[] =
311 {'I','n','t','e','g','e','r','V','a','l','u','e',0};
312static const WCHAR prop_ipaddressW[] =
313 {'I','P','A','d','d','r','e','s','s',0};
315 {'I','P','C','o','n','n','e','c','t','i','o','n','M','e','t','r','i','c',0};
316static const WCHAR prop_ipenabledW[] =
317 {'I','P','E','n','a','b','l','e','d',0};
318static const WCHAR prop_ipsubnet[] =
319 {'I','P','S','u','b','n','e','t',0};
321 {'L','a','s','t','B','o','o','t','U','p','T','i','m','e',0};
322static const WCHAR prop_levelW[] =
323 {'L','e','v','e','l',0};
324static const WCHAR prop_localW[] =
325 {'L','o','c','a','l',0};
327 {'L','o','c','a','l','D','a','t','e','T','i','m','e',0};
328static const WCHAR prop_localeW[] =
329 {'L','o','c','a','l','e',0};
330static const WCHAR prop_locationW[] =
331 {'L','o','c','a','t','i','o','n',0};
332static const WCHAR prop_lockpresentW[] =
333 {'L','o','c','k','P','r','e','s','e','n','t',0};
334static const WCHAR prop_macaddressW[] =
335 {'M','A','C','A','d','d','r','e','s','s',0};
336static const WCHAR prop_manufacturerW[] =
337 {'M','a','n','u','f','a','c','t','u','r','e','r',0};
339 {'M','a','x','C','l','o','c','k','S','p','e','e','d',0};
340static const WCHAR prop_mediatypeW[] =
341 {'M','e','d','i','a','T','y','p','e',0};
342static const WCHAR prop_memberW[] =
343 {'M','e','m','b','e','r',0};
344static const WCHAR prop_memoryscoreW[] =
345 {'M','e','m','o','r','y','S','c','o','r','e',0};
346static const WCHAR prop_memorytypeW[] =
347 {'M','e','m','o','r','y','T','y','p','e',0};
348static const WCHAR prop_methodW[] =
349 {'M','e','t','h','o','d',0};
350static const WCHAR prop_modelW[] =
351 {'M','o','d','e','l',0};
353 {'N','e','t','C','o','n','n','e','c','t','i','o','n','S','t','a','t','u','s',0};
354static const WCHAR prop_networkW[] =
355 {'N','e','t','w','o','r','k',0};
356static const WCHAR prop_nexthopW[] =
357 {'N','e','x','t','H','o','p',0};
358static const WCHAR prop_numcoresW[] =
359 {'N','u','m','b','e','r','O','f','C','o','r','e','s',0};
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};
363 {'N','u','m','b','e','r','O','f','P','r','o','c','e','s','s','o','r','s',0};
365 {'O','p','e','r','a','t','i','n','g','S','y','s','t','e','m','S','K','U',0};
367 {'O','S','A','r','c','h','i','t','e','c','t','u','r','e',0};
368static const WCHAR prop_oslanguageW[] =
369 {'O','S','L','a','n','g','u','a','g','e',0};
371 {'O','S','P','r','o','d','u','c','t','S','u','i','t','e',0};
372static const WCHAR prop_ostypeW[] =
373 {'O','S','T','y','p','e',0};
374static const WCHAR prop_parameterW[] =
375 {'P','a','r','a','m','e','t','e','r',0};
376static const WCHAR prop_partnumberW[] =
377 {'P','a','r','t','N','u','m','b','e','r',0};
379 {'P','h','y','s','i','c','a','l','A','d','a','p','t','e','r',0};
381 {'P','i','x','e','l','s','P','e','r','X','L','o','g','i','c','a','l','I','n','c','h',0};
382static const WCHAR prop_pnpdeviceidW[] =
383 {'P','N','P','D','e','v','i','c','e','I','D',0};
384static const WCHAR prop_portnameW[] =
385 {'P','o','r','t','N','a','m','e',0};
386static const WCHAR prop_pprocessidW[] =
387 {'P','a','r','e','n','t','P','r','o','c','e','s','s','I','D',0};
388static const WCHAR prop_primaryW[] =
389 {'P','r','i','m','a','r','y',0};
390static const WCHAR prop_processidW[] =
391 {'P','r','o','c','e','s','s','I','D',0};
392static const WCHAR prop_processoridW[] =
393 {'P','r','o','c','e','s','s','o','r','I','d',0};
395 {'P','r','o','c','e','s','s','o','r','T','y','p','e',0};
396static const WCHAR prop_productW[] =
397 {'P','r','o','d','u','c','t',0};
398static const WCHAR prop_productnameW[] =
399 {'P','r','o','d','u','c','t','N','a','m','e',0};
401 {'R','e','f','e','r','e','n','c','e','d','D','o','m','a','i','n','N','a','m','e',0};
402static const WCHAR prop_releasedateW[] =
403 {'R','e','l','e','a','s','e','D','a','t','e',0};
404static const WCHAR prop_revisionW[] =
405 {'R','e','v','i','s','i','o','n',0};
406static const WCHAR prop_serialnumberW[] =
407 {'S','e','r','i','a','l','N','u','m','b','e','r',0};
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};
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};
412static const WCHAR prop_servicetypeW[] =
413 {'S','e','r','v','i','c','e','T','y','p','e',0};
414static const WCHAR prop_settingidW[] =
415 {'S','e','t','t','i','n','g','I','D',0};
416static const WCHAR prop_skunumberW[] =
417 {'S','K','U','N','u','m','b','e','r',0};
419 {'S','M','B','I','O','S','B','I','O','S','V','e','r','s','i','o','n',0};
421 {'S','M','B','I','O','S','M','a','j','o','r','V','e','r','s','i','o','n',0};
423 {'S','M','B','I','O','S','M','i','n','o','r','V','e','r','s','i','o','n',0};
424static const WCHAR prop_startmodeW[] =
425 {'S','t','a','r','t','M','o','d','e',0};
426static const WCHAR prop_sidW[] =
427 {'S','I','D',0};
428static const WCHAR prop_sidlengthW[] =
429 {'S','i','d','L','e','n','g','t','h',0};
430static const WCHAR prop_sizeW[] =
431 {'S','i','z','e',0};
432static const WCHAR prop_speedW[] =
433 {'S','p','e','e','d',0};
435 {'S','t','a','r','t','i','n','g','O','f','f','s','e','t',0};
436static const WCHAR prop_stateW[] =
437 {'S','t','a','t','e',0};
438static const WCHAR prop_statusW[] =
439 {'S','t','a','t','u','s',0};
440static const WCHAR prop_statusinfoW[] =
441 {'S','t','a','t','u','s','I','n','f','o',0};
442static const WCHAR prop_strvalueW[] =
443 {'S','t','r','i','n','g','V','a','l','u','e',0};
444static const WCHAR prop_suitemaskW[] =
445 {'S','u','i','t','e','M','a','s','k',0};
447 {'S','y','s','t','e','m','D','i','r','e','c','t','o','r','y',0};
448static const WCHAR prop_systemdriveW[] =
449 {'S','y','s','t','e','m','D','r','i','v','e',0};
450static const WCHAR prop_systemnameW[] =
451 {'S','y','s','t','e','m','N','a','m','e',0};
452static const WCHAR prop_tagW[] =
453 {'T','a','g',0};
454static const WCHAR prop_threadcountW[] =
455 {'T','h','r','e','a','d','C','o','u','n','t',0};
456static const WCHAR prop_timetakenW[] =
457 {'T','i','m','e','T','a','k','e','n',0};
459 {'T','o','t','a','l','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
461 {'T','o','t','a','l','V','i','r','t','u','a','l','M','e','m','o','r','y','S','i','z','e',0};
463 {'T','o','t','a','l','V','i','s','i','b','l','e','M','e','m','o','r','y','S','i','z','e',0};
464static const WCHAR prop_typeW[] =
465 {'T','y','p','e',0};
466static const WCHAR prop_uniqueidW[] =
467 {'U','n','i','q','u','e','I','d',0};
468static const WCHAR prop_usernameW[] =
469 {'U','s','e','r','N','a','m','e',0};
470static const WCHAR prop_uuidW[] =
471 {'U','U','I','D',0};
472static const WCHAR prop_vendorW[] =
473 {'V','e','n','d','o','r',0};
474static const WCHAR prop_versionW[] =
475 {'V','e','r','s','i','o','n',0};
477 {'V','e','r','t','i','c','a','l','R','e','s','o','l','u','t','i','o','n',0};
478#ifndef __REACTOS__
480 {'V','i','d','e','o','A','r','c','h','i','t','e','c','t','u','r','e',0};
482 {'V','i','d','e','o','M','e','m','o','r','y','T','y','p','e',0};
484 {'V','i','d','e','o','M','o','d','e','D','e','s','c','r','i','p','t','i','o','n',0};
486 {'V','i','d','e','o','P','r','o','c','e','s','s','o','r',0};
487#endif /* !__REACTOS__ */
488static const WCHAR prop_volumenameW[] =
489 {'V','o','l','u','m','e','N','a','m','e',0};
491 {'V','o','l','u','m','e','S','e','r','i','a','l','N','u','m','b','e','r',0};
493 {'W','i','n','S','A','T','A','s','s','e','s','s','m','e','n','t','S','t','a','t','e',0};
494static const WCHAR prop_winsprlevelW[] =
495 {'W','i','n','S','P','R','L','e','v','e','l',0};
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 */
500static const struct column col_associator[] =
501{
505};
506static const struct column col_baseboard[] =
507{
515};
516static const struct column col_bios[] =
517{
529};
530static const struct column col_cdromdrive[] =
531{
537};
538static const struct column col_compsys[] =
539{
550};
551static const struct column col_compsysproduct[] =
552{
559};
560static const struct column col_datafile[] =
561{
564};
565static const struct column col_desktopmonitor[] =
566{
568};
569static const struct column col_directory[] =
570{
573};
574static const struct column col_diskdrive[] =
575{
585};
587{
590};
591static const struct column col_diskpartition[] =
592{
602};
603static const struct column col_displaycontrollerconfig[] =
604{
610};
611static const struct column col_ip4routetable[] =
612{
616};
617static const struct column col_logicaldisk[] =
618{
627};
628static const struct column col_logicaldisktopartition[] =
629{
632};
633static const struct column col_networkadapter[] =
634{
648};
649static const struct column col_networkadapterconfig[] =
650{
663};
664static const struct column col_operatingsystem[] =
665{
695};
696static const struct column col_param[] =
697{
704};
705static const struct column col_physicalmedia[] =
706{
709};
710static const struct column col_physicalmemory[] =
711{
717};
718static const struct column col_pnpentity[] =
719{
721};
722static const struct column col_printer[] =
723{
733};
734static const struct column col_process[] =
735{
745 /* methods */
747};
748static const struct column col_processor[] =
749{
770};
771static const struct column col_qualifier[] =
772{
781};
782static const struct column col_quickfixengineering[] =
783{
786};
787static const struct column col_service[] =
788{
798 /* methods */
803};
804static const struct column col_sid[] =
805{
811};
812static const struct column col_sounddevice[] =
813{
817};
818static const struct column col_stdregprov[] =
819{
824};
825static const struct column col_systemenclosure[] =
826{
834};
835static const struct column col_systemsecurity[] =
836{
839};
840
841#ifndef __REACTOS__
842static const struct column col_videocontroller[] =
843{
866};
867#endif
868
869static const struct column col_winsat[] =
870{
879};
880
881
883 {'I','n','t','e','l',' ','C','o','r','p','o','r','a','t','i','o','n',0};
885 {'N','o','n','e',0};
886static const WCHAR baseboard_tagW[] =
887 {'B','a','s','e',' ','B','o','a','r','d',0};
888static const WCHAR baseboard_versionW[] =
889 {'1','.','0',0};
890static const WCHAR bios_descriptionW[] =
891 {'D','e','f','a','u','l','t',' ','S','y','s','t','e','m',' ','B','I','O','S',0};
892static const WCHAR bios_manufacturerW[] =
893 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
894static 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};
896static const WCHAR bios_serialnumberW[] =
897 {'0',0};
899 {'W','i','n','e',0};
900static const WCHAR bios_versionW[] =
901 {'W','I','N','E',' ',' ',' ','-',' ','1',0};
903 {'C','D','-','R','O','M',0};
904static const WCHAR cdromdrive_nameW[] =
905 {'W','i','n','e',' ','C','D','-','R','O','M',' ','A','T','A',' ','D','e','v','i','c','e',0};
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};
912 {'A','T','/','A','T',' ','C','O','M','P','A','T','I','B','L','E',0};
913static const WCHAR compsys_domainW[] =
914 {'W','O','R','K','G','R','O','U','P',0};
916 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
917static const WCHAR compsys_modelW[] =
918 {'W','i','n','e',0};
920 {'0',0};
922 {'W','i','n','e',0};
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};
927 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
929 {'1','.','0',0};
931 {'I','D','E',0};
933 {'(','S','t','a','n','d','a','r','d',' ','d','i','s','k',' ','d','r','i','v','e','s',')',0};
935 {'F','i','x','e','d',' ','h','a','r','d',' ','d','i','s','k',0};
937 {'R','e','m','o','v','a','b','l','e',' ','m','e','d','i','a',0};
938static const WCHAR diskdrive_modelW[] =
939 {'W','i','n','e',' ','D','i','s','k',' ','D','r','i','v','e',0};
941 {'I','D','E','\\','D','i','s','k','\\','V','E','N','_','W','I','N','E',0};
942static const WCHAR diskdrive_serialW[] =
943 {'W','I','N','E','H','D','I','S','K',0};
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};
948static const WCHAR os_32bitW[] =
949 {'3','2','-','b','i','t',0};
950static const WCHAR os_64bitW[] =
951 {'6','4','-','b','i','t',0};
952static 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};
954static 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};
956static const WCHAR physicalmedia_tagW[] =
957 {'\\','\\','.','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','0',0};
959 {'h','t','t','p',':','/','/','w','i','n','e','h','q','.','o','r','g',0};
961 {'K','B','1','2','3','4','5','6','7',0};
963 {'W','i','n','e',' ','A','u','d','i','o',' ','D','e','v','i','c','e',0};
965 {'S','y','s','t','e','m',' ','E','n','c','l','o','s','u','r','e',0};
967 {'S','y','s','t','e','m',' ','E','n','c','l','o','s','u','r','e',' ','0',0};
969 {'W','i','n','e',0};
971 {'I','n','t','e','g','r','a','t','e','d',' ','R','A','M','D','A','C',0};
973 {'V','i','d','e','o','C','o','n','t','r','o','l','l','e','r','1',0};
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};
977 {'1','.','0',0};
979 {'O','K',0};
980static 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"
985{
987 const WCHAR *class;
989};
991{
993 const WCHAR *model;
994 const WCHAR *name;
997 const WCHAR *tag;
999};
1001{
1006 const WCHAR *name;
1013};
1015{
1017 const WCHAR *drive;
1019 const WCHAR *name;
1021};
1023{
1028 const WCHAR *model;
1029 const WCHAR *name;
1034};
1036{
1038 const WCHAR *name;
1040 const WCHAR *uuid;
1043};
1045{
1046 const WCHAR *name;
1048};
1050{
1052};
1054{
1056 const WCHAR *name;
1057};
1059{
1065 const WCHAR *model;
1069};
1071{
1074};
1076{
1085 const WCHAR *type;
1086};
1088{
1092 const WCHAR *name;
1094};
1096{
1100};
1102{
1107 const WCHAR *name;
1111};
1113{
1116};
1118{
1127 const WCHAR *name;
1132};
1134{
1141 const struct array *ipaddress;
1144 const struct array *ipsubnet;
1147};
1149{
1163 const WCHAR *name;
1179};
1181{
1182 const WCHAR *class;
1188};
1190{
1192 const WCHAR *tag;
1193};
1195{
1201};
1203{
1205};
1207{
1214 const WCHAR *name;
1217};
1219{
1224 const WCHAR *name;
1229 /* methods */
1231};
1233{
1246 const WCHAR *name;
1254};
1256{
1257 const WCHAR *class;
1261 const WCHAR *name;
1265};
1267{
1270};
1272{
1276 const WCHAR *name;
1280 const WCHAR *state;
1282 /* methods */
1287};
1289{
1293 const WCHAR *sid;
1295};
1297{
1298 const WCHAR *name;
1301};
1303{
1308};
1310{
1313};
1315{
1317 const struct array *chassistypes;
1321 const WCHAR *name;
1322 const WCHAR *tag;
1323};
1325{
1341 const WCHAR *name;
1348};
1350{
1359};
1360#include "poppack.h"
1361
1362static const struct record_associator data_associator[] =
1363{
1366};
1367static const struct record_param data_param[] =
1368{
1397};
1398
1399#define FLAVOR_ID (WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE | WBEM_FLAVOR_NOT_OVERRIDABLE |\
1400 WBEM_FLAVOR_ORIGIN_PROPAGATED)
1401
1403{
1405};
1406static const struct record_qualifier data_qualifier[] =
1407{
1410};
1412{
1414};
1416{
1418};
1419static const struct record_stdregprov data_stdregprov[] =
1420{
1422};
1424{
1425 1,
1426};
1428{
1429 sizeof(*systemenclosure_chassistypes),
1432};
1434{
1436};
1437static 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 */
1443static 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 {
1451 return TRUE;
1452 }
1453 if (eval_cond( table, row, cond, &val, &type ) != S_OK)
1454 {
1456 return FALSE;
1457 }
1459 return val != 0;
1460}
1461
1462static BOOL resize_table( struct table *table, UINT row_count, UINT row_size )
1463{
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;
1477 }
1478 return TRUE;
1479}
1480
1481#include "pshpack1.h"
1483{
1489};
1490
1492{
1497};
1498
1500{
1504};
1505
1507{
1513};
1514
1516{
1524};
1525
1527{
1534};
1535
1537{
1544};
1545#include "poppack.h"
1546
1547#define RSMB (('R' << 24) | ('S' << 16) | ('M' << 8) | 'B')
1548
1549static 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
1591static 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
1605static 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
1619{
1622 return ret;
1623}
1624
1625static WCHAR *get_baseboard_product( const char *buf, UINT len )
1626{
1628 if (!ret) return heap_strdupW( baseboard_tagW );
1629 return ret;
1630}
1631
1633{
1636 return ret;
1637}
1638
1639static WCHAR *get_baseboard_version( const char *buf, UINT len )
1640{
1642 if (!ret) return heap_strdupW( baseboard_versionW );
1643 return ret;
1644}
1645
1646static enum fill_status fill_baseboard( struct table *table, const struct expr *cond )
1647{
1648 struct record_baseboard *rec;
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;
1658
1659 rec = (struct record_baseboard *)table->data;
1661 rec->model = baseboard_tagW;
1662 rec->name = baseboard_tagW;
1665 rec->tag = baseboard_tagW;
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
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
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
1691static 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
1704static 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
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
1743static WCHAR *get_bios_releasedate( const char *buf, UINT len )
1744{
1745 WCHAR *ret, *date = get_bios_string( 3, buf, len );
1747 heap_free( date );
1748 return ret;
1749}
1750
1752{
1753 WCHAR *ret = get_bios_string( 2, buf, len );
1755 return ret;
1756}
1757
1758static enum fill_status fill_bios( struct table *table, const struct expr *cond )
1759{
1760 struct record_bios *rec;
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;
1770
1771 rec = (struct record_bios *)table->data;
1772 rec->currentlanguage = NULL;
1774 rec->identificationcode = NULL;
1776 rec->name = bios_descriptionW;
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
1793static 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();
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);
1816 swprintf( drive, fmtW, 'A' + i );
1817 rec->drive = heap_strdupW( drive );
1819 rec->name = cdromdrive_nameW;
1821 if (!match_row( table, row, cond, &status ))
1822 {
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
1836{
1838
1839 if (NtQuerySystemInformation( SystemBasicInformation, &info, sizeof(info), NULL )) return 1;
1840 return info.NumberOfProcessors;
1841}
1842
1843#ifdef __REACTOS__
1844static UINT get_logical_processor_count( UINT *num_cores )
1845{
1847 UINT i, j, count = 0;
1849 ULONG len;
1850
1851 if (num_cores) *num_cores = get_processor_count();
1854
1855 if (!(info = heap_alloc( len ))) return get_processor_count();
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
1878static UINT get_logical_processor_count( UINT *num_physical, UINT *num_packages )
1879{
1881 UINT core_relation_count = 0, package_relation_count = 0;
1883 ULONG len, offset = 0;
1884 BOOL smt_enabled = FALSE;
1885 DWORD all = RelationAll;
1886
1887 if (num_packages) *num_packages = 1;
1890
1891 if (!(buf = heap_alloc( len ))) return get_processor_count();
1893 if (status != STATUS_SUCCESS)
1894 {
1895 heap_free( buf );
1896 return get_processor_count();
1897 }
1898
1899 while (offset < len)
1900 {
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
1923{
1924 MEMORYSTATUSEX status;
1925
1926 status.dwLength = sizeof(status);
1927 if (!GlobalMemoryStatusEx( &status )) return 1024 * 1024 * 1024;
1928 return status.ullTotalPhys;
1929}
1930
1932{
1933 MEMORYSTATUSEX status;
1934
1935 status.dwLength = sizeof(status);
1936 if (!GlobalMemoryStatusEx( &status )) return 1024 * 1024 * 1024;
1937 return status.ullAvailPhys;
1938}
1939
1941{
1942 WCHAR *ret;
1944
1945 if (!(ret = heap_alloc( size * sizeof(WCHAR) ))) return NULL;
1947 return ret;
1948}
1949
1950static 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
1968static enum fill_status fill_compsys( struct table *table, const struct expr *cond )
1969{
1970 struct record_computersystem *rec;
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;
1978 rec->domain = compsys_domainW;
1979 rec->domainrole = 0; /* standalone workstation */
1981 rec->model = compsys_modelW;
1982 rec->name = get_computername();
1983#ifdef __REACTOS__
1986#else
1988#endif
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
1999static 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
2013{
2016 return ret;
2017}
2018
2020{
2022 if (!ret) return heap_strdupW( compsysproduct_nameW );
2023 return ret;
2024}
2025
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
2046done:
2048 return ret;
2049}
2050
2052{
2054 if (!ret) return heap_strdupW( compsysproduct_vendorW );
2055 return ret;
2056}
2057
2059{
2062 return ret;
2063}
2064
2065static enum fill_status fill_compsysproduct( struct table *table, const struct expr *cond )
2066{
2067 struct record_computersystemproduct *rec;
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;
2077
2078 rec = (struct record_computersystemproduct *)table->data;
2081 rec->skunumber = NULL;
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
2096{
2101};
2102
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 {
2111 return NULL;
2112 }
2113 if (!(dirstack->len_dirs = heap_alloc( sizeof(UINT) * size )))
2114 {
2117 return NULL;
2118 }
2119 dirstack->num_dirs = 0;
2121 return dirstack;
2122}
2123
2124static 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
2131static void free_dirstack( struct dirstack *dirstack )
2132{
2137}
2138
2140{
2142
2143 if (!dir) return FALSE;
2144
2145 if (i == dirstack->num_allocated)
2146 {
2147 WCHAR **tmp;
2148 UINT *len_tmp;
2149
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;
2156 }
2157 dirstack->dirs[i] = dir;
2158 dirstack->len_dirs[i] = len;
2159 dirstack->num_dirs++;
2160 return TRUE;
2161}
2162
2164{
2165 if (!dirstack->num_dirs)
2166 {
2167 *len = 0;
2168 return NULL;
2169 }
2170 dirstack->num_dirs--;
2172 return dirstack->dirs[dirstack->num_dirs];
2173}
2174
2175static 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
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
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
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
2260static 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='...']* */
2268static 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
2317static 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
2338{
2339 static const WCHAR slashW[] = {'\\',0}, fmtW[] = {'%','u','.','%','u','.','%','u','.','%','u',0};
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;
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
2364static 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();
2372 HANDLE handle;
2373 struct dirstack *dirstack;
2375
2376 if (!resize_table( table, 8, sizeof(*rec) )) return FILL_STATUS_FAILED;
2377
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 {
2398 goto done;
2399 }
2401 {
2402 do
2403 {
2404 if (!resize_table( table, row + 1, sizeof(*rec) ))
2405 {
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 {
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 );
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 {
2434 continue;
2435 }
2436 else if (num_expected_rows && row == num_expected_rows - 1)
2437 {
2438 row++;
2439 FindClose( handle );
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
2453done:
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
2464{
2465 HDC hdc = GetDC( NULL );
2466 UINT32 ret;
2467
2468 if (!hdc) return 96;
2470 ReleaseDC( NULL, hdc );
2471 return ret;
2472}
2473
2474static enum fill_status fill_desktopmonitor( struct table *table, const struct expr *cond )
2475{
2476 struct record_desktopmonitor *rec;
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;
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
2492static 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();
2500 HANDLE handle;
2501 struct dirstack *dirstack;
2503
2504 if (!resize_table( table, 4, sizeof(*rec) )) return FILL_STATUS_FAILED;
2505
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 {
2526 goto done;
2527 }
2529 {
2530 do
2531 {
2532 if (!resize_table( table, row + 1, sizeof(*rec) ))
2533 {
2534 FindClose( handle );
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 );
2546 goto done;
2547 }
2548
2549 if (!(push_dir( dirstack, new_path, len )))
2550 {
2551 heap_free( new_path );
2552 FindClose( handle );
2554 goto done;
2555 }
2556 rec = (struct record_directory *)(table->data + offset);
2558 rec->name = build_name( root[0], new_path );
2559 heap_free( new_path );
2560 if (!match_row( table, row, cond, &status ))
2561 {
2563 continue;
2564 }
2565 else if (num_expected_rows && row == num_expected_rows - 1)
2566 {
2567 row++;
2568 FindClose( handle );
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
2582done:
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
2592static UINT64 get_freespace( const WCHAR *dir, UINT64 *disksize )
2593{
2594 WCHAR root[] = {'\\','\\','.','\\','A',':',0};
2597 HANDLE handle;
2598 DWORD bytes_returned;
2599
2600 free.QuadPart = 512 * 1024 * 1024;
2602
2603 root[4] = dir[0];
2606 {
2607 if (DeviceIoControl( handle, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, NULL, 0, &info, sizeof(info), &bytes_returned, NULL ))
2608 *disksize = info.DiskSize.QuadPart;
2610 }
2611 return free.QuadPart;
2612}
2613
2614static 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();
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 );
2641 rec->index = index++;
2645 rec->model = diskdrive_modelW;
2648 get_freespace( root, &size );
2649 rec->size = size;
2650 if (!match_row( table, row, cond, &status ))
2651 {
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
2665{
2668};
2669
2670static void free_assocations( struct association *assoc, UINT count