ReactOS 0.4.17-dev-1133-gc25e4fd
fxregistryapi.cpp
Go to the documentation of this file.
1/*++
2
3Copyright (c) Microsoft Corporation
4
5Module Name:
6
7 FxRegistryAPI.cpp
8
9Abstract:
10
11 This module implements registry access in the framework
12
13Author:
14
15
16
17Environment:
18
19 Both kernel and user mode
20
21Revision History:
22
23--*/
24
25#include "fxsupportpch.hpp"
26
27extern "C" {
28// #include "FxRegistryAPI.tmh"
29#define RtlSizeTToULong RtlULongPtrToULong
30}
31
32extern "C" {
33//
34// Not in a public header that we can reach, but is documented
35//
42 );
43}
44
45
46//
47// Extern "C" the entire file
48//
49extern "C" {
50
55WDFEXPORT(WdfRegistryOpenKey)(
56 __in
57 PWDF_DRIVER_GLOBALS DriverGlobals,
59 WDFKEY ParentKey,
60 __in
62 __in
66 __out
67 WDFKEY* Key
68 )
69{
70 DDI_ENTRY();
71
75 WDFKEY keyHandle;
77
78 pFxDriverGlobals = GetFxDriverGlobals(DriverGlobals);
80
81 if (ParentKey != NULL) {
83
87 (PVOID*) &pParent,
89
90 parentHandle = pParent->GetHandle();
91 }
92 else {
94
95 //
96 // Get the parent's globals if it is present
97 //
99 KeyAttributes))) {
101
103 KeyAttributes->ParentObject,
105 (PVOID*)&pParent,
107 }
108 }
109
112
113 *Key = NULL;
114
117 return status;
118 }
119
121 if (!NT_SUCCESS(status)) {
122 return status;
123 }
124
126 if (!NT_SUCCESS(status)) {
127 return status;
128 }
129
131 if (pKey == NULL) {
133
136 "Could not allocate memory for a WDFKEY, %!STATUS!", status);
137
138 return status;
139 }
140
142
145
146 if (NT_SUCCESS(status)) {
147 *Key = keyHandle;
148 }
149 else {
152#ifdef __REACTOS__
153 "new WDFKEY object open of %wZ failed, %!STATUS!",
154 KeyName, status);
155#else
156 "new WDFKEY object open failed, %!STATUS!", status);
157#endif
158 }
159 }
160
161 if (!NT_SUCCESS(status)) {
163 pKey = NULL;
164 }
165
166 return status;
167}
168
172NTAPI
173WDFEXPORT(WdfRegistryCreateKey)(
174 __in
175 PWDF_DRIVER_GLOBALS DriverGlobals,
177 WDFKEY ParentKey,
178 __in
180 __in
182 __in
188 __out
189 WDFKEY* Key
190 )
191{
192 DDI_ENTRY();
193
195 FxRegKey* pKey;
197 WDFKEY keyHandle;
199
200 pFxDriverGlobals = GetFxDriverGlobals(DriverGlobals);
201
202 if (ParentKey != NULL) {
204
206 ParentKey,
208 (PVOID*) &pParent,
210
211 parentHandle = pParent->GetHandle();
212 }
213 else {
215
216 //
217 // Get the parent's globals if it is present
218 //
220 KeyAttributes))) {
222
224 KeyAttributes->ParentObject,
226 (PVOID*)&pParent,
228 }
229 }
230
233
234 *Key = NULL;
235 keyHandle = NULL;
236
238 if (!NT_SUCCESS(status)) {
239 return status;
240 }
241
243 if (!NT_SUCCESS(status)) {
244 return status;
245 }
246
248 if (!NT_SUCCESS(status)) {
249 return status;
250 }
251
253
254 if (pKey == NULL) {
258 "Could not allocate memory for WDFKEY, %!STATUS!", status);
259
260 return status;
261 }
262
264
265 if (NT_SUCCESS(status)) {
266 status = pKey->Create(parentHandle,
267 KeyName,
271
272 if (NT_SUCCESS(status)) {
273 *Key = keyHandle;
274 }
275 else {
278 "Registry key creation failed, %!STATUS!", status);
279 }
280 }
281
282 if (!NT_SUCCESS(status)) {
284 pKey = NULL;
285 }
286
287 return status;
288}
289
291VOID
292NTAPI
293WDFEXPORT(WdfRegistryClose)(
294 __in
295 PWDF_DRIVER_GLOBALS DriverGlobals,
296 __in
297 WDFKEY Key
298 )
299{
300 DDI_ENTRY();
301
303 FxRegKey* pKey;
305
307 Key,
309 (PVOID*) &pKey,
311
313 if (!NT_SUCCESS(status)) {
315 return;
316 }
317
318 pKey->Close();
319
321}
322
324HANDLE
325NTAPI
326WDFEXPORT(WdfRegistryWdmGetHandle)(
327 __in
328 PWDF_DRIVER_GLOBALS DriverGlobals,
329 __in
330 WDFKEY Key
331 )
332{
333 DDI_ENTRY();
334
335 FxRegKey* pKey;
336
338 Key,
340 (PVOID*) &pKey);
341
342 return pKey->GetHandle();
343}
344
348NTAPI
349WDFEXPORT(WdfRegistryRemoveKey)(
350 __in
351 PWDF_DRIVER_GLOBALS DriverGlobals,
352 __in
353 WDFKEY Key
354 )
355{
356 DDI_ENTRY();
357
359 FxRegKey* pKey;
361
363 Key,
365 (PVOID*) &pKey,
367
369 if (!NT_SUCCESS(status)) {
370 return status;
371 }
372
374
375 if (NT_SUCCESS(status)) {
376 //
377 // pKey->GetHandle() is now useless, delete the Fx object
378 //
380 }
381
382 return status;
383}
384
388NTAPI
389WDFEXPORT(WdfRegistryRemoveValue)(
390 __in
391 PWDF_DRIVER_GLOBALS DriverGlobals,
392 __in
393 WDFKEY Key,
394 __in
396 )
397{
398 DDI_ENTRY();
399
401 FxRegKey* pKey;
403
405 Key,
407 (PVOID*) &pKey,
409
411 if (!NT_SUCCESS(status)) {
412 return status;
413 }
414
416 if (!NT_SUCCESS(status)) {
417 return status;
418 }
419
421
423
424 return status;
425}
426
430NTAPI
431WDFEXPORT(WdfRegistryQueryValue)(
432 __in
433 PWDF_DRIVER_GLOBALS DriverGlobals,
434 __in
435 WDFKEY Key,
436 __in
438 __in
441 PVOID Value,
446 )
447{
448 DDI_ENTRY();
449
451 FxRegKey* pKey;
453
455 Key,
457 (PVOID*) &pKey,
459
461
463 if (!NT_SUCCESS(status)) {
464 return status;
465 }
466
468 if (!NT_SUCCESS(status)) {
469 return status;
470 }
471
472 status = FxRegKey::_QueryValue(pFxDriverGlobals,
473 pKey->GetHandle(),
474 ValueName,
476 Value,
478 ValueType);
479 if (!NT_SUCCESS(status)) {
480 UCHAR traceLevel = TRACE_LEVEL_ERROR;
481
482 //
483 // Label message as Verbose if this is the known pattern of
484 // passing a 0-length NULL buffer to query the required buffer size.
485 //
486 if (status == STATUS_BUFFER_OVERFLOW && Value == NULL && ValueLength == 0) {
487 traceLevel = TRACE_LEVEL_VERBOSE;
488 }
489
491 "WDFKEY %p QueryValue failed, %!STATUS!",
492 Key, status);
493 }
494
495 return status;
496}
497
501NTAPI
502WDFEXPORT(WdfRegistryQueryMemory)(
503 __in
504 PWDF_DRIVER_GLOBALS DriverGlobals,
505 __in
506 WDFKEY Key,
507 __in
509 __in
514 __out
515 WDFMEMORY* Memory,
518 )
519{
520 DDI_ENTRY();
521
522 FxRegKey* pKey;
527
529 Key,
531 (PVOID*) &pKey,
533
536
537 *Memory = NULL;
538
540 if (!NT_SUCCESS(status)) {
541 return status;
542 }
543
545
547 if (!NT_SUCCESS(status)) {
548 return status;
549 }
550
552 if (!NT_SUCCESS(status)) {
553 return status;
554 }
555
556 //
557 // Query the buffer length required.
558 //
559 status = pKey->QueryValue(ValueName, 0, NULL, &dataLength, NULL);
561 return status;
562 }
563
565 if (dataBuffer == NULL) {
567
570 "WDFKEY %p KEY_VALUE_PARTIAL_INFORMATION allocation failed, %!STATUS!",
571 Key, status);
572
573 return status;
574 }
575
577 if (NT_SUCCESS(status)) {
579
582 PoolType,
585 &pObject);
586
587 if (NT_SUCCESS(status)) {
589
590 if (NT_SUCCESS(status)) {
591 RtlCopyMemory(pObject->GetBuffer(),
593 dataLength);
594 }
595 else {
597 }
598 }
599 else {
602 "WDFKEY %p WDFMEMORY object create failed, %!STATUS!",
603 Key, status);
604 }
605 }
606 else {
608 "WDFKEY %p QueryPartial failed, %!STATUS!",
609 Key, status);
610 }
611
613
614 return status;
615}
616
620NTAPI
621WDFEXPORT(WdfRegistryQueryMultiString)(
622 __in
623 PWDF_DRIVER_GLOBALS DriverGlobals,
624 __in
625 WDFKEY Key,
626 __in
630 __in
631 WDFCOLLECTION Collection
632 )
633{
634 DDI_ENTRY();
635
639 FxRegKey* pKey;
643
645 Key,
647 (PVOID*) &pKey,
649
651
654
656 if (!NT_SUCCESS(status)) {
657 return status;
658 }
659
661 if (!NT_SUCCESS(status)) {
662 return status;
663 }
664
666 if (!NT_SUCCESS(status)) {
667 return status;
668 }
669
673 (PVOID*) &pCollection);
674
677
678 status = pKey->QueryValue(ValueName, 0, NULL, &dataLength, &type);
682 "WDFKEY %p QueryPartial failed: %!STATUS!", Key, status);
683
684 return status;
685 }
686
689 }
690
692 if (dataBuffer == NULL) {
694
697 "WDFKEY %p KEY_VALUE_PARTIAL_INFORMATION allocation failed, %!STATUS!",
698 Key, status);
699
700 return status;
701 }
702
704 if (NT_SUCCESS(status)) {
705 //
706 // Verify that the data from the registry is a valid multi-sz string.
707 //
709 ValueName,
711 dataLength);
712 }
713
714 if (NT_SUCCESS(status)) {
715 ULONG initialCount;
716 PWCHAR pCur;
717
718 initialCount = pCollection->Count();
720
721 while (*pCur != UNICODE_NULL) {
723
726
727 if (pString != NULL) {
728 if (pDeviceBase != NULL) {
730 }
731
733
734 if (NT_SUCCESS(status)) {
736
738 }
739
740 if (NT_SUCCESS(status)) {
741 if (pCollection->Add(pString) == FALSE) {
743
746 "WDFKEY %p, WDFCOLLECTION %p, collection add failed "
747 "%!STATUS!", Key, Collection, status);
748 }
749 }
750
751 if (!NT_SUCCESS(status)) {
752 //
753 // Delete the string we just created
754 //
756 }
757 else {
758 //
759 // NT_SUCCES(status)
760 //
761 // Either the caller is responsible for freeing the
762 // WDFSTRING or it has been parented to another object.
763 //
764 DO_NOTHING();
765 }
766 }
767 else {
769 }
770
771 if (!NT_SUCCESS(status)) {
774 "WDFKEY %p: WDFSTRING creation failed: %!STATUS!",
775 Key, status);
776 break;
777 }
778
779 //
780 // Increment to the next string in the multi sz (length of string +
781 // 1 for the NULL)
782 //
783 pCur += wcslen(pCur) + 1;
784 }
785
786 if (!NT_SUCCESS(status)) {
787 //
788 // Clear out all the items we added to the collection
789 //
790 while (pCollection->Count() > initialCount) {
791 pCollection->Remove(initialCount);
792 }
793 }
794 }
795
797
798 return status;
799}
800
804NTAPI
805WDFEXPORT(WdfRegistryQueryUnicodeString)(
806 __in
807 PWDF_DRIVER_GLOBALS DriverGlobals,
808 __in
809 WDFKEY Key,
810 __in
816 )
817{
818 DDI_ENTRY();
819
821 FxRegKey* pKey;
825
827 Key,
829 (PVOID*) &pKey,
831
833
835 if (!NT_SUCCESS(status)) {
836 return status;
837 }
838
840 if (!NT_SUCCESS(status)) {
841 return status;
842 }
843
844 if (Value != NULL) {
846 if (!NT_SUCCESS(status)) {
847 return status;
848 }
849 }
850
851 if (Value == NULL) {
852 //
853 // Caller wants to know just the length
854 //
855 dataLength = 0;
857 }
858 else {
859 dataLength = Value->MaximumLength;
861
862 if (dataBuffer == NULL) {
864
867 "WDFKEY %p KEY_VALUE_PARTIAL_INFORMATION allocation failed, "
868 "%!STATUS!", Key, status);
869
870 return status;
871 }
872 }
873
878 }
879
880 //
881 // Set ValueByteLength before doing the copy
882 //
884 //
885 // pPartial->DataLength is in bytes, convert to number of
886 // WCHARs
887 //
888 if (ValueByteLength != NULL) {
890 }
891 }
892
894
895
896
897
900
901 //
902 // pPartial->DataLength cannot be greater than Value->MaximumLength
903 // based on the call to _ComputePartialSize above. So it is safe to
904 // copy the pPartial data buffer to the Value buffer.
905 //
906 __analysis_assume(dataLength <= Value->MaximumLength);
908
909 //terminating null shouldn't be included in the Length
910 Value->Length = (USHORT)dataLength;
911
912 if (Value->Buffer[Value->Length/sizeof(WCHAR)-1] == UNICODE_NULL) {
913 Value->Length -= sizeof(WCHAR);
914 }
915 }
916
917 if (dataBuffer != NULL) {
919 }
920
921 return status;
922}
923
927NTAPI
928WDFEXPORT(WdfRegistryQueryString)(
929 __in
930 PWDF_DRIVER_GLOBALS DriverGlobals,
931 __in
932 WDFKEY Key,
933 __in
935 __in
936 WDFSTRING String
937 )
938{
939 DDI_ENTRY();
940
943 FxRegKey* pKey;
947
949 Key,
951 (PVOID*) &pKey,
953
956
958 if (!NT_SUCCESS(status)) {
959 return status;
960 }
961
963 if (!NT_SUCCESS(status)) {
964 return status;
965 }
966
968 String,
970 (PVOID*) &pString);
971
972 status = pKey->QueryValue(ValueName, 0, NULL, &dataLength, &type);
973 if (NT_SUCCESS(status) &&
976 }
977
980 "WDFKEY %p, QueryPartial failed, %!STATUS!",
981 Key, status);
982 return status;
983 }
984
986 if (dataBuffer == NULL) {
988
991 "WDFKEY %p KEY_VALUE_PARTIAL_INFORMATION allocation failed, "
992 "%!STATUS!", Key, status);
993
994 return status;
995 }
996
998 if (NT_SUCCESS(status) &&
1001 }
1002
1003 if (NT_SUCCESS(status)) {
1004 if (dataLength <= USHORT_MAX) {
1005 UNICODE_STRING tmp;
1006
1007 if (dataLength == 0x0) {
1008 //
1009 // Empty string
1010 //
1011 tmp.Buffer = L"";
1012 tmp.Length = 0;
1013 tmp.MaximumLength = 0;
1014 }
1015 else {
1016
1017 //
1018 // The string we read may not be NULL terminated, so put it into a
1019 // UNICODE_STRING. If the final character is NULL, shorten the
1020 // length of the string so that it does not include for the NULL.
1021 //
1022 // If there are embedded NULLs in the string previous to the final
1023 // character, we leave them in place.
1024 //
1025 tmp.Buffer = (PWCHAR) dataBuffer;
1026 tmp.Length = (USHORT) dataLength;
1027 tmp.MaximumLength = tmp.Length;
1028
1029 if (tmp.Buffer[(tmp.Length/sizeof(WCHAR))-1] == UNICODE_NULL) {
1030 //
1031 // Do not include the UNICODE_NULL in the length
1032 //
1033 tmp.Length -= sizeof(WCHAR);
1034 }
1035 }
1036
1037 status = pString->Assign(&tmp);
1038 }
1039 else {
1041
1044 "WDFKEY %p QueryPartial failed, Length %d > max %d, %!STATUS!",
1046 }
1047 }
1048 else {
1051 "WDFKEY %p QueryPartial failed, Length %d, %!STATUS!",
1053 }
1054
1056
1057 return status;
1058}
1059
1063NTAPI
1064WDFEXPORT(WdfRegistryQueryULong)(
1065 __in
1066 PWDF_DRIVER_GLOBALS DriverGlobals,
1067 __in
1068 WDFKEY Key,
1069 __in
1071 __out
1073 )
1074{
1075 DDI_ENTRY();
1076
1078 FxRegKey* pKey;
1080
1082 Key,
1084 (PVOID*) &pKey,
1086
1089
1091 if (!NT_SUCCESS(status)) {
1092 return status;
1093 }
1094
1096 if (!NT_SUCCESS(status)) {
1097 return status;
1098 }
1099
1100 status = FxRegKey::_QueryULong(pKey->GetHandle(), ValueName, Value);
1101
1102 if (!NT_SUCCESS(status)) {
1105 "WDFKEY %p, QueryULong, %!STATUS!", Key, status);
1106 }
1107
1108 return status;
1109}
1110
1111
1115NTAPI
1116WDFEXPORT(WdfRegistryAssignValue)(
1117 __in
1118 PWDF_DRIVER_GLOBALS DriverGlobals,
1119 __in
1120 WDFKEY Key,
1121 __in
1123 __in
1125 __in
1128 PVOID Value
1129 )
1130{
1131 DDI_ENTRY();
1132
1134 FxRegKey* pKey;
1136
1138 Key,
1140 (PVOID*) &pKey,
1142
1144
1146 if (!NT_SUCCESS(status)) {
1147 return status;
1148 }
1149
1151 if (!NT_SUCCESS(status)) {
1152 return status;
1153 }
1154
1156
1157 if (!NT_SUCCESS(status)) {
1159 "WDFKEY %p SetValue, %!STATUS!", Key, status);
1160 }
1161
1162 return status;
1163}
1164
1165
1169NTAPI
1170WDFEXPORT(WdfRegistryAssignMemory)(
1171 __in
1172 PWDF_DRIVER_GLOBALS DriverGlobals,
1173 __in
1174 WDFKEY Key,
1175 __in
1177 __in
1179 __in
1180 WDFMEMORY Memory,
1181 __in_opt
1183 )
1184{
1185 DDI_ENTRY();
1186
1189 FxRegKey* pKey;
1193
1195 Key,
1197 (PVOID*) &pKey,
1199
1202
1204 if (!NT_SUCCESS(status)) {
1205 return status;
1206 }
1207
1209 if (!NT_SUCCESS(status)) {
1210 return status;
1211 }
1212
1214 Memory,
1216 (PVOID*) &pMemory);
1217
1220
1223
1224 if (!NT_SUCCESS(status)) {
1227 "WDFKEY %p, WDFMEMORY %p Offsets overflowed, %!STATUS!",
1228 Key, Memory, status);
1229
1230 return status;
1231 }
1232
1233 if (MemoryOffsets->BufferLength > 0) {
1234 status = RtlSizeTToULong(MemoryOffsets->BufferLength, &length);
1235
1236 if (!NT_SUCCESS(status)) {
1239 "WDFKEY %p, WDFMEMORY %p BufferLength in Offsets truncated, "
1240 "%!STATUS!", Key, Memory, status);
1241
1242 return status;
1243 }
1244 }
1245
1247 }
1248
1249 status = pKey->SetValue(ValueName, ValueType, pBuffer, length);
1250
1251 if (!NT_SUCCESS(status)) {
1253 "WDFKEY handle %p SetValue, %!STATUS!", Key, status);
1254 }
1255
1256 return status;
1257}
1258
1262NTAPI
1263WDFEXPORT(WdfRegistryAssignULong)(
1264 __in
1265 PWDF_DRIVER_GLOBALS DriverGlobals,
1266 __in
1267 WDFKEY Key,
1268 __in
1270 __in
1271 ULONG Value
1272 )
1273{
1274 DDI_ENTRY();
1275
1277 FxRegKey* pKey;
1279
1281 Key,
1283 (PVOID*) &pKey,
1285
1287
1289 if (!NT_SUCCESS(status)) {
1290 return status;
1291 }
1292
1294 if (!NT_SUCCESS(status)) {
1295 return status;
1296 }
1297
1298 status = pKey->SetValue(ValueName, REG_DWORD, &Value, sizeof(Value));
1299
1300 if (!NT_SUCCESS(status)) {
1302 "WDFKEY %p SetValue, %!STATUS!",
1303 Key, status);
1304 }
1305
1306 return status;
1307}
1308
1312NTAPI
1313WDFEXPORT(WdfRegistryAssignUnicodeString)(
1314 __in
1315 PWDF_DRIVER_GLOBALS DriverGlobals,
1316 __in
1317 WDFKEY Key,
1318 __in
1320 __in
1322 )
1323{
1324 DDI_ENTRY();
1325
1327 FxRegKey* pKey;
1330 ULONG length;
1331
1333 Key,
1335 (PVOID*) &pKey,
1337
1340
1342
1344 if (!NT_SUCCESS(status)) {
1345 return status;
1346 }
1347
1349 if (!NT_SUCCESS(status)) {
1350 return status;
1351 }
1352
1354 if (!NT_SUCCESS(status)) {
1355 return status;
1356 }
1357
1358 length = Value->Length + sizeof(UNICODE_NULL);
1359
1360 //
1361 // Buffer must be NULL terminated and Length of the buffer must also include the NULL
1362 // Allocate a temporary buffer and NULL terminate it.
1363 //
1364 tempValueBuf = (PWCHAR) FxPoolAllocate(pFxDriverGlobals, PagedPool, length);
1365
1368
1370 "WDFKEY %p allocate temporary buffer failed, "
1371 "%!STATUS!", Key, status);
1372
1373 return status;
1374 }
1375
1376 //
1377 // Copy over the string from the callers buffer and make sure it is
1378 // NULL terminated.
1379 //
1381 tempValueBuf[Value->Length/sizeof(WCHAR)] = UNICODE_NULL;
1382
1384
1386
1387 if (!NT_SUCCESS(status)) {
1389 "WDFKEY %p set value failed, %!STATUS!",
1390 Key, status);
1391 }
1392
1393 return status;
1394}
1395
1399NTAPI
1400WDFEXPORT(WdfRegistryAssignString)(
1401 __in
1402 PWDF_DRIVER_GLOBALS DriverGlobals,
1403 __in
1404 WDFKEY Key,
1405 __in
1407 __in
1408 WDFSTRING String
1409 )
1410{
1411 DDI_ENTRY();
1412
1415 FxRegKey* pKey;
1417
1419 Key,
1421 (PVOID*) &pKey,
1423
1426
1428 if (!NT_SUCCESS(status)) {
1429 return status;
1430 }
1431
1433 if (!NT_SUCCESS(status)) {
1434 return status;
1435 }
1436
1438 String,
1440 (PVOID*) &pString);
1441
1442 status = pKey->SetValue(ValueName,
1443 REG_SZ,
1444 pString->Buffer(),
1446
1447 if (!NT_SUCCESS(status)) {
1449 "WDFKEY handle %p SetValue, %!STATUS!",
1450 Key, status);
1451 }
1452
1453 return status;
1454}
1455
1459NTAPI
1460WDFEXPORT(WdfRegistryAssignMultiString)(
1461 __in
1462 PWDF_DRIVER_GLOBALS DriverGlobals,
1463 __in
1464 WDFKEY Key,
1465 __in
1467 __in
1468 WDFCOLLECTION StringsCollection
1469 )
1470{
1471 DDI_ENTRY();
1472
1475 FxRegKey* pKey;
1478 ULONG length;
1480
1482 Key,
1484 (PVOID*) &pKey,
1486
1489
1491 if (!NT_SUCCESS(status)) {
1492 return status;
1493 }
1494
1496 if (!NT_SUCCESS(status)) {
1497 return status;
1498 }
1499
1503 (PVOID *) &pCollection);
1504
1505 valid = FALSE;
1506
1509 &length);
1510
1511 if (!NT_SUCCESS(status)) {
1513 "WDFCOLLECTION %p, collection too large to fit into "
1514 "a ULONG, %!STATUS!", StringsCollection, status);
1515 return status;
1516 }
1517
1518 if (valid == FALSE) {
1521 "WDFKEY %p, WDFCOLLECTION %p contains "
1522 "non string objects, %!STATUS!",
1524 return status;
1525 }
1526
1527 pValue = (PWCHAR) FxPoolAllocate(pFxDriverGlobals, PagedPool, length);
1528
1529 if (pValue == NULL) {
1531
1533 "WDFKEY %p allocate for query buffer failed, "
1534 "%!STATUS!", Key, status);
1535
1536 return status;
1537 }
1538
1540
1542
1543 if (!NT_SUCCESS(status)) {
1545 "WDFKEY %p SetValue, %!STATUS!",
1546 Key, status);
1547 }
1548
1550
1551 return status;
1552}
1553
1554} // extern "C"
unsigned char BOOLEAN
Definition: actypes.h:127
#define REG_SZ
Definition: layer.c:22
LONG NTSTATUS
Definition: precomp.h:26
#define NTSYSAPI
Definition: ntoskrnl.h:12
BOOLEAN Add(__in FxObject *Item)
static FxDeviceBase * _SearchForDevice(__in FxObject *Object, __out_opt IFxHasCallbacks **Callbacks)
static _Must_inspect_result_ NTSTATUS _Create(__in PFX_DRIVER_GLOBALS DriverGlobals, __in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __in POOL_TYPE PoolType, __in ULONG PoolTag, __in size_t BufferSize, __out FxMemoryObject **Object)
VOID SetDeviceBase(__in CfxDeviceBase *DeviceBase)
Definition: fxobject.hpp:797
virtual VOID DeleteObject(VOID)
VOID DeleteFromFailedCreate(VOID)
Definition: fxobject.cpp:391
_Must_inspect_result_ NTSTATUS Commit(__in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __out_opt WDFOBJECT *ObjectHandle, __in_opt FxObject *Parent=NULL, __in BOOLEAN AssignDriverAsDefaultParent=TRUE)
Definition: fxobject.cpp:904
static _Must_inspect_result_ NTSTATUS _VerifyMultiSzString(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PCUNICODE_STRING RegValueName, __in_bcount(DataLength) PWCHAR DataString, __in ULONG DataLength)
Definition: fxregkey.cpp:14
static BOOLEAN __inline _IsValidSzType(__in ULONG RegValueType)
Definition: fxregkey.hpp:230
__inline HANDLE GetHandle(VOID)
Definition: fxregkey.hpp:103
__inline USHORT ByteLength(__in BOOLEAN IncludeNull)
Definition: fxstring.hpp:94
__inline PWCHAR Buffer(VOID)
Definition: fxstring.hpp:144
_Must_inspect_result_ NTSTATUS Assign(__in PCWSTR SourceString)
Definition: fxstring.cpp:57
virtual size_t GetBufferSize(VOID)=0
_Must_inspect_result_ NTSTATUS ValidateMemoryOffsets(__in_opt PWDFMEMORY_OFFSET Offsets)
Definition: ifxmemory.hpp:105
virtual PVOID GetBuffer(VOID)=0
static __inline NTSTATUS MxDeleteKey(_In_ HANDLE KeyHandle)
Definition: mxgeneralkm.h:634
#define STATUS_OBJECT_TYPE_MISMATCH
Definition: d3dkmdt.h:46
#define __out_opt
Definition: dbghelp.h:65
#define __in_ecount(x)
Definition: dbghelp.h:47
#define __inout_opt
Definition: dbghelp.h:53
#define __in
Definition: dbghelp.h:35
#define __in_opt
Definition: dbghelp.h:38
#define __out
Definition: dbghelp.h:62
#define __out_bcount_opt(x)
Definition: dbghelp.h:71
#define TRACINGERROR
Definition: dbgtrace.h:63
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2988
#define L(x)
Definition: resources.c:13
#define __drv_maxIRQL(irql)
Definition: driverspecs.h:291
#define __drv_strictTypeMatch(mode)
Definition: driverspecs.h:330
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define PagedPool
Definition: env_spec_w32.h:308
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
SINGLE_LIST_ENTRY * pCur
FxVerifierDbgBreakPoint(pFxDriverGlobals)
FxObject * pParent
Definition: fxdpcapi.cpp:86
__inline PFX_DRIVER_GLOBALS GetFxDriverGlobals(__in PWDF_DRIVER_GLOBALS DriverGlobals)
Definition: fxglobals.h:597
#define DDI_ENTRY()
Definition: fxglobalskm.h:56
#define WDFEXPORT(a)
Definition: fxmacros.hpp:157
#define FxPointerNotNull(FxDriverGlobals, Ptr)
Definition: fxmacros.hpp:253
FxObject * pObject
_Must_inspect_result_ __in WDFKEY __in PCUNICODE_STRING __in_opt PWDF_OBJECT_ATTRIBUTES StringsAttributes
FxDeviceBase * pDeviceBase
FxCollection * pCollection
FxRegKey * pKey
_Must_inspect_result_ __in WDFKEY __in PCUNICODE_STRING __in_opt PWDF_OBJECT_ATTRIBUTES __in WDFCOLLECTION Collection
_Must_inspect_result_ __in_opt WDFKEY __in PCUNICODE_STRING KeyName
_Must_inspect_result_ __in WDFKEY __in PCUNICODE_STRING __in WDFCOLLECTION StringsCollection
#define RtlSizeTToULong
FxObjectHandleGetPtr(GetFxDriverGlobals(DriverGlobals), Key, FX_TYPE_REG_KEY,(PVOID *) &pKey)
_Must_inspect_result_ __in WDFKEY __in PCUNICODE_STRING __in ULONG __out_opt PULONG __out_opt PULONG ValueType
_Must_inspect_result_ __in WDFKEY __in PCUNICODE_STRING __in ULONG __in WDFMEMORY __in_opt PWDFMEMORY_OFFSET MemoryOffsets
_Must_inspect_result_ __in_opt WDFKEY __in PCUNICODE_STRING __in ACCESS_MASK __in ULONG __out_opt PULONG CreateDisposition
BOOLEAN valid
FxCopyMultiSz(pValue, pCollection)
PVOID pBuffer
ULONG type
_Must_inspect_result_ __in WDFKEY __in PCUNICODE_STRING __in WDFSTRING String
_Must_inspect_result_ __in_opt WDFKEY ParentKey
FxPoolFree(dataBuffer)
_Must_inspect_result_ __in WDFKEY __in PCUNICODE_STRING ValueName
_Must_inspect_result_ __in WDFKEY __in PCUNICODE_STRING __in ULONG ValueLength
PWCHAR tempValueBuf
_Must_inspect_result_ __in WDFKEY __in PCUNICODE_STRING __out_opt PUSHORT __inout_opt PUNICODE_STRING Value
_Must_inspect_result_ __in WDFKEY __in PCUNICODE_STRING __in ULONG __out_opt PULONG ValueLengthQueried
ULONG length
NTSTATUS status
PWCHAR pValue
IFxMemory * pMemory
_Must_inspect_result_ __in WDFKEY __in PCUNICODE_STRING __out_opt PUSHORT ValueByteLength
FxString * pString
_Must_inspect_result_ __in WDFKEY __in PCUNICODE_STRING __in __in_opt PWDF_OBJECT_ATTRIBUTES __out WDFMEMORY * Memory
FxObjectHandleGetPtrAndGlobals(GetFxDriverGlobals(DriverGlobals), Key, FX_TYPE_REG_KEY,(PVOID *) &pKey, &pFxDriverGlobals)
FxVerifierCheckNxPoolType(pFxDriverGlobals, PoolType, pFxDriverGlobals->Tag)
_Must_inspect_result_ __in_opt WDFKEY __in PCUNICODE_STRING __in ACCESS_MASK __in ULONG CreateOptions
NTSYSAPI NTSTATUS NTAPI ZwDeleteValueKey(__in IN HANDLE Key, __in IN PUNICODE_STRING ValueName)
PVOID dataBuffer
WDFKEY keyHandle
HANDLE parentHandle
_Must_inspect_result_ __in_opt WDFKEY __in PCUNICODE_STRING __in ACCESS_MASK DesiredAccess
_Must_inspect_result_ __in_opt WDFKEY __in PCUNICODE_STRING __in ACCESS_MASK __in_opt PWDF_OBJECT_ATTRIBUTES KeyAttributes
ULONG dataLength
_Must_inspect_result_ __in_opt WDFKEY __in PCUNICODE_STRING __in ACCESS_MASK __in_opt PWDF_OBJECT_ATTRIBUTES __out WDFKEY * Key
PFX_DRIVER_GLOBALS pFxDriverGlobals
@ FX_TYPE_REG_KEY
Definition: fxtypes.h:51
@ FX_TYPE_OBJECT
Definition: fxtypes.h:45
@ FX_TYPE_COLLECTION
Definition: fxtypes.h:59
@ IFX_TYPE_MEMORY
Definition: fxtypes.h:55
@ FX_TYPE_STRING
Definition: fxtypes.h:52
_Must_inspect_result_ NTSTATUS __inline FxValidateUnicodeString(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PCUNICODE_STRING String)
_Must_inspect_result_ NTSTATUS __inline FxValidateObjectAttributesForParentHandle(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PWDF_OBJECT_ATTRIBUTES Attributes, __in ULONG Flags=FX_VALIDATE_OPTION_NONE_SPECIFIED)
_Must_inspect_result_ NTSTATUS FxValidateObjectAttributes(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PWDF_OBJECT_ATTRIBUTES Attributes, __in ULONG Flags=FX_VALIDATE_OPTION_NONE_SPECIFIED)
__inline NTSTATUS FxVerifierCheckIrqlLevel(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in KIRQL Irql)
Definition: fxverifier.h:158
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
#define USHORT_MAX
Definition: intsafe.h:147
#define ASSERT(a)
Definition: mode.c:44
#define __analysis_assume(expr)
Definition: ms_sal.h:2893
#define DO_NOTHING()
Definition: mxgeneral.h:32
#define _Must_inspect_result_
Definition: no_sal2.h:62
ULONG ACCESS_MASK
Definition: nt_native.h:40
#define REG_MULTI_SZ
Definition: nt_native.h:1504
#define UNICODE_NULL
#define STATUS_INVALID_BUFFER_SIZE
Definition: ntstatus.h:772
short WCHAR
Definition: pedump.c:58
unsigned short USHORT
Definition: pedump.c:61
#define REG_DWORD
Definition: sdbapi.c:615
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
size_t FxCalculateTotalStringSize(__in FxCollectionInternal *StringCollection, __in BOOLEAN Verify=FALSE, __out_opt PBOOLEAN ContainsOnlyStrings=NULL)
Definition: stringutil.cpp:32
NTSTATUS Remove(__in ULONG Index)
USHORT MaximumLength
Definition: env_spec_w32.h:370
Definition: ps.c:97
uint32_t * PULONG
Definition: typedefs.h:59
unsigned char UCHAR
Definition: typedefs.h:53
INT POOL_TYPE
Definition: typedefs.h:78
#define NTAPI
Definition: typedefs.h:36
uint16_t * PUSHORT
Definition: typedefs.h:56
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define IN
Definition: typedefs.h:39
uint16_t * PWCHAR
Definition: typedefs.h:56
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define WDF_PTR_ADD_OFFSET(_ptr, _offset)
Definition: wdfcore.h:144
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK _In_opt_ PWDF_OBJECT_ATTRIBUTES KeyAttributes
Definition: wdfdevice.h:2666
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2664
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3821
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2705
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2439
_In_ WDFDMATRANSACTION _In_ size_t MaximumLength
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ _In_ _Strict_type_match_ POOL_TYPE _In_opt_ PWDF_OBJECT_ATTRIBUTES MemoryAttributes
Definition: wdfmemory.h:409
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ _Strict_type_match_ POOL_TYPE _In_opt_ ULONG _In_ _Out_ WDFMEMORY * Memory
Definition: wdfmemory.h:169
_Must_inspect_result_ _In_opt_ WDFKEY _In_ PCUNICODE_STRING _In_ ACCESS_MASK _In_ ULONG _Out_opt_ PULONG CreateDisposition
Definition: wdfregistry.h:120
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ WDFCOLLECTION Collection
Definition: wdfregistry.h:374
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_ ULONG _Out_opt_ PULONG ValueLengthQueried
Definition: wdfregistry.h:279
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_opt_ PWDF_OBJECT_ATTRIBUTES StringsAttributes
Definition: wdfregistry.h:371
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT ValueByteLength
Definition: wdfregistry.h:410
_Must_inspect_result_ _In_opt_ WDFKEY _In_ PCUNICODE_STRING _In_ ACCESS_MASK _In_ ULONG CreateOptions
Definition: wdfregistry.h:118
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_ WDFCOLLECTION StringsCollection
Definition: wdfregistry.h:606
_Must_inspect_result_ _In_opt_ WDFKEY ParentKey
Definition: wdfregistry.h:69
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_ ULONG _Out_opt_ PULONG _Out_opt_ PULONG ValueType
Definition: wdfregistry.h:282
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:243
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_ ULONG ValueLength
Definition: wdfregistry.h:275
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_ ULONG _In_ WDFMEMORY _In_opt_ PWDFMEMORY_OFFSET MemoryOffsets
Definition: wdfregistry.h:567
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413