ReactOS 0.4.16-dev-1515-g853b446
rpcserver.c
Go to the documentation of this file.
1/*
2 * ReactOS kernel
3 * Copyright (C) 2005 ReactOS Team
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19/*
20 * COPYRIGHT: See COPYING in the top level directory
21 * PROJECT: ReactOS kernel
22 * FILE: base/services/umpnpmgr/rpcserver.c
23 * PURPOSE: RPC server
24 * PROGRAMMER: Eric Kohl (eric.kohl@reactos.org)
25 * Hervé Poussineau (hpoussin@reactos.org)
26 * Colin Finck (colin@reactos.org)
27 */
28
29/* INCLUDES *****************************************************************/
30
31#include "precomp.h"
32
33#define NDEBUG
34#include <debug.h>
35
36
37/* GLOBALS ******************************************************************/
38
39static WCHAR szRootDeviceInstanceID[] = L"HTREE\\ROOT\\0";
41
44
45/* FUNCTIONS *****************************************************************/
46
49{
51 BOOLEAN RegisteredProtSeq = FALSE;
52
53 UNREFERENCED_PARAMETER(lpParameter);
54
55 DPRINT("RpcServerThread() called\n");
56
59
60#if 0
61 /* 2k/XP/2k3-compatible protocol sequence/endpoint */
63 20,
64 L"\\pipe\\ntsvcs",
65 NULL); // Security descriptor
66 if (Status == RPC_S_OK)
67 RegisteredProtSeq = TRUE;
68 else
69 DPRINT1("RpcServerUseProtseqEpW() failed (Status %lx)\n", Status);
70#endif
71
72 /* Vista/7-compatible protocol sequence/endpoint */
74 20,
75 L"\\pipe\\plugplay",
76 NULL); // Security descriptor
77 if (Status == RPC_S_OK)
78 RegisteredProtSeq = TRUE;
79 else
80 DPRINT1("RpcServerUseProtseqEpW() failed (Status %lx)\n", Status);
81
82 /* Make sure there's a usable endpoint */
83 if (RegisteredProtSeq == FALSE)
84 return 0;
85
86 Status = RpcServerRegisterIf(pnp_v1_0_s_ifspec,
87 NULL,
88 NULL);
89 if (Status != RPC_S_OK)
90 {
91 DPRINT1("RpcServerRegisterIf() failed (Status %lx)\n", Status);
92 return 0;
93 }
94
96 20,
97 FALSE);
98 if (Status != RPC_S_OK)
99 {
100 DPRINT1("RpcServerListen() failed (Status %lx)\n", Status);
101 return 0;
102 }
103
104 /* ROS HACK (this should never happen...) */
105 DPRINT1("*** Other devices won't be installed correctly. If something\n");
106 DPRINT1("*** doesn't work, try to reboot to get a new chance.\n");
107
108 DPRINT("RpcServerThread() done\n");
109
110 return 0;
111}
112
113
115{
117}
118
119
121{
123}
124
125
126static CONFIGRET WINAPI
128{
129 switch (Status)
130 {
133
135 return CR_INVALID_DATA;
136
138 return CR_NO_SUCH_DEVINST;
139
141 return CR_ACCESS_DENIED;
142
144 return CR_BUFFER_SMALL;
145
147 return CR_NO_SUCH_VALUE;
148
149 default:
150 return CR_FAILURE;
151 }
152}
153
154
155static VOID
156SplitDeviceInstanceID(IN LPWSTR pszDeviceInstanceID,
157 OUT LPWSTR pszEnumerator,
158 OUT LPWSTR pszDevice,
159 OUT LPWSTR pszInstance)
160{
161 WCHAR szLocalDeviceInstanceID[MAX_DEVICE_ID_LEN];
162 LPWSTR lpEnumerator = NULL;
163 LPWSTR lpDevice = NULL;
164 LPWSTR lpInstance = NULL;
165 LPWSTR ptr;
166
167 wcscpy(szLocalDeviceInstanceID, pszDeviceInstanceID);
168
169 *pszEnumerator = 0;
170 *pszDevice = 0;
171 *pszInstance = 0;
172
173 lpEnumerator = szLocalDeviceInstanceID;
174
175 ptr = wcschr(lpEnumerator, L'\\');
176 if (ptr != NULL)
177 {
178 *ptr = 0;
179 lpDevice = ++ptr;
180
181 ptr = wcschr(lpDevice, L'\\');
182 if (ptr != NULL)
183 {
184 *ptr = 0;
185 lpInstance = ++ptr;
186 }
187 }
188
189 if (lpEnumerator != NULL)
190 wcscpy(pszEnumerator, lpEnumerator);
191
192 if (lpDevice != NULL)
193 wcscpy(pszDevice, lpDevice);
194
195 if (lpInstance != NULL)
196 wcscpy(pszInstance, lpInstance);
197}
198
199
200static
203 _In_ LPWSTR pszDeviceID,
204 _In_ DWORD ulStatus,
205 _In_ DWORD ulProblem)
206{
207 PLUGPLAY_CONTROL_STATUS_DATA PlugPlayData;
210
211 DPRINT1("ClearDeviceStatus(%S 0x%lx 0x%lx)\n",
212 pszDeviceID, ulStatus, ulProblem);
213
215 pszDeviceID);
216 PlugPlayData.Operation = PNP_CLEAR_DEVICE_STATUS;
217 PlugPlayData.DeviceStatus = ulStatus;
218 PlugPlayData.DeviceProblem = ulProblem;
219
221 (PVOID)&PlugPlayData,
223 if (!NT_SUCCESS(Status))
225
226 return ret;
227}
228
229
230static
233 _In_ LPWSTR pszDeviceID,
234 _Out_ DWORD *pulStatus,
235 _Out_ DWORD *pulProblem)
236{
237 PLUGPLAY_CONTROL_STATUS_DATA PlugPlayData;
240
241 DPRINT("GetDeviceStatus(%S %p %p)\n",
242 pszDeviceID, pulStatus, pulProblem);
243
245 pszDeviceID);
246 PlugPlayData.Operation = PNP_GET_DEVICE_STATUS;
247
249 (PVOID)&PlugPlayData,
251 if (NT_SUCCESS(Status))
252 {
253 *pulStatus = PlugPlayData.DeviceStatus;
254 *pulProblem = PlugPlayData.DeviceProblem;
255 }
256 else
257 {
259 }
260
261 return ret;
262}
263
264
265static
268 _In_ LPWSTR pszDeviceID,
269 _In_ DWORD ulStatus,
270 _In_ DWORD ulProblem)
271{
272 PLUGPLAY_CONTROL_STATUS_DATA PlugPlayData;
275
276 DPRINT1("SetDeviceStatus(%S 0x%lx 0x%lx)\n",
277 pszDeviceID, ulStatus, ulProblem);
278
280 pszDeviceID);
281 PlugPlayData.Operation = PNP_SET_DEVICE_STATUS;
282 PlugPlayData.DeviceStatus = ulStatus;
283 PlugPlayData.DeviceProblem = ulProblem;
284
286 (PVOID)&PlugPlayData,
288 if (!NT_SUCCESS(Status))
290
291 return ret;
292}
293
294
295static
298 _In_ LPWSTR pszDeviceInstance,
299 _Inout_opt_ PPNP_VETO_TYPE pVetoType,
300 _Inout_opt_ LPWSTR pszVetoName,
301 _In_ DWORD ulNameLength)
302{
306
307 DPRINT1("DisableDeviceInstance(%S %p %p %lu)\n",
308 pszDeviceInstance, pVetoType, pszVetoName, ulNameLength);
309
310 RtlInitUnicodeString(&QueryRemoveData.DeviceInstance,
311 pszDeviceInstance);
312
313 QueryRemoveData.Flags = 0;
314 QueryRemoveData.VetoType = 0;
315 QueryRemoveData.VetoName = pszVetoName;
316 QueryRemoveData.NameLength = ulNameLength;
317
319 &QueryRemoveData,
322 {
324 }
326 {
327 if (pVetoType != NULL)
328 *pVetoType = QueryRemoveData.VetoType;
329
331 }
332 else if (!NT_SUCCESS(Status))
333 {
335 }
336
337 return ret;
338}
339
340
341static
342BOOL
344 _In_ PWSTR pszDeviceInstanceID)
345{
346 INT nPartLength[3] = {0, 0, 0};
347 INT nLength = 0, nParts = 0;
348 PWCHAR p;
349
350 DPRINT("IsValidDeviceInstanceID(%S)\n",
351 pszDeviceInstanceID);
352
353 if (pszDeviceInstanceID == NULL)
354 {
355 DPRINT("Device instance ID is NULL!\n");
356 return FALSE;
357 }
358
359 p = pszDeviceInstanceID;
360 while (*p != UNICODE_NULL)
361 {
362 if (*p == L'\\')
363 {
364 nParts++;
365 if (nParts >= 3)
366 {
367 DPRINT("Too many separators: %d\n", nParts);
368 return FALSE;
369 }
370 }
371 else
372 {
373 nPartLength[nParts]++;
374 }
375
376 nLength++;
378 {
379 DPRINT("Too long: %d\n", nLength);
380 return FALSE;
381 }
382
383 p++;
384 }
385
386 if (nParts != 2)
387 {
388 DPRINT("Invalid number of separtors: %d\n", nParts);
389 return FALSE;
390 }
391
392 if ((nPartLength[0] == 0) ||
393 (nPartLength[1] == 0) ||
394 (nPartLength[2] == 0))
395 {
396 DPRINT("Invalid part lengths: %d %d %d\n",
397 nPartLength[0], nPartLength[1], nPartLength[2]);
398 return FALSE;
399 }
400
401 DPRINT("Valid device instance ID!\n");
402
403 return TRUE;
404}
405
406
407static
408BOOL
410 _In_ PWSTR pszDeviceInstanceID)
411{
412 if (_wcsicmp(pszDeviceInstanceID, szRootDeviceInstanceID) == 0)
413 return TRUE;
414
415 return FALSE;
416}
417
418
419static
420BOOL
422 _In_ LPWSTR pszDeviceInstanceID)
423{
424 DWORD ulStatus, ulProblem;
425
426 return (GetDeviceStatus(pszDeviceInstanceID, &ulStatus, &ulProblem) == CR_SUCCESS);
427}
428
429
430static
433 _In_ LPCWSTR pszDeviceID,
434 _In_ DWORD ulLogConfType,
435 _Out_ PHKEY phKey)
436{
437 WCHAR szKeyName[MAX_PATH];
438 PCWSTR pszSubKeyName;
439 HKEY hInstanceKey;
440 DWORD dwError;
441
442 /* Build the full device instance key name */
443 wcscpy(szKeyName, L"System\\CurrentControlSet\\Enum\\");
444 wcscat(szKeyName, pszDeviceID);
445
446 /* Open the device instance key */
448 szKeyName,
449 0,
451 &hInstanceKey);
452 if (dwError != ERROR_SUCCESS)
453 return CR_INVALID_DEVINST;
454
455 switch (ulLogConfType)
456 {
457 case BOOT_LOG_CONF:
458 case BASIC_LOG_CONF:
459 pszSubKeyName = L"LogConf";
460 break;
461
462 case ALLOC_LOG_CONF:
464 pszSubKeyName = L"Control";
465 break;
466
467 default:
468 DPRINT1("Unsupported configuration type!\n");
469 return CR_FAILURE;
470 }
471
472 /* Create or open the LogConf key */
473 dwError = RegCreateKeyExW(hInstanceKey,
474 pszSubKeyName,
475 0,
476 NULL,
479 NULL,
480 phKey,
481 NULL);
482
483 /* Close the device instance key */
484 RegCloseKey(hInstanceKey);
485
486 if (dwError != ERROR_SUCCESS)
487 return CR_REGISTRY_ERROR;
488
489 return CR_SUCCESS;
490}
491
492
493static
496 _In_ HKEY hKey,
497 _In_ ULONG ulLogConfType,
498 _Out_ PULONG pulRegDataType,
499 _Out_ PULONG pulDataSize,
500 _Out_ LPBYTE *ppBuffer,
501 _In_ ULONG ulValueNameBufferSize,
502 _Out_opt_ LPWSTR pszValueNameBuffer)
503{
504 LPCWSTR pszValueName;
505
506 switch (ulLogConfType)
507 {
508 case BOOT_LOG_CONF:
509 pszValueName = L"BootConfig";
510 *pulRegDataType = REG_RESOURCE_LIST;
511 break;
512
513 case ALLOC_LOG_CONF:
514 pszValueName = L"AllocConfig";
515 *pulRegDataType = REG_RESOURCE_LIST;
516 break;
517
518 case FORCED_LOG_CONF:
519 pszValueName = L"ForcedConfig";
520 *pulRegDataType = REG_RESOURCE_LIST;
521 break;
522
524 pszValueName = L"FilteredConfigVector";
525 *pulRegDataType = REG_RESOURCE_REQUIREMENTS_LIST;
526 break;
527
528 case BASIC_LOG_CONF:
529 pszValueName = L"BasicConfigVector";
530 *pulRegDataType = REG_RESOURCE_REQUIREMENTS_LIST;
531 break;
532
534 pszValueName = L"OverrideConfigVector";
535 *pulRegDataType = REG_RESOURCE_REQUIREMENTS_LIST;
536 break;
537
538 default:
539 DPRINT1("Unsupported configuration type!\n");
540 return CR_FAILURE;
541 }
542
543 /* Return the selected configuration value name */
544 if ((ulValueNameBufferSize > 0) && (pszValueNameBuffer != NULL) &&
545 (wcslen(pszValueName) + 1 <= ulValueNameBufferSize))
546 wcscpy(pszValueNameBuffer, pszValueName);
547
548 /* Get the configuration data size */
550 pszValueName,
551 NULL,
552 NULL,
553 NULL,
554 pulDataSize) != ERROR_SUCCESS)
555 {
556 return CR_INVALID_LOG_CONF;
557 }
558
559 /* Allocate the buffer */
560 *ppBuffer = HeapAlloc(GetProcessHeap(), 0, *pulDataSize);
561 if (*ppBuffer == NULL)
562 {
563 return CR_OUT_OF_MEMORY;
564 }
565
566 /* Retrieve the configuration data */
568 pszValueName,
569 NULL,
570 NULL,
571 (LPBYTE)*ppBuffer,
572 pulDataSize) != ERROR_SUCCESS)
573 {
574 return CR_INVALID_LOG_CONF;
575 }
576
577 return CR_SUCCESS;
578}
579
580
581static
585{
586 PBYTE pNext = NULL;
587 ULONG ulLastIndex = 0;
588
589 if (pDescriptor == NULL)
590 return NULL;
591
592 /* Skip the full resource descriptor */
593 pNext = (LPBYTE)pDescriptor + sizeof(CM_FULL_RESOURCE_DESCRIPTOR);
594
595 /* Skip the partial resource descriptors */
596 pNext += (pDescriptor->PartialResourceList.Count - 1) *
598
599 /* Skip the device specific data, if present */
600 if (pDescriptor->PartialResourceList.Count > 0)
601 {
602 ulLastIndex = pDescriptor->PartialResourceList.Count - 1;
603
604 if (pDescriptor->PartialResourceList.PartialDescriptors[ulLastIndex].Type ==
606 {
607 pNext += pDescriptor->PartialResourceList.PartialDescriptors[ulLastIndex].
608 u.DeviceSpecificData.DataSize;
609 }
610 }
611
612 return (PCM_FULL_RESOURCE_DESCRIPTOR)pNext;
613}
614
615
616static
619 _In_ PIO_RESOURCE_LIST pResourceList)
620{
621 LPBYTE pNext = NULL;
622
623 if (pResourceList == NULL)
624 return NULL;
625
626 /* Skip the resource list */
627 pNext = (LPBYTE)pResourceList + sizeof(IO_RESOURCE_LIST);
628
629 /* Skip the resource descriptors */
630 pNext += (pResourceList->Count - 1) * sizeof(IO_RESOURCE_DESCRIPTOR);
631
632 return (PIO_RESOURCE_LIST)pNext;
633}
634
635
636static
637BOOL
640{
642 HANDLE hToken;
643 PSID pInteractiveSid = NULL;
644 BOOL bInteractive = FALSE;
645 RPC_STATUS RpcStatus;
646
647 DPRINT("IsCallerInteractive(%p)\n", hBinding);
648
649 /* Allocate an interactive user sid */
651 1,
653 0, 0, 0, 0, 0, 0, 0,
654 &pInteractiveSid))
655 {
656 DPRINT1("AllocateAndInitializeSid failed\n");
657 return FALSE;
658 }
659
660 /* Impersonate the client */
661 RpcStatus = RpcImpersonateClient(hBinding);
662 if (RpcStatus != RPC_S_OK)
663 {
664 DPRINT1("RpcImpersonateClient failed (Status 0x%08lx)\n", RpcStatus);
665 goto done;
666 }
667
668 /* Open the thread token and check for interactive user membership */
670 {
671 CheckTokenMembership(hToken, pInteractiveSid, &bInteractive);
672 CloseHandle(hToken);
673 }
674
675 /* Revert the impersonation */
677
678done:
679 if (pInteractiveSid)
680 FreeSid(pInteractiveSid);
681
682 return bInteractive;
683}
684
685
686VOID
689 PNP_NOTIFY_HANDLE pHandle)
690{
691 DPRINT1("PNP_NOTIFY_HANDLE_rundown(%p)\n", pHandle);
692}
693
694
695/* PUBLIC FUNCTIONS **********************************************************/
696
697/* Function 0 */
698DWORD
699WINAPI
702{
704 return CR_SUCCESS;
705}
706
707
708/* Function 1 */
709DWORD
710WINAPI
713{
715 return CR_SUCCESS;
716}
717
718
719/* Function 2 */
720DWORD
721WINAPI
724 WORD *pVersion)
725{
727
728 DPRINT("PNP_GetVersion(%p %p)\n",
729 hBinding, pVersion);
730
731 *pVersion = CONFIGMG_VERSION;
732
733 return CR_SUCCESS;
734}
735
736
737/* Function 3 */
738DWORD
739WINAPI
742 DWORD *pulState,
743 DWORD ulFlags)
744{
746
747 DPRINT("PNP_GetGlobalState(%p %p 0x%08lx)\n",
748 hBinding, pulState, ulFlags);
749
750 if (ulFlags != 0)
751 return CR_INVALID_FLAG;
752
754
755 if (g_ShuttingDown)
757
758 return CR_SUCCESS;
759}
760
761
762/* Function 4 */
763DWORD
764WINAPI
767{
769
770 DPRINT("PNP_InitDetection(%p)\n",
771 hBinding);
772
773 return CR_SUCCESS;
774}
775
776
777/* Function 5 */
778DWORD
779WINAPI
782 BOOL Admin,
784{
787
789
790 DPRINT("PNP_ReportLogOn(%p %u, %u)\n",
791 hBinding, Admin, ProcessId);
792
793 /* Fail, if the caller is not an interactive user */
795 goto cleanup;
796
797 /* Get the users token */
799
800 if (!hProcess)
801 {
802 DPRINT1("OpenProcess failed with error %u\n", GetLastError());
803 goto cleanup;
804 }
805
806 if (hUserToken)
807 {
810 }
811
813 {
814 DPRINT1("OpenProcessToken failed with error %u\n", GetLastError());
815 goto cleanup;
816 }
817
818 /* Trigger the installer thread */
819 if (hInstallEvent)
821
823
824cleanup:
825 if (hProcess)
827
828 return ReturnValue;
829}
830
831
832/* Function 6 */
833DWORD
834WINAPI
837 LPWSTR pDeviceID,
838 DWORD ulFlags)
839{
841 HKEY hDeviceKey = NULL;
842
844 UNREFERENCED_PARAMETER(ulFlags);
845
846 DPRINT("PNP_ValidateDeviceInstance(%p %S 0x%08lx)\n",
847 hBinding, pDeviceID, ulFlags);
848
849 if (!IsValidDeviceInstanceID(pDeviceID))
850 return CR_INVALID_DEVINST;
851
853 pDeviceID,
854 0,
855 KEY_READ,
856 &hDeviceKey))
857 {
858 DPRINT("Could not open the Device Key!\n");
860 goto Done;
861 }
862
863 /* FIXME: add more tests */
864
865Done:
866 if (hDeviceKey != NULL)
867 RegCloseKey(hDeviceKey);
868
869 DPRINT("PNP_ValidateDeviceInstance() done (returns %lx)\n", ret);
870
871 return ret;
872}
873
874
875/* Function 7 */
876DWORD
877WINAPI
880 LPWSTR pDeviceID,
881 PNP_RPC_STRING_LEN ulLength)
882{
884
886
887 DPRINT("PNP_GetRootDeviceInstance(%p %S %lu)\n",
888 hBinding, pDeviceID, ulLength);
889
890 if (!pDeviceID)
891 {
893 goto Done;
894 }
895
896 if (ulLength < lstrlenW(szRootDeviceInstanceID) + 1)
897 {
899 goto Done;
900 }
901
902 lstrcpyW(pDeviceID,
904
905Done:
906 DPRINT("PNP_GetRootDeviceInstance() done (returns %lx)\n", ret);
907
908 return ret;
909}
910
911
912/* Function 8 */
913DWORD
914WINAPI
917 DWORD ulRelationship,
918 LPWSTR pDeviceID,
919 LPWSTR pRelatedDeviceId,
920 PNP_RPC_STRING_LEN *pulLength,
921 DWORD ulFlags)
922{
926
928 UNREFERENCED_PARAMETER(ulFlags);
929
930 DPRINT("PNP_GetRelatedDeviceInstance(%p %lu %S %p %p 0x%lx)\n",
931 hBinding, ulRelationship, pDeviceID, pRelatedDeviceId,
932 pulLength, ulFlags);
933
934 if (!IsValidDeviceInstanceID(pDeviceID))
935 return CR_INVALID_DEVINST;
936
937 if (ulRelationship == PNP_GET_PARENT_DEVICE_INSTANCE)
938 {
939 /* The root device does not have a parent */
940 if (IsRootDeviceInstanceID(pDeviceID))
941 return CR_NO_SUCH_DEVINST;
942
943 /* Return the root device for non existing devices */
944 if (!IsPresentDeviceInstanceID(pDeviceID))
945 {
946 if ((wcslen(szRootDeviceInstanceID) + 1) > *pulLength)
947 {
948 *pulLength = wcslen(szRootDeviceInstanceID) + 1;
949 return CR_BUFFER_SMALL;
950 }
951
952 wcscpy(pRelatedDeviceId, szRootDeviceInstanceID);
953 *pulLength = wcslen(szRootDeviceInstanceID) + 1;
954 return CR_SUCCESS;
955 }
956 }
957 else if (ulRelationship == PNP_GET_SIBLING_DEVICE_INSTANCE)
958 {
959 /* The root device does not have siblings */
960 if (IsRootDeviceInstanceID(pDeviceID))
961 return CR_NO_SUCH_DEVINST;
962 }
963
965 pDeviceID);
966
967 PlugPlayData.Relation = ulRelationship;
968
969 PlugPlayData.RelatedDeviceInstanceLength = *pulLength;
970 PlugPlayData.RelatedDeviceInstance = pRelatedDeviceId;
971
973 (PVOID)&PlugPlayData,
975 if (!NT_SUCCESS(Status))
976 {
978 }
979
980 DPRINT("PNP_GetRelatedDeviceInstance() done (returns %lx)\n", ret);
981 if (ret == CR_SUCCESS)
982 {
983 DPRINT("RelatedDevice: %wZ\n", &PlugPlayData.RelatedDeviceInstance);
984 }
985
986 return ret;
987}
988
989
990/* Function 9 */
991DWORD
992WINAPI
995 DWORD ulBranch,
996 DWORD ulIndex,
998 PNP_RPC_STRING_LEN ulLength,
999 PNP_RPC_STRING_LEN *pulRequiredLen,
1000 DWORD ulFlags)
1001{
1003 HKEY hKey;
1004 DWORD dwError;
1005
1007 UNREFERENCED_PARAMETER(ulFlags);
1008
1009 DPRINT("PNP_EnumerateSubKeys(%p %lu %lu %p %lu %p 0x%08lx)\n",
1010 hBinding, ulBranch, ulIndex, Buffer, ulLength,
1011 pulRequiredLen, ulFlags);
1012
1013 switch (ulBranch)
1014 {
1015 case PNP_ENUMERATOR_SUBKEYS:
1016 hKey = hEnumKey;
1017 break;
1018
1019 case PNP_CLASS_SUBKEYS:
1020 hKey = hClassKey;
1021 break;
1022
1023 default:
1024 return CR_FAILURE;
1025 }
1026
1027 *pulRequiredLen = ulLength;
1028 dwError = RegEnumKeyExW(hKey,
1029 ulIndex,
1030 Buffer,
1031 pulRequiredLen,
1032 NULL,
1033 NULL,
1034 NULL,
1035 NULL);
1036 if (dwError != ERROR_SUCCESS)
1037 {
1039 }
1040 else
1041 {
1042 (*pulRequiredLen)++;
1043 }
1044
1045 DPRINT("PNP_EnumerateSubKeys() done (returns %lx)\n", ret);
1046
1047 return ret;
1048}
1049
1050
1051static
1054 _In_ PWSTR pszDevice,
1055 _In_ DWORD ulFlags,
1056 _Inout_ PWSTR pszBuffer,
1057 _Inout_ PDWORD pulLength)
1058{
1062
1064 pszDevice);
1065
1067 {
1068 PlugPlayData.Relations = 3;
1069 }
1070 else if (ulFlags & CM_GETIDLIST_FILTER_POWERRELATIONS)
1071 {
1072 PlugPlayData.Relations = 2;
1073 }
1074 else if (ulFlags & CM_GETIDLIST_FILTER_REMOVALRELATIONS)
1075 {
1076 PlugPlayData.Relations = 1;
1077 }
1078 else if (ulFlags & CM_GETIDLIST_FILTER_EJECTRELATIONS)
1079 {
1080 PlugPlayData.Relations = 0;
1081 }
1082
1083 PlugPlayData.BufferSize = *pulLength * sizeof(WCHAR);
1084 PlugPlayData.Buffer = pszBuffer;
1085
1087 (PVOID)&PlugPlayData,
1089 if (NT_SUCCESS(Status))
1090 {
1091 *pulLength = PlugPlayData.BufferSize / sizeof(WCHAR);
1092 }
1093 else
1094 {
1096 }
1097
1098 return ret;
1099}
1100
1101
1102static
1105 _In_ PWSTR pszService,
1106 _Inout_ PWSTR pszBuffer,
1107 _Inout_ PDWORD pulLength)
1108{
1109 WCHAR szPathBuffer[512];
1110 WCHAR szName[16];
1111 HKEY hServicesKey = NULL, hServiceKey = NULL, hEnumKey = NULL;
1112 DWORD dwValues, dwSize, dwIndex, dwUsedLength, dwPathLength;
1113 DWORD dwError;
1114 PWSTR pPtr;
1116
1117 /* Open the device key */
1119 L"System\\CurrentControlSet\\Services",
1120 0,
1121 KEY_READ,
1122 &hServicesKey);
1123 if (dwError != ERROR_SUCCESS)
1124 {
1125 DPRINT("Failed to open the services key (Error %lu)\n", dwError);
1126 return CR_REGISTRY_ERROR;
1127 }
1128
1129 dwError = RegOpenKeyExW(hServicesKey,
1130 pszService,
1131 0,
1132 KEY_READ,
1133 &hServiceKey);
1134 if (dwError != ERROR_SUCCESS)
1135 {
1136 DPRINT("Failed to open the service key (Error %lu)\n", dwError);
1138 goto Done;
1139 }
1140
1141 dwError = RegOpenKeyExW(hServiceKey,
1142 L"Enum",
1143 0,
1144 KEY_READ,
1145 &hEnumKey);
1146 if (dwError != ERROR_SUCCESS)
1147 {
1148 DPRINT("Failed to open the service enum key (Error %lu)\n", dwError);
1150 goto Done;
1151 }
1152
1153 /* Retrieve the number of device instances */
1154 dwSize = sizeof(DWORD);
1155 dwError = RegQueryValueExW(hEnumKey,
1156 L"Count",
1157 NULL,
1158 NULL,
1159 (LPBYTE)&dwValues,
1160 &dwSize);
1161 if (dwError != ERROR_SUCCESS)
1162 {
1163 DPRINT("RegQueryValueExW failed (Error %lu)\n", dwError);
1164 dwValues = 1;
1165 }
1166
1167 DPRINT("dwValues %lu\n", dwValues);
1168
1169 dwUsedLength = 0;
1170 pPtr = pszBuffer;
1171
1172 for (dwIndex = 0; dwIndex < dwValues; dwIndex++)
1173 {
1174 wsprintf(szName, L"%lu", dwIndex);
1175
1176 dwSize = sizeof(szPathBuffer);
1177 dwError = RegQueryValueExW(hEnumKey,
1178 szName,
1179 NULL,
1180 NULL,
1181 (LPBYTE)szPathBuffer,
1182 &dwSize);
1183 if (dwError != ERROR_SUCCESS)
1184 break;
1185
1186 DPRINT("Path: %S\n", szPathBuffer);
1187
1188 dwPathLength = wcslen(szPathBuffer) + 1;
1189 if (dwUsedLength + dwPathLength + 1 > *pulLength)
1190 {
1192 break;
1193 }
1194
1195 wcscpy(pPtr, szPathBuffer);
1196 dwUsedLength += dwPathLength;
1197 pPtr += dwPathLength;
1198
1199 *pPtr = UNICODE_NULL;
1200 }
1201
1202Done:
1203 if (hEnumKey != NULL)
1205
1206 if (hServiceKey != NULL)
1207 RegCloseKey(hServiceKey);
1208
1209 if (hServicesKey != NULL)
1211
1212 if (ret == CR_SUCCESS)
1213 *pulLength = dwUsedLength + 1;
1214 else
1215 *pulLength = 0;
1216
1217 return ret;
1218}
1219
1220
1221static
1224 _In_ PWSTR pszDevice,
1225 _Inout_ PWSTR pszBuffer,
1226 _Inout_ PDWORD pulLength)
1227{
1228 WCHAR szInstanceBuffer[MAX_DEVICE_ID_LEN];
1229 WCHAR szPathBuffer[512];
1230 HKEY hDeviceKey;
1231 DWORD dwInstanceLength, dwPathLength, dwUsedLength;
1232 DWORD dwIndex, dwError;
1233 PWSTR pPtr;
1235
1236 /* Open the device key */
1237 dwError = RegOpenKeyExW(hEnumKey,
1238 pszDevice,
1239 0,
1241 &hDeviceKey);
1242 if (dwError != ERROR_SUCCESS)
1243 {
1244 DPRINT("Failed to open the device key (Error %lu)\n", dwError);
1245 return CR_REGISTRY_ERROR;
1246 }
1247
1248 dwUsedLength = 0;
1249 pPtr = pszBuffer;
1250
1251 for (dwIndex = 0; ; dwIndex++)
1252 {
1253 dwInstanceLength = MAX_DEVICE_ID_LEN;
1254 dwError = RegEnumKeyExW(hDeviceKey,
1255 dwIndex,
1256 szInstanceBuffer,
1257 &dwInstanceLength,
1258 NULL,
1259 NULL,
1260 NULL,
1261 NULL);
1262 if (dwError != ERROR_SUCCESS)
1263 break;
1264
1265 wsprintf(szPathBuffer, L"%s\\%s", pszDevice, szInstanceBuffer);
1266 DPRINT("Path: %S\n", szPathBuffer);
1267
1268 dwPathLength = wcslen(szPathBuffer) + 1;
1269 if (dwUsedLength + dwPathLength + 1 > *pulLength)
1270 {
1272 break;
1273 }
1274
1275 wcscpy(pPtr, szPathBuffer);
1276 dwUsedLength += dwPathLength;
1277 pPtr += dwPathLength;
1278
1279 *pPtr = UNICODE_NULL;
1280 }
1281
1282 RegCloseKey(hDeviceKey);
1283
1284 if (ret == CR_SUCCESS)
1285 *pulLength = dwUsedLength + 1;
1286 else
1287 *pulLength = 0;
1288
1289 return ret;
1290}
1291
1292
1295 _In_ PWSTR pszEnumerator,
1296 _Inout_ PWSTR pszBuffer,
1297 _Inout_ PDWORD pulLength)
1298{
1299 WCHAR szDeviceBuffer[MAX_DEVICE_ID_LEN];
1300 WCHAR szPathBuffer[512];
1301 HKEY hEnumeratorKey;
1302 PWSTR pPtr;
1303 DWORD dwIndex, dwDeviceLength, dwUsedLength, dwRemainingLength, dwPathLength;
1304 DWORD dwError;
1306
1307 /* Open the enumerator key */
1308 dwError = RegOpenKeyExW(hEnumKey,
1309 pszEnumerator,
1310 0,
1312 &hEnumeratorKey);
1313 if (dwError != ERROR_SUCCESS)
1314 {
1315 DPRINT("Failed to open the enumerator key (Error %lu)\n", dwError);
1316 return CR_REGISTRY_ERROR;
1317 }
1318
1319 dwUsedLength = 0;
1320 dwRemainingLength = *pulLength;
1321 pPtr = pszBuffer;
1322
1323 for (dwIndex = 0; ; dwIndex++)
1324 {
1325 dwDeviceLength = MAX_DEVICE_ID_LEN;
1326 dwError = RegEnumKeyExW(hEnumeratorKey,
1327 dwIndex,
1328 szDeviceBuffer,
1329 &dwDeviceLength,
1330 NULL,
1331 NULL,
1332 NULL,
1333 NULL);
1334 if (dwError != ERROR_SUCCESS)
1335 break;
1336
1337 wsprintf(szPathBuffer, L"%s\\%s", pszEnumerator, szDeviceBuffer);
1338 DPRINT("Path: %S\n", szPathBuffer);
1339
1340 dwPathLength = dwRemainingLength;
1341 ret = GetDeviceInstanceList(szPathBuffer,
1342 pPtr,
1343 &dwPathLength);
1344 if (ret != CR_SUCCESS)
1345 break;
1346
1347 dwUsedLength += dwPathLength - 1;
1348 dwRemainingLength -= dwPathLength - 1;
1349 pPtr += dwPathLength - 1;
1350 }
1351
1352 RegCloseKey(hEnumeratorKey);
1353
1354 if (ret == CR_SUCCESS)
1355 *pulLength = dwUsedLength + 1;
1356 else
1357 *pulLength = 0;
1358
1359 return ret;
1360}
1361
1362
1363static
1366 _Inout_ PWSTR pszBuffer,
1367 _Inout_ PDWORD pulLength)
1368{
1369 WCHAR szEnumeratorBuffer[MAX_DEVICE_ID_LEN];
1370 PWSTR pPtr;
1371 DWORD dwIndex, dwEnumeratorLength, dwUsedLength, dwRemainingLength, dwPathLength;
1372 DWORD dwError;
1374
1375 dwUsedLength = 0;
1376 dwRemainingLength = *pulLength;
1377 pPtr = pszBuffer;
1378
1379 for (dwIndex = 0; ; dwIndex++)
1380 {
1381 dwEnumeratorLength = MAX_DEVICE_ID_LEN;
1382 dwError = RegEnumKeyExW(hEnumKey,
1383 dwIndex,
1384 szEnumeratorBuffer,
1385 &dwEnumeratorLength,
1386 NULL, NULL, NULL, NULL);
1387 if (dwError != ERROR_SUCCESS)
1388 break;
1389
1390 dwPathLength = dwRemainingLength;
1391 ret = GetEnumeratorInstanceList(szEnumeratorBuffer,
1392 pPtr,
1393 &dwPathLength);
1394 if (ret != CR_SUCCESS)
1395 break;
1396
1397 dwUsedLength += dwPathLength - 1;
1398 dwRemainingLength -= dwPathLength - 1;
1399 pPtr += dwPathLength - 1;
1400 }
1401
1402 if (ret == CR_SUCCESS)
1403 *pulLength = dwUsedLength + 1;
1404 else
1405 *pulLength = 0;
1406
1407 return ret;
1408}
1409
1410
1411/* Function 10 */
1412DWORD
1413WINAPI
1416 LPWSTR pszFilter,
1417 LPWSTR Buffer,
1418 PNP_RPC_STRING_LEN *pulLength,
1419 DWORD ulFlags)
1420{
1421 WCHAR szEnumerator[MAX_DEVICE_ID_LEN];
1422 WCHAR szDevice[MAX_DEVICE_ID_LEN];
1423 WCHAR szInstance[MAX_DEVICE_ID_LEN];
1425
1426 DPRINT("PNP_GetDeviceList(%p %S %p %p 0x%08lx)\n",
1427 hBinding, pszFilter, Buffer, pulLength, ulFlags);
1428
1429 if (ulFlags & ~CM_GETIDLIST_FILTER_BITS)
1430 return CR_INVALID_FLAG;
1431
1432 if (pulLength == NULL)
1433 return CR_INVALID_POINTER;
1434
1435 if ((ulFlags != CM_GETIDLIST_FILTER_NONE) &&
1436 (pszFilter == NULL))
1437 return CR_INVALID_POINTER;
1438
1439 if (ulFlags &
1444 {
1445 ret = GetRelationsInstanceList(pszFilter,
1446 ulFlags,
1447 Buffer,
1448 pulLength);
1449 }
1450 else if (ulFlags & CM_GETIDLIST_FILTER_SERVICE)
1451 {
1452 ret = GetServiceInstanceList(pszFilter,
1453 Buffer,
1454 pulLength);
1455 }
1456 else if (ulFlags & CM_GETIDLIST_FILTER_ENUMERATOR)
1457 {
1458 SplitDeviceInstanceID(pszFilter,
1459 szEnumerator,
1460 szDevice,
1461 szInstance);
1462
1463 if (*szEnumerator != UNICODE_NULL && *szDevice != UNICODE_NULL)
1464 {
1465 ret = GetDeviceInstanceList(pszFilter,
1466 Buffer,
1467 pulLength);
1468 }
1469 else
1470 {
1471 ret = GetEnumeratorInstanceList(pszFilter,
1472 Buffer,
1473 pulLength);
1474 }
1475 }
1476 else /* CM_GETIDLIST_FILTER_NONE */
1477 {
1479 pulLength);
1480 }
1481
1482 return ret;
1483}
1484
1485
1486static
1489 _In_ PWSTR pszDevice,
1490 _In_ DWORD ulFlags,
1491 _Inout_ PDWORD pulLength)
1492{
1496
1498 pszDevice);
1499
1501 {
1502 PlugPlayData.Relations = 3;
1503 }
1504 else if (ulFlags & CM_GETIDLIST_FILTER_POWERRELATIONS)
1505 {
1506 PlugPlayData.Relations = 2;
1507 }
1508 else if (ulFlags & CM_GETIDLIST_FILTER_REMOVALRELATIONS)
1509 {
1510 PlugPlayData.Relations = 1;
1511 }
1512 else if (ulFlags & CM_GETIDLIST_FILTER_EJECTRELATIONS)
1513 {
1514 PlugPlayData.Relations = 0;
1515 }
1516
1517 PlugPlayData.BufferSize = 0;
1518 PlugPlayData.Buffer = NULL;
1519
1521 (PVOID)&PlugPlayData,
1523 if (NT_SUCCESS(Status))
1524 {
1525 *pulLength = PlugPlayData.BufferSize / sizeof(WCHAR);
1526 }
1527 else
1528 {
1530 }
1531
1532 return ret;
1533}
1534
1535
1536static
1539 _In_ PWSTR pszService,
1540 _Out_ PDWORD pulLength)
1541{
1542 HKEY hServicesKey = NULL, hServiceKey = NULL, hEnumKey = NULL;
1543 DWORD dwValues, dwMaxValueLength, dwSize;
1544 DWORD dwError;
1546
1547 /* Open the device key */
1549 L"System\\CurrentControlSet\\Services",
1550 0,
1551 KEY_READ,
1552 &hServicesKey);
1553 if (dwError != ERROR_SUCCESS)
1554 {
1555 DPRINT("Failed to open the services key (Error %lu)\n", dwError);
1556 return CR_REGISTRY_ERROR;
1557 }
1558
1559 dwError = RegOpenKeyExW(hServicesKey,
1560 pszService,
1561 0,
1562 KEY_READ,
1563 &hServiceKey);
1564 if (dwError != ERROR_SUCCESS)
1565 {
1566 DPRINT("Failed to open the service key (Error %lu)\n", dwError);
1568 goto Done;
1569 }
1570
1571 dwError = RegOpenKeyExW(hServiceKey,
1572 L"Enum",
1573 0,
1574 KEY_READ,
1575 &hEnumKey);
1576 if (dwError != ERROR_SUCCESS)
1577 {
1578 DPRINT("Failed to open the service enum key (Error %lu)\n", dwError);
1580 goto Done;
1581 }
1582
1583 /* Retrieve the number of device instances */
1584 dwSize = sizeof(DWORD);
1585 dwError = RegQueryValueExW(hEnumKey,
1586 L"Count",
1587 NULL,
1588 NULL,
1589 (LPBYTE)&dwValues,
1590 &dwSize);
1591 if (dwError != ERROR_SUCCESS)
1592 {
1593 DPRINT("RegQueryValueExW failed (Error %lu)\n", dwError);
1594 dwValues = 1;
1595 }
1596
1597 /* Retrieve the maximum instance name length */
1598 dwError = RegQueryInfoKeyW(hEnumKey,
1599 NULL,
1600 NULL,
1601 NULL,
1602 NULL,
1603 NULL,
1604 NULL,
1605 NULL,
1606 NULL,
1607 &dwMaxValueLength,
1608 NULL,
1609 NULL);
1610 if (dwError != ERROR_SUCCESS)
1611 {
1612 DPRINT("RegQueryInfoKeyW failed (Error %lu)\n", dwError);
1613 dwMaxValueLength = MAX_DEVICE_ID_LEN;
1614 }
1615
1616 DPRINT("dwValues %lu dwMaxValueLength %lu\n", dwValues, dwMaxValueLength / sizeof(WCHAR));
1617
1618 /* Return the largest possible buffer size */
1619 *pulLength = dwValues * dwMaxValueLength / sizeof(WCHAR) + 2;
1620
1621Done:
1622 if (hEnumKey != NULL)
1624
1625 if (hServiceKey != NULL)
1626 RegCloseKey(hServiceKey);
1627
1628 if (hServicesKey != NULL)
1630
1631 return ret;
1632}
1633
1634
1635static
1638 _In_ LPCWSTR pszDevice,
1639 _Out_ PULONG pulLength)
1640{
1641 HKEY hDeviceKey;
1642 DWORD dwSubKeys, dwMaxSubKeyLength;
1643 DWORD dwError;
1644
1645 /* Open the device key */
1646 dwError = RegOpenKeyExW(hEnumKey,
1647 pszDevice,
1648 0,
1649 KEY_READ,
1650 &hDeviceKey);
1651 if (dwError != ERROR_SUCCESS)
1652 {
1653 DPRINT("Failed to open the device key (Error %lu)\n", dwError);
1654 return CR_REGISTRY_ERROR;
1655 }
1656
1657 /* Retrieve the number of device instances and the maximum name length */
1658 dwError = RegQueryInfoKeyW(hDeviceKey,
1659 NULL,
1660 NULL,
1661 NULL,
1662 &dwSubKeys,
1663 &dwMaxSubKeyLength,
1664 NULL,
1665 NULL,
1666 NULL,
1667 NULL,
1668 NULL,
1669 NULL);
1670 if (dwError != ERROR_SUCCESS)
1671 {
1672 DPRINT("RegQueryInfoKeyW failed (Error %lu)\n", dwError);
1673 dwSubKeys = 0;
1674 dwMaxSubKeyLength = 0;
1675 }
1676
1677 /* Close the device key */
1678 RegCloseKey(hDeviceKey);
1679
1680 /* Return the largest possible buffer size */
1681 *pulLength = dwSubKeys * (wcslen(pszDevice) + 1 + dwMaxSubKeyLength + 1);
1682
1683 return CR_SUCCESS;
1684}
1685
1686
1687static
1690 _In_ LPCWSTR pszEnumerator,
1691 _Out_ PULONG pulLength)
1692{
1693 WCHAR szDeviceBuffer[MAX_DEVICE_ID_LEN];
1694 WCHAR szPathBuffer[512];
1695 HKEY hEnumeratorKey;
1696 DWORD dwIndex, dwDeviceLength, dwBufferLength;
1697 DWORD dwError;
1699
1700 *pulLength = 0;
1701
1702 /* Open the enumerator key */
1703 dwError = RegOpenKeyExW(hEnumKey,
1704 pszEnumerator,
1705 0,
1707 &hEnumeratorKey);
1708 if (dwError != ERROR_SUCCESS)
1709 {
1710 DPRINT("Failed to open the enumerator key (Error %lu)\n", dwError);
1711 return CR_REGISTRY_ERROR;
1712 }
1713
1714 for (dwIndex = 0; ; dwIndex++)
1715 {
1716 dwDeviceLength = MAX_DEVICE_ID_LEN;
1717 dwError = RegEnumKeyExW(hEnumeratorKey,
1718 dwIndex,
1719 szDeviceBuffer,
1720 &dwDeviceLength,
1721 NULL,
1722 NULL,
1723 NULL,
1724 NULL);
1725 if (dwError != ERROR_SUCCESS)
1726 break;
1727
1728 wsprintf(szPathBuffer, L"%s\\%s", pszEnumerator, szDeviceBuffer);
1729 DPRINT("Path: %S\n", szPathBuffer);
1730
1731 ret = GetDeviceInstanceListSize(szPathBuffer, &dwBufferLength);
1732 if (ret != CR_SUCCESS)
1733 {
1734 *pulLength = 0;
1735 break;
1736 }
1737
1738 *pulLength += dwBufferLength;
1739 }
1740
1741 /* Close the enumerator key */
1742 RegCloseKey(hEnumeratorKey);
1743
1744 return ret;
1745}
1746
1747
1748static
1751 _Out_ PULONG pulLength)
1752{
1753 WCHAR szEnumeratorBuffer[MAX_DEVICE_ID_LEN];
1754 DWORD dwIndex, dwEnumeratorLength, dwBufferLength;
1755 DWORD dwError;
1757
1758 for (dwIndex = 0; ; dwIndex++)
1759 {
1760 dwEnumeratorLength = MAX_DEVICE_ID_LEN;
1761 dwError = RegEnumKeyExW(hEnumKey,
1762 dwIndex,
1763 szEnumeratorBuffer,
1764 &dwEnumeratorLength,
1765 NULL, NULL, NULL, NULL);
1766 if (dwError != ERROR_SUCCESS)
1767 break;
1768
1769 /* Get the size of all device instances for the enumerator */
1770 ret = GetEnumeratorInstanceListSize(szEnumeratorBuffer,
1771 &dwBufferLength);
1772 if (ret != CR_SUCCESS)
1773 break;
1774
1775 *pulLength += dwBufferLength;
1776 }
1777
1778 return ret;
1779}
1780
1781
1782/* Function 11 */
1783DWORD
1784WINAPI
1787 LPWSTR pszFilter,
1788 PNP_RPC_BUFFER_SIZE *pulLength,
1789 DWORD ulFlags)
1790{
1791 WCHAR szEnumerator[MAX_DEVICE_ID_LEN];
1792 WCHAR szDevice[MAX_DEVICE_ID_LEN];
1793 WCHAR szInstance[MAX_DEVICE_ID_LEN];
1795
1796 DPRINT("PNP_GetDeviceListSize(%p %S %p 0x%08lx)\n",
1797 hBinding, pszFilter, pulLength, ulFlags);
1798
1799 if (ulFlags & ~CM_GETIDLIST_FILTER_BITS)
1800 return CR_INVALID_FLAG;
1801
1802 if (pulLength == NULL)
1803 return CR_INVALID_POINTER;
1804
1805 if ((ulFlags != CM_GETIDLIST_FILTER_NONE) &&
1806 (pszFilter == NULL))
1807 return CR_INVALID_POINTER;
1808
1809 *pulLength = 0;
1810
1811 if (ulFlags &
1816 {
1818 ulFlags,
1819 pulLength);
1820 }
1821 else if (ulFlags & CM_GETIDLIST_FILTER_SERVICE)
1822 {
1823 ret = GetServiceInstanceListSize(pszFilter,
1824 pulLength);
1825 }
1826 else if (ulFlags & CM_GETIDLIST_FILTER_ENUMERATOR)
1827 {
1828 SplitDeviceInstanceID(pszFilter,
1829 szEnumerator,
1830 szDevice,
1831 szInstance);
1832
1833 if (*szEnumerator != UNICODE_NULL && *szDevice != UNICODE_NULL)
1834 {
1835 ret = GetDeviceInstanceListSize(pszFilter,
1836 pulLength);
1837 }
1838 else
1839 {
1841 pulLength);
1842 }
1843 }
1844 else /* CM_GETIDLIST_FILTER_NONE */
1845 {
1846 ret = GetAllInstanceListSize(pulLength);
1847 }
1848
1849 /* Add one character for the terminating double UNICODE_NULL */
1850 if (ret == CR_SUCCESS)
1851 (*pulLength) += 1;
1852
1853 return ret;
1854}
1855
1856
1857/* Function 12 */
1858DWORD
1859WINAPI
1862 LPWSTR pszDeviceID,
1863 DWORD *pulDepth,
1864 DWORD ulFlags)
1865{
1866 PLUGPLAY_CONTROL_DEPTH_DATA PlugPlayData;
1869
1871 UNREFERENCED_PARAMETER(ulFlags);
1872
1873 DPRINT("PNP_GetDepth(%p %S %p 0x%08lx)\n",
1874 hBinding, pszDeviceID, pulDepth, ulFlags);
1875
1876 if (!IsValidDeviceInstanceID(pszDeviceID))
1877 return CR_INVALID_DEVINST;
1878
1880 pszDeviceID);
1881
1883 (PVOID)&PlugPlayData,
1885 if (NT_SUCCESS(Status))
1886 {
1887 *pulDepth = PlugPlayData.Depth;
1888 }
1889 else
1890 {
1892 }
1893
1894 DPRINT("PNP_GetDepth() done (returns %lx)\n", ret);
1895
1896 return ret;
1897}
1898
1899
1900/* Function 13 */
1901DWORD
1902WINAPI
1905 LPWSTR pDeviceID,
1906 DWORD ulProperty,
1907 DWORD *pulRegDataType,
1908 BYTE *Buffer,
1909 PNP_PROP_SIZE *pulTransferLen,
1910 PNP_PROP_SIZE *pulLength,
1911 DWORD ulFlags)
1912{
1913 PLUGPLAY_CONTROL_PROPERTY_DATA PlugPlayData;
1915 LPWSTR lpValueName = NULL;
1916 HKEY hKey = NULL;
1917 LONG lError;
1919
1921
1922 DPRINT("PNP_GetDeviceRegProp(%p %S %lu %p %p %p %p 0x%08lx)\n",
1923 hBinding, pDeviceID, ulProperty, pulRegDataType, Buffer,
1924 pulTransferLen, pulLength, ulFlags);
1925
1926 if (pulTransferLen == NULL || pulLength == NULL)
1927 {
1929 goto done;
1930 }
1931
1932 if (ulFlags != 0)
1933 {
1935 goto done;
1936 }
1937
1938 /* Check pDeviceID */
1939 if (!IsValidDeviceInstanceID(pDeviceID))
1940 {
1942 goto done;
1943 }
1944
1945 if (*pulLength < *pulTransferLen)
1946 *pulLength = *pulTransferLen;
1947
1948 *pulTransferLen = 0;
1949
1950 switch (ulProperty)
1951 {
1952 case CM_DRP_DEVICEDESC:
1953 lpValueName = L"DeviceDesc";
1954 break;
1955
1956 case CM_DRP_HARDWAREID:
1957 lpValueName = L"HardwareID";
1958 break;
1959
1961 lpValueName = L"CompatibleIDs";
1962 break;
1963
1964 case CM_DRP_SERVICE:
1965 lpValueName = L"Service";
1966 break;
1967
1968 case CM_DRP_CLASS:
1969 lpValueName = L"Class";
1970 break;
1971
1972 case CM_DRP_CLASSGUID:
1973 lpValueName = L"ClassGUID";
1974 break;
1975
1976 case CM_DRP_DRIVER:
1977 lpValueName = L"Driver";
1978 break;
1979
1980 case CM_DRP_CONFIGFLAGS:
1981 lpValueName = L"ConfigFlags";
1982 break;
1983
1984 case CM_DRP_MFG:
1985 lpValueName = L"Mfg";
1986 break;
1987
1989 lpValueName = L"FriendlyName";
1990 break;
1991
1993 lpValueName = L"LocationInformation";
1994 break;
1995
1998 *pulRegDataType = REG_SZ;
1999 break;
2000
2002 lpValueName = L"Capabilities";
2003 break;
2004
2005 case CM_DRP_UI_NUMBER:
2006 PlugPlayData.Property = PNP_PROPERTY_UI_NUMBER;
2007 break;
2008
2010 lpValueName = L"UpperFilters";
2011 break;
2012
2014 lpValueName = L"LowerFilters";
2015 break;
2016
2017 case CM_DRP_BUSTYPEGUID:
2018 PlugPlayData.Property = PNP_PROPERTY_BUSTYPEGUID;
2019 *pulRegDataType = REG_BINARY;
2020 break;
2021
2023 PlugPlayData.Property = PNP_PROPERTY_LEGACYBUSTYPE;
2024 *pulRegDataType = REG_DWORD;
2025 break;
2026
2027 case CM_DRP_BUSNUMBER:
2028 PlugPlayData.Property = PNP_PROPERTY_BUSNUMBER;
2029 *pulRegDataType = REG_DWORD;
2030 break;
2031
2034 *pulRegDataType = REG_SZ;
2035 break;
2036
2037 case CM_DRP_SECURITY:
2038 lpValueName = L"Security";
2039 break;
2040
2041 case CM_DRP_DEVTYPE:
2042 lpValueName = L"DeviceType";
2043 break;
2044
2045 case CM_DRP_EXCLUSIVE:
2046 lpValueName = L"Exclusive";
2047 break;
2048
2050 lpValueName = L"DeviceCharacteristics";
2051 break;
2052
2053 case CM_DRP_ADDRESS:
2054 PlugPlayData.Property = PNP_PROPERTY_ADDRESS;
2055 *pulRegDataType = REG_DWORD;
2056 break;
2057
2059 lpValueName = L"UINumberDescFormat";
2060 break;
2061
2063 PlugPlayData.Property = PNP_PROPERTY_POWER_DATA;
2064 *pulRegDataType = REG_BINARY;
2065 break;
2066
2069 *pulRegDataType = REG_DWORD;
2070 break;
2071
2074 *pulRegDataType = REG_DWORD;
2075 break;
2076
2078 lpValueName = L"RemovalPolicy";
2079 *pulRegDataType = REG_DWORD;
2080 break;
2081
2083 PlugPlayData.Property = PNP_PROPERTY_INSTALL_STATE;
2084 *pulRegDataType = REG_DWORD;
2085 break;
2086
2087#if (WINVER >= _WIN32_WINNT_WS03)
2090 *pulRegDataType = REG_MULTI_SZ;
2091 break;
2092#endif
2093
2094#if (WINVER >= _WIN32_WINNT_WIN7)
2096 PlugPlayData.Property = PNP_PROPERTY_CONTAINERID;
2097 *pulRegDataType = REG_SZ;
2098 break;
2099#endif
2100
2101 default:
2103 goto done;
2104 }
2105
2106 DPRINT("Value name: %S\n", lpValueName);
2107
2108 if (lpValueName)
2109 {
2110 /* Retrieve information from the Registry */
2111 lError = RegOpenKeyExW(hEnumKey,
2112 pDeviceID,
2113 0,
2115 &hKey);
2116 if (lError != ERROR_SUCCESS)
2117 {
2118 hKey = NULL;
2119 *pulLength = 0;
2121 goto done;
2122 }
2123
2124 lError = RegQueryValueExW(hKey,
2125 lpValueName,
2126 NULL,
2127 pulRegDataType,
2128 Buffer,
2129 pulLength);
2130 if (lError != ERROR_SUCCESS)
2131 {
2132 if (lError == ERROR_MORE_DATA)
2133 {
2135 }
2136 else
2137 {
2138 *pulLength = 0;
2140 }
2141 }
2142 }
2143 else
2144 {
2145 /* Retrieve information from the Device Node */
2147 pDeviceID);
2148 PlugPlayData.Buffer = Buffer;
2149 PlugPlayData.BufferSize = *pulLength;
2150
2152 (PVOID)&PlugPlayData,
2154 if (NT_SUCCESS(Status))
2155 {
2156 *pulLength = PlugPlayData.BufferSize;
2157 }
2158 else
2159 {
2161 }
2162 }
2163
2164done:
2165 if (pulTransferLen)
2166 *pulTransferLen = (ret == CR_SUCCESS) ? *pulLength : 0;
2167
2168 if (hKey != NULL)
2170
2171 DPRINT("PNP_GetDeviceRegProp() done (returns %lx)\n", ret);
2172
2173 return ret;
2174}
2175
2176
2177/* Function 14 */
2178DWORD
2179WINAPI
2182 LPWSTR pDeviceId,
2183 DWORD ulProperty,
2184 DWORD ulDataType,
2185 BYTE *Buffer,
2186 PNP_PROP_SIZE ulLength,
2187 DWORD ulFlags)
2188{
2190 LPWSTR lpValueName = NULL;
2191 HKEY hKey = 0;
2192
2194 UNREFERENCED_PARAMETER(ulFlags);
2195
2196 DPRINT("PNP_SetDeviceRegProp(%p %S %lu %lu %p %lu 0x%08lx)\n",
2197 hBinding, pDeviceId, ulProperty, ulDataType, Buffer,
2198 ulLength, ulFlags);
2199
2200 if (!IsValidDeviceInstanceID(pDeviceId))
2201 return CR_INVALID_DEVINST;
2202
2203 switch (ulProperty)
2204 {
2205 case CM_DRP_DEVICEDESC:
2206 lpValueName = L"DeviceDesc";
2207 break;
2208
2209 case CM_DRP_HARDWAREID:
2210 lpValueName = L"HardwareID";
2211 break;
2212
2214 lpValueName = L"CompatibleIDs";
2215 break;
2216
2217 case CM_DRP_SERVICE:
2218 lpValueName = L"Service";
2219 break;
2220
2221 case CM_DRP_CLASS:
2222 lpValueName = L"Class";
2223 break;
2224
2225 case CM_DRP_CLASSGUID:
2226 lpValueName = L"ClassGUID";
2227 break;
2228
2229 case CM_DRP_DRIVER:
2230 lpValueName = L"Driver";
2231 break;
2232
2233 case CM_DRP_CONFIGFLAGS:
2234 lpValueName = L"ConfigFlags";
2235 break;
2236
2237 case CM_DRP_MFG:
2238 lpValueName = L"Mfg";
2239 break;
2240
2242 lpValueName = L"FriendlyName";
2243 break;
2244
2246 lpValueName = L"LocationInformation";
2247 break;
2248
2250 lpValueName = L"UpperFilters";
2251 break;
2252
2254 lpValueName = L"LowerFilters";
2255 break;
2256
2257 case CM_DRP_SECURITY:
2258 lpValueName = L"Security";
2259 break;
2260
2261 case CM_DRP_DEVTYPE:
2262 lpValueName = L"DeviceType";
2263 break;
2264
2265 case CM_DRP_EXCLUSIVE:
2266 lpValueName = L"Exclusive";
2267 break;
2268
2270 lpValueName = L"DeviceCharacteristics";
2271 break;
2272
2274 lpValueName = L"UINumberDescFormat";
2275 break;
2276
2278 lpValueName = L"RemovalPolicy";
2279 break;
2280
2281 default:
2282 return CR_INVALID_PROPERTY;
2283 }
2284
2285 DPRINT("Value name: %S\n", lpValueName);
2286
2288 pDeviceId,
2289 0,
2291 &hKey))
2292 return CR_INVALID_DEVNODE;
2293
2294 if (ulLength == 0)
2295 {
2297 lpValueName))
2299 }
2300 else
2301 {
2302 if (RegSetValueExW(hKey,
2303 lpValueName,
2304 0,
2305 ulDataType,
2306 Buffer,
2307 ulLength))
2309 }
2310
2312
2313 DPRINT("PNP_SetDeviceRegProp() done (returns %lx)\n", ret);
2314
2315 return ret;
2316}
2317
2318
2319/* Function 15 */
2320DWORD
2321WINAPI
2324 LPWSTR pDeviceId,
2325 LPWSTR pszClassInstance,
2326 PNP_RPC_STRING_LEN ulLength)
2327{
2328 WCHAR szClassGuid[40];
2329 WCHAR szClassInstance[5];
2330 HKEY hDeviceClassKey = NULL;
2331 HKEY hClassInstanceKey;
2332 ULONG ulTransferLength, ulDataLength;
2333 DWORD dwDataType, dwDisposition, i;
2334 DWORD dwError;
2336
2337 DPRINT("PNP_GetClassInstance(%p %S %p %lu)\n",
2338 hBinding, pDeviceId, pszClassInstance, ulLength);
2339
2340 if (!IsValidDeviceInstanceID(pDeviceId))
2341 return CR_INVALID_DEVINST;
2342
2343 ulTransferLength = ulLength;
2345 pDeviceId,
2347 &dwDataType,
2348 (BYTE *)pszClassInstance,
2349 &ulTransferLength,
2350 &ulLength,
2351 0);
2352 if (ret == CR_SUCCESS)
2353 return ret;
2354
2355 ulTransferLength = sizeof(szClassGuid);
2356 ulDataLength = sizeof(szClassGuid);
2358 pDeviceId,
2360 &dwDataType,
2361 (BYTE *)szClassGuid,
2362 &ulTransferLength,
2363 &ulDataLength,
2364 0);
2365 if (ret != CR_SUCCESS)
2366 {
2367 DPRINT1("PNP_GetDeviceRegProp() failed (Error %lu)\n", ret);
2368 goto done;
2369 }
2370
2371 dwError = RegOpenKeyExW(hClassKey,
2372 szClassGuid,
2373 0,
2374 KEY_READ,
2375 &hDeviceClassKey);
2376 if (dwError != ERROR_SUCCESS)
2377 {
2378 DPRINT1("RegOpenKeyExW() failed (Error %lu)\n", dwError);
2379 ret = CR_FAILURE;
2380 goto done;
2381 }
2382
2383 for (i = 0; i < 10000; i++)
2384 {
2385 wsprintf(szClassInstance, L"%04lu", i);
2386
2387 dwError = RegCreateKeyExW(hDeviceClassKey,
2388 szClassInstance,
2389 0,
2390 NULL,
2393 NULL,
2394 &hClassInstanceKey,
2395 &dwDisposition);
2396 if (dwError == ERROR_SUCCESS)
2397 {
2398 RegCloseKey(hClassInstanceKey);
2399
2400 if (dwDisposition == REG_CREATED_NEW_KEY)
2401 {
2402 wsprintf(pszClassInstance,
2403 L"%s\\%s",
2404 szClassGuid,
2405 szClassInstance);
2406
2407 ulDataLength = (wcslen(pszClassInstance) + 1) * sizeof(WCHAR);
2409 pDeviceId,
2411 REG_SZ,
2412 (BYTE *)pszClassInstance,
2413 ulDataLength,
2414 0);
2415 if (ret != CR_SUCCESS)
2416 {
2417 DPRINT1("PNP_SetDeviceRegProp() failed (Error %lu)\n", ret);
2418 RegDeleteKeyW(hDeviceClassKey,
2419 szClassInstance);
2420 }
2421
2422 break;
2423 }
2424 }
2425 }
2426
2427done:
2428 if (hDeviceClassKey != NULL)
2429 RegCloseKey(hDeviceClassKey);
2430
2431 return ret;
2432}
2433
2434
2435/* Function 16 */
2436DWORD
2437WINAPI
2440 LPWSTR pszSubKey,
2441 DWORD samDesired,
2442 DWORD ulFlags)
2443{
2444 HKEY hDeviceKey = NULL, hParametersKey = NULL;
2445 DWORD dwError;
2447
2449 UNREFERENCED_PARAMETER(samDesired);
2450
2451 DPRINT("PNP_CreateKey(%p %S 0x%lx 0x%08lx)\n",
2452 hBinding, pszSubKey, samDesired, ulFlags);
2453
2454 if (ulFlags != 0)
2455 return CR_INVALID_FLAG;
2456
2457 if (!IsValidDeviceInstanceID(pszSubKey))
2458 return CR_INVALID_DEVINST;
2459
2460 dwError = RegOpenKeyExW(hEnumKey,
2461 pszSubKey,
2462 0,
2463 KEY_WRITE,
2464 &hDeviceKey);
2465 if (dwError != ERROR_SUCCESS)
2466 {
2468 goto done;
2469 }
2470
2471 dwError = RegCreateKeyExW(hDeviceKey,
2472 L"Device Parameters",
2473 0,
2474 NULL,
2477 NULL,
2478 &hParametersKey,
2479 NULL);
2480 if (dwError != ERROR_SUCCESS)
2481 {
2483 goto done;
2484 }
2485
2486 /* FIXME: Set key security */
2487
2488done:
2489 if (hParametersKey != NULL)
2490 RegCloseKey(hParametersKey);
2491
2492 if (hDeviceKey != NULL)
2493 RegCloseKey(hDeviceKey);
2494
2495 return ret;
2496}
2497
2498
2499/* Function 17 */
2500DWORD
2501WINAPI
2504 LPWSTR pszDeviceID,
2505 LPWSTR pszParentKey,
2506 LPWSTR pszChildKey,
2507 DWORD ulFlags)
2508{
2511}
2512
2513
2514/* Function 18 */
2515DWORD
2516WINAPI
2519 DWORD *pulClassCount,
2520 DWORD ulFlags)
2521{
2522 HKEY hKey;
2523 DWORD dwError;
2524
2526 UNREFERENCED_PARAMETER(ulFlags);
2527
2528 DPRINT("PNP_GetClassCount(%p %p 0x%08lx)\n",
2529 hBinding, pulClassCount, ulFlags);
2530
2533 0,
2535 &hKey);
2536 if (dwError != ERROR_SUCCESS)
2537 return CR_INVALID_DATA;
2538
2539 dwError = RegQueryInfoKeyW(hKey,
2540 NULL,
2541 NULL,
2542 NULL,
2543 pulClassCount,
2544 NULL,
2545 NULL,
2546 NULL,
2547 NULL,
2548 NULL,
2549 NULL,
2550 NULL);
2552 if (dwError != ERROR_SUCCESS)
2553 return CR_INVALID_DATA;
2554
2555 return CR_SUCCESS;
2556}
2557
2558
2559/* Function 19 */
2560DWORD
2561WINAPI
2564 LPWSTR pszClassGuid,
2565 LPWSTR Buffer,
2566 PNP_RPC_STRING_LEN *pulLength,
2567 DWORD ulFlags)
2568{
2569 WCHAR szKeyName[MAX_PATH];
2571 HKEY hKey;
2572 DWORD dwSize;
2573
2575 UNREFERENCED_PARAMETER(ulFlags);
2576
2577 DPRINT("PNP_GetClassName(%p %S %p %p 0x%08lx)\n",
2578 hBinding, pszClassGuid, Buffer, pulLength, ulFlags);
2579
2580 lstrcpyW(szKeyName, L"System\\CurrentControlSet\\Control\\Class\\");
2581 if (lstrlenW(pszClassGuid) + 1 < sizeof(szKeyName)/sizeof(WCHAR)-(lstrlenW(szKeyName) * sizeof(WCHAR)))
2582 lstrcatW(szKeyName, pszClassGuid);
2583 else
2584 return CR_INVALID_DATA;
2585
2587 szKeyName,
2588 0,
2590 &hKey))
2591 return CR_REGISTRY_ERROR;
2592
2593 dwSize = *pulLength * sizeof(WCHAR);
2595 L"Class",
2596 NULL,
2597 NULL,
2598 (LPBYTE)Buffer,
2599 &dwSize))
2600 {
2601 *pulLength = 0;
2603 }
2604 else
2605 {
2606 *pulLength = dwSize / sizeof(WCHAR);
2607 }
2608
2610
2611 DPRINT("PNP_GetClassName() done (returns %lx)\n", ret);
2612
2613 return ret;
2614}
2615
2616
2617/* Function 20 */
2618DWORD
2619WINAPI
2622 LPWSTR pszClassGuid,
2623 DWORD ulFlags)
2624{
2626
2628
2629 DPRINT("PNP_DeleteClassKey(%p %S 0x%08lx)\n",
2630 hBinding, pszClassGuid, ulFlags);
2631
2632 if (ulFlags & CM_DELETE_CLASS_SUBKEYS)
2633 {
2634 if (SHDeleteKeyW(hClassKey, pszClassGuid) != ERROR_SUCCESS)
2636 }
2637 else
2638 {
2639 if (RegDeleteKeyW(hClassKey, pszClassGuid) != ERROR_SUCCESS)
2641 }
2642
2643 DPRINT("PNP_DeleteClassKey() done (returns %lx)\n", ret);
2644
2645 return ret;
2646}
2647
2648
2649/* Function 21 */
2650DWORD
2651WINAPI
2654 LPWSTR pszInterfaceDevice,
2655 GUID *AliasInterfaceGuid,
2656 LPWSTR pszAliasInterfaceDevice,
2657 PNP_RPC_STRING_LEN *pulLength,
2658 PNP_RPC_STRING_LEN *pulTransferLen,
2659 DWORD ulFlags)
2660{
2664
2666
2667 DPRINT("PNP_GetInterfaceDeviceAlias(%p %S %p %p %p %p 0x%08lx)\n",
2668 hBinding, pszInterfaceDevice, AliasInterfaceGuid, pszAliasInterfaceDevice, pulLength,
2669 pulTransferLen, ulFlags);
2670
2671 if ((AliasInterfaceGuid == NULL) ||
2672 (pulLength == NULL))
2673 return CR_INVALID_POINTER;
2674
2675 if (ulFlags != 0)
2676 return CR_INVALID_FLAG;
2677
2678 RtlInitUnicodeString(&PlugPlayData.SymbolicLinkName, pszInterfaceDevice);
2679 PlugPlayData.AliasInterfaceClassGuid = AliasInterfaceGuid;
2680 PlugPlayData.AliasSymbolicLinkName = pszAliasInterfaceDevice;
2681 PlugPlayData.AliasSymbolicLinkNameLength = *pulTransferLen;
2682
2684 &PlugPlayData,
2686 if (NT_SUCCESS(Status))
2687 {
2688 *pulLength = PlugPlayData.AliasSymbolicLinkNameLength;
2689 *pulTransferLen = *pulLength + 1;
2690 }
2691 else
2692 {
2693 *pulLength = 0;
2694 *pulTransferLen = 0;
2696 }
2697
2698 DPRINT("PNP_GetInterfaceDeviceAlias() done (returns %lx)\n", ret);
2699 return ret;
2700}
2701
2702
2703/* Function 22 */
2704DWORD
2705WINAPI
2709 LPWSTR pszDeviceID,
2710 BYTE *Buffer,
2711 PNP_RPC_BUFFER_SIZE *pulLength,
2712 DWORD ulFlags)
2713{
2717
2719
2720 DPRINT("PNP_GetInterfaceDeviceList(%p %p %S %p %p 0x%08lx)\n",
2721 hBinding, InterfaceGuid, pszDeviceID, Buffer, pulLength, ulFlags);
2722
2723 if (!IsValidDeviceInstanceID(pszDeviceID))
2724 return CR_INVALID_DEVINST;
2725
2727 pszDeviceID);
2728
2729 PlugPlayData.Flags = ulFlags;
2730 PlugPlayData.FilterGuid = InterfaceGuid;
2731 PlugPlayData.Buffer = Buffer;
2732 PlugPlayData.BufferSize = *pulLength;
2733
2735 (PVOID)&PlugPlayData,
2737 if (NT_SUCCESS(Status))
2738 {
2739 *pulLength = PlugPlayData.BufferSize;
2740 }
2741 else
2742 {
2744 }
2745
2746 DPRINT("PNP_GetInterfaceDeviceList() done (returns %lx)\n", ret);
2747 return ret;
2748}
2749
2750
2751/* Function 23 */
2752DWORD
2753WINAPI
2756 PNP_RPC_BUFFER_SIZE *pulLen,
2758 LPWSTR pszDeviceID,
2759 DWORD ulFlags)
2760{
2764
2766
2767 DPRINT("PNP_GetInterfaceDeviceListSize(%p %p %p %S 0x%08lx)\n",
2768 hBinding, pulLen, InterfaceGuid, pszDeviceID, ulFlags);
2769
2770 if (!IsValidDeviceInstanceID(pszDeviceID))
2771 return CR_INVALID_DEVINST;
2772
2774 pszDeviceID);
2775
2776 PlugPlayData.FilterGuid = InterfaceGuid;
2777 PlugPlayData.Buffer = NULL;
2778 PlugPlayData.BufferSize = 0;
2779 PlugPlayData.Flags = ulFlags;
2780
2782 (PVOID)&PlugPlayData,
2784 if (NT_SUCCESS(Status))
2785 {
2786 *pulLen = PlugPlayData.BufferSize;
2787 }
2788 else
2789 {
2791 }
2792
2793 DPRINT("PNP_GetInterfaceDeviceListSize() done (returns %lx)\n", ret);
2794 return ret;
2795}
2796
2797
2798/* Function 24 */
2799DWORD
2800WINAPI
2803 LPWSTR pszDeviceID,
2805 LPWSTR pszReference,
2806 LPWSTR pszSymLink,
2807 PNP_RPC_STRING_LEN *pulLength,
2808 PNP_RPC_STRING_LEN *pulTransferLen,
2809 DWORD ulFlags)
2810{
2814
2816
2817 DPRINT1("PNP_RegisterDeviceClassAssociation(%p %S %p %S %S %p %p 0x%08lx)\n",
2818 hBinding, pszDeviceID, InterfaceGuid, pszReference, pszSymLink,
2819 pulLength, pulTransferLen, ulFlags);
2820
2821 if ((InterfaceGuid == NULL) ||
2822 (pszSymLink == NULL) ||
2823 (pulLength == NULL) ||
2824 (pulTransferLen == NULL))
2825 return CR_INVALID_POINTER;
2826
2827 if (ulFlags != 0)
2828 return CR_INVALID_FLAG;
2829
2830 if (!IsValidDeviceInstanceID(pszDeviceID))
2831 return CR_INVALID_DEVINST;
2832
2833 RtlInitUnicodeString(&PlugPlayData.DeviceInstance, pszDeviceID);
2834 PlugPlayData.InterfaceGuid = InterfaceGuid;
2835 RtlInitUnicodeString(&PlugPlayData.Reference, pszReference);
2836 PlugPlayData.Register = TRUE;
2837 PlugPlayData.SymbolicLinkName = pszSymLink;
2838 PlugPlayData.SymbolicLinkNameLength = *pulLength;
2839
2841 &PlugPlayData,
2843 if (NT_SUCCESS(Status))
2844 {
2845 *pulLength = PlugPlayData.SymbolicLinkNameLength;
2846 *pulTransferLen = *pulLength;
2847 }
2848 else
2849 {
2850 *pulLength = 0;
2852 }
2853
2854 return ret;
2855}
2856
2857
2858/* Function 25 */
2859DWORD
2860WINAPI
2863 LPWSTR pszInterfaceDevice,
2864 DWORD ulFlags)
2865{
2869
2871
2872 DPRINT1("PNP_UnregisterDeviceClassAssociation(%p %S 0x%08lx)\n",
2873 hBinding, pszInterfaceDevice, ulFlags);
2874
2875 if (pszInterfaceDevice == NULL)
2876 return CR_INVALID_POINTER;
2877
2878 if (ulFlags != 0)
2879 return CR_INVALID_FLAG;
2880
2881 ZeroMemory(&PlugPlayData, sizeof(PlugPlayData));
2882 PlugPlayData.Register = FALSE;
2883 PlugPlayData.SymbolicLinkName = pszInterfaceDevice;
2884 PlugPlayData.SymbolicLinkNameLength = wcslen(pszInterfaceDevice) + 1;
2885
2887 &PlugPlayData,
2889 if (!NT_SUCCESS(Status))
2891
2892 return ret;
2893}
2894
2895
2896/* Function 26 */
2897DWORD
2898WINAPI
2901 LPWSTR pszClassGuid,
2902 DWORD ulProperty,
2903 DWORD *pulRegDataType,
2904 BYTE *Buffer,
2905 PNP_RPC_STRING_LEN *pulTransferLen,
2906 PNP_RPC_STRING_LEN *pulLength,
2907 DWORD ulFlags)
2908{
2910 LPWSTR lpValueName = NULL;
2911 HKEY hInstKey = NULL;
2912 HKEY hPropKey = NULL;
2913 LONG lError;
2914
2916
2917 DPRINT("PNP_GetClassRegProp(%p %S %lu %p %p %p %p 0x%08lx)\n",
2918 hBinding, pszClassGuid, ulProperty, pulRegDataType,
2919 Buffer, pulTransferLen, pulLength, ulFlags);
2920
2921 if (pulTransferLen == NULL || pulLength == NULL)
2922 {
2924 goto done;
2925 }
2926
2927 if (ulFlags != 0)
2928 {
2930 goto done;
2931 }
2932
2933 if (*pulLength < *pulTransferLen)
2934 *pulLength = *pulTransferLen;
2935
2936 *pulTransferLen = 0;
2937
2938 switch (ulProperty)
2939 {
2940 case CM_CRP_SECURITY:
2941 lpValueName = L"Security";
2942 break;
2943
2944 case CM_CRP_DEVTYPE:
2945 lpValueName = L"DeviceType";
2946 break;
2947
2948 case CM_CRP_EXCLUSIVE:
2949 lpValueName = L"Exclusive";
2950 break;
2951
2953 lpValueName = L"DeviceCharacteristics";
2954 break;
2955
2956 default:
2958 goto done;
2959 }
2960
2961 DPRINT("Value name: %S\n", lpValueName);
2962
2963 lError = RegOpenKeyExW(hClassKey,
2964 pszClassGuid,
2965 0,
2966 KEY_READ,
2967 &hInstKey);
2968 if (lError != ERROR_SUCCESS)
2969 {
2970 *pulLength = 0;
2972 goto done;
2973 }
2974
2975 lError = RegOpenKeyExW(hInstKey,
2976 L"Properties",
2977 0,
2978 KEY_READ,
2979 &hPropKey);
2980 if (lError != ERROR_SUCCESS)
2981 {
2982 *pulLength = 0;
2984 goto done;
2985 }
2986
2987 lError = RegQueryValueExW(hPropKey,
2988 lpValueName,
2989 NULL,
2990 pulRegDataType,
2991 Buffer,
2992 pulLength);
2993 if (lError != ERROR_SUCCESS)
2994 {
2995 if (lError == ERROR_MORE_DATA)
2996 {
2998 }
2999 else
3000 {
3001 *pulLength = 0;
3003 }
3004 }
3005
3006done:
3007 if (ret == CR_SUCCESS)
3008 *pulTransferLen = *pulLength;
3009
3010 if (hPropKey != NULL)
3011 RegCloseKey(hPropKey);
3012
3013 if (hInstKey != NULL)
3014 RegCloseKey(hInstKey);
3015
3016 DPRINT("PNP_GetClassRegProp() done (returns %lx)\n", ret);
3017
3018 return ret;
3019}
3020
3021
3022/* Function 27 */
3023DWORD
3024WINAPI
3027 LPWSTR pszClassGuid,
3028 DWORD ulProperty,
3029 DWORD ulDataType,
3030 BYTE *Buffer,
3031 PNP_PROP_SIZE ulLength,
3032 DWORD ulFlags)
3033{
3035 LPWSTR lpValueName = NULL;
3036 HKEY hInstKey = 0;
3037 HKEY hPropKey = 0;
3038 LONG lError;
3039
3041
3042 DPRINT("PNP_SetClassRegProp(%p %S %lu %lu %p %lu 0x%08lx)\n",
3043 hBinding, pszClassGuid, ulProperty, ulDataType,
3044 Buffer, ulLength, ulFlags);
3045
3046 if (ulFlags != 0)
3047 return CR_INVALID_FLAG;
3048
3049 switch (ulProperty)
3050 {
3051 case CM_CRP_SECURITY:
3052 lpValueName = L"Security";
3053 break;
3054
3055 case CM_CRP_DEVTYPE:
3056 lpValueName = L"DeviceType";
3057 break;
3058
3059 case CM_CRP_EXCLUSIVE:
3060 lpValueName = L"Exclusive";
3061 break;
3062
3064 lpValueName = L"DeviceCharacteristics";
3065 break;
3066
3067 default:
3068 return CR_INVALID_PROPERTY;
3069 }
3070
3071 lError = RegOpenKeyExW(hClassKey,
3072 pszClassGuid,
3073 0,
3074 KEY_WRITE,
3075 &hInstKey);
3076 if (lError != ERROR_SUCCESS)
3077 {
3079 goto done;
3080 }
3081
3082 /* FIXME: Set security descriptor */
3083 lError = RegCreateKeyExW(hInstKey,
3084 L"Properties",
3085 0,
3086 NULL,
3089 NULL,
3090 &hPropKey,
3091 NULL);
3092 if (lError != ERROR_SUCCESS)
3093 {
3095 goto done;
3096 }
3097
3098 if (ulLength == 0)
3099 {
3100 if (RegDeleteValueW(hPropKey,
3101 lpValueName))
3103 }
3104 else
3105 {
3106 if (RegSetValueExW(hPropKey,
3107 lpValueName,
3108 0,
3109 ulDataType,
3110 Buffer,
3111 ulLength))
3113 }
3114
3115done:
3116 if (hPropKey != NULL)
3117 RegCloseKey(hPropKey);
3118
3119 if (hInstKey != NULL)
3120 RegCloseKey(hInstKey);
3121
3122 return ret;
3123}
3124
3125
3126static
3129 _In_ LPWSTR pszDeviceID,
3130 _In_ BOOL bPhantomDevice)
3131{
3132 WCHAR szEnumerator[MAX_DEVICE_ID_LEN];
3133 WCHAR szDevice[MAX_DEVICE_ID_LEN];
3134 WCHAR szInstance[MAX_DEVICE_ID_LEN];
3135 HKEY hKeyEnumerator;
3136 HKEY hKeyDevice;
3137 HKEY hKeyInstance;
3138 HKEY hKeyControl;
3139 LONG lError;
3140
3141 /* Split the instance ID */
3142 SplitDeviceInstanceID(pszDeviceID,
3143 szEnumerator,
3144 szDevice,
3145 szInstance);
3146
3147 /* Open or create the enumerator key */
3148 lError = RegCreateKeyExW(hEnumKey,
3149 szEnumerator,
3150 0,
3151 NULL,
3154 NULL,
3155 &hKeyEnumerator,
3156 NULL);
3157 if (lError != ERROR_SUCCESS)
3158 {
3159 return CR_REGISTRY_ERROR;
3160 }
3161
3162 /* Open or create the device key */
3163 lError = RegCreateKeyExW(hKeyEnumerator,
3164 szDevice,
3165 0,
3166 NULL,
3169 NULL,
3170 &hKeyDevice,
3171 NULL);
3172
3173 /* Close the enumerator key */
3174 RegCloseKey(hKeyEnumerator);
3175
3176 if (lError != ERROR_SUCCESS)
3177 {
3178 return CR_REGISTRY_ERROR;
3179 }
3180
3181 /* Try to open the instance key and fail if it exists */
3182 lError = RegOpenKeyExW(hKeyDevice,
3183 szInstance,
3184 0,
3186 &hKeyInstance);
3187 if (lError == ERROR_SUCCESS)
3188 {
3189 DPRINT1("Instance %S already exists!\n", szInstance);
3190 RegCloseKey(hKeyInstance);
3191 RegCloseKey(hKeyDevice);
3193 }
3194
3195 /* Create a new instance key */
3196 lError = RegCreateKeyExW(hKeyDevice,
3197 szInstance,
3198 0,
3199 NULL,
3202 NULL,
3203 &hKeyInstance,
3204 NULL);
3205
3206 /* Close the device key */
3207 RegCloseKey(hKeyDevice);
3208
3209 if (lError != ERROR_SUCCESS)
3210 {
3211 return CR_REGISTRY_ERROR;
3212 }
3213
3214 if (bPhantomDevice)
3215 {
3216 DWORD dwPhantomValue = 1;
3217 RegSetValueExW(hKeyInstance,
3218 L"Phantom",
3219 0,
3220 REG_DWORD,
3221 (PBYTE)&dwPhantomValue,
3222 sizeof(dwPhantomValue));
3223 }
3224
3225 /* Create the 'Control' sub key */
3226 lError = RegCreateKeyExW(hKeyInstance,
3227 L"Control",
3228 0,
3229 NULL,
3232 NULL,
3233 &hKeyControl,
3234 NULL);
3235 if (lError == ERROR_SUCCESS)
3236 {
3237 RegCloseKey(hKeyControl);
3238 }
3239
3240 RegCloseKey(hKeyInstance);
3241
3242 return (lError == ERROR_SUCCESS) ? CR_SUCCESS : CR_REGISTRY_ERROR;
3243}
3244
3245
3246static
3249 _Inout_ LPWSTR pszDeviceID,
3250 _In_ PNP_RPC_STRING_LEN ulLength)
3251{
3252 WCHAR szGeneratedInstance[MAX_DEVICE_ID_LEN];
3253 HKEY hKey;
3254 DWORD dwInstanceNumber;
3255 DWORD dwError = ERROR_SUCCESS;
3257
3258 /* Fail, if the device name contains backslashes */
3259 if (wcschr(pszDeviceID, L'\\') != NULL)
3260 return CR_INVALID_DEVICE_ID;
3261
3262 /* Generated ID is: Root<Device ID><Instance number> */
3263 dwInstanceNumber = 0;
3264 while (dwError == ERROR_SUCCESS)
3265 {
3266 if (dwInstanceNumber >= 10000)
3267 return CR_FAILURE;
3268
3269 swprintf(szGeneratedInstance, L"Root\\%ls\\%04lu",
3270 pszDeviceID, dwInstanceNumber);
3271
3272 /* Try to open the enum key of the device instance */
3273 dwError = RegOpenKeyEx(hEnumKey, szGeneratedInstance, 0, KEY_QUERY_VALUE, &hKey);
3274 if (dwError == ERROR_SUCCESS)
3275 {
3277 dwInstanceNumber++;
3278 }
3279 }
3280
3281 /* pszDeviceID is an out parameter too for generated IDs */
3282 if (wcslen(szGeneratedInstance) > ulLength)
3283 {
3285 }
3286 else
3287 {
3288 wcscpy(pszDeviceID, szGeneratedInstance);
3289 }
3290
3291 return ret;
3292}
3293
3294
3295/* Function 28 */
3296DWORD
3297WINAPI
3300 LPWSTR pszDeviceID,
3301 LPWSTR pszParentDeviceID,
3302 PNP_RPC_STRING_LEN ulLength,
3303 DWORD ulFlags)
3304{
3306 HKEY hKey = NULL;
3307 DWORD dwSize, dwPhantom;
3310
3311 DPRINT("PNP_CreateDevInst(%p %S %S %lu 0x%08lx)\n",
3312 hBinding, pszParentDeviceID, pszDeviceID, ulLength, ulFlags);
3313
3314 if (ulFlags & ~CM_CREATE_DEVNODE_BITS)
3315 return CR_INVALID_FLAG;
3316
3317 if (pszDeviceID == NULL || pszParentDeviceID == NULL)
3318 return CR_INVALID_POINTER;
3319
3320 /* Fail, if the parent device is not the root device */
3321 if (!IsRootDeviceInstanceID(pszParentDeviceID))
3322 return CR_INVALID_DEVINST;
3323
3324 if (ulFlags & CM_CREATE_DEVNODE_GENERATE_ID)
3325 {
3326 ret = GenerateDeviceID(pszDeviceID,
3327 ulLength);
3328 if (ret != CR_SUCCESS)
3329 return ret;
3330 }
3331
3332 /* Try to open the device instance key */
3333 RegOpenKeyEx(hEnumKey, pszDeviceID, 0, KEY_READ | KEY_WRITE, &hKey);
3334
3335 if (ulFlags & CM_CREATE_DEVNODE_PHANTOM)
3336 {
3337 /* Fail, if the device already exists */
3338 if (hKey != NULL)
3339 {
3341 goto done;
3342 }
3343
3344 /* Create the phantom device instance */
3345 ret = CreateDeviceInstance(pszDeviceID, TRUE);
3346 }
3347 else
3348 {
3349 /* Fail, if the device exists and is present */
3350 if ((hKey != NULL) && (IsPresentDeviceInstanceID(pszDeviceID)))
3351 {
3353 goto done;
3354 }
3355
3356 /* If it does not already exist ... */
3357 if (hKey == NULL)
3358 {
3359 /* Create the device instance */
3360 ret = CreateDeviceInstance(pszDeviceID, FALSE);
3361
3362 /* Open the device instance key */
3363 RegOpenKeyEx(hEnumKey, pszDeviceID, 0, KEY_READ | KEY_WRITE, &hKey);
3364 }
3365
3366 /* Create a device node for the device */
3367 RtlInitUnicodeString(&ControlData.DeviceInstance, pszDeviceID);
3369 &ControlData,
3370 sizeof(ControlData));
3371 if (!NT_SUCCESS(Status))
3372 {
3373 ret = CR_FAILURE;
3374 goto done;
3375 }
3376
3377 /* If the device is a phantom device, turn it into a normal device */
3378 if (hKey != NULL)
3379 {
3380 dwPhantom = 0;
3381 dwSize = sizeof(DWORD);
3382 RegQueryValueEx(hKey, L"Phantom", NULL, NULL, (PBYTE)&dwPhantom, &dwSize);
3383
3384 if (dwPhantom != 0)
3385 RegDeleteValue(hKey, L"Phantom");
3386 }
3387 }
3388
3389done:
3390 if (hKey)
3392
3393 DPRINT("PNP_CreateDevInst() done (returns %lx)\n", ret);
3394
3395 return ret;
3396}
3397
3398
3399static CONFIGRET
3401 _In_ LPWSTR pszDeviceInstance,
3402 _In_ DWORD ulMinorAction)
3403{
3405 HKEY hDeviceKey = NULL;
3406 DWORD dwDisableCount, dwSize;
3407 DWORD ulStatus, ulProblem;
3408 DWORD dwError;
3411
3412 DPRINT1("SetupDeviceInstance(%S 0x%08lx)\n",
3413 pszDeviceInstance, ulMinorAction);
3414
3415 if (IsRootDeviceInstanceID(pszDeviceInstance))
3416 return CR_INVALID_DEVINST;
3417
3418 if (ulMinorAction & ~CM_SETUP_BITS)
3419 return CR_INVALID_FLAG;
3420
3421 if ((ulMinorAction == CM_SETUP_DOWNLOAD) ||
3422 (ulMinorAction == CM_SETUP_WRITE_LOG_CONFS))
3423 return CR_SUCCESS;
3424
3425 dwError = RegOpenKeyExW(hEnumKey,
3426 pszDeviceInstance,
3427 0,
3428 KEY_READ,
3429 &hDeviceKey);
3430 if (dwError != ERROR_SUCCESS)
3431 return CR_INVALID_DEVNODE;
3432
3433 dwSize = sizeof(dwDisableCount);
3434 dwError = RegQueryValueExW(hDeviceKey,
3435 L"DisableCount",
3436 NULL,
3437 NULL,
3438 (LPBYTE)&dwDisableCount,
3439 &dwSize);
3440 if ((dwError == ERROR_SUCCESS) &&
3441 (dwDisableCount > 0))
3442 {
3443 goto done;
3444 }
3445
3446 GetDeviceStatus(pszDeviceInstance,
3447 &ulStatus,
3448 &ulProblem);
3449
3450 if (ulStatus & DN_STARTED)
3451 {
3452 goto done;
3453 }
3454
3455 if (ulStatus & DN_HAS_PROBLEM)
3456 {
3457 ret = ClearDeviceStatus(pszDeviceInstance,
3459 ulProblem);
3460 }
3461
3462 if (ret != CR_SUCCESS)
3463 goto done;
3464
3465 /* Start the device */
3467 pszDeviceInstance);
3469 &ControlData,
3471 if (!NT_SUCCESS(Status))
3473
3474done:
3475 if (hDeviceKey != NULL)
3476 RegCloseKey(hDeviceKey);
3477
3478 return ret;
3479}
3480
3481
3482static CONFIGRET
3484 _In_ LPWSTR pszDeviceInstance)
3485{
3489
3490 DPRINT("Enable device instance %S\n", pszDeviceInstance);
3491
3492 RtlInitUnicodeString(&ControlData.DeviceInstance, pszDeviceInstance);
3493 Status = NtPlugPlayControl(PlugPlayControlStartDevice, &ControlData, sizeof(ControlData));
3494 if (!NT_SUCCESS(Status))
3496
3497 return ret;
3498}
3499
3500
3501static CONFIGRET
3503 _In_ LPWSTR pszDeviceInstance,
3504 _In_ ULONG ulMinorAction)
3505{
3506 PLUGPLAY_CONTROL_ENUMERATE_DEVICE_DATA EnumerateDeviceData;
3509
3510 DPRINT1("ReenumerateDeviceInstance(%S 0x%08lx)\n",
3511 pszDeviceInstance, ulMinorAction);
3512
3513 if (ulMinorAction & ~CM_REENUMERATE_BITS)
3514 return CR_INVALID_FLAG;
3515
3516 if (ulMinorAction & CM_REENUMERATE_RETRY_INSTALLATION)
3517 {
3518 DPRINT1("CM_REENUMERATE_RETRY_INSTALLATION not implemented!\n");
3519 }
3520
3521 RtlInitUnicodeString(&EnumerateDeviceData.DeviceInstance,
3522 pszDeviceInstance);
3523 EnumerateDeviceData.Flags = 0;
3524
3526 &EnumerateDeviceData,
3528 if (!NT_SUCCESS(Status))
3530
3531 return ret;
3532}
3533
3534
3535/* Function 29 */
3536DWORD
3537WINAPI
3540 DWORD ulMajorAction,
3541 DWORD ulMinorAction,
3542 LPWSTR pszDeviceInstance1,
3543 LPWSTR pszDeviceInstance2)
3544{
3546
3548
3549 DPRINT("PNP_DeviceInstanceAction(%p %lu 0x%08lx %S %S)\n",
3550 hBinding, ulMajorAction, ulMinorAction,
3551 pszDeviceInstance1, pszDeviceInstance2);
3552
3553 switch (ulMajorAction)
3554 {
3555 case PNP_DEVINST_SETUP:
3556 ret = SetupDeviceInstance(pszDeviceInstance1,
3557 ulMinorAction);
3558 break;
3559
3560 case PNP_DEVINST_ENABLE:
3561 ret = EnableDeviceInstance(pszDeviceInstance1);
3562 break;
3563
3564 case PNP_DEVINST_REENUMERATE:
3565 ret = ReenumerateDeviceInstance(pszDeviceInstance1,
3566 ulMinorAction);
3567 break;
3568
3569 default:
3570 DPRINT1("Unknown device action %lu: not implemented\n", ulMajorAction);
3572 }
3573
3574 DPRINT("PNP_DeviceInstanceAction() done (returns %lx)\n", ret);
3575
3576 return ret;
3577}
3578
3579
3580/* Function 30 */
3581DWORD
3582WINAPI
3585 LPWSTR pDeviceID,
3586 DWORD *pulStatus,
3587 DWORD *pulProblem,
3588 DWORD ulFlags)
3589{
3590 DWORD ulDataType, ulTransferLength, ulLength;
3591 DWORD ulCapabilities, ulConfigFlags;
3592 CONFIGRET ret;
3593
3595 UNREFERENCED_PARAMETER(ulFlags);
3596
3597 DPRINT("PNP_GetDeviceStatus(%p %S %p %p 0x%08lx)\n",
3598 hBinding, pDeviceID, pulStatus, pulProblem, ulFlags);
3599
3600 if (ulFlags != 0)
3601 return CR_INVALID_FLAG;
3602
3603 if ((pulStatus == NULL) || (pulProblem == NULL))
3604 return CR_INVALID_POINTER;
3605
3606 if (!IsValidDeviceInstanceID(pDeviceID))
3607 return CR_INVALID_DEVINST;
3608
3609 ret = GetDeviceStatus(pDeviceID, pulStatus, pulProblem);
3610 if (ret != CR_SUCCESS)
3611 return ret;
3612
3613 /* Check for DN_REMOVABLE */
3614 ulTransferLength = sizeof(ulCapabilities);
3615 ulLength = sizeof(ulCapabilities);
3617 pDeviceID,
3619 &ulDataType,
3620 (PBYTE)&ulCapabilities,
3621 &ulTransferLength,
3622 &ulLength,
3623 0);
3624 if (ret != CR_SUCCESS)
3625 ulCapabilities = 0;
3626
3627 if (ulCapabilities & CM_DEVCAP_REMOVABLE)
3628 *pulStatus |= DN_REMOVABLE;
3629
3630 /* Check for DN_MANUAL */
3631 ulTransferLength = sizeof(ulConfigFlags);
3632 ulLength = sizeof(ulConfigFlags);
3634 pDeviceID,
3636 &ulDataType,
3637 (PBYTE)&ulConfigFlags,
3638 &ulTransferLength,
3639 &ulLength,
3640 0);
3641 if (ret != CR_SUCCESS)
3642 ulConfigFlags = 0;
3643
3644 if (ulConfigFlags & CONFIGFLAG_MANUAL_INSTALL)
3645 *pulStatus |= DN_MANUAL;
3646
3647 /* Check for failed install */
3648 if (((*pulStatus & DN_HAS_PROBLEM) == 0) && (ulConfigFlags & CONFIGFLAG_FAILEDINSTALL))
3649 {
3650 *pulStatus |= DN_HAS_PROBLEM;
3651 *pulProblem = CM_PROB_FAILED_INSTALL;
3652 }
3653
3654 return CR_SUCCESS;
3655}
3656
3657
3658/* Function 31 */
3659DWORD
3660WINAPI
3663 LPWSTR pDeviceID,
3664 DWORD ulProblem,
3665 DWORD ulFlags)
3666{
3667 ULONG ulOldStatus, ulOldProblem;
3669
3671
3672 DPRINT1("PNP_SetDeviceProblem(%p %S %lu 0x%08lx)\n",
3673 hBinding, pDeviceID, ulProblem, ulFlags);
3674
3675 if (ulFlags & ~CM_SET_DEVNODE_PROBLEM_BITS)
3676 return CR_INVALID_FLAG;
3677
3678 if (!IsValidDeviceInstanceID(pDeviceID))
3679 return CR_INVALID_DEVINST;
3680
3681 ret = GetDeviceStatus(pDeviceID,
3682 &ulOldStatus,
3683 &ulOldProblem);
3684 if (ret != CR_SUCCESS)
3685 return ret;
3686
3687 if (((ulFlags & CM_SET_DEVNODE_PROBLEM_OVERRIDE) == 0) &&
3688 (ulOldProblem != 0) &&
3689 (ulOldProblem != ulProblem))
3690 {
3691 return CR_FAILURE;
3692 }
3693
3694 if (ulProblem == 0)
3695 {
3696 ret = ClearDeviceStatus(pDeviceID,
3698 ulOldProblem);
3699 }
3700 else
3701 {
3702 ret = SetDeviceStatus(pDeviceID,
3704 ulProblem);
3705 }
3706
3707 return ret;
3708}
3709
3710
3711/* Function 32 */
3712DWORD
3713WINAPI
3716 LPWSTR pDeviceID,
3717 PPNP_VETO_TYPE pVetoType,
3718 LPWSTR pszVetoName,
3719 DWORD ulNameLength,
3720 DWORD ulFlags)
3721{
3723
3724 DPRINT1("PNP_DisableDevInst(%p %S %p %p %lu 0x%08lx)\n",
3725 hBinding, pDeviceID, pVetoType, pszVetoName, ulNameLength, ulFlags);
3726
3727 if (ulFlags & ~CM_DISABLE_BITS)
3728 return CR_INVALID_FLAG;
3729
3730 if (!IsValidDeviceInstanceID(pDeviceID) ||
3731 IsRootDeviceInstanceID(pDeviceID))
3732 return CR_INVALID_DEVINST;
3733
3734 return DisableDeviceInstance(pDeviceID,
3735 pVetoType,
3736 pszVetoName,
3737 ulNameLength);
3738}
3739
3740
3741/* Function 33 */
3742DWORD
3743WINAPI
3746 LPWSTR pDeviceID,
3747 DWORD ulFlags)
3748{
3751}
3752
3753
3754static BOOL
3756 LPWSTR lpDeviceId)
3757{
3758 LPWSTR lpPtr;
3760
3761 lpPtr = lpDeviceIdList;
3762 while (*lpPtr != 0)
3763 {
3764 dwLength = wcslen(lpPtr);
3765 if (0 == _wcsicmp(lpPtr, lpDeviceId))
3766 return TRUE;
3767
3768 lpPtr += (dwLength + 1);
3769 }
3770
3771 return FALSE;
3772}
3773
3774
3775static VOID
3776AppendDeviceId(LPWSTR lpDeviceIdList,
3777 LPDWORD lpDeviceIdListSize,
3778 LPWSTR lpDeviceId)
3779{
3780 DWORD dwLen;
3781 DWORD dwPos;
3782
3783 dwLen = wcslen(lpDeviceId);
3784 dwPos = (*lpDeviceIdListSize / sizeof(WCHAR)) - 1;
3785
3786 wcscpy(&lpDeviceIdList[dwPos], lpDeviceId);
3787
3788 dwPos += (dwLen + 1);
3789
3790 lpDeviceIdList[dwPos] = 0;
3791
3792 *lpDeviceIdListSize = dwPos * sizeof(WCHAR);
3793}
3794
3795
3796/* Function 34 */
3797DWORD
3798WINAPI
3801 LPWSTR pszDeviceID,
3802 LPWSTR pszID,
3803 DWORD ulFlags)
3804{
3806 HKEY hDeviceKey;
3807 LPWSTR pszSubKey;
3808 DWORD dwDeviceIdListSize;
3809 DWORD dwNewDeviceIdSize;
3810 WCHAR * pszDeviceIdList = NULL;
3811
3813
3814 DPRINT("PNP_AddID(%p %S %S 0x%08lx)\n",
3815 hBinding, pszDeviceID, pszID, ulFlags);
3816
3818 pszDeviceID,
3819 0,
3821 &hDeviceKey) != ERROR_SUCCESS)
3822 {
3823 DPRINT("Failed to open the device key!\n");
3824 return CR_INVALID_DEVNODE;
3825 }
3826
3827 pszSubKey = (ulFlags & CM_ADD_ID_COMPATIBLE) ? L"CompatibleIDs" : L"HardwareID";
3828
3829 if (RegQueryValueExW(hDeviceKey,
3830 pszSubKey,
3831 NULL,
3832 NULL,
3833 NULL,
3834 &dwDeviceIdListSize) != ERROR_SUCCESS)
3835 {
3836 DPRINT("Failed to query the desired ID string!\n");
3838 goto Done;
3839 }
3840
3841 dwNewDeviceIdSize = lstrlenW(pszDeviceID);
3842 if (!dwNewDeviceIdSize)
3843 {
3845 goto Done;
3846 }
3847
3848 dwDeviceIdListSize += (dwNewDeviceIdSize + 2) * sizeof(WCHAR);
3849
3850 pszDeviceIdList = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwDeviceIdListSize);
3851 if (!pszDeviceIdList)
3852 {
3853 DPRINT("Failed to allocate memory for the desired ID string!\n");
3855 goto Done;
3856 }
3857
3858 if (RegQueryValueExW(hDeviceKey,
3859 pszSubKey,
3860 NULL,
3861 NULL,
3862 (LPBYTE)pszDeviceIdList,
3863 &dwDeviceIdListSize) != ERROR_SUCCESS)
3864 {
3865 DPRINT("Failed to query the desired ID string!\n");
3867 goto Done;
3868 }
3869
3870 /* Check whether the device ID is already in use */
3871 if (CheckForDeviceId(pszDeviceIdList, pszDeviceID))
3872 {
3873 DPRINT("Device ID was found in the ID string!\n");
3874 ret = CR_SUCCESS;
3875 goto Done;
3876 }
3877
3878 /* Append the Device ID */
3879 AppendDeviceId(pszDeviceIdList, &dwDeviceIdListSize, pszID);
3880
3881 if (RegSetValueExW(hDeviceKey,
3882 pszSubKey,
3883 0,
3885 (LPBYTE)pszDeviceIdList,
3886 dwDeviceIdListSize) != ERROR_SUCCESS)
3887 {
3888 DPRINT("Failed to set the desired ID string!\n");
3890 }
3891
3892Done:
3893 RegCloseKey(hDeviceKey);
3894 if (pszDeviceIdList)
3895 HeapFree(GetProcessHeap(), 0, pszDeviceIdList);
3896
3897 DPRINT("PNP_AddID() done (returns %lx)\n", ret);
3898
3899 return ret;
3900}
3901
3902
3903/* Function 35 */
3904DWORD
3905WINAPI
3908 LPWSTR pszDeviceID,
3909 DWORD ulFlags)
3910{
3911 DPRINT("PNP_RegisterDriver(%p %S 0x%lx)\n",
3912 hBinding, pszDeviceID, ulFlags);
3913
3914 if (ulFlags & ~CM_REGISTER_DEVICE_DRIVER_BITS)
3915 return CR_INVALID_FLAG;
3916
3917 if (!IsValidDeviceInstanceID(pszDeviceID))
3918 return CR_INVALID_DEVINST;
3919
3920 SetDeviceStatus(pszDeviceID, 0, 0);
3921
3922 return CR_SUCCESS;
3923}
3924
3925
3926/* Function 36 */
3927DWORD
3928WINAPI
3931 LPWSTR pszDeviceID,
3932 PPNP_VETO_TYPE pVetoType,
3933 LPWSTR pszVetoName,
3934 DWORD ulNameLength,
3935 DWORD ulFlags)
3936{
3940
3941 DPRINT1("PNP_QueryRemove(%p %S %p %p %lu 0x%lx)\n",
3942 hBinding, pszDeviceID, pVetoType, pszVetoName,
3943 ulNameLength, ulFlags);
3944
3945 if (ulFlags & ~CM_REMOVE_BITS)
3946 return CR_INVALID_FLAG;
3947
3948 if (!IsValidDeviceInstanceID(pszDeviceID) ||
3949 IsRootDeviceInstanceID(pszDeviceID))
3950 return CR_INVALID_DEVINST;
3951
3952 if (pVetoType != NULL)
3953 *pVetoType = PNP_VetoTypeUnknown;
3954
3955 if (pszVetoName != NULL && ulNameLength > 0)
3956 *pszVetoName = UNICODE_NULL;
3957
3958 RtlZeroMemory(&PlugPlayData, sizeof(PlugPlayData));
3960 pszDeviceID);
3961 PlugPlayData.VetoName = pszVetoName;
3962 PlugPlayData.NameLength = ulNameLength;
3963// PlugPlayData.Flags =
3964
3966 &PlugPlayData,
3967 sizeof(PlugPlayData));
3968 if (!NT_SUCCESS(Status))
3970
3971 return ret;
3972}
3973
3974
3975/* Function 37 */
3976DWORD
3977WINAPI
3980 LPWSTR pszDeviceID,
3981 PPNP_VETO_TYPE pVetoType,
3982 LPWSTR pszVetoName,
3983 DWORD ulNameLength,
3984 DWORD ulFlags)
3985{
3989
3990 DPRINT1("PNP_RequestDeviceEject(%p %S %p %p %lu 0x%lx)\n",
3991 hBinding, pszDeviceID, pVetoType, pszVetoName,
3992 ulNameLength, ulFlags);
3993
3994 if (ulFlags != 0)
3995 return CR_INVALID_FLAG;
3996
3997 if (!IsValidDeviceInstanceID(pszDeviceID))
3998 return CR_INVALID_DEVINST;
3999
4000 if (pVetoType != NULL)
4001 *pVetoType = PNP_VetoTypeUnknown;
4002
4003 if (pszVetoName != NULL && ulNameLength > 0)
4004 *pszVetoName = UNICODE_NULL;
4005
4006 RtlZeroMemory(&PlugPlayData, sizeof(PlugPlayData));
4008 pszDeviceID);
4009 PlugPlayData.VetoName = pszVetoName;
4010 PlugPlayData.NameLength = ulNameLength;
4011// PlugPlayData.Flags =
4012
4014 &PlugPlayData,
4015 sizeof(PlugPlayData));
4016 if (!NT_SUCCESS(Status))
4018
4019 return ret;
4020}
4021
4022
4023/* Function 38 */
4025WINAPI
4028 BOOL *Present)
4029{
4030 HKEY hKey;
4031 DWORD dwType;
4032 DWORD dwValue;
4033 DWORD dwSize;
4035
4037
4038 DPRINT1("PNP_IsDockStationPresent(%p %p)\n",
4039 hBinding, Present);
4040
4041 *Present = FALSE;
4042
4044 L"CurrentDockInfo",
4045 0,
4046 KEY_READ,
4047 &hKey) != ERROR_SUCCESS)
4048 return CR_REGISTRY_ERROR;
4049
4050 dwSize = sizeof(DWORD);
4052 L"DockingState",
4053 NULL,
4054 &dwType,
4055 (LPBYTE)&dwValue,
4056 &dwSize) != ERROR_SUCCESS)
4058
4060
4061 if (ret == CR_SUCCESS)
4062 {
4063 if (dwType != REG_DWORD || dwSize != sizeof(DWORD))
4064 {
4066 }
4067 else if (dwValue != 0)
4068 {
4069 *Present = TRUE;
4070 }
4071 }
4072
4073 DPRINT1("PNP_IsDockStationPresent() done (returns %lx)\n", ret);
4074
4075 return ret;
4076}
4077
4078
4079/* Function 39 */
4080DWORD
4081WINAPI
4084{
4085 WCHAR szDockDeviceInstance[MAX_DEVICE_ID_LEN];
4088
4089 DPRINT("PNP_RequestEjectPC(%p)\n", hBinding);
4090
4091 /* Retrieve the dock device */
4092 DockData.DeviceInstanceLength = ARRAYSIZE(szDockDeviceInstance);
4093 DockData.DeviceInstance = szDockDeviceInstance;
4094
4096 &DockData,
4097 sizeof(DockData));
4098 if (!NT_SUCCESS(Status))
4099 return NtStatusToCrError(Status);
4100
4101 /* Eject the dock device */
4103 szDockDeviceInstance,
4104 NULL,
4105 NULL,
4106 0,
4107 0);
4108}
4109
4110
4111/* Function 40 */
4112DWORD
4113WINAPI
4116 DWORD ulAction,
4117 LPWSTR pDeviceID,
4118 DWORD ulConfig,
4119 DWORD *pulValue,
4120 PPNP_VETO_TYPE pVetoType,
4121 LPWSTR pszVetoName,
4122 DWORD ulNameLength,
4123 DWORD ulFlags)
4124{
4126 WCHAR szKeyName[MAX_PATH];
4127 HKEY hKey;
4128 HKEY hDeviceKey;
4129 DWORD dwSize;
4130
4132
4133 DPRINT("PNP_HwProfFlags() called\n");
4134
4135 if (!IsValidDeviceInstanceID(pDeviceID))
4136 return CR_INVALID_DEVINST;
4137
4138 if (ulConfig == 0)
4139 {
4140 wcscpy(szKeyName,
4141 L"System\\CurrentControlSet\\HardwareProfiles\\Current\\System\\CurrentControlSet\\Enum");
4142 }
4143 else
4144 {
4145 swprintf(szKeyName,
4146 L"System\\CurrentControlSet\\HardwareProfiles\\%04lu\\System\\CurrentControlSet\\Enum",
4147 ulConfig);
4148 }
4149
4151 szKeyName,
4152 0,
4154 &hKey) != ERROR_SUCCESS)
4155 return CR_REGISTRY_ERROR;
4156
4157 if (ulAction == PNP_GET_HWPROFFLAGS)
4158 {
4159 if (RegOpenKeyExW(hKey,
4160 pDeviceID,
4161 0,
4163 &hDeviceKey) != ERROR_SUCCESS)
4164 {
4165 *pulValue = 0;
4166 }
4167 else
4168 {
4169 dwSize = sizeof(DWORD);
4170 if (RegQueryValueExW(hDeviceKey,
4171 L"CSConfigFlags",
4172 NULL,
4173 NULL,
4174 (LPBYTE)pulValue,
4175 &dwSize) != ERROR_SUCCESS)
4176 {
4177 *pulValue = 0;
4178 }
4179
4180 RegCloseKey(hDeviceKey);
4181 }
4182 }
4183 else if (ulAction == PNP_SET_HWPROFFLAGS)
4184 {
4185 /* FIXME: not implemented yet */
4187 }
4188
4190
4191 return ret;
4192}
4193
4194
4195/* Function 41 */
4196DWORD
4197WINAPI
4200 DWORD ulIndex,
4201 HWPROFILEINFO *pHWProfileInfo,
4202 DWORD ulProfileInfoSize,
4203 DWORD ulFlags)
4204{
4205 WCHAR szProfileName[5];
4206 HKEY hKeyConfig = NULL;
4207 HKEY hKeyProfiles = NULL;
4208 HKEY hKeyProfile = NULL;
4209 DWORD dwDisposition;
4210 DWORD dwSize;
4211 LONG lError;
4213
4215
4216 DPRINT("PNP_GetHwProfInfo() called\n");
4217
4218 if (ulProfileInfoSize == 0)
4219 {
4221 goto done;
4222 }
4223
4224 if (ulFlags != 0)
4225 {
4227 goto done;
4228 }
4229
4230 /* Initialize the profile information */
4231 pHWProfileInfo->HWPI_ulHWProfile = 0;
4232 pHWProfileInfo->HWPI_szFriendlyName[0] = 0;
4233 pHWProfileInfo->HWPI_dwFlags = 0;
4234
4235 /* Open the 'IDConfigDB' key */
4237 L"System\\CurrentControlSet\\Control\\IDConfigDB",
4238 0,
4239 NULL,
4242 NULL,
4243 &hKeyConfig,
4244 &dwDisposition);
4245 if (lError != ERROR_SUCCESS)
4246 {
4248 goto done;
4249 }
4250
4251 /* Open the 'Hardware Profiles' subkey */
4252 lError = RegCreateKeyExW(hKeyConfig,
4253 L"Hardware Profiles",
4254 0,
4255 NULL,
4258 NULL,
4259 &hKeyProfiles,
4260 &dwDisposition);
4261 if (lError != ERROR_SUCCESS)
4262 {
4264 goto done;
4265 }
4266
4267 if (ulIndex == (ULONG)-1)
4268 {
4269 dwSize = sizeof(ULONG);
4270 lError = RegQueryValueExW(hKeyConfig,
4271 L"CurrentConfig",
4272 NULL,
4273 NULL,
4274 (LPBYTE)&pHWProfileInfo->HWPI_ulHWProfile,
4275 &dwSize);
4276 if (lError != ERROR_SUCCESS)
4277 {
4278 pHWProfileInfo->HWPI_ulHWProfile = 0;
4280 goto done;
4281 }
4282 }
4283 else
4284 {
4285 /* FIXME: not implemented yet */
4287 goto done;
4288 }
4289
4290 swprintf(szProfileName, L"%04lu", pHWProfileInfo->HWPI_ulHWProfile);
4291
4292 lError = RegOpenKeyExW(hKeyProfiles,
4293 szProfileName,
4294 0,
4296 &hKeyProfile);
4297 if (lError != ERROR_SUCCESS)
4298 {
4300 goto done;
4301 }
4302
4303 dwSize = sizeof(pHWProfileInfo->HWPI_szFriendlyName);
4304 lError = RegQueryValueExW(hKeyProfile,
4305 L"FriendlyName",
4306 NULL,
4307 NULL,
4308 (LPBYTE)&pHWProfileInfo->HWPI_szFriendlyName,
4309 &dwSize);
4310 if (lError != ERROR_SUCCESS)
4311 {
4313 goto done;
4314 }
4315
4316done:
4317 if (hKeyProfile != NULL)
4318 RegCloseKey(hKeyProfile);
4319
4320 if (hKeyProfiles != NULL)
4321 RegCloseKey(hKeyProfiles);
4322
4323 if (hKeyConfig != NULL)
4324 RegCloseKey(hKeyConfig);
4325
4326 return ret;
4327}
4328
4329
4330/* Function 42 */
4331DWORD
4332WINAPI
4335 LPWSTR pDeviceID,
4336 DWORD ulPriority,
4337 DWORD *pulLogConfTag,
4338 DWORD ulFlags)
4339{
4340 HKEY hConfigKey = NULL;
4341 DWORD RegDataType = 0;
4342 ULONG ulDataSize = 0, ulNewSize = 0;
4343 PBYTE pDataBuffer = NULL;
4344 WCHAR szValueNameBuffer[LOGCONF_NAME_BUFFER_SIZE];
4346
4347 DPRINT("PNP_AddEmptyLogConf(%p %S %lu %p 0x%08lx)\n",
4348 hBinding, pDeviceID, ulPriority, pulLogConfTag, ulFlags);
4349
4350 if (pulLogConfTag == NULL)
4351 return CR_INVALID_POINTER;
4352
4353 *pulLogConfTag = 0;
4354
4355 if (ulFlags & ~(LOG_CONF_BITS | PRIORITY_BIT))
4356 return CR_INVALID_FLAG;
4357
4358 if (!IsValidDeviceInstanceID(pDeviceID) || IsRootDeviceInstanceID(pDeviceID))
4359 return CR_INVALID_DEVNODE;
4360
4361 ret = OpenConfigurationKey(pDeviceID,
4362 ulFlags & LOG_CONF_BITS,
4363 &hConfigKey);
4364 if (ret != CR_SUCCESS)
4365 {
4366 DPRINT1("OpenConfigurationKey() failed (Error %lu)\n", ret);
4368 goto done;
4369 }
4370
4371 ret = GetConfigurationData(hConfigKey,
4372 ulFlags & LOG_CONF_BITS,
4373 &RegDataType,
4374 &ulDataSize,
4375 &pDataBuffer,
4377 szValueNameBuffer);
4378
4379 if (ret != CR_SUCCESS || ulDataSize == 0)
4380 {
4381 ret = CR_SUCCESS;
4382
4383 if (RegDataType == REG_RESOURCE_LIST)
4384 {
4385 PCM_RESOURCE_LIST pResourceList = NULL;
4387
4388 /* Allocate a buffer for the new configuration */
4389 ulDataSize = sizeof(CM_RESOURCE_LIST) - sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
4390 pDataBuffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, ulDataSize);
4391 if (pDataBuffer == NULL)
4392 {
4394 goto done;
4395 }
4396
4397 pResourceList = (PCM_RESOURCE_LIST)pDataBuffer;
4398 pResourceList->Count = 1;
4399
4400 pResource = (PCM_FULL_RESOURCE_DESCRIPTOR)&pResourceList->List[0];
4402 pResource->BusNumber = 0;
4403 pResource->PartialResourceList.Version = 1;
4404 pResource->PartialResourceList.Revision = 1;
4405 pResource->PartialResourceList.Count = 0;
4406 }
4407 else if (RegDataType == REG_RESOURCE_REQUIREMENTS_LIST)
4408 {
4409 PIO_RESOURCE_REQUIREMENTS_LIST pRequirementsList = NULL;
4410 PIO_RESOURCE_LIST pResourceList = NULL;
4411
4412 ulDataSize = sizeof(IO_RESOURCE_REQUIREMENTS_LIST);
4413 pDataBuffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, ulDataSize);
4414 if (pDataBuffer == NULL)
4415 {
4417 goto done;
4418 }
4419
4420 pRequirementsList = (PIO_RESOURCE_REQUIREMENTS_LIST)pDataBuffer;
4421 pRequirementsList->ListSize = ulDataSize;
4422 pRequirementsList->InterfaceType = InterfaceTypeUndefined;
4423 pRequirementsList->BusNumber = 0;
4424 pRequirementsList->SlotNumber = 0;
4425 pRequirementsList->AlternativeLists = 1;
4426
4427 pResourceList = (PIO_RESOURCE_LIST)&pRequirementsList->List[0];
4428 pResourceList->Version = 1;
4429 pResourceList->Revision = 1;
4430 pResourceList->Count = 1;
4431
4432 pResourceList->Descriptors[0].Option = IO_RESOURCE_PREFERRED;
4433 pResourceList->Descriptors[0].Type = CmResourceTypeConfigData;
4434 pResourceList->Descriptors[0].u.ConfigData.Priority = ulPriority;
4435 }
4436 else
4437 {
4438 ret = CR_FAILURE;
4439 goto done;
4440 }
4441 }
4442 else
4443 {
4444 if (RegDataType == REG_RESOURCE_LIST)
4445 {
4446 PCM_RESOURCE_LIST pResourceList = NULL;
4448 ULONG ulIndex;
4449
4450 /* Reallocate a larger buffer in order to add the new configuration */
4451 ulNewSize = sizeof(CM_FULL_RESOURCE_DESCRIPTOR) - sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
4452 pDataBuffer = HeapReAlloc(GetProcessHeap(),
4453 0,
4454 pDataBuffer,
4455 ulDataSize + ulNewSize);
4456 if (pDataBuffer == NULL)
4457 {
4459 goto done;
4460 }
4461
4462 pResourceList = (PCM_RESOURCE_LIST)pDataBuffer;
4463
4464 /* Get a pointer to the new (uninitialized) resource descriptor */
4465 pResource = (PCM_FULL_RESOURCE_DESCRIPTOR)&pResourceList->List[0];
4466 for (ulIndex = 0; ulIndex < pResourceList->Count; ulIndex++)
4467 pResource = NextResourceDescriptor(pResource);
4468
4469 /* Initialize the new resource descriptor */
4470 pResourceList->Count++;
4472 pResource->BusNumber = 0;
4473 pResource->PartialResourceList.Version = 1;
4474 pResource->PartialResourceList.Revision = 1;
4475 pResource->PartialResourceList.Count = 0;
4476
4477 *pulLogConfTag = ulIndex;
4478 }
4479 else if (RegDataType == REG_RESOURCE_REQUIREMENTS_LIST)
4480 {
4481 PIO_RESOURCE_REQUIREMENTS_LIST pRequirementsList = NULL;
4482 PIO_RESOURCE_LIST pResourceList = NULL;
4483 ULONG ulIndex;
4484
4485 /* Reallocate a larger buffer in order to add the new configuration */
4486 ulNewSize = sizeof(IO_RESOURCE_REQUIREMENTS_LIST);
4487 pDataBuffer = HeapReAlloc(GetProcessHeap(),
4488 0,
4489 pDataBuffer,
4490 ulDataSize + ulNewSize);
4491 if (pDataBuffer == NULL)
4492 {
4494 goto done;
4495 }
4496
4497 pRequirementsList = (PIO_RESOURCE_REQUIREMENTS_LIST)pDataBuffer;
4498 pResourceList = (PIO_RESOURCE_LIST)&pRequirementsList->List[0];
4499 for (ulIndex = 0; ulIndex < pRequirementsList->AlternativeLists - 1; ulIndex++)
4500 pResourceList = NextResourceRequirement(pResourceList);
4501
4502 pRequirementsList->ListSize = ulDataSize + ulNewSize;
4503 pRequirementsList->AlternativeLists++;
4504
4505 pResourceList->Version = 1;
4506 pResourceList->Revision = 1;
4507 pResourceList->Count = 1;
4508
4509 pResourceList->Descriptors[0].Option = IO_RESOURCE_PREFERRED;
4510 pResourceList->Descriptors[0].Type = CmResourceTypeConfigData;
4511 pResourceList->Descriptors[0].u.ConfigData.Priority = ulPriority;
4512
4513 *pulLogConfTag = ulIndex;
4514 }
4515 else
4516 {
4517 ret = CR_FAILURE;
4518 goto done;
4519 }
4520 }
4521
4522 /* Store the configuration */
4523 if (RegSetValueEx(hConfigKey,
4524 szValueNameBuffer,
4525 0,
4526 RegDataType,
4527 pDataBuffer,
4528 ulDataSize + ulNewSize) != ERROR_SUCCESS)
4529 {
4531 goto done;
4532 }
4533
4534done:
4535 if (pDataBuffer != NULL)
4536 HeapFree(GetProcessHeap(), 0, pDataBuffer);
4537
4538 if (hConfigKey != NULL)
4539 RegCloseKey(hConfigKey);
4540
4541 DPRINT("PNP_AddEmptyLogConf() returns %lu\n", ret);
4542
4543 return ret;
4544}
4545
4546
4547/* Function 43 */
4548DWORD
4549WINAPI
4552 LPWSTR pDeviceID,
4553 DWORD ulLogConfType,
4554 DWORD ulLogConfTag,
4555 DWORD ulFlags)
4556{
4557 HKEY hConfigKey = NULL;
4558 DWORD RegDataType = 0;
4559 ULONG ulDataSize = 0;
4560 LPBYTE pDataBuffer = NULL;
4561 WCHAR szValueNameBuffer[LOGCONF_NAME_BUFFER_SIZE];
4563
4564 DPRINT("PNP_FreeLogConf(%p %S %lu %lu 0x%08lx)\n",
4565 hBinding, pDeviceID, ulLogConfType, ulLogConfTag, ulFlags);
4566
4567 if (ulFlags != 0)
4568 return CR_INVALID_FLAG;
4569
4570 if (!IsValidDeviceInstanceID(pDeviceID))
4571 return CR_INVALID_DEVNODE;
4572
4573 ret = OpenConfigurationKey(pDeviceID,
4574 ulLogConfType,
4575 &hConfigKey);
4576 if (ret != CR_SUCCESS)
4577 {
4578 DPRINT1("OpenConfigurationKey() failed (Error %lu)\n", ret);
4580 goto done;
4581 }
4582
4583 ret = GetConfigurationData(hConfigKey,
4584 ulLogConfType,
4585 &RegDataType,
4586 &ulDataSize,
4587 &pDataBuffer,
4589 szValueNameBuffer);
4590 if (ret != CR_SUCCESS)
4591 {
4593 goto done;
4594 }
4595
4596 if (RegDataType == REG_RESOURCE_LIST)
4597 {
4598 PCM_RESOURCE_LIST pResourceList = (PCM_RESOURCE_LIST)pDataBuffer;
4599
4600 if (pResourceList->Count <= 1)
4601 {
4602 /* Delete the key if there is only one or no configuration in the key */
4603 DPRINT("Delete value %S\n", szValueNameBuffer);
4604 RegDeleteValue(hConfigKey, szValueNameBuffer);
4605 }
4606 else
4607 {
4608 PCM_FULL_RESOURCE_DESCRIPTOR pResource = NULL, pNextResource = NULL;
4609 ULONG ulIndex, ulMoveSize;
4610 DWORD dwError;
4611
4612 /* Fail if we try to delete an entry outside of our resource list */
4613 if (ulLogConfTag >= pResourceList->Count)
4614 {
4616 goto done;
4617 }
4618
4619 /* Get a pointer to the resource descriptor to be deleted */
4620 pResource = (PCM_FULL_RESOURCE_DESCRIPTOR)&pResourceList->List[0];
4621 for (ulIndex = 0; ulIndex < ulLogConfTag; ulIndex++)
4622 pResource = NextResourceDescriptor(pResource);
4623
4624 /* Delete the resource descriptor */
4625 if (ulLogConfTag == pResourceList->Count - 1)
4626 {
4627 /* Delete the last resource descriptor */
4628 ulDataSize = (ULONG)((ULONG_PTR)pResource - (ULONG_PTR)pResourceList);
4629 }
4630 else
4631 {
4632 pNextResource = NextResourceDescriptor(pResource);
4633
4634 ulMoveSize = ulDataSize - (DWORD)((ULONG_PTR)pNextResource - (ULONG_PTR)pResourceList);
4635 MoveMemory(pResource, pNextResource, ulMoveSize);
4636
4637 ulDataSize -= (DWORD)((ULONG_PTR)pNextResource - (ULONG_PTR)pResource);
4638 }
4639
4640 pResourceList->Count--;
4641
4642 /* Store the new configuration */
4643 dwError = RegSetValueEx(hConfigKey,
4644 szValueNameBuffer,
4645 0,
4646 RegDataType,
4647 pDataBuffer,
4648 ulDataSize);
4649 if (dwError != ERROR_SUCCESS)
4650 {
4652 goto done;
4653 }
4654 }
4655 }
4656 else if (RegDataType == REG_RESOURCE_REQUIREMENTS_LIST)
4657 {
4658 if (((PIO_RESOURCE_REQUIREMENTS_LIST)pDataBuffer)->AlternativeLists <= 1)
4659 {
4660 /* Delete the key if there is only one or no configuration in the key */
4661 DPRINT("Delete value %S\n", szValueNameBuffer);
4662 RegDeleteValue(hConfigKey, szValueNameBuffer);
4663 }
4664 else
4665 {
4666 /* FIXME */
4667 }
4668 }
4669 else
4670 {
4671 ret = CR_FAILURE;
4672 goto done;
4673 }
4674
4675done:
4676 if (pDataBuffer != NULL)
4677 HeapFree(GetProcessHeap(), 0, pDataBuffer);
4678
4679 if (hConfigKey != NULL)
4680 RegCloseKey(hConfigKey);
4681
4682 DPRINT("PNP_FreeLogConf() returns %lu\n", ret);
4683
4684 return ret;
4685}
4686
4687
4688/* Function 44 */
4689DWORD
4690WINAPI
4693 LPWSTR pDeviceID,
4694 DWORD ulLogConfType,
4695 DWORD *pulLogConfTag,
4696 DWORD ulFlags)
4697{
4698 HKEY hConfigKey = NULL;
4699 DWORD RegDataType = 0;
4700 ULONG ulDataSize = 0;
4701 LPBYTE lpData = NULL;
4703
4704 DPRINT("PNP_GetFirstLogConf(%p %S %lu %p 0x%08lx)\n",
4705 hBinding, pDeviceID, ulLogConfType, pulLogConfTag, ulFlags);
4706
4707 if (pulLogConfTag == NULL)
4708 return CR_INVALID_POINTER;
4709
4710 *pulLogConfTag = (DWORD)0;
4711
4712 if (ulFlags & ~LOG_CONF_BITS)
4713 return CR_INVALID_FLAG;
4714
4715 if (!IsValidDeviceInstanceID(pDeviceID))
4716 return CR_INVALID_DEVINST;
4717
4718 ret = OpenConfigurationKey(pDeviceID,
4719 ulLogConfType,
4720 &hConfigKey);
4721 if (ret != CR_SUCCESS)
4722 {
4723 DPRINT1("OpenConfigurationKey() failed (Error %lu)\n", ret);
4725 goto done;
4726 }
4727
4728 ret = GetConfigurationData(hConfigKey,
4729 ulLogConfType,
4730 &RegDataType,
4731 &ulDataSize,
4732 &lpData,
4733 0,
4734 NULL);
4735 if (ret != CR_SUCCESS)
4736 {
4737 DPRINT1("GetConfigurationData() failed (Error %lu)\n", ret);
4739 goto done;
4740 }
4741
4742 DPRINT1("Data size %lu\n", ulDataSize);
4743 if (ulDataSize == 0 || lpData == NULL)
4744 {
4745 DPRINT1("No config data available!\n");
4747 goto done;
4748 }
4749
4750 /* Get the first tag */
4751 if (RegDataType == REG_RESOURCE_LIST)
4752 {
4753 DPRINT("REG_RESOURCE_LIST->Count %lu\n", ((PCM_RESOURCE_LIST)lpData)->Count);
4754
4755 /* Fail, if we do not have any resource */
4756 if (((PCM_RESOURCE_LIST)lpData)->Count == 0)
4757 {
4758 DPRINT1("No resource descriptors!\n");
4760 goto done;
4761 }
4762 }
4763 else if (RegDataType == REG_RESOURCE_REQUIREMENTS_LIST)
4764 {
4765 DPRINT("REG_RESOURCE_REQUIREMENTS_LIST->AlternativeLists %lu\n",
4766 ((PIO_RESOURCE_REQUIREMENTS_LIST)lpData)->AlternativeLists);
4767
4768 /* Fail, if we do not have any requirements */
4769 if (((PIO_RESOURCE_REQUIREMENTS_LIST)lpData)->AlternativeLists == 0)
4770 {
4772 goto done;
4773 }
4774 }
4775
4776done:
4777 if (lpData != NULL)
4778 HeapFree(GetProcessHeap(), 0, lpData);
4779
4780 if (hConfigKey != NULL)
4781 RegCloseKey(hConfigKey);
4782
4783 DPRINT("PNP_GetFirstLogConf() returns %lu\n", ret);
4784
4785 return ret;
4786}
4787
4788
4789/* Function 45 */
4790DWORD
4791WINAPI
4794 LPWSTR pDeviceID,
4795 DWORD ulLogConfType,
4796 DWORD ulCurrentTag,
4797 DWORD *pulNextTag,
4798 DWORD ulFlags)
4799{
4800 HKEY hConfigKey = NULL;
4801 DWORD RegDataType = 0;
4802 ULONG ulDataSize = 0;
4803 LPBYTE lpData = NULL;
4805
4806 DPRINT("PNP_GetNextLogConf(%p %S %lu %lu %p 0x%08lx)\n",
4807 hBinding, pDeviceID, ulLogConfType, ulCurrentTag, pulNextTag, ulFlags);
4808
4809 if (pulNextTag == NULL)
4810 return CR_INVALID_POINTER;
4811
4812 *pulNextTag = (DWORD)0;
4813
4814 if (ulFlags != 0)
4815 return CR_INVALID_FLAG;
4816
4817 if (!IsValidDeviceInstanceID(pDeviceID))
4818 return CR_INVALID_DEVINST;
4819
4820 ret = OpenConfigurationKey(pDeviceID,
4821 ulLogConfType,
4822 &hConfigKey);
4823 if (ret != CR_SUCCESS)
4824 {
4825 DPRINT1("OpenConfigurationKey() failed (Error %lu)\n", ret);
4827 goto done;
4828 }
4829
4830 ret = GetConfigurationData(hConfigKey,
4831 ulLogConfType,
4832 &RegDataType,
4833 &ulDataSize,
4834 &lpData,
4835 0,
4836 NULL);
4837 if (ret != CR_SUCCESS)
4838 {
4839 DPRINT1("GetConfigurationData() failed (Error %lu)\n", ret);
4841 goto done;
4842 }
4843
4844 DPRINT("Data size %lu\n", ulDataSize);
4845
4846 if (ulDataSize == 0 || lpData == NULL)
4847 {
4848 DPRINT1("No config data available!\n");
4850 goto done;
4851 }
4852
4853 /* Check if the next entry is available */
4854 if (RegDataType == REG_RESOURCE_LIST)
4855 {
4856 DPRINT("REG_RESOURCE_LIST->Count %lu\n", ((PCM_RESOURCE_LIST)lpData)->Count);
4857
4858 /* Fail, if we are beyond the end of the list */
4859 if (ulCurrentTag >= ((PCM_RESOURCE_LIST)lpData)->Count)
4860 {
4862 goto done;
4863 }
4864
4865 /* Indicate that we reached the end of the list */
4866 if (ulCurrentTag == ((PCM_RESOURCE_LIST)lpData)->Count - 1)
4867 {
4869 goto done;
4870 }
4871 }
4872 else if (RegDataType == REG_RESOURCE_REQUIREMENTS_LIST)
4873 {
4874 DPRINT("REG_RESOURCE_REQUIREMENTS_LIST->AlternativeLists %lu\n",
4875 ((PIO_RESOURCE_REQUIREMENTS_LIST)lpData)->AlternativeLists);
4876
4877 /* Fail, if we are beyond the end of the list */
4878 if (ulCurrentTag >= ((PIO_RESOURCE_REQUIREMENTS_LIST)lpData)->AlternativeLists)
4879 {
4881 goto done;
4882 }
4883
4884 /* Indicate that we reached the end of the list */
4885 if (ulCurrentTag == ((PIO_RESOURCE_REQUIREMENTS_LIST)lpData)->AlternativeLists - 1)
4886 {
4888 goto done;
4889 }
4890 }
4891
4892 /* Return the next tag value */
4893 *pulNextTag = ulCurrentTag + 1;
4894
4895done:
4896 if (lpData != NULL)
4897 HeapFree(GetProcessHeap(), 0, lpData);
4898
4899 if (hConfigKey != NULL)
4900 RegCloseKey(hConfigKey);
4901
4902 DPRINT("PNP_GetNextLogConf() returns %lu\n", ret);
4903
4904 return ret;
4905}
4906
4907
4908/* Function 46 */
4909DWORD
4910WINAPI
4913 LPWSTR pDeviceID,
4914 DWORD ulType,
4915 DWORD ulTag,
4916 DWORD *pPriority,
4917 DWORD ulFlags)
4918{
4921}
4922
4923
4924/* Function 47 */
4925DWORD
4926WINAPI
4929 LPWSTR pDeviceID,
4930 DWORD ulLogConfTag,
4931 DWORD ulLogConfType,
4932 RESOURCEID ResourceID,
4933 DWORD *pulResourceTag,
4934 BYTE *ResourceData,
4935 PNP_RPC_BUFFER_SIZE ResourceLen,
4936 DWORD ulFlags)
4937{
4940}
4941
4942
4943/* Function 48 */
4944DWORD
4945WINAPI
4948 LPWSTR pDeviceID,
4949 DWORD ulLogConfTag,
4950 DWORD ulLogConfType,
4951 RESOURCEID ResourceID,
4952 DWORD ulResourceTag,
4953 DWORD *pulPreviousResType,
4954 DWORD *pulPreviousResTag,
4955 DWORD ulFlags)
4956{
4959}
4960
4961
4962/* Function 49 */
4963DWORD
4964WINAPI
4967 LPWSTR pDeviceID,
4968 DWORD ulLogConfTag,
4969 DWORD ulLogConfType,
4970 RESOURCEID ResourceID,
4971 DWORD ulResourceTag,
4972 DWORD *pulNextResType,
4973 DWORD *pulNextResTag,
4974 DWORD ulFlags)
4975{
4976 HKEY hConfigKey = NULL;
4977 DWORD RegDataType = 0;
4978 ULONG ulDataSize = 0;
4979 LPBYTE lpData = NULL;
4981
4982 DPRINT1("PNP_GetNextResDes(%p %S 0x%lx %lu %lu %ul %p %p 0x%08lx)\n",
4983 hBinding, pDeviceID, ulLogConfTag, ulLogConfType, ResourceID,
4984 ulResourceTag, pulNextResType, pulNextResTag, ulFlags);
4985
4986 if (pulNextResType == NULL)
4987 return CR_INVALID_POINTER;
4988
4989 *pulNextResType = 0;
4990
4991 if (ulFlags != 0)
4992 return CR_INVALID_FLAG;
4993
4994 if (!IsValidDeviceInstanceID(pDeviceID))
4995 return CR_INVALID_DEVINST;
4996
4997 ret = OpenConfigurationKey(pDeviceID,
4998 ulLogConfType,
4999 &hConfigKey);
5000 if (ret != CR_SUCCESS)
5001 {
5002 DPRINT1("OpenConfigurationKey() failed (Error %lu)\n", ret);
5004 goto done;
5005 }
5006
5007 ret = GetConfigurationData(hConfigKey,
5008 ulLogConfType,
5009 &RegDataType,
5010 &ulDataSize,
5011 &lpData,
5012 0,
5013 NULL);
5014 if (ret != CR_SUCCESS)
5015 {
5016 DPRINT1("GetConfigurationData() failed (Error %lu)\n", ret);
5018 goto done;
5019 }
5020
5021 DPRINT1("Data size %lu\n", ulDataSize);
5022
5023 if (ulDataSize == 0 || lpData == NULL)
5024 {
5025 DPRINT1("No config data available!\n");
5027 goto done;
5028 }
5029
5030 /* Get the next resource descriptor */
5031 if (RegDataType == REG_RESOURCE_LIST)
5032 {
5033 DPRINT1("FIXME: REG_RESOURCE_LIST\n");
5034 /* FIXME */
5036 goto done;
5037 }
5038 else if (RegDataType == REG_RESOURCE_REQUIREMENTS_LIST)
5039 {
5040 DPRINT1("FIXME: REG_RESOURCE_REQUIREMENTS_LIST\n");
5041 /* FIXME */
5043 goto done;
5044 }
5045
5046done:
5047 if (lpData != NULL)
5048 HeapFree(GetProcessHeap(), 0, lpData);
5049
5050 if (hConfigKey != NULL)
5051 RegCloseKey(hConfigKey);
5052
5053 DPRINT1("PNP_GetNextResDes() returns %lu\n", ret);
5054
5055 return ret;
5056}
5057
5058
5059/* Function 50 */
5060DWORD
5061WINAPI
5064 LPWSTR pDeviceID,
5065 DWORD ulLogConfTag,
5066 DWORD ulLogConfType,
5067 RESOURCEID ResourceID,
5068 DWORD ulResourceTag,
5069 BYTE *Buffer,
5070 PNP_RPC_BUFFER_SIZE BufferLen,
5071 DWORD ulFlags)
5072{
5075}
5076
5077
5078/* Function 51 */
5079DWORD
5080WINAPI
5083 LPWSTR pDeviceID,
5084 DWORD ulLogConfTag,
5085 DWORD ulLogConfType,
5086 RESOURCEID ResourceID,
5087 DWORD ulResourceTag,
5088 DWORD *pulSize,
5089 DWORD ulFlags)
5090{
5093}
5094
5095
5096/* Function 52 */
5097DWORD
5098WINAPI
5101 LPWSTR pDeviceID,
5102 DWORD ulLogConfTag,
5103 DWORD ulLogConfType,
5104 RESOURCEID CurrentResourceID,
5105 RESOURCEID NewResourceID,
5106 DWORD ulResourceTag,
5107 BYTE *ResourceData,
5108 PNP_RPC_BUFFER_SIZE ResourceLen,
5109 DWORD ulFlags)
5110{
5113}
5114
5115
5116/* Function 53 */
5117DWORD
5118WINAPI
5121 LPWSTR pDeviceID,
5122 RESOURCEID ResourceID,
5123 BYTE *ResourceData,
5124 PNP_RPC_BUFFER_SIZE ResourceLen,
5125 BOOL *pbConflictDetected,
5126 DWORD ulFlags)
5127{
5128 DPRINT("PNP_DetectResourceConflict()\n");
5129
5130 if (pbConflictDetected != NULL)
5131 *pbConflictDetected = FALSE;
5132
5134}
5135
5136
5137/* Function 54 */
5138DWORD
5139WINAPI
5142 LPWSTR pDeviceID,
5143 RESOURCEID ResourceID,
5144 BYTE *ResourceData,
5145 PNP_RPC_BUFFER_SIZE ResourceLen,
5146 BYTE *Buffer,
5147 PNP_RPC_BUFFER_SIZE BufferLen,
5148 DWORD ulFlags)
5149{
5152}
5153
5154
5155/* Function 55 */
5156DWORD
5157WINAPI
5160 DWORD ulHardwareProfile,
5161 DWORD ulFlags)
5162{
5164}
5165
5166
5167/* Function 56 */
5168DWORD
5169WINAPI
5172 BYTE *pData,
5173 DWORD DataLen,
5174 LPWSTR pDeviceID,
5175 RESOURCEID ResourceID,
5176 DWORD ulFlags)
5177{
5179}
5180
5181
5182/* Function 57 */
5183DWORD
5184WINAPI
5187 DWORD *pulSize,
5188 LPWSTR pDeviceID,
5189 RESOURCEID ResourceID,
5190 DWORD ulFlags)
5191{
5192 if (pulSize != NULL)
5193 *pulSize = 0;
5194
5196}
5197
5198
5199/* Function 58 */
5201WINAPI
5204 DWORD ulFlags)
5205{
5207}
5208
5209
5210/* Function 59 */
5211DWORD
5212WINAPI
5215 DWORD_PTR hRecipient,
5216 LPWSTR pszName,
5217 BYTE *pNotificationFilter,
5218 DWORD ulNotificationFilterSize,
5219 DWORD ulFlags,
5220 PNP_NOTIFY_HANDLE *pNotifyHandle,
5221 DWORD ulProcessId,
5222 DWORD *pulUnknown9)
5223{
5224 PDEV_BROADCAST_DEVICEINTERFACE_W pBroadcastDeviceInterface;
5225 PDEV_BROADCAST_HANDLE pBroadcastDeviceHandle;
5226 PNOTIFY_ENTRY pNotifyData = NULL;
5228
5229 DPRINT1("PNP_RegisterNotification(%p %p '%S' %p %lu 0x%lx %p %lx %p)\n",
5230 hBinding, hRecipient, pszName, pNotificationFilter,
5231 ulNotificationFilterSize, ulFlags, pNotifyHandle, ulProcessId, pulUnknown9);
5232
5233 if (pNotifyHandle == NULL)
5234 return CR_INVALID_POINTER;
5235
5236 *pNotifyHandle = NULL;
5237
5238 if (pNotificationFilter == NULL ||
5239 pulUnknown9 == NULL)
5240 return CR_INVALID_POINTER;
5241
5242 if (ulFlags & ~0x7)
5243 return CR_INVALID_FLAG;
5244
5245 if ((ulNotificationFilterSize < sizeof(DEV_BROADCAST_HDR)) ||
5246 (((PDEV_BROADCAST_HDR)pNotificationFilter)->dbch_size < sizeof(DEV_BROADCAST_HDR)))
5247 return CR_INVALID_DATA;
5248
5249 if (((PDEV_BROADCAST_HDR)pNotificationFilter)->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE)
5250 {
5251 DPRINT1("DBT_DEVTYP_DEVICEINTERFACE\n");
5252 pBroadcastDeviceInterface = (PDEV_BROADCAST_DEVICEINTERFACE_W)pNotificationFilter;
5253
5254 if ((ulNotificationFilterSize < sizeof(DEV_BROADCAST_DEVICEINTERFACE_W)) ||
5255 (pBroadcastDeviceInterface->dbcc_size < sizeof(DEV_BROADCAST_DEVICEINTERFACE_W)))
5256 return CR_INVALID_DATA;
5257
5259 if (pNotifyData == NULL)
5260 {
5262 goto done;
5263 }
5264
5265 pNotifyData->dwType = CLASS_NOTIFICATION;
5266
5267 if (pszName != NULL)
5268 {
5269 pNotifyData->pszName = RtlAllocateHeap(GetProcessHeap(),
5271 (wcslen(pszName) + 1) * sizeof(WCHAR));
5272 if (pNotifyData->pszName == NULL)
5273 {
5275 goto done;
5276 }
5277
5278 wcscpy(pNotifyData->pszName, pszName);
5279 }
5280
5281 if ((ulFlags & DEVICE_NOTIFY_SERVICE_HANDLE) == DEVICE_NOTIFY_WINDOW_HANDLE)
5282 {
5283 pNotifyData->hRecipient = hRecipient;
5284 }
5285 else
5286 {
5287 DPRINT("Validate service: %S\n", pszName);
5289 pszName,
5290 (SERVICE_STATUS_HANDLE *)&pNotifyData->hRecipient) != ERROR_SUCCESS)
5291 {
5292 DPRINT1("I_ScValidatePnpService failed!\n");
5294 goto done;
5295 }
5296
5297 DPRINT("Service status handle: %p\n", pNotifyData->hRecipient);
5298 }
5299
5300 pNotifyData->ulFlags = ulFlags;
5301
5302 if ((ulFlags & DEVICE_NOTIFY_ALL_INTERFACE_CLASSES) == 0)
5303 {
5304 CopyMemory(&pNotifyData->ClassGuid,
5305 &pBroadcastDeviceInterface->dbcc_classguid,
5306 sizeof(GUID));
5307 }
5308
5309 /* Add the entry to the notification list */
5313
5314 DPRINT("pNotifyData: %p\n", pNotifyData);
5315 *pNotifyHandle = (PNP_NOTIFY_HANDLE)pNotifyData;
5316 }
5317 else if (((PDEV_BROADCAST_HDR)pNotificationFilter)->dbch_devicetype == DBT_DEVTYP_HANDLE)
5318 {
5319 DPRINT1("DBT_DEVTYP_HANDLE\n");
5320 pBroadcastDeviceHandle = (PDEV_BROADCAST_HANDLE)pNotificationFilter;
5321
5322 if ((ulNotificationFilterSize < sizeof(DEV_BROADCAST_HANDLE)) ||
5323 (pBroadcastDeviceHandle->dbch_size < sizeof(DEV_BROADCAST_HANDLE)))
5324 {
5326 goto done;
5327 }
5328
5329 if (ulFlags & DEVICE_NOTIFY_ALL_INTERFACE_CLASSES)
5330 {
5332 goto done;
5333 }
5334
5335 /* FIXME */
5336 }
5337 else
5338 {
5339 DPRINT1("Invalid device type %lu\n", ((PDEV_BROADCAST_HDR)pNotificationFilter)->dbch_devicetype);
5341 }
5342
5343done:
5344 if (ret != CR_SUCCESS)
5345 {
5346 if (pNotifyData)
5347 {
5348 if (pNotifyData->pszName)
5349 RtlFreeHeap(GetProcessHeap(), 0, pNotifyData->pszName);
5350
5351 RtlFreeHeap(GetProcessHeap(), 0, pNotifyData);
5352 }
5353 }
5354
5355 return ret;
5356}
5357
5358
5359/* Function 60 */
5360DWORD
5361WINAPI
5364 PNP_NOTIFY_HANDLE *pNotifyHandle)
5365{
5367
5368 DPRINT1("PNP_UnregisterNotification(%p %p)\n",
5369 hBinding, pNotifyHandle);
5370
5371 pEntry = (PNOTIFY_ENTRY)*pNotifyHandle;
5372 if (pEntry == NULL)
5373 return CR_INVALID_DATA;
5374
5376 RemoveEntryList(&pEntry->ListEntry);
5378
5379 if (pEntry->pszName)
5380 RtlFreeHeap(RtlGetProcessHeap(), 0, pEntry->pszName);
5381 RtlFreeHeap(RtlGetProcessHeap(), 0, pEntry);
5382 *pNotifyHandle = NULL;
5383
5384 return CR_SUCCESS;
5385}
5386
5387
5388/* Function 61 */
5389DWORD
5390WINAPI
5393 LPWSTR pDeviceID,
5394 LPWSTR CustomPropName,
5395 DWORD *pulRegDataType,
5396 BYTE *Buffer,
5397 PNP_RPC_STRING_LEN *pulTransferLen,
5398 PNP_RPC_STRING_LEN *pulLength,
5399 DWORD ulFlags)
5400{
5401 HKEY hDeviceKey = NULL;
5402 HKEY hParamKey = NULL;
5403 LONG lError;
5405
5407
5408 DPRINT("PNP_GetCustomDevProp() called\n");
5409
5410 if (pulTransferLen == NULL || pulLength == NULL)
5411 {
5413 goto done;
5414 }
5415
5416 if (ulFlags & ~CM_CUSTOMDEVPROP_BITS)
5417 {
5419 goto done;
5420 }
5421
5422 if (!IsValidDeviceInstanceID(pDeviceID))
5423 return CR_INVALID_DEVINST;
5424
5425 if (*pulLength < *pulTransferLen)
5426 *pulLength = *pulTransferLen;
5427
5428 *pulTransferLen = 0;
5429
5430 lError = RegOpenKeyExW(hEnumKey,
5431 pDeviceID,
5432 0,
5433 KEY_READ,
5434 &hDeviceKey);
5435 if (lError != ERROR_SUCCESS)
5436 {
5438 goto done;
5439 }
5440
5441 lError = RegOpenKeyExW(hDeviceKey,
5442 L"Device Parameters",
5443 0,
5444 KEY_READ,
5445 &hParamKey);
5446 if (lError != ERROR_SUCCESS)
5447 {
5449 goto done;
5450 }
5451
5452 lError = RegQueryValueExW(hParamKey,
5453 CustomPropName,
5454 NULL,
5455 pulRegDataType,
5456 Buffer,
5457 pulLength);
5458 if (lError != ERROR_SUCCESS)
5459 {
5460 if (lError == ERROR_MORE_DATA)
5461 {
5463 }
5464 else
5465 {
5466 *pulLength = 0;
5468 }
5469 }
5470
5471done:
5472 if (ret == CR_SUCCESS)
5473 *pulTransferLen = *pulLength;
5474
5475 if (hParamKey != NULL)
5476 RegCloseKey(hParamKey);
5477
5478 if (hDeviceKey != NULL)
5479 RegCloseKey(hDeviceKey);
5480
5481 DPRINT("PNP_GetCustomDevProp() done (returns %lx)\n", ret);
5482
5483 return ret;
5484}
5485
5486
5487/* Function 62 */
5488DWORD
5489WINAPI
5492 WORD *pwVersion)
5493{
5495
5496 *pwVersion = WINVER;
5497 return CR_SUCCESS;
5498}
5499
5500
5501/* Function 63 */
5502DWORD
5503WINAPI
5506 BYTE *Buffer,
5507 PNP_RPC_BUFFER_SIZE *pulTransferLen,
5508 PNP_RPC_BUFFER_SIZE *pulLength,
5509 DWORD ulFlags)
5510{
5513}
5514
5515
5516/* Function 64 */
5517DWORD
5518WINAPI
5521 DWORD *pulSSDIFlags,
5522 DWORD ulFlags)
5523{
5525
5526 DPRINT1("PNP_GetServerSideDeviceInstallFlags(%p %p %lu)\n",
5527 hBinding, pulSSDIFlags, ulFlags);
5528
5529 if (pulSSDIFlags == NULL)
5530 return CR_INVALID_POINTER;
5531
5532 if (ulFlags != 0)
5533 return CR_INVALID_FLAG;
5534
5535 /* FIXME */
5536 *pulSSDIFlags = 0;
5537
5538 return CR_SUCCESS;
5539}
5540
5541
5542/* Function 65 */
5543DWORD
5544WINAPI
5549 LPWSTR PropertyCultureName,
5550 PNP_PROP_COUNT *PropertyCount,
5551 PNP_PROP_COUNT *TransferLen,
5552 DEVPROPKEY *PropertyKeys,
5553 DWORD Flags)
5554{
5557}
5558
5559
5560/* Function 66 */
5561DWORD
5562WINAPI
5567 LPWSTR PropertyCultureName,
5568 const DEVPROPKEY *PropertyKey,
5570 PNP_PROP_SIZE *PropertySize,
5571 PNP_PROP_SIZE *TransferLen,
5573 DWORD Flags)
5574{
5577}
5578
5579
5580/* Function 67 */
5581DWORD
5582WINAPI
5587 LPWSTR PropertyCultureName,
5588 const DEVPROPKEY *PropertyKey,
5590 PNP_PROP_SIZE PropertySize,
5592 DWORD Flags)
5593{
5596}
5597
5598
5599/* Function 68 */
5600DWORD
5601WINAPI
5604{
5607}
5608
5609
5610/* Function 69 */
5611DWORD
5612WINAPI
5615{
5618}
5619
5620
5621/* Function 70 */
5622DWORD
5623WINAPI
5626{
5629}
5630
5631
5632/* Function 71 */
5633DWORD
5634WINAPI
5637{
5640}
5641
5642
5643/* Function 72 */
5644DWORD
5645WINAPI
5648{
5651}
5652
5653
5654/* Function 73 */
5655DWORD
5656WINAPI
5659 LPWSTR pszFilter,
5660 DWORD ulFlags)
5661{
5664}
5665
5666
5667/* Function 74 */
5668DWORD
5669WINAPI
5672{
5675}
static SERVICE_STATUS_HANDLE(WINAPI *pRegisterServiceCtrlHandlerExA)(LPCSTR
unsigned char BOOLEAN
UINT32 void void ** ReturnValue
Definition: acevents.h:216
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
HANDLE hInstallEvent
Definition: install.c:40
HANDLE hUserToken
Definition: install.c:39
#define LOGCONF_NAME_BUFFER_SIZE
Definition: precomp.h:38
@ CLASS_NOTIFICATION
Definition: precomp.h:48
struct NOTIFY_ENTRY * PNOTIFY_ENTRY
HKEY hEnumKey
Definition: umpnpmgr.c:44
BOOL g_ShuttingDown
Definition: umpnpmgr.c:47
HKEY hClassKey
Definition: umpnpmgr.c:45
DWORD WINAPI PNP_RegisterServiceNotification(handle_t hBinding)
Definition: rpcserver.c:5646
DWORD WINAPI PNP_GetVersion(handle_t hBinding, WORD *pVersion)
Definition: rpcserver.c:722
DWORD WINAPI PNP_GetInterfaceDeviceList(handle_t hBinding, GUID *InterfaceGuid, LPWSTR pszDeviceID, BYTE *Buffer, PNP_RPC_BUFFER_SIZE *pulLength, DWORD ulFlags)
Definition: rpcserver.c:2706
DWORD WINAPI PNP_SetHwProf(handle_t hBinding, DWORD ulHardwareProfile, DWORD ulFlags)
Definition: rpcserver.c:5158
DWORD WINAPI PNP_UnregisterNotification(handle_t hBinding, PNP_NOTIFY_HANDLE *pNotifyHandle)
Definition: rpcserver.c:5362
static CONFIGRET GetDeviceInstanceListSize(_In_ LPCWSTR pszDevice, _Out_ PULONG pulLength)
Definition: rpcserver.c:1637
DWORD WINAPI PNP_InstallDevInst(handle_t hBinding)
Definition: rpcserver.c:5602
DWORD WINAPI PNP_DriverStoreDeleteDriverPackage(handle_t hBinding)
Definition: rpcserver.c:5635
static CONFIGRET GetServiceInstanceListSize(_In_ PWSTR pszService, _Out_ PDWORD pulLength)
Definition: rpcserver.c:1538
DWORD WINAPI PNP_QueryResConfList(handle_t hBinding, LPWSTR pDeviceID, RESOURCEID ResourceID, BYTE *ResourceData, PNP_RPC_BUFFER_SIZE ResourceLen, BYTE *Buffer, PNP_RPC_BUFFER_SIZE BufferLen, DWORD ulFlags)
Definition: rpcserver.c:5140
DWORD WINAPI PNP_Connect(handle_t hBinding)
Definition: rpcserver.c:711
DWORD WINAPI PNP_GetRelatedDeviceInstance(handle_t hBinding, DWORD ulRelationship, LPWSTR pDeviceID, LPWSTR pRelatedDeviceId, PNP_RPC_STRING_LEN *pulLength, DWORD ulFlags)
Definition: rpcserver.c:915
DWORD WINAPI PNP_EnumerateSubKeys(handle_t hBinding, DWORD ulBranch, DWORD ulIndex, LPWSTR Buffer, PNP_RPC_STRING_LEN ulLength, PNP_RPC_STRING_LEN *pulRequiredLen, DWORD ulFlags)
Definition: rpcserver.c:993
DWORD WINAPI PNP_SetActiveService(handle_t hBinding, LPWSTR pszFilter, DWORD ulFlags)
Definition: rpcserver.c:5657
LUID LoadDriverPrivilege
Definition: rpcserver.c:40
DWORD WINAPI PNP_UnregisterDeviceClassAssociation(handle_t hBinding, LPWSTR pszInterfaceDevice, DWORD ulFlags)
Definition: rpcserver.c:2861
DWORD WINAPI PNP_DetectResourceConflict(handle_t hBinding, LPWSTR pDeviceID, RESOURCEID ResourceID, BYTE *ResourceData, PNP_RPC_BUFFER_SIZE ResourceLen, BOOL *pbConflictDetected, DWORD ulFlags)
Definition: rpcserver.c:5119
static CONFIGRET WINAPI NtStatusToCrError(NTSTATUS Status)
Definition: rpcserver.c:127
DWORD WINAPI PNP_GetDeviceListSize(handle_t hBinding, LPWSTR pszFilter, PNP_RPC_BUFFER_SIZE *pulLength, DWORD ulFlags)
Definition: rpcserver.c:1785
DWORD WINAPI PNP_InitDetection(handle_t hBinding)
Definition: rpcserver.c:765
DWORD WINAPI PNP_AddEmptyLogConf(handle_t hBinding, LPWSTR pDeviceID, DWORD ulPriority, DWORD *pulLogConfTag, DWORD ulFlags)
Definition: rpcserver.c:4333
DWORD WINAPI PNP_ApplyPowerSettings(handle_t hBinding)
Definition: rpcserver.c:5613
DWORD WINAPI PNP_GetClassCount(handle_t hBinding, DWORD *pulClassCount, DWORD ulFlags)
Definition: rpcserver.c:2517
DWORD WINAPI PNP_GetClassRegProp(handle_t hBinding, LPWSTR pszClassGuid, DWORD ulProperty, DWORD *pulRegDataType, BYTE *Buffer, PNP_RPC_STRING_LEN *pulTransferLen, PNP_RPC_STRING_LEN *pulLength, DWORD ulFlags)
Definition: rpcserver.c:2899
DWORD WINAPI PNP_GetServerSideDeviceInstallFlags(handle_t hBinding, DWORD *pulSSDIFlags, DWORD ulFlags)
Definition: rpcserver.c:5519
DWORD WINAPI PNP_FreeLogConf(handle_t hBinding, LPWSTR pDeviceID, DWORD ulLogConfType, DWORD ulLogConfTag, DWORD ulFlags)
Definition: rpcserver.c:4550
LIST_ENTRY NotificationListHead
Definition: rpcserver.c:42
DWORD WINAPI PNP_GetDeviceRegProp(handle_t hBinding, LPWSTR pDeviceID, DWORD ulProperty, DWORD *pulRegDataType, BYTE *Buffer, PNP_PROP_SIZE *pulTransferLen, PNP_PROP_SIZE *pulLength, DWORD ulFlags)
Definition: rpcserver.c:1903
DWORD WINAPI PNP_GetBlockedDriverInfo(handle_t hBinding, BYTE *Buffer, PNP_RPC_BUFFER_SIZE *pulTransferLen, PNP_RPC_BUFFER_SIZE *pulLength, DWORD ulFlags)
Definition: rpcserver.c:5504
DWORD WINAPI PNP_GetInterfaceDeviceListSize(handle_t hBinding, PNP_RPC_BUFFER_SIZE *pulLen, GUID *InterfaceGuid, LPWSTR pszDeviceID, DWORD ulFlags)
Definition: rpcserver.c:2754
static WCHAR szRootDeviceInstanceID[]
Definition: rpcserver.c:39
DWORD WINAPI PNP_UninstallDevInst(handle_t hBinding, LPWSTR pDeviceID, DWORD ulFlags)
Definition: rpcserver.c:3744
static VOID AppendDeviceId(LPWSTR lpDeviceIdList, LPDWORD lpDeviceIdListSize, LPWSTR lpDeviceId)
Definition: rpcserver.c:3776
DWORD WINAPI PNP_GetDeviceStatus(handle_t hBinding, LPWSTR pDeviceID, DWORD *pulStatus, DWORD *pulProblem, DWORD ulFlags)
Definition: rpcserver.c:3583
DWORD WINAPI PNP_GetClassInstance(handle_t hBinding, LPWSTR pDeviceId, LPWSTR pszClassInstance, PNP_RPC_STRING_LEN ulLength)
Definition: rpcserver.c:2322
static BOOL CheckForDeviceId(LPWSTR lpDeviceIdList, LPWSTR lpDeviceId)
Definition: rpcserver.c:3755
DWORD WINAPI PNP_DeviceInstanceAction(handle_t hBinding, DWORD ulMajorAction, DWORD ulMinorAction, LPWSTR pszDeviceInstance1, LPWSTR pszDeviceInstance2)
Definition: rpcserver.c:3538
static CONFIGRET GetAllInstanceListSize(_Out_ PULONG pulLength)
Definition: rpcserver.c:1750
VOID __RPC_USER PNP_NOTIFY_HANDLE_rundown(PNP_NOTIFY_HANDLE pHandle)
Definition: rpcserver.c:688
DWORD WINAPI PNP_RegisterDriver(handle_t hBinding, LPWSTR pszDeviceID, DWORD ulFlags)
Definition: rpcserver.c:3906
static CONFIGRET GenerateDeviceID(_Inout_ LPWSTR pszDeviceID, _In_ PNP_RPC_STRING_LEN ulLength)
Definition: rpcserver.c:3248
DWORD WINAPI PNP_GetDepth(handle_t hBinding, LPWSTR pszDeviceID, DWORD *pulDepth, DWORD ulFlags)
Definition: rpcserver.c:1860
DWORD WINAPI PNP_HwProfFlags(handle_t hBinding, DWORD ulAction, LPWSTR pDeviceID, DWORD ulConfig, DWORD *pulValue, PPNP_VETO_TYPE pVetoType, LPWSTR pszVetoName, DWORD ulNameLength, DWORD ulFlags)
Definition: rpcserver.c:4114
static CONFIGRET SetDeviceStatus(_In_ LPWSTR pszDeviceID, _In_ DWORD ulStatus, _In_ DWORD ulProblem)
Definition: rpcserver.c:267
DWORD WINAPI PNP_DisableDevInst(handle_t hBinding, LPWSTR pDeviceID, PPNP_VETO_TYPE pVetoType, LPWSTR pszVetoName, DWORD ulNameLength, DWORD ulFlags)
Definition: rpcserver.c:3714
static CONFIGRET OpenConfigurationKey(_In_ LPCWSTR pszDeviceID, _In_ DWORD ulLogConfType, _Out_ PHKEY phKey)
Definition: rpcserver.c:432
DWORD WINAPI PNP_GetClassName(handle_t hBinding, LPWSTR pszClassGuid, LPWSTR Buffer, PNP_RPC_STRING_LEN *pulLength, DWORD ulFlags)
Definition: rpcserver.c:2562
RTL_RESOURCE NotificationListLock
Definition: rpcserver.c:43
DWORD WINAPI PNP_RequestDeviceEject(handle_t hBinding, LPWSTR pszDeviceID, PPNP_VETO_TYPE pVetoType, LPWSTR pszVetoName, DWORD ulNameLength, DWORD ulFlags)
Definition: rpcserver.c:3978
DWORD WINAPI PNP_GetObjectProp(handle_t hBinding, LPWSTR ObjectName, DWORD ObjectType, LPWSTR PropertyCultureName, const DEVPROPKEY *PropertyKey, DEVPROPTYPE *PropertyType, PNP_PROP_SIZE *PropertySize, PNP_PROP_SIZE *TransferLen, BYTE *PropertyBuffer, DWORD Flags)
Definition: rpcserver.c:5563
DWORD WINAPI PNP_GetLogConfPriority(handle_t hBinding, LPWSTR pDeviceID, DWORD ulType, DWORD ulTag, DWORD *pPriority, DWORD ulFlags)
Definition: rpcserver.c:4911
static CONFIGRET SetupDeviceInstance(_In_ LPWSTR pszDeviceInstance, _In_ DWORD ulMinorAction)
Definition: rpcserver.c:3400
DWORD WINAPI PNP_GetObjectPropKeys(handle_t hBinding, LPWSTR ObjectName, DWORD ObjectType, LPWSTR PropertyCultureName, PNP_PROP_COUNT *PropertyCount, PNP_PROP_COUNT *TransferLen, DEVPROPKEY *PropertyKeys, DWORD Flags)
Definition: rpcserver.c:5545
DWORD WINAPI PNP_GetInterfaceDeviceAlias(handle_t hBinding, LPWSTR pszInterfaceDevice, GUID *AliasInterfaceGuid, LPWSTR pszAliasInterfaceDevice, PNP_RPC_STRING_LEN *pulLength, PNP_RPC_STRING_LEN *pulTransferLen, DWORD ulFlags)
Definition: rpcserver.c:2652
static PCM_FULL_RESOURCE_DESCRIPTOR NextResourceDescriptor(_In_ PCM_FULL_RESOURCE_DESCRIPTOR pDescriptor)
Definition: rpcserver.c:583
static CONFIGRET GetDeviceStatus(_In_ LPWSTR pszDeviceID, _Out_ DWORD *pulStatus, _Out_ DWORD *pulProblem)
Definition: rpcserver.c:232
DWORD WINAPI RpcServerThread(LPVOID lpParameter)
Definition: rpcserver.c:48
static CONFIGRET GetDeviceInstanceList(_In_ PWSTR pszDevice, _Inout_ PWSTR pszBuffer, _Inout_ PDWORD pulLength)
Definition: rpcserver.c:1223
CONFIGRET GetEnumeratorInstanceList(_In_ PWSTR pszEnumerator, _Inout_ PWSTR pszBuffer, _Inout_ PDWORD pulLength)
Definition: rpcserver.c:1294
static CONFIGRET ClearDeviceStatus(_In_ LPWSTR pszDeviceID, _In_ DWORD ulStatus, _In_ DWORD ulProblem)
Definition: rpcserver.c:202
DWORD WINAPI PNP_RequestEjectPC(handle_t hBinding)
Definition: rpcserver.c:4082
DWORD WINAPI PNP_DeleteServiceDevices(handle_t hBinding)
Definition: rpcserver.c:5670
DWORD WINAPI PNP_CreateDevInst(handle_t hBinding, LPWSTR pszDeviceID, LPWSTR pszParentDeviceID, PNP_RPC_STRING_LEN ulLength, DWORD ulFlags)
Definition: rpcserver.c:3298
static CONFIGRET GetRelationsInstanceList(_In_ PWSTR pszDevice, _In_ DWORD ulFlags, _Inout_ PWSTR pszBuffer, _Inout_ PDWORD pulLength)
Definition: rpcserver.c:1053
DWORD WINAPI PNP_SetDeviceRegProp(handle_t hBinding, LPWSTR pDeviceId, DWORD ulProperty, DWORD ulDataType, BYTE *Buffer, PNP_PROP_SIZE ulLength, DWORD ulFlags)
Definition: rpcserver.c:2180
static CONFIGRET GetAllInstanceList(_Inout_ PWSTR pszBuffer, _Inout_ PDWORD pulLength)
Definition: rpcserver.c:1365
DWORD WINAPI PNP_AddID(handle_t hBinding, LPWSTR pszDeviceID, LPWSTR pszID, DWORD ulFlags)
Definition: rpcserver.c:3799
DWORD WINAPI PNP_QueryRemove(handle_t hBinding, LPWSTR pszDeviceID, PPNP_VETO_TYPE pVetoType, LPWSTR pszVetoName, DWORD ulNameLength, DWORD ulFlags)
Definition: rpcserver.c:3929
DWORD WINAPI PNP_GetFirstLogConf(handle_t hBinding, LPWSTR pDeviceID, DWORD ulLogConfType, DWORD *pulLogConfTag, DWORD ulFlags)
Definition: rpcserver.c:4691
static BOOL IsPresentDeviceInstanceID(_In_ LPWSTR pszDeviceInstanceID)
Definition: rpcserver.c:421
DWORD WINAPI PNP_SetClassRegProp(handle_t hBinding, LPWSTR pszClassGuid, DWORD ulProperty, DWORD ulDataType, BYTE *Buffer, PNP_PROP_SIZE ulLength, DWORD ulFlags)
Definition: rpcserver.c:3025
static VOID SplitDeviceInstanceID(IN LPWSTR pszDeviceInstanceID, OUT LPWSTR pszEnumerator, OUT LPWSTR pszDevice, OUT LPWSTR pszInstance)
Definition: rpcserver.c:156
DWORD WINAPI PNP_GetNextLogConf(handle_t hBinding, LPWSTR pDeviceID, DWORD ulLogConfType, DWORD ulCurrentTag, DWORD *pulNextTag, DWORD ulFlags)
Definition: rpcserver.c:4792
DWORD WINAPI PNP_GetGlobalState(handle_t hBinding, DWORD *pulState, DWORD ulFlags)
Definition: rpcserver.c:740
CONFIGRET WINAPI PNP_IsDockStationPresent(handle_t hBinding, BOOL *Present)
Definition: rpcserver.c:4026
DWORD WINAPI PNP_RegisterNotification(handle_t hBinding, DWORD_PTR hRecipient, LPWSTR pszName, BYTE *pNotificationFilter, DWORD ulNotificationFilterSize, DWORD ulFlags, PNP_NOTIFY_HANDLE *pNotifyHandle, DWORD ulProcessId, DWORD *pulUnknown9)
Definition: rpcserver.c:5213
DWORD WINAPI PNP_GetHwProfInfo(handle_t hBinding, DWORD ulIndex, HWPROFILEINFO *pHWProfileInfo, DWORD ulProfileInfoSize, DWORD ulFlags)
Definition: rpcserver.c:4198
DWORD WINAPI PNP_FreeResDes(handle_t hBinding, LPWSTR pDeviceID, DWORD ulLogConfTag, DWORD ulLogConfType, RESOURCEID ResourceID, DWORD ulResourceTag, DWORD *pulPreviousResType, DWORD *pulPreviousResTag, DWORD ulFlags)
Definition: rpcserver.c:4946
DWORD WINAPI PNP_AddResDes(handle_t hBinding, LPWSTR pDeviceID, DWORD ulLogConfTag, DWORD ulLogConfType, RESOURCEID ResourceID, DWORD *pulResourceTag, BYTE *ResourceData, PNP_RPC_BUFFER_SIZE ResourceLen, DWORD ulFlags)
Definition: rpcserver.c:4927
DWORD WINAPI PNP_SetDeviceProblem(handle_t hBinding, LPWSTR pDeviceID, DWORD ulProblem, DWORD ulFlags)
Definition: rpcserver.c:3661
CONFIGRET WINAPI PNP_RunDetection(handle_t hBinding, DWORD ulFlags)
Definition: rpcserver.c:5202
static CONFIGRET ReenumerateDeviceInstance(_In_ LPWSTR pszDeviceInstance, _In_ ULONG ulMinorAction)
Definition: rpcserver.c:3502
static CONFIGRET GetServiceInstanceList(_In_ PWSTR pszService, _Inout_ PWSTR pszBuffer, _Inout_ PDWORD pulLength)
Definition: rpcserver.c:1104
DWORD WINAPI PNP_CreateKey(handle_t hBinding, LPWSTR pszSubKey, DWORD samDesired, DWORD ulFlags)
Definition: rpcserver.c:2438
DWORD WINAPI PNP_GetResDesDataSize(handle_t hBinding, LPWSTR pDeviceID, DWORD ulLogConfTag, DWORD ulLogConfType, RESOURCEID ResourceID, DWORD ulResourceTag, DWORD *pulSize, DWORD ulFlags)
Definition: rpcserver.c:5081
DWORD WINAPI PNP_GetRootDeviceInstance(handle_t hBinding, LPWSTR pDeviceID, PNP_RPC_STRING_LEN ulLength)
Definition: rpcserver.c:878
DWORD WINAPI PNP_GetDeviceList(handle_t hBinding, LPWSTR pszFilter, LPWSTR Buffer, PNP_RPC_STRING_LEN *pulLength, DWORD ulFlags)
Definition: rpcserver.c:1414
DWORD WINAPI PNP_SetObjectProp(handle_t hBinding, LPWSTR ObjectName, DWORD ObjectType, LPWSTR PropertyCultureName, const DEVPROPKEY *PropertyKey, DEVPROPTYPE PropertyType, PNP_PROP_SIZE PropertySize, BYTE *PropertyBuffer, DWORD Flags)
Definition: rpcserver.c:5583
static BOOL IsCallerInteractive(_In_ handle_t hBinding)
Definition: rpcserver.c:638
static CONFIGRET GetRelationsInstanceListSize(_In_ PWSTR pszDevice, _In_ DWORD ulFlags, _Inout_ PDWORD pulLength)
Definition: rpcserver.c:1488
static CONFIGRET EnableDeviceInstance(_In_ LPWSTR pszDeviceInstance)
Definition: rpcserver.c:3483
DWORD WINAPI PNP_GetCustomDevProp(handle_t hBinding, LPWSTR pDeviceID, LPWSTR CustomPropName, DWORD *pulRegDataType, BYTE *Buffer, PNP_RPC_STRING_LEN *pulTransferLen, PNP_RPC_STRING_LEN *pulLength, DWORD ulFlags)
Definition: rpcserver.c:5391
DWORD WINAPI PNP_DeleteRegistryKey(handle_t hBinding, LPWSTR pszDeviceID, LPWSTR pszParentKey, LPWSTR pszChildKey, DWORD ulFlags)
Definition: rpcserver.c:2502
DWORD WINAPI PNP_Disconnect(handle_t hBinding)
Definition: rpcserver.c:700
DWORD WINAPI PNP_QueryArbitratorFreeData(handle_t hBinding, BYTE *pData, DWORD DataLen, LPWSTR pDeviceID, RESOURCEID ResourceID, DWORD ulFlags)
Definition: rpcserver.c:5170
static CONFIGRET DisableDeviceInstance(_In_ LPWSTR pszDeviceInstance, _Inout_opt_ PPNP_VETO_TYPE pVetoType, _Inout_opt_ LPWSTR pszVetoName, _In_ DWORD ulNameLength)
Definition: rpcserver.c:297
DWORD WINAPI PNP_ReportLogOn(handle_t hBinding, BOOL Admin, DWORD ProcessId)
Definition: rpcserver.c:780
static PIO_RESOURCE_LIST NextResourceRequirement(_In_ PIO_RESOURCE_LIST pResourceList)
Definition: rpcserver.c:618
static BOOL IsRootDeviceInstanceID(_In_ PWSTR pszDeviceInstanceID)
Definition: rpcserver.c:409
DWORD WINAPI PNP_GetNextResDes(handle_t hBinding, LPWSTR pDeviceID, DWORD ulLogConfTag, DWORD ulLogConfType, RESOURCEID ResourceID, DWORD ulResourceTag, DWORD *pulNextResType, DWORD *pulNextResTag, DWORD ulFlags)
Definition: rpcserver.c:4965
DWORD WINAPI PNP_GetResDesData(handle_t hBinding, LPWSTR pDeviceID, DWORD ulLogConfTag, DWORD ulLogConfType, RESOURCEID ResourceID, DWORD ulResourceTag, BYTE *Buffer, PNP_RPC_BUFFER_SIZE BufferLen, DWORD ulFlags)
Definition: rpcserver.c:5062
static CONFIGRET GetConfigurationData(_In_ HKEY hKey, _In_ ULONG ulLogConfType, _Out_ PULONG pulRegDataType, _Out_ PULONG pulDataSize, _Out_ LPBYTE *ppBuffer, _In_ ULONG ulValueNameBufferSize, _Out_opt_ LPWSTR pszValueNameBuffer)
Definition: rpcserver.c:495
DWORD WINAPI PNP_ValidateDeviceInstance(handle_t hBinding, LPWSTR pDeviceID, DWORD ulFlags)
Definition: rpcserver.c:835
DWORD WINAPI PNP_ModifyResDes(handle_t hBinding, LPWSTR pDeviceID, DWORD ulLogConfTag, DWORD ulLogConfType, RESOURCEID CurrentResourceID, RESOURCEID NewResourceID, DWORD ulResourceTag, BYTE *ResourceData, PNP_RPC_BUFFER_SIZE ResourceLen, DWORD ulFlags)
Definition: rpcserver.c:5099
DWORD WINAPI PNP_QueryArbitratorFreeSize(handle_t hBinding, DWORD *pulSize, LPWSTR pDeviceID, RESOURCEID ResourceID, DWORD ulFlags)
Definition: rpcserver.c:5185
static CONFIGRET GetEnumeratorInstanceListSize(_In_ LPCWSTR pszEnumerator, _Out_ PULONG pulLength)
Definition: rpcserver.c:1689
DWORD WINAPI PNP_DriverStoreAddDriverPackage(handle_t hBinding)
Definition: rpcserver.c:5624
DWORD WINAPI PNP_DeleteClassKey(handle_t hBinding, LPWSTR pszClassGuid, DWORD ulFlags)
Definition: rpcserver.c:2620
static BOOL IsValidDeviceInstanceID(_In_ PWSTR pszDeviceInstanceID)
Definition: rpcserver.c:343
DWORD WINAPI PNP_GetVersionInternal(handle_t hBinding, WORD *pwVersion)
Definition: rpcserver.c:5490
static CONFIGRET CreateDeviceInstance(_In_ LPWSTR pszDeviceID, _In_ BOOL bPhantomDevice)
Definition: rpcserver.c:3128
DWORD WINAPI PNP_RegisterDeviceClassAssociation(handle_t hBinding, LPWSTR pszDeviceID, GUID *InterfaceGuid, LPWSTR pszReference, LPWSTR pszSymLink, PNP_RPC_STRING_LEN *pulLength, PNP_RPC_STRING_LEN *pulTransferLen, DWORD ulFlags)
Definition: rpcserver.c:2801
static HANDLE hServicesKey
Definition: devinst.c:21
static SID_IDENTIFIER_AUTHORITY NtAuthority
Definition: security.c:40
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:616
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:634
#define RegCloseKey(hKey)
Definition: registry.h:49
@ PNP_VetoTypeUnknown
Definition: cfg.h:180
#define DN_REMOVABLE
Definition: cfg.h:132
#define DN_HAS_PROBLEM
Definition: cfg.h:128
#define DN_STARTED
Definition: cfg.h:121
#define DN_MANUAL
Definition: cfg.h:122
#define CM_PROB_FAILED_INSTALL
Definition: cfg.h:58
enum _PNP_VETO_TYPE * PPNP_VETO_TYPE
#define CM_DRP_BUSNUMBER
Definition: cfgmgr32.h:703
#define CM_REGISTER_DEVICE_DRIVER_BITS
Definition: cfgmgr32.h:798
#define CM_DRP_LOCATION_INFORMATION
Definition: cfgmgr32.h:689
#define CM_DRP_CONFIGFLAGS
Definition: cfgmgr32.h:686
#define CR_INVALID_PROPERTY
Definition: cfgmgr32.h:899
#define FILTERED_LOG_CONF
Definition: cfgmgr32.h:597
#define CM_SETUP_DOWNLOAD
Definition: cfgmgr32.h:821
#define CM_CUSTOMDEVPROP_BITS
Definition: cfgmgr32.h:836
#define CR_INVALID_DATA
Definition: cfgmgr32.h:877
#define CM_DRP_REMOVAL_POLICY
Definition: cfgmgr32.h:719
#define CM_DRP_ENUMERATOR_NAME
Definition: cfgmgr32.h:704
#define CM_ADD_ID_COMPATIBLE
Definition: cfgmgr32.h:615
#define BASIC_LOG_CONF
Definition: cfgmgr32.h:596
#define CM_DRP_REMOVAL_POLICY_HW_DEFAULT
Definition: cfgmgr32.h:720
#define CR_INVALID_DEVICE_ID
Definition: cfgmgr32.h:876
#define CM_DRP_BUSTYPEGUID
Definition: cfgmgr32.h:701
#define CR_NO_MORE_LOG_CONF
Definition: cfgmgr32.h:859
#define CR_OUT_OF_MEMORY
Definition: cfgmgr32.h:844
#define CR_INVALID_LOG_CONF
Definition: cfgmgr32.h:850
#define CM_GETIDLIST_FILTER_BITS
Definition: cfgmgr32.h:669
#define CM_DRP_LOWERFILTERS
Definition: cfgmgr32.h:697
#define CM_DRP_SECURITY
Definition: cfgmgr32.h:705
#define CM_SET_DEVNODE_PROBLEM_BITS
Definition: cfgmgr32.h:808
#define CM_CRP_DEVTYPE
Definition: cfgmgr32.h:710
#define CM_DRP_MFG
Definition: cfgmgr32.h:687
#define CM_DRP_EXCLUSIVE
Definition: cfgmgr32.h:711
#define CM_DRP_DRIVER
Definition: cfgmgr32.h:685
#define CR_NO_SUCH_DEVINST
Definition: cfgmgr32.h:858
#define CM_GETIDLIST_FILTER_REMOVALRELATIONS
Definition: cfgmgr32.h:658
#define CM_SETUP_BITS
Definition: cfgmgr32.h:828
#define CM_DRP_LOCATION_PATHS
Definition: cfgmgr32.h:725
#define CM_DRP_REMOVAL_POLICY_OVERRIDE
Definition: cfgmgr32.h:721
#define CM_DRP_CAPABILITIES
Definition: cfgmgr32.h:691
#define CM_DRP_UPPERFILTERS
Definition: cfgmgr32.h:693
#define CR_FAILURE
Definition: cfgmgr32.h:865
#define CM_SETUP_WRITE_LOG_CONFS
Definition: cfgmgr32.h:822
#define CM_DRP_CLASSGUID
Definition: cfgmgr32.h:684
#define CONFIGMG_VERSION
Definition: cfgmgr32.h:64
#define CM_DRP_COMPATIBLEIDS
Definition: cfgmgr32.h:678
ULONG RESOURCEID
Definition: cfgmgr32.h:96
#define CR_INVALID_DEVINST
Definition: cfgmgr32.h:848
#define CM_DRP_DEVICEDESC
Definition: cfgmgr32.h:676
#define LOG_CONF_BITS
Definition: cfgmgr32.h:603
#define CM_REENUMERATE_BITS
Definition: cfgmgr32.h:793
#define CM_DRP_CLASS
Definition: cfgmgr32.h:683
#define CM_GETIDLIST_FILTER_EJECTRELATIONS
Definition: cfgmgr32.h:657
#define CM_REENUMERATE_RETRY_INSTALLATION
Definition: cfgmgr32.h:790
#define CM_CRP_SECURITY
Definition: cfgmgr32.h:706
#define PRIORITY_BIT
Definition: cfgmgr32.h:607
#define CR_ACCESS_DENIED
Definition: cfgmgr32.h:897
#define BOOT_LOG_CONF
Definition: cfgmgr32.h:599
#define CM_DRP_LEGACYBUSTYPE
Definition: cfgmgr32.h:702
#define CM_DRP_PHYSICAL_DEVICE_OBJECT_NAME
Definition: cfgmgr32.h:690
#define CR_INVALID_FLAG
Definition: cfgmgr32.h:846
#define CM_SET_DEVNODE_PROBLEM_OVERRIDE
Definition: cfgmgr32.h:807
#define CM_DRP_DEVTYPE
Definition: cfgmgr32.h:709
#define CM_DELETE_CLASS_SUBKEYS
Definition: cfgmgr32.h:635
#define CM_GLOBAL_STATE_SERVICES_AVAILABLE
Definition: cfgmgr32.h:910
#define CM_GETIDLIST_FILTER_ENUMERATOR
Definition: cfgmgr32.h:655
#define CR_ALREADY_SUCH_DEVINST
Definition: cfgmgr32.h:862
#define CM_GLOBAL_STATE_CAN_DO_UI
Definition: cfgmgr32.h:908
#define CM_GETIDLIST_FILTER_BUSRELATIONS
Definition: cfgmgr32.h:660
#define CM_DRP_FRIENDLYNAME
Definition: cfgmgr32.h:688
#define CM_DRP_INSTALL_STATE
Definition: cfgmgr32.h:722
#define CM_DRP_UI_NUMBER
Definition: cfgmgr32.h:692
#define OVERRIDE_LOG_CONF
Definition: cfgmgr32.h:601
#define ALLOC_LOG_CONF
Definition: cfgmgr32.h:598
#define CM_DRP_CHARACTERISTICS
Definition: cfgmgr32.h:713
#define CR_NO_SUCH_DEVNODE
Definition: cfgmgr32.h:857
#define CM_CRP_EXCLUSIVE
Definition: cfgmgr32.h:712
#define CM_CREATE_DEVNODE_BITS
Definition: cfgmgr32.h:624
#define CM_DRP_BASE_CONTAINERID
Definition: cfgmgr32.h:728
#define CR_BUFFER_SMALL
Definition: cfgmgr32.h:872
#define CM_GETIDLIST_FILTER_POWERRELATIONS
Definition: cfgmgr32.h:659
#define FORCED_LOG_CONF
Definition: cfgmgr32.h:600
#define CR_CALL_NOT_IMPLEMENTED
Definition: cfgmgr32.h:898
#define CM_DEVCAP_REMOVABLE
Definition: cfgmgr32.h:737
#define CM_CREATE_DEVNODE_GENERATE_ID
Definition: cfgmgr32.h:622
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
#define CM_DRP_UI_NUMBER_DESC_FORMAT
Definition: cfgmgr32.h:716
#define CR_INVALID_POINTER
Definition: cfgmgr32.h:845
#define CM_GETIDLIST_FILTER_SERVICE
Definition: cfgmgr32.h:656
#define CR_SUCCESS
Definition: cfgmgr32.h:842
#define CM_DRP_ADDRESS
Definition: cfgmgr32.h:715
#define CR_NO_SUCH_VALUE
Definition: cfgmgr32.h:883
#define CM_CRP_CHARACTERISTICS
Definition: cfgmgr32.h:714
#define CM_CREATE_DEVNODE_PHANTOM
Definition: cfgmgr32.h:621
#define CM_GLOBAL_STATE_SHUTTING_DOWN
Definition: cfgmgr32.h:911
#define CM_REMOVE_BITS
Definition: cfgmgr32.h:780
#define CM_GETIDLIST_FILTER_NONE
Definition: cfgmgr32.h:654
#define CM_DRP_DEVICE_POWER_DATA
Definition: cfgmgr32.h:718
#define CM_DRP_HARDWAREID
Definition: cfgmgr32.h:677
#define CR_NO_SUCH_REGISTRY_KEY
Definition: cfgmgr32.h:892
#define CM_DISABLE_BITS
Definition: cfgmgr32.h:652
#define CM_DRP_SERVICE
Definition: cfgmgr32.h:680
#define CR_INVALID_DEVNODE
Definition: cfgmgr32.h:847
#define CR_REGISTRY_ERROR
Definition: cfgmgr32.h:875
#define CR_REMOVE_VETOED
Definition: cfgmgr32.h:869
Definition: bufpool.h:45
wcscat
wcscpy
handle_t hBinding
Definition: ctx_c.c:54
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42
#define DBT_DEVTYP_HANDLE
Definition: dbt.h:25
struct _DEV_BROADCAST_DEVICEINTERFACE_W DEV_BROADCAST_DEVICEINTERFACE_W
struct _DEV_BROADCAST_HANDLE DEV_BROADCAST_HANDLE
#define DBT_DEVTYP_DEVICEINTERFACE
Definition: dbt.h:24
struct _DEV_BROADCAST_HANDLE * PDEV_BROADCAST_HANDLE
struct _DEV_BROADCAST_DEVICEINTERFACE_W * PDEV_BROADCAST_DEVICEINTERFACE_W
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define ERROR_SUCCESS
Definition: deptool.c:10
#define MAX_DEVICE_ID_LEN
Definition: devaction.c:40
ULONG DEVPROPTYPE
Definition: devpropdef.h:24
#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
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1096
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2504
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1239
LONG WINAPI RegDeleteValueW(HKEY hKey, LPCWSTR lpValueName)
Definition: reg.c:2330
LONG WINAPI RegQueryInfoKeyW(HKEY hKey, LPWSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved, LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen, LPDWORD lpcMaxClassLen, LPDWORD lpcValues, LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen, LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime)
Definition: reg.c:3662
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
BOOL WINAPI CheckTokenMembership(IN HANDLE ExistingTokenHandle, IN PSID SidToCheck, OUT PBOOL IsMember)
Definition: token.c:21
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:294
BOOL WINAPI AllocateAndInitializeSid(PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority, BYTE nSubAuthorityCount, DWORD nSubAuthority0, DWORD nSubAuthority1, DWORD nSubAuthority2, DWORD nSubAuthority3, DWORD nSubAuthority4, DWORD nSubAuthority5, DWORD nSubAuthority6, DWORD nSubAuthority7, PSID *pSid)
Definition: security.c:674
BOOL WINAPI OpenThreadToken(HANDLE ThreadHandle, DWORD DesiredAccess, BOOL OpenAsSelf, HANDLE *TokenHandle)
Definition: security.c:336
PVOID WINAPI FreeSid(PSID pSid)
Definition: security.c:698
#define CloseHandle
Definition: compat.h:739
#define wcschr
Definition: compat.h:17
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapReAlloc
Definition: compat.h:734
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:105
#define MAX_PATH
Definition: compat.h:34
#define HeapFree(x, y, z)
Definition: compat.h:735
#define lstrcpyW
Definition: compat.h:749
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define lstrlenW
Definition: compat.h:750
static DWORD DWORD * dwLength
Definition: fusion.c:86
static void cleanup(void)
Definition: main.c:1335
HANDLE WINAPI OpenProcess(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwProcessId)
Definition: proc.c:1227
DWORD WINAPI SHDeleteKeyW(HKEY hKey, LPCWSTR lpszSubKey)
Definition: reg.c:1546
#define swprintf
Definition: precomp.h:40
return ret
Definition: mutex.c:146
#define L(x)
Definition: resources.c:13
#define ULONG_PTR
Definition: config.h:101
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define InsertTailList(ListHead, Entry)
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ProcessId
Definition: fatprocs.h:2712
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
_In_ WDFDEVICE _In_ PWDF_DEVICE_INTERFACE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG _Out_ PDEVPROPTYPE PropertyType
FxAutoRegKey hKey
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
Status
Definition: gdiplustypes.h:25
GLfloat GLfloat p
Definition: glext.h:8902
GLenum GLsizei len
Definition: glext.h:6722
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define REG_SZ
Definition: layer.c:22
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:71
#define for
Definition: utility.h:88
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
static PVOID ptr
Definition: dispmode.c:27
#define SE_LOAD_DRIVER_PRIVILEGE
Definition: security.c:664
ObjectType
Definition: metafile.c:81
#define PNP_PROPERTY_UI_NUMBER
Definition: cmtypes.h:34
#define PNP_SET_DEVICE_STATUS
Definition: cmtypes.h:60
#define PNP_PROPERTY_REMOVAL_POLICY
Definition: cmtypes.h:40
#define PNP_PROPERTY_POWER_DATA
Definition: cmtypes.h:39
#define PNP_PROPERTY_ENUMERATOR_NAME
Definition: cmtypes.h:43
#define PNP_PROPERTY_PHYSICAL_DEVICE_OBJECT_NAME
Definition: cmtypes.h:35
@ PlugPlayControlEnumerateDevice
Definition: cmtypes.h:209
@ PlugPlayControlProperty
Definition: cmtypes.h:219
@ PlugPlayControlQueryDeviceRelations
Definition: cmtypes.h:225
@ PlugPlayControlGetRelatedDevice
Definition: cmtypes.h:221
@ PlugPlayControlDeviceStatus
Definition: cmtypes.h:223
@ PlugPlayControlQueryAndRemoveDevice
Definition: cmtypes.h:215
@ PlugPlayControlGetDeviceDepth
Definition: cmtypes.h:224
@ PlugPlayControlDeviceClassAssociation
Definition: cmtypes.h:220
@ PlugPlayControlInitializeDevice
Definition: cmtypes.h:212
@ PlugPlayControlGetInterfaceDeviceList
Definition: cmtypes.h:218
@ PlugPlayControlStartDevice
Definition: cmtypes.h:213
@ PlugPlayControlGetInterfaceDeviceAlias
Definition: cmtypes.h:222
@ PlugPlayControlRetrieveDock
Definition: cmtypes.h:228
#define PNP_PROPERTY_INSTALL_STATE
Definition: cmtypes.h:45
#define PNP_PROPERTY_LOCATION_PATHS
Definition: cmtypes.h:46
#define PNP_PROPERTY_REMOVAL_POLICY_HARDWARE_DEFAULT
Definition: cmtypes.h:44
#define PNP_CLEAR_DEVICE_STATUS
Definition: cmtypes.h:61
#define PNP_PROPERTY_LEGACYBUSTYPE
Definition: cmtypes.h:37
#define PNP_GET_DEVICE_STATUS
Definition: cmtypes.h:59
#define PNP_PROPERTY_BUSTYPEGUID
Definition: cmtypes.h:36
#define PNP_PROPERTY_ADDRESS
Definition: cmtypes.h:42
#define PNP_PROPERTY_BUSNUMBER
Definition: cmtypes.h:38
#define PNP_PROPERTY_CONTAINERID
Definition: cmtypes.h:47
NTSYSAPI VOID NTAPI RtlInitializeResource(_In_ PRTL_RESOURCE Resource)
NTSYSAPI BOOLEAN NTAPI RtlAcquireResourceExclusive(_In_ PRTL_RESOURCE Resource, _In_ BOOLEAN Wait)
NTSYSAPI VOID NTAPI RtlReleaseResource(_In_ PRTL_RESOURCE Resource)
#define _Out_opt_
Definition: no_sal2.h:214
#define _Inout_
Definition: no_sal2.h:162
#define _Inout_opt_
Definition: no_sal2.h:216
#define _Out_
Definition: no_sal2.h:160
#define _In_
Definition: no_sal2.h:158
int Count
Definition: noreturn.cpp:7
#define REG_BINARY
Definition: nt_native.h:1496
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define KEY_READ
Definition: nt_native.h:1023
#define PROCESS_ALL_ACCESS
Definition: nt_native.h:1324
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define KEY_CREATE_SUB_KEY
Definition: nt_native.h:1018
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define REG_CREATED_NEW_KEY
Definition: nt_native.h:1084
#define REG_RESOURCE_LIST
Definition: nt_native.h:1502
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define REG_MULTI_SZ
Definition: nt_native.h:1501
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019
#define REG_RESOURCE_REQUIREMENTS_LIST
Definition: nt_native.h:1504
#define KEY_WRITE
Definition: nt_native.h:1031
#define DWORD
Definition: nt_native.h:44
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define UNICODE_NULL
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
#define STATUS_PLUGPLAY_QUERY_VETOED
Definition: ntstatus.h:219
BYTE * PBYTE
Definition: pedump.c:66
DWORD * PDWORD
Definition: pedump.c:68
long LONG
Definition: pedump.c:60
NTSTATUS NTAPI NtPlugPlayControl(IN PLUGPLAY_CONTROL_CLASS PlugPlayControlClass, IN OUT PVOID Buffer, IN ULONG BufferLength)
Definition: plugplay.c:1573
unsigned long PNP_PROP_COUNT
Definition: pnp.idl:32
unsigned long PNP_RPC_BUFFER_SIZE
Definition: pnp.idl:34
void * PNP_NOTIFY_HANDLE
Definition: pnp.idl:7
unsigned long PNP_RPC_STRING_LEN
Definition: pnp.idl:33
unsigned long PNP_PROP_SIZE
Definition: pnp.idl:31
static const WCHAR szName[]
Definition: powrprof.c:45
#define CONFIGFLAG_MANUAL_INSTALL
Definition: regstr.h:392
#define CONFIGFLAG_FAILEDINSTALL
Definition: regstr.h:396
#define REGSTR_PATH_CLASS
Definition: regstr.h:42
struct _CM_FULL_RESOURCE_DESCRIPTOR CM_FULL_RESOURCE_DESCRIPTOR
struct _CM_FULL_RESOURCE_DESCRIPTOR * PCM_FULL_RESOURCE_DESCRIPTOR
struct _CM_RESOURCE_LIST CM_RESOURCE_LIST
#define CmResourceTypeConfigData
Definition: restypes.h:111
struct _CM_RESOURCE_LIST * PCM_RESOURCE_LIST
#define CmResourceTypeDeviceSpecific
Definition: restypes.h:108
@ InterfaceTypeUndefined
Definition: restypes.h:120
RPC_STATUS WINAPI RpcRevertToSelf(void)
Definition: rpc_binding.c:1463
RPC_STATUS WINAPI RpcImpersonateClient(RPC_BINDING_HANDLE BindingHandle)
Definition: rpc_binding.c:1056
RPC_STATUS WINAPI RpcServerListen(UINT MinimumCallThreads, UINT MaxCalls, UINT DontWait)
Definition: rpc_server.c:1520
RPC_STATUS WINAPI RpcServerRegisterIf(RPC_IF_HANDLE IfSpec, UUID *MgrTypeUuid, RPC_MGR_EPV *MgrEpv)
Definition: rpc_server.c:1116
RPC_STATUS WINAPI RpcServerUseProtseqEpW(RPC_WSTR Protseq, UINT MaxCalls, RPC_WSTR Endpoint, LPVOID SecurityDescriptor)
Definition: rpc_server.c:927
#define RPC_S_OK
Definition: rpcnterr.h:22
DWORD WINAPI I_ScValidatePnpService(_In_ LPCWSTR pszMachineName, _In_ LPCWSTR pszServiceName, _Out_ SERVICE_STATUS_HANDLE *phServiceStatus)
Definition: scm.c:1948
#define REG_DWORD
Definition: sdbapi.c:596
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define midl_user_free
Definition: rpc.h:41
#define __RPC_FAR
Definition: rpc.h:52
long RPC_STATUS
Definition: rpc.h:48
#define __RPC_USER
Definition: rpc.h:61
#define midl_user_allocate
Definition: rpc.h:40
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define DPRINT
Definition: sndvol32.h:73
ULONG HWPI_ulHWProfile
Definition: cfgmgr32.h:554
CHAR HWPI_szFriendlyName[MAX_PROFILE_LEN]
Definition: cfgmgr32.h:555
DWORD HWPI_dwFlags
Definition: cfgmgr32.h:556
Definition: precomp.h:54
NOTIFICATION_TYPE dwType
Definition: precomp.h:56
PWSTR pszName
Definition: precomp.h:57
DWORD ulFlags
Definition: precomp.h:59
LIST_ENTRY ListEntry
Definition: precomp.h:55
DWORD_PTR hRecipient
Definition: precomp.h:58
GUID ClassGuid
Definition: precomp.h:60
CM_PARTIAL_RESOURCE_LIST PartialResourceList
Definition: restypes.h:144
INTERFACE_TYPE InterfaceType
Definition: restypes.h:142
CM_FULL_RESOURCE_DESCRIPTOR List[1]
Definition: restypes.h:149
union _IO_RESOURCE_DESCRIPTOR::@2226 u
struct _IO_RESOURCE_DESCRIPTOR::@2226::@2234 ConfigData
IO_RESOURCE_DESCRIPTOR Descriptors[1]
Definition: iotypes.h:2737
INTERFACE_TYPE InterfaceType
Definition: iotypes.h:2742
IO_RESOURCE_LIST List[1]
Definition: iotypes.h:2747
Definition: typedefs.h:120
UNICODE_STRING DeviceInstance
Definition: cmtypes.h:545
UNICODE_STRING DeviceInstance
Definition: cmtypes.h:554
UNICODE_STRING DeviceInstance
Definition: cmtypes.h:507
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
#define WINVER
Definition: targetver.h:11
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
uint16_t * PWSTR
Definition: typedefs.h:56
uint32_t * PULONG
Definition: typedefs.h:59
const uint16_t * PCWSTR
Definition: typedefs.h:57
uint32_t DWORD_PTR
Definition: typedefs.h:65
unsigned char * LPBYTE
Definition: typedefs.h:53
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint32_t * LPDWORD
Definition: typedefs.h:59
int32_t INT
Definition: typedefs.h:58
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
uint16_t * PWCHAR
Definition: typedefs.h:56
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
_In_z_ PCWSTR _In_ ULONG ulType
Definition: ntuser.h:43
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID PropertyBuffer
Definition: wdfdevice.h:4437
#define ZeroMemory
Definition: winbase.h:1753
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
HANDLE WINAPI GetCurrentThread(void)
Definition: proc.c:1148
#define CopyMemory
Definition: winbase.h:1751
#define MoveMemory
Definition: winbase.h:1750
WINBASEAPI _In_ DWORD nLength
Definition: wincon.h:682
_In_ ULONG _In_ ULONG ulTag
Definition: winddi.h:3942
_Check_return_ _Out_ PULONG pulSize
Definition: winddi.h:2120
#define WINAPI
Definition: msvc.h:6
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define HKEY_CURRENT_CONFIG
Definition: winreg.h:15
#define RegOpenKeyEx
Definition: winreg.h:520
#define RegSetValueEx
Definition: winreg.h:533
#define RegQueryValueEx
Definition: winreg.h:524
#define RegDeleteValue
Definition: winreg.h:508
#define wsprintf
Definition: winuser.h:5976
static const GUID InterfaceGuid
Definition: wlanapi.c:25
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
_In_ PVOID _Out_opt_ PULONG_PTR _Outptr_opt_ PCUNICODE_STRING * ObjectName
Definition: cmfuncs.h:64
_In_ CONST DEVPROPKEY * PropertyKey
Definition: iofuncs.h:2414
struct _IO_RESOURCE_LIST * PIO_RESOURCE_LIST
#define IO_RESOURCE_PREFERRED
struct _IO_RESOURCE_REQUIREMENTS_LIST * PIO_RESOURCE_REQUIREMENTS_LIST
struct _IO_RESOURCE_REQUIREMENTS_LIST IO_RESOURCE_REQUIREMENTS_LIST
#define TOKEN_DUPLICATE
Definition: setypes.h:938
#define SECURITY_INTERACTIVE_RID
Definition: setypes.h:559
#define TOKEN_QUERY
Definition: setypes.h:940
#define SECURITY_NT_AUTHORITY
Definition: setypes.h:554
#define TOKEN_ASSIGN_PRIMARY
Definition: setypes.h:937
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
unsigned char BYTE
Definition: xxhash.c:193