7510fff8b97074898690e779b2dcc52014577bca
[reactos.git] / reactos / dll / win32 / setupapi / cfgmgr.c
1 /*
2 * Configuration manager functions
3 *
4 * Copyright 2000 James Hatheway
5 * Copyright 2005, 2006 Eric Kohl
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 */
21
22 #include "setupapi_private.h"
23
24 #include <dbt.h>
25 #include <pnp_c.h>
26
27 #include "rpc_private.h"
28
29 /* Registry key and value names */
30 static const WCHAR Backslash[] = {'\\', 0};
31 static const WCHAR Class[] = {'C','l','a','s','s',0};
32
33 static const WCHAR ControlClass[] = {'S','y','s','t','e','m','\\',
34 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
35 'C','o','n','t','r','o','l','\\',
36 'C','l','a','s','s',0};
37
38 static const WCHAR DeviceClasses[] = {'S','y','s','t','e','m','\\',
39 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
40 'C','o','n','t','r','o','l','\\',
41 'D','e','v','i','c','e','C','l','a','s','s','e','s',0};
42
43 typedef struct _MACHINE_INFO
44 {
45 WCHAR szMachineName[SP_MAX_MACHINENAME_LENGTH];
46 RPC_BINDING_HANDLE BindingHandle;
47 HSTRING_TABLE StringTable;
48 BOOL bLocal;
49 } MACHINE_INFO, *PMACHINE_INFO;
50
51
52 typedef struct _LOG_CONF_INFO
53 {
54 ULONG ulMagic;
55 DEVINST dnDevInst;
56 ULONG ulFlags;
57 ULONG ulTag;
58 } LOG_CONF_INFO, *PLOG_CONF_INFO;
59
60 #define LOG_CONF_MAGIC 0x464E434C /* "LCNF" */
61
62
63 typedef struct _NOTIFY_DATA
64 {
65 ULONG ulMagic;
66 ULONG ulNotifyData;
67 } NOTIFY_DATA, *PNOTIFY_DATA;
68
69 #define NOTIFY_MAGIC 0x44556677
70
71
72 static BOOL GuidToString(LPGUID Guid, LPWSTR String)
73 {
74 LPWSTR lpString;
75
76 if (UuidToStringW(Guid, &lpString) != RPC_S_OK)
77 return FALSE;
78
79 lstrcpyW(&String[1], lpString);
80
81 String[0] = '{';
82 String[MAX_GUID_STRING_LEN - 2] = '}';
83 String[MAX_GUID_STRING_LEN - 1] = UNICODE_NULL;
84
85 RpcStringFreeW(&lpString);
86
87 return TRUE;
88 }
89
90
91 static CONFIGRET
92 RpcStatusToCmStatus(RPC_STATUS Status)
93 {
94 return CR_FAILURE;
95 }
96
97
98 static
99 ULONG
100 GetRegistryPropertyType(
101 ULONG ulProperty)
102 {
103 switch (ulProperty)
104 {
105 case CM_DRP_DEVICEDESC:
106 case CM_DRP_SERVICE:
107 case CM_DRP_CLASS:
108 case CM_DRP_CLASSGUID:
109 case CM_DRP_DRIVER:
110 case CM_DRP_MFG:
111 case CM_DRP_FRIENDLYNAME:
112 case CM_DRP_LOCATION_INFORMATION:
113 case CM_DRP_PHYSICAL_DEVICE_OBJECT_NAME:
114 case CM_DRP_ENUMERATOR_NAME:
115 case CM_DRP_SECURITY_SDS:
116 case CM_DRP_UI_NUMBER_DESC_FORMAT:
117 return REG_SZ;
118
119 case CM_DRP_HARDWAREID:
120 case CM_DRP_COMPATIBLEIDS:
121 case CM_DRP_UPPERFILTERS:
122 case CM_DRP_LOWERFILTERS:
123 return REG_MULTI_SZ;
124
125 case CM_DRP_CONFIGFLAGS:
126 case CM_DRP_CAPABILITIES:
127 case CM_DRP_UI_NUMBER:
128 case CM_DRP_LEGACYBUSTYPE:
129 case CM_DRP_BUSNUMBER:
130 case CM_DRP_DEVTYPE:
131 case CM_DRP_EXCLUSIVE:
132 case CM_DRP_CHARACTERISTICS:
133 case CM_DRP_ADDRESS:
134 case CM_DRP_REMOVAL_POLICY:
135 case CM_DRP_REMOVAL_POLICY_HW_DEFAULT:
136 case CM_DRP_REMOVAL_POLICY_OVERRIDE:
137 case CM_DRP_INSTALL_STATE:
138 return REG_DWORD;
139
140 case CM_DRP_BUSTYPEGUID:
141 case CM_DRP_SECURITY:
142 case CM_DRP_DEVICE_POWER_DATA:
143 default:
144 return REG_BINARY;
145 }
146
147 return REG_NONE;
148 }
149
150
151 /***********************************************************************
152 * CMP_GetServerSideDeviceInstallFlags [SETUPAPI.@]
153 */
154 CONFIGRET
155 WINAPI
156 CMP_GetServerSideDeviceInstallFlags(
157 _Out_ PULONG pulSSDIFlags,
158 _In_ ULONG ulFlags,
159 _In_ HMACHINE hMachine)
160 {
161 RPC_BINDING_HANDLE BindingHandle = NULL;
162 CONFIGRET ret;
163
164 TRACE("CMP_GetServerSideDeviceInstallFlags(%p %lx %p)\n",
165 pulSSDIFlags, ulFlags, hMachine);
166
167 if (pulSSDIFlags == NULL)
168 return CR_INVALID_POINTER;
169
170 if (ulFlags != 0)
171 return CR_INVALID_FLAG;
172
173 if (hMachine != NULL)
174 {
175 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
176 if (BindingHandle == NULL)
177 return CR_FAILURE;
178 }
179 else
180 {
181 if (!PnpGetLocalHandles(&BindingHandle, NULL))
182 return CR_FAILURE;
183 }
184
185 RpcTryExcept
186 {
187 ret = PNP_GetServerSideDeviceInstallFlags(BindingHandle,
188 pulSSDIFlags,
189 ulFlags);
190 }
191 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
192 {
193 ret = RpcStatusToCmStatus(RpcExceptionCode());
194 }
195 RpcEndExcept;
196
197 return ret;
198 }
199
200
201 /***********************************************************************
202 * CMP_Init_Detection [SETUPAPI.@]
203 */
204 CONFIGRET
205 WINAPI
206 CMP_Init_Detection(
207 _In_ ULONG ulMagic)
208 {
209 RPC_BINDING_HANDLE BindingHandle = NULL;
210 CONFIGRET ret;
211
212 TRACE("CMP_Init_Detection(%lu)\n", ulMagic);
213
214 if (ulMagic != CMP_MAGIC)
215 return CR_INVALID_DATA;
216
217 if (!PnpGetLocalHandles(&BindingHandle, NULL))
218 return CR_FAILURE;
219
220 RpcTryExcept
221 {
222 ret = PNP_InitDetection(BindingHandle);
223 }
224 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
225 {
226 ret = RpcStatusToCmStatus(RpcExceptionCode());
227 }
228 RpcEndExcept;
229
230 return ret;
231 }
232
233
234 /***********************************************************************
235 * CMP_RegisterNotification [SETUPAPI.@]
236 */
237 CONFIGRET
238 WINAPI
239 CMP_RegisterNotification(
240 _In_ HANDLE hRecipient,
241 _In_ LPVOID lpvNotificationFilter,
242 _In_ ULONG ulFlags,
243 _Out_ PHDEVNOTIFY phDevNotify)
244 {
245 RPC_BINDING_HANDLE BindingHandle = NULL;
246 PNOTIFY_DATA pNotifyData = NULL;
247 CONFIGRET ret = CR_SUCCESS;
248
249 TRACE("CMP_RegisterNotification(%p %p %lu %p)\n",
250 hRecipient, lpvNotificationFilter, ulFlags, phDevNotify);
251
252 if ((hRecipient == NULL) ||
253 (lpvNotificationFilter == NULL) ||
254 (phDevNotify == NULL))
255 return CR_INVALID_POINTER;
256
257 if (ulFlags & ~0x7)
258 return CR_INVALID_FLAG;
259
260 if (((PDEV_BROADCAST_HDR)lpvNotificationFilter)->dbch_size < sizeof(DEV_BROADCAST_HDR))
261 return CR_INVALID_DATA;
262
263 if (!PnpGetLocalHandles(&BindingHandle, NULL))
264 return CR_FAILURE;
265
266 pNotifyData = HeapAlloc(GetProcessHeap(),
267 HEAP_ZERO_MEMORY,
268 sizeof(NOTIFY_DATA));
269 if (pNotifyData == NULL)
270 return CR_OUT_OF_MEMORY;
271
272 pNotifyData->ulMagic = NOTIFY_MAGIC;
273
274 /*
275 if (dwFlags & DEVICE_NOTIFY_SERVICE_HANDLE == DEVICE_NOTYFY_WINDOW_HANDLE)
276 {
277
278 }
279 else if (dwFlags & DEVICE_NOTIFY_SERVICE_HANDLE == DEVICE_NOTYFY_SERVICE_HANDLE)
280 {
281
282 }
283 */
284
285 RpcTryExcept
286 {
287 ret = PNP_RegisterNotification(BindingHandle,
288 ulFlags,
289 &pNotifyData->ulNotifyData);
290 }
291 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
292 {
293 ret = RpcStatusToCmStatus(RpcExceptionCode());
294 }
295 RpcEndExcept;
296
297 if (ret == CR_SUCCESS)
298 {
299 *phDevNotify = (HDEVNOTIFY)pNotifyData;
300 }
301 else
302 {
303 if (pNotifyData != NULL)
304 HeapFree(GetProcessHeap(), 0, pNotifyData);
305
306 *phDevNotify = (HDEVNOTIFY)NULL;
307 }
308
309 return ret;
310 }
311
312
313 /***********************************************************************
314 * CMP_Report_LogOn [SETUPAPI.@]
315 */
316 CONFIGRET
317 WINAPI
318 CMP_Report_LogOn(
319 _In_ DWORD dwMagic,
320 _In_ DWORD dwProcessId)
321 {
322 RPC_BINDING_HANDLE BindingHandle = NULL;
323 CONFIGRET ret = CR_SUCCESS;
324 BOOL bAdmin;
325 DWORD i;
326
327 TRACE("CMP_Report_LogOn(%lu %lu)\n", dwMagic, dwProcessId);
328
329 if (dwMagic != CMP_MAGIC)
330 return CR_INVALID_DATA;
331
332 if (!PnpGetLocalHandles(&BindingHandle, NULL))
333 return CR_FAILURE;
334
335 bAdmin = pSetupIsUserAdmin();
336
337 for (i = 0; i < 30; i++)
338 {
339 RpcTryExcept
340 {
341 ret = PNP_ReportLogOn(BindingHandle,
342 bAdmin,
343 dwProcessId);
344 }
345 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
346 {
347 ret = RpcStatusToCmStatus(RpcExceptionCode());
348 }
349 RpcEndExcept;
350
351 if (ret == CR_SUCCESS)
352 break;
353
354 Sleep(5000);
355 }
356
357 return ret;
358 }
359
360
361 /***********************************************************************
362 * CMP_UnregisterNotification [SETUPAPI.@]
363 */
364 CONFIGRET
365 WINAPI
366 CMP_UnregisterNotification(
367 _In_ HDEVNOTIFY hDevNotify)
368 {
369 RPC_BINDING_HANDLE BindingHandle = NULL;
370 PNOTIFY_DATA pNotifyData;
371 CONFIGRET ret = CR_SUCCESS;
372
373 TRACE("CMP_UnregisterNotification(%p)\n", hDevNotify);
374
375 pNotifyData = (PNOTIFY_DATA)hDevNotify;
376
377 if ((pNotifyData == NULL) ||
378 (pNotifyData->ulMagic != NOTIFY_MAGIC))
379 return CR_INVALID_POINTER;
380
381 if (!PnpGetLocalHandles(&BindingHandle, NULL))
382 return CR_FAILURE;
383
384 RpcTryExcept
385 {
386 ret = PNP_UnregisterNotification(BindingHandle,
387 pNotifyData->ulNotifyData);
388 }
389 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
390 {
391 ret = RpcStatusToCmStatus(RpcExceptionCode());
392 }
393 RpcEndExcept;
394
395 if (ret == CR_SUCCESS)
396 HeapFree(GetProcessHeap(), 0, pNotifyData);
397
398 return ret;
399 }
400
401
402 /***********************************************************************
403 * CMP_WaitNoPendingInstallEvents [SETUPAPI.@]
404 */
405 DWORD
406 WINAPI
407 CMP_WaitNoPendingInstallEvents(
408 _In_ DWORD dwTimeout)
409 {
410 HANDLE hEvent;
411 DWORD ret;
412
413 TRACE("CMP_WaitNoPendingInstallEvents(%lu)\n", dwTimeout);
414
415 hEvent = OpenEventW(SYNCHRONIZE, FALSE, L"Global\\PnP_No_Pending_Install_Events");
416 if (hEvent == NULL)
417 return WAIT_FAILED;
418
419 ret = WaitForSingleObject(hEvent, dwTimeout);
420 CloseHandle(hEvent);
421 return ret;
422 }
423
424
425 /***********************************************************************
426 * CMP_WaitServicesAvailable [SETUPAPI.@]
427 */
428 CONFIGRET
429 WINAPI
430 CMP_WaitServicesAvailable(
431 _In_ HMACHINE hMachine)
432 {
433 RPC_BINDING_HANDLE BindingHandle = NULL;
434 CONFIGRET ret = CR_SUCCESS;
435 WORD Version;
436
437 TRACE("CMP_WaitServicesAvailable(%p)\n", hMachine);
438
439 if (!PnpGetLocalHandles(&BindingHandle, NULL))
440 return CR_FAILURE;
441
442 RpcTryExcept
443 {
444 ret = PNP_GetVersion(BindingHandle, &Version);
445 }
446 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
447 {
448 ret = RpcStatusToCmStatus(RpcExceptionCode());
449 }
450 RpcEndExcept;
451
452 return ret;
453 }
454
455
456 /***********************************************************************
457 * CM_Add_Empty_Log_Conf [SETUPAPI.@]
458 */
459 CONFIGRET WINAPI CM_Add_Empty_Log_Conf(
460 PLOG_CONF plcLogConf, DEVINST dnDevInst, PRIORITY Priority,
461 ULONG ulFlags)
462 {
463 TRACE("%p %p %lu %lx\n", plcLogConf, dnDevInst, Priority, ulFlags);
464 return CM_Add_Empty_Log_Conf_Ex(plcLogConf, dnDevInst, Priority,
465 ulFlags, NULL);
466 }
467
468
469 /***********************************************************************
470 * CM_Add_Empty_Log_Conf_Ex [SETUPAPI.@]
471 */
472 CONFIGRET WINAPI CM_Add_Empty_Log_Conf_Ex(
473 PLOG_CONF plcLogConf, DEVINST dnDevInst, PRIORITY Priority,
474 ULONG ulFlags, HMACHINE hMachine)
475 {
476 RPC_BINDING_HANDLE BindingHandle = NULL;
477 HSTRING_TABLE StringTable = NULL;
478 ULONG ulLogConfTag = 0;
479 LPWSTR lpDevInst;
480 PLOG_CONF_INFO pLogConfInfo;
481 CONFIGRET ret = CR_SUCCESS;
482
483 FIXME("%p %p %lu %lx %p\n",
484 plcLogConf, dnDevInst, Priority, ulFlags, hMachine);
485
486 if (!pSetupIsUserAdmin())
487 return CR_ACCESS_DENIED;
488
489 if (plcLogConf == NULL)
490 return CR_INVALID_POINTER;
491
492 if (dnDevInst == 0)
493 return CR_INVALID_DEVINST;
494
495 if (Priority > 0xFFFF)
496 return CR_INVALID_PRIORITY;
497
498 if (ulFlags & ~(LOG_CONF_BITS | PRIORITY_BIT))
499 return CR_INVALID_FLAG;
500
501 if (hMachine != NULL)
502 {
503 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
504 if (BindingHandle == NULL)
505 return CR_FAILURE;
506
507 StringTable = ((PMACHINE_INFO)hMachine)->StringTable;
508 if (StringTable == 0)
509 return CR_FAILURE;
510 }
511 else
512 {
513 if (!PnpGetLocalHandles(&BindingHandle, &StringTable))
514 return CR_FAILURE;
515 }
516
517 lpDevInst = pSetupStringTableStringFromId(StringTable, dnDevInst);
518 if (lpDevInst == NULL)
519 return CR_INVALID_DEVNODE;
520
521 RpcTryExcept
522 {
523 ret = PNP_AddEmptyLogConf(BindingHandle, lpDevInst, Priority,
524 &ulLogConfTag, ulFlags);
525 }
526 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
527 {
528 ret = RpcStatusToCmStatus(RpcExceptionCode());
529 }
530 RpcEndExcept;
531
532 if (ret == CR_SUCCESS)
533 {
534 pLogConfInfo = HeapAlloc(GetProcessHeap(), 0, sizeof(LOG_CONF_INFO));
535 if (pLogConfInfo == NULL)
536 {
537 ret = CR_OUT_OF_MEMORY;
538 }
539 else
540 {
541 pLogConfInfo->ulMagic = LOG_CONF_MAGIC;
542 pLogConfInfo->dnDevInst = dnDevInst;
543 pLogConfInfo->ulFlags = ulFlags;
544 pLogConfInfo->ulTag = ulLogConfTag;
545
546 *plcLogConf = (LOG_CONF)pLogConfInfo;
547
548 ret = CR_SUCCESS;
549 }
550 }
551
552 return ret;
553 }
554
555
556 /***********************************************************************
557 * CM_Add_IDA [SETUPAPI.@]
558 */
559 CONFIGRET WINAPI CM_Add_IDA(
560 DEVINST dnDevInst, PSTR pszID, ULONG ulFlags)
561 {
562 TRACE("%p %s %lx\n", dnDevInst, pszID, ulFlags);
563 return CM_Add_ID_ExA(dnDevInst, pszID, ulFlags, NULL);
564 }
565
566
567 /***********************************************************************
568 * CM_Add_IDW [SETUPAPI.@]
569 */
570 CONFIGRET WINAPI CM_Add_IDW(
571 DEVINST dnDevInst, PWSTR pszID, ULONG ulFlags)
572 {
573 TRACE("%p %s %lx\n", dnDevInst, debugstr_w(pszID), ulFlags);
574 return CM_Add_ID_ExW(dnDevInst, pszID, ulFlags, NULL);
575 }
576
577
578 /***********************************************************************
579 * CM_Add_ID_ExA [SETUPAPI.@]
580 */
581 CONFIGRET WINAPI CM_Add_ID_ExA(
582 DEVINST dnDevInst, PSTR pszID, ULONG ulFlags, HMACHINE hMachine)
583 {
584 PWSTR pszIDW;
585 CONFIGRET ret;
586
587 TRACE("%p %s %lx %p\n", dnDevInst, pszID, ulFlags, hMachine);
588
589 if (pSetupCaptureAndConvertAnsiArg(pszID, &pszIDW))
590 return CR_INVALID_DATA;
591
592 ret = CM_Add_ID_ExW(dnDevInst, pszIDW, ulFlags, hMachine);
593
594 MyFree(pszIDW);
595
596 return ret;
597 }
598
599
600 /***********************************************************************
601 * CM_Add_ID_ExW [SETUPAPI.@]
602 */
603 CONFIGRET WINAPI CM_Add_ID_ExW(
604 DEVINST dnDevInst, PWSTR pszID, ULONG ulFlags, HMACHINE hMachine)
605 {
606 RPC_BINDING_HANDLE BindingHandle = NULL;
607 HSTRING_TABLE StringTable = NULL;
608 LPWSTR lpDevInst;
609 CONFIGRET ret;
610
611 TRACE("%p %s %lx %p\n", dnDevInst, debugstr_w(pszID), ulFlags, hMachine);
612
613 if (!pSetupIsUserAdmin())
614 return CR_ACCESS_DENIED;
615
616 if (dnDevInst == 0)
617 return CR_INVALID_DEVINST;
618
619 if (pszID == NULL)
620 return CR_INVALID_POINTER;
621
622 if (ulFlags & ~CM_ADD_ID_BITS)
623 return CR_INVALID_FLAG;
624
625 if (hMachine != NULL)
626 {
627 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
628 if (BindingHandle == NULL)
629 return CR_FAILURE;
630
631 StringTable = ((PMACHINE_INFO)hMachine)->StringTable;
632 if (StringTable == 0)
633 return CR_FAILURE;
634 }
635 else
636 {
637 if (!PnpGetLocalHandles(&BindingHandle, &StringTable))
638 return CR_FAILURE;
639 }
640
641 lpDevInst = pSetupStringTableStringFromId(StringTable, dnDevInst);
642 if (lpDevInst == NULL)
643 return CR_INVALID_DEVNODE;
644
645 RpcTryExcept
646 {
647 ret = PNP_AddID(BindingHandle,
648 lpDevInst,
649 pszID,
650 ulFlags);
651 }
652 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
653 {
654 ret = RpcStatusToCmStatus(RpcExceptionCode());
655 }
656 RpcEndExcept;
657
658 return ret;
659 }
660
661
662 /***********************************************************************
663 * CM_Add_Res_Des [SETUPAPI.@]
664 */
665 CONFIGRET WINAPI CM_Add_Res_Des(
666 PRES_DES prdResDes, LOG_CONF lcLogConf, RESOURCEID ResourceID,
667 PCVOID ResourceData, ULONG ResourceLen, ULONG ulFlags)
668 {
669 TRACE("%p %p %lu %p %lu %lx\n", prdResDes, lcLogConf, ResourceID,
670 ResourceData, ResourceLen, ulFlags);
671 return CM_Add_Res_Des_Ex(prdResDes, lcLogConf, ResourceID, ResourceData,
672 ResourceLen, ulFlags, NULL);
673 }
674
675
676 /***********************************************************************
677 * CM_Add_Res_Des_Ex [SETUPAPI.@]
678 */
679 CONFIGRET WINAPI CM_Add_Res_Des_Ex(
680 PRES_DES prdResDes, LOG_CONF lcLogConf, RESOURCEID ResourceID,
681 PCVOID ResourceData, ULONG ResourceLen, ULONG ulFlags, HMACHINE hMachine)
682 {
683 FIXME("%p %p %lu %p %lu %lx %p\n", prdResDes, lcLogConf, ResourceID,
684 ResourceData, ResourceLen, ulFlags, hMachine);
685
686 return CR_CALL_NOT_IMPLEMENTED;
687 }
688
689
690 /***********************************************************************
691 * CM_Connect_MachineA [SETUPAPI.@]
692 */
693 CONFIGRET WINAPI CM_Connect_MachineA(
694 PCSTR UNCServerName, PHMACHINE phMachine)
695 {
696 PWSTR pServerNameW;
697 CONFIGRET ret;
698
699 TRACE("%s %p\n", UNCServerName, phMachine);
700
701 if (UNCServerName == NULL || *UNCServerName == 0)
702 return CM_Connect_MachineW(NULL, phMachine);
703
704 if (pSetupCaptureAndConvertAnsiArg(UNCServerName, &pServerNameW))
705 return CR_INVALID_DATA;
706
707 ret = CM_Connect_MachineW(pServerNameW, phMachine);
708
709 MyFree(pServerNameW);
710
711 return ret;
712 }
713
714
715 /***********************************************************************
716 * CM_Connect_MachineW [SETUPAPI.@]
717 */
718 CONFIGRET WINAPI CM_Connect_MachineW(
719 PCWSTR UNCServerName, PHMACHINE phMachine)
720 {
721 PMACHINE_INFO pMachine;
722
723 TRACE("%s %p\n", debugstr_w(UNCServerName), phMachine);
724
725 if (phMachine == NULL)
726 return CR_INVALID_POINTER;
727
728 *phMachine = NULL;
729
730 pMachine = HeapAlloc(GetProcessHeap(), 0, sizeof(MACHINE_INFO));
731 if (pMachine == NULL)
732 return CR_OUT_OF_MEMORY;
733
734 if (UNCServerName == NULL || *UNCServerName == 0)
735 {
736 pMachine->bLocal = TRUE;
737
738 /* FIXME: store the computers name in pMachine->szMachineName */
739
740 if (!PnpGetLocalHandles(&pMachine->BindingHandle,
741 &pMachine->StringTable))
742 {
743 HeapFree(GetProcessHeap(), 0, pMachine);
744 return CR_FAILURE;
745 }
746 }
747 else
748 {
749 pMachine->bLocal = FALSE;
750 if (wcslen(UNCServerName) >= SP_MAX_MACHINENAME_LENGTH - 1)
751 {
752 HeapFree(GetProcessHeap(), 0, pMachine);
753 return CR_INVALID_MACHINENAME;
754 }
755 lstrcpyW(pMachine->szMachineName, UNCServerName);
756
757 pMachine->StringTable = pSetupStringTableInitialize();
758 if (pMachine->StringTable == NULL)
759 {
760 HeapFree(GetProcessHeap(), 0, pMachine);
761 return CR_FAILURE;
762 }
763
764 pSetupStringTableAddString(pMachine->StringTable, L"PLT", 1);
765
766 if (!PnpBindRpc(UNCServerName, &pMachine->BindingHandle))
767 {
768 pSetupStringTableDestroy(pMachine->StringTable);
769 HeapFree(GetProcessHeap(), 0, pMachine);
770 return CR_INVALID_MACHINENAME;
771 }
772 }
773
774 *phMachine = (PHMACHINE)pMachine;
775
776 return CR_SUCCESS;
777 }
778
779
780 /***********************************************************************
781 * CM_Create_DevNodeA [SETUPAPI.@]
782 */
783 CONFIGRET WINAPI CM_Create_DevNodeA(
784 PDEVINST pdnDevInst, DEVINSTID_A pDeviceID, DEVINST dnParent,
785 ULONG ulFlags)
786 {
787 TRACE("%p %s %p %lx\n",
788 pdnDevInst, debugstr_a(pDeviceID), dnParent, ulFlags);
789 return CM_Create_DevNode_ExA(pdnDevInst, pDeviceID, dnParent,
790 ulFlags, NULL);
791 }
792
793
794 /***********************************************************************
795 * CM_Create_DevNodeW [SETUPAPI.@]
796 */
797 CONFIGRET WINAPI CM_Create_DevNodeW(
798 PDEVINST pdnDevInst, DEVINSTID_W pDeviceID, DEVINST dnParent,
799 ULONG ulFlags)
800 {
801 TRACE("%p %s %p %lx\n",
802 pdnDevInst, debugstr_w(pDeviceID), dnParent, ulFlags);
803 return CM_Create_DevNode_ExW(pdnDevInst, pDeviceID, dnParent,
804 ulFlags, NULL);
805 }
806
807
808 /***********************************************************************
809 * CM_Create_DevNode_ExA [SETUPAPI.@]
810 */
811 CONFIGRET WINAPI CM_Create_DevNode_ExA(
812 PDEVINST pdnDevInst, DEVINSTID_A pDeviceID, DEVINST dnParent,
813 ULONG ulFlags, HANDLE hMachine)
814 {
815 DEVINSTID_W pDeviceIDW;
816 CONFIGRET ret;
817
818 TRACE("%p %s %p %lx %p\n",
819 pdnDevInst, debugstr_a(pDeviceID), dnParent, ulFlags, hMachine);
820
821 if (pSetupCaptureAndConvertAnsiArg(pDeviceID, &pDeviceIDW))
822 return CR_INVALID_DATA;
823
824 ret = CM_Create_DevNode_ExW(pdnDevInst, pDeviceIDW, dnParent, ulFlags,
825 hMachine);
826
827 MyFree(pDeviceIDW);
828
829 return ret;
830 }
831
832
833 /***********************************************************************
834 * CM_Create_DevNode_ExW [SETUPAPI.@]
835 */
836 CONFIGRET WINAPI CM_Create_DevNode_ExW(
837 PDEVINST pdnDevInst, DEVINSTID_W pDeviceID, DEVINST dnParent,
838 ULONG ulFlags, HANDLE hMachine)
839 {
840 RPC_BINDING_HANDLE BindingHandle = NULL;
841 HSTRING_TABLE StringTable = NULL;
842 LPWSTR lpParentDevInst;
843 CONFIGRET ret = CR_SUCCESS;
844 WCHAR szLocalDeviceID[MAX_DEVICE_ID_LEN];
845
846 TRACE("%p %s %p %lx %p\n",
847 pdnDevInst, debugstr_w(pDeviceID), dnParent, ulFlags, hMachine);
848
849 if (!pSetupIsUserAdmin())
850 return CR_ACCESS_DENIED;
851
852 if (pdnDevInst == NULL)
853 return CR_INVALID_POINTER;
854
855 if (pDeviceID == NULL || wcslen(pDeviceID) == 0 || wcslen(pDeviceID) >= MAX_DEVICE_ID_LEN)
856 return CR_INVALID_DEVICE_ID;
857
858 if (dnParent == 0)
859 return CR_INVALID_DEVNODE;
860
861 if (ulFlags & ~CM_CREATE_DEVNODE_BITS)
862 return CR_INVALID_FLAG;
863
864 if (hMachine != NULL)
865 {
866 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
867 if (BindingHandle == NULL)
868 return CR_FAILURE;
869
870 StringTable = ((PMACHINE_INFO)hMachine)->StringTable;
871 if (StringTable == 0)
872 return CR_FAILURE;
873 }
874 else
875 {
876 if (!PnpGetLocalHandles(&BindingHandle, &StringTable))
877 return CR_FAILURE;
878 }
879
880 lpParentDevInst = pSetupStringTableStringFromId(StringTable, dnParent);
881 if (lpParentDevInst == NULL)
882 return CR_INVALID_DEVNODE;
883
884 wcscpy(szLocalDeviceID, pDeviceID);
885
886 RpcTryExcept
887 {
888 ret = PNP_CreateDevInst(BindingHandle,
889 szLocalDeviceID,
890 lpParentDevInst,
891 MAX_DEVICE_ID_LEN,
892 ulFlags);
893 }
894 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
895 {
896 ret = RpcStatusToCmStatus(RpcExceptionCode());
897 }
898 RpcEndExcept;
899
900 if (ret == CR_SUCCESS)
901 {
902 /* If CM_CREATE_DEVINST_GENERATE_ID was passed in, PNP_CreateDevInst
903 * will return the generated device ID in szLocalDeviceID */
904 *pdnDevInst = pSetupStringTableAddString(StringTable, szLocalDeviceID, 1);
905 if (*pdnDevInst == 0)
906 ret = CR_NO_SUCH_DEVNODE;
907 }
908
909 return ret;
910 }
911
912
913 /***********************************************************************
914 * CM_Delete_Class_Key [SETUPAPI.@]
915 */
916 CONFIGRET WINAPI CM_Delete_Class_Key(
917 LPGUID ClassGuid, ULONG ulFlags)
918 {
919 TRACE("%p %lx\n", ClassGuid, ulFlags);
920 return CM_Delete_Class_Key_Ex(ClassGuid, ulFlags, NULL);
921 }
922
923
924 /***********************************************************************
925 * CM_Delete_Class_Key_Ex [SETUPAPI.@]
926 */
927 CONFIGRET WINAPI CM_Delete_Class_Key_Ex(
928 LPGUID ClassGuid, ULONG ulFlags, HANDLE hMachine)
929 {
930 WCHAR szGuidString[MAX_GUID_STRING_LEN];
931 RPC_BINDING_HANDLE BindingHandle = NULL;
932 CONFIGRET ret;
933
934 TRACE("%p %lx %lx\n", ClassGuid, ulFlags, hMachine);
935
936 if (ClassGuid == NULL)
937 return CR_INVALID_POINTER;
938
939 if (ulFlags & ~CM_DELETE_CLASS_BITS)
940 return CR_INVALID_FLAG;
941
942 if (!GuidToString(ClassGuid, szGuidString))
943 return CR_INVALID_DATA;
944
945 if (hMachine != NULL)
946 {
947 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
948 if (BindingHandle == NULL)
949 return CR_FAILURE;
950 }
951 else
952 {
953 if (!PnpGetLocalHandles(&BindingHandle, NULL))
954 return CR_FAILURE;
955 }
956
957 RpcTryExcept
958 {
959 ret = PNP_DeleteClassKey(BindingHandle,
960 szGuidString,
961 ulFlags);
962 }
963 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
964 {
965 ret = RpcStatusToCmStatus(RpcExceptionCode());
966 }
967 RpcEndExcept;
968
969 return ret;
970 }
971
972
973 /***********************************************************************
974 * CM_Delete_DevNode_Key [SETUPAPI.@]
975 */
976 CONFIGRET WINAPI CM_Delete_DevNode_Key(
977 DEVNODE dnDevNode, ULONG ulHardwareProfile, ULONG ulFlags)
978 {
979 TRACE("%p %lu %lx\n", dnDevNode, ulHardwareProfile, ulFlags);
980 return CM_Delete_DevNode_Key_Ex(dnDevNode, ulHardwareProfile, ulFlags,
981 NULL);
982 }
983
984
985 /***********************************************************************
986 * CM_Delete_DevNode_Key_Ex [SETUPAPI.@]
987 */
988 CONFIGRET WINAPI CM_Delete_DevNode_Key_Ex(
989 DEVNODE dnDevNode, ULONG ulHardwareProfile, ULONG ulFlags,
990 HANDLE hMachine)
991 {
992 FIXME("%p %lu %lx %p\n",
993 dnDevNode, ulHardwareProfile, ulFlags, hMachine);
994
995 return CR_CALL_NOT_IMPLEMENTED;
996 }
997
998
999 /***********************************************************************
1000 * CM_Disable_DevNode [SETUPAPI.@]
1001 */
1002 CONFIGRET WINAPI CM_Disable_DevNode(
1003 DEVINST dnDevInst, ULONG ulFlags)
1004 {
1005 TRACE("%p %lx\n", dnDevInst, ulFlags);
1006 return CM_Disable_DevNode_Ex(dnDevInst, ulFlags, NULL);
1007 }
1008
1009
1010 /***********************************************************************
1011 * CM_Disable_DevNode_Ex [SETUPAPI.@]
1012 */
1013 CONFIGRET WINAPI CM_Disable_DevNode_Ex(
1014 DEVINST dnDevInst, ULONG ulFlags, HMACHINE hMachine)
1015 {
1016 RPC_BINDING_HANDLE BindingHandle = NULL;
1017 HSTRING_TABLE StringTable = NULL;
1018 LPWSTR lpDevInst;
1019 CONFIGRET ret;
1020
1021 FIXME("%p %lx %p\n", dnDevInst, ulFlags, hMachine);
1022
1023 if (!pSetupIsUserAdmin())
1024 return CR_ACCESS_DENIED;
1025
1026 if (dnDevInst == 0)
1027 return CR_INVALID_DEVINST;
1028
1029 if (ulFlags != 0)
1030 return CR_INVALID_FLAG;
1031
1032 if (hMachine != NULL)
1033 {
1034 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
1035 if (BindingHandle == NULL)
1036 return CR_FAILURE;
1037
1038 StringTable = ((PMACHINE_INFO)hMachine)->StringTable;
1039 if (StringTable == 0)
1040 return CR_FAILURE;
1041 }
1042 else
1043 {
1044 if (!PnpGetLocalHandles(&BindingHandle, &StringTable))
1045 return CR_FAILURE;
1046 }
1047
1048 lpDevInst = pSetupStringTableStringFromId(StringTable, dnDevInst);
1049 if (lpDevInst == NULL)
1050 return CR_INVALID_DEVNODE;
1051
1052 RpcTryExcept
1053 {
1054 ret = PNP_DeviceInstanceAction(BindingHandle,
1055 PNP_DEVINST_DISABLE,
1056 ulFlags,
1057 lpDevInst,
1058 NULL);
1059 }
1060 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1061 {
1062 ret = RpcStatusToCmStatus(RpcExceptionCode());
1063 }
1064 RpcEndExcept;
1065
1066 return ret;
1067 }
1068
1069
1070 /***********************************************************************
1071 * CM_Disconnect_Machine [SETUPAPI.@]
1072 */
1073 CONFIGRET WINAPI CM_Disconnect_Machine(HMACHINE hMachine)
1074 {
1075 PMACHINE_INFO pMachine;
1076
1077 TRACE("%lx\n", hMachine);
1078
1079 pMachine = (PMACHINE_INFO)hMachine;
1080 if (pMachine == NULL)
1081 return CR_SUCCESS;
1082
1083 if (pMachine->bLocal == FALSE)
1084 {
1085 if (pMachine->StringTable != NULL)
1086 pSetupStringTableDestroy(pMachine->StringTable);
1087
1088 if (!PnpUnbindRpc(pMachine->BindingHandle))
1089 return CR_ACCESS_DENIED;
1090 }
1091
1092 HeapFree(GetProcessHeap(), 0, pMachine);
1093
1094 return CR_SUCCESS;
1095 }
1096
1097
1098 /***********************************************************************
1099 * CM_Enable_DevNode [SETUPAPI.@]
1100 */
1101 CONFIGRET WINAPI CM_Enable_DevNode(
1102 DEVINST dnDevInst, ULONG ulFlags)
1103 {
1104 TRACE("%p %lx\n", dnDevInst, ulFlags);
1105 return CM_Enable_DevNode_Ex(dnDevInst, ulFlags, NULL);
1106 }
1107
1108
1109 /***********************************************************************
1110 * CM_Enable_DevNode_Ex [SETUPAPI.@]
1111 */
1112 CONFIGRET WINAPI CM_Enable_DevNode_Ex(
1113 DEVINST dnDevInst, ULONG ulFlags, HMACHINE hMachine)
1114 {
1115 RPC_BINDING_HANDLE BindingHandle = NULL;
1116 HSTRING_TABLE StringTable = NULL;
1117 LPWSTR lpDevInst;
1118 CONFIGRET ret;
1119
1120 TRACE("%p %lx %p\n", dnDevInst, ulFlags, hMachine);
1121
1122 if (!pSetupIsUserAdmin())
1123 return CR_ACCESS_DENIED;
1124
1125 if (dnDevInst == 0)
1126 return CR_INVALID_DEVINST;
1127
1128 if (ulFlags != 0)
1129 return CR_INVALID_FLAG;
1130
1131 if (hMachine != NULL)
1132 {
1133 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
1134 if (BindingHandle == NULL)
1135 return CR_FAILURE;
1136
1137 StringTable = ((PMACHINE_INFO)hMachine)->StringTable;
1138 if (StringTable == 0)
1139 return CR_FAILURE;
1140 }
1141 else
1142 {
1143 if (!PnpGetLocalHandles(&BindingHandle, &StringTable))
1144 return CR_FAILURE;
1145 }
1146
1147 lpDevInst = pSetupStringTableStringFromId(StringTable, dnDevInst);
1148 if (lpDevInst == NULL)
1149 return CR_INVALID_DEVNODE;
1150
1151 RpcTryExcept
1152 {
1153 ret = PNP_DeviceInstanceAction(BindingHandle,
1154 PNP_DEVINST_ENABLE,
1155 ulFlags,
1156 lpDevInst,
1157 NULL);
1158 }
1159 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1160 {
1161 ret = RpcStatusToCmStatus(RpcExceptionCode());
1162 }
1163 RpcEndExcept;
1164
1165 return ret;
1166 }
1167
1168
1169 /***********************************************************************
1170 * CM_Enumerate_Classes [SETUPAPI.@]
1171 */
1172 CONFIGRET WINAPI CM_Enumerate_Classes(
1173 ULONG ulClassIndex, LPGUID ClassGuid, ULONG ulFlags)
1174 {
1175 TRACE("%lx %p %lx\n", ulClassIndex, ClassGuid, ulFlags);
1176 return CM_Enumerate_Classes_Ex(ulClassIndex, ClassGuid, ulFlags, NULL);
1177 }
1178
1179
1180 /***********************************************************************
1181 * CM_Enumerate_Classes_Ex [SETUPAPI.@]
1182 */
1183 CONFIGRET WINAPI CM_Enumerate_Classes_Ex(
1184 ULONG ulClassIndex, LPGUID ClassGuid, ULONG ulFlags, HMACHINE hMachine)
1185 {
1186 WCHAR szBuffer[MAX_GUID_STRING_LEN];
1187 RPC_BINDING_HANDLE BindingHandle = NULL;
1188 CONFIGRET ret = CR_SUCCESS;
1189 ULONG ulLength = MAX_GUID_STRING_LEN;
1190
1191 TRACE("%lx %p %lx %p\n", ulClassIndex, ClassGuid, ulFlags, hMachine);
1192
1193 if (ClassGuid == NULL)
1194 return CR_INVALID_POINTER;
1195
1196 if (ulFlags != 0)
1197 return CR_INVALID_FLAG;
1198
1199 if (hMachine != NULL)
1200 {
1201 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
1202 if (BindingHandle == NULL)
1203 return CR_FAILURE;
1204 }
1205 else
1206 {
1207 if (!PnpGetLocalHandles(&BindingHandle, NULL))
1208 return CR_FAILURE;
1209 }
1210
1211 RpcTryExcept
1212 {
1213 ret = PNP_EnumerateSubKeys(BindingHandle,
1214 PNP_CLASS_SUBKEYS,
1215 ulClassIndex,
1216 szBuffer,
1217 MAX_GUID_STRING_LEN,
1218 &ulLength,
1219 ulFlags);
1220 }
1221 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1222 {
1223 ret = RpcStatusToCmStatus(RpcExceptionCode());
1224 }
1225 RpcEndExcept;
1226
1227 if (ret == CR_SUCCESS)
1228 {
1229 /* Remove the {} */
1230 szBuffer[MAX_GUID_STRING_LEN - 2] = UNICODE_NULL;
1231
1232 /* Convert the buffer to a GUID */
1233 if (UuidFromStringW(&szBuffer[1], ClassGuid) != RPC_S_OK)
1234 return CR_FAILURE;
1235 }
1236
1237 return ret;
1238 }
1239
1240
1241 /***********************************************************************
1242 * CM_Enumerate_EnumeratorsA [SETUPAPI.@]
1243 */
1244 CONFIGRET WINAPI CM_Enumerate_EnumeratorsA(
1245 ULONG ulEnumIndex, PCHAR Buffer, PULONG pulLength, ULONG ulFlags)
1246 {
1247 TRACE("%lu %p %p %lx\n", ulEnumIndex, Buffer, pulLength, ulFlags);
1248 return CM_Enumerate_Enumerators_ExA(ulEnumIndex, Buffer, pulLength,
1249 ulFlags, NULL);
1250 }
1251
1252
1253 /***********************************************************************
1254 * CM_Enumerate_EnumeratorsW [SETUPAPI.@]
1255 */
1256 CONFIGRET WINAPI CM_Enumerate_EnumeratorsW(
1257 ULONG ulEnumIndex, PWCHAR Buffer, PULONG pulLength, ULONG ulFlags)
1258 {
1259 TRACE("%lu %p %p %lx\n", ulEnumIndex, Buffer, pulLength, ulFlags);
1260 return CM_Enumerate_Enumerators_ExW(ulEnumIndex, Buffer, pulLength,
1261 ulFlags, NULL);
1262 }
1263
1264
1265 /***********************************************************************
1266 * CM_Enumerate_Enumerators_ExA [SETUPAPI.@]
1267 */
1268 CONFIGRET WINAPI CM_Enumerate_Enumerators_ExA(
1269 ULONG ulEnumIndex, PCHAR Buffer, PULONG pulLength, ULONG ulFlags,
1270 HMACHINE hMachine)
1271 {
1272 WCHAR szBuffer[MAX_DEVICE_ID_LEN];
1273 ULONG ulOrigLength;
1274 ULONG ulLength;
1275 CONFIGRET ret = CR_SUCCESS;
1276
1277 TRACE("%lu %p %p %lx %lx\n", ulEnumIndex, Buffer, pulLength, ulFlags,
1278 hMachine);
1279
1280 if (Buffer == NULL || pulLength == NULL)
1281 return CR_INVALID_POINTER;
1282
1283 if (ulFlags != 0)
1284 return CR_INVALID_FLAG;
1285
1286 ulOrigLength = *pulLength;
1287 *pulLength = 0;
1288
1289 ulLength = MAX_DEVICE_ID_LEN;
1290 ret = CM_Enumerate_Enumerators_ExW(ulEnumIndex, szBuffer, &ulLength,
1291 ulFlags, hMachine);
1292 if (ret == CR_SUCCESS)
1293 {
1294 if (WideCharToMultiByte(CP_ACP,
1295 0,
1296 szBuffer,
1297 ulLength,
1298 Buffer,
1299 ulOrigLength,
1300 NULL,
1301 NULL) == 0)
1302 ret = CR_FAILURE;
1303 else
1304 *pulLength = lstrlenA(Buffer) + 1;
1305 }
1306
1307 return ret;
1308 }
1309
1310
1311 /***********************************************************************
1312 * CM_Enumerate_Enumerators_ExW [SETUPAPI.@]
1313 */
1314 CONFIGRET WINAPI CM_Enumerate_Enumerators_ExW(
1315 ULONG ulEnumIndex, PWCHAR Buffer, PULONG pulLength, ULONG ulFlags,
1316 HMACHINE hMachine)
1317 {
1318 RPC_BINDING_HANDLE BindingHandle = NULL;
1319 CONFIGRET ret;
1320
1321 TRACE("%lu %p %p %lx %lx\n", ulEnumIndex, Buffer, pulLength, ulFlags,
1322 hMachine);
1323
1324 if (Buffer == NULL || pulLength == NULL)
1325 return CR_INVALID_POINTER;
1326
1327 if (ulFlags != 0)
1328 return CR_INVALID_FLAG;
1329
1330 *Buffer = UNICODE_NULL;
1331
1332 if (hMachine != NULL)
1333 {
1334 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
1335 if (BindingHandle == NULL)
1336 return CR_FAILURE;
1337 }
1338 else
1339 {
1340 if (!PnpGetLocalHandles(&BindingHandle, NULL))
1341 return CR_FAILURE;
1342 }
1343
1344 RpcTryExcept
1345 {
1346 ret = PNP_EnumerateSubKeys(BindingHandle,
1347 PNP_ENUMERATOR_SUBKEYS,
1348 ulEnumIndex,
1349 Buffer,
1350 *pulLength,
1351 pulLength,
1352 ulFlags);
1353 }
1354 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1355 {
1356 ret = RpcStatusToCmStatus(RpcExceptionCode());
1357 }
1358 RpcEndExcept;
1359
1360 return ret;
1361 }
1362
1363
1364 /***********************************************************************
1365 * CM_Free_Log_Conf [SETUPAPI.@]
1366 */
1367 CONFIGRET WINAPI CM_Free_Log_Conf(
1368 LOG_CONF lcLogConfToBeFreed, ULONG ulFlags)
1369 {
1370 TRACE("%lx %lx\n", lcLogConfToBeFreed, ulFlags);
1371 return CM_Free_Log_Conf_Ex(lcLogConfToBeFreed, ulFlags, NULL);
1372 }
1373
1374
1375 /***********************************************************************
1376 * CM_Free_Log_Conf_Ex [SETUPAPI.@]
1377 */
1378 CONFIGRET WINAPI CM_Free_Log_Conf_Ex(
1379 LOG_CONF lcLogConfToBeFreed, ULONG ulFlags, HMACHINE hMachine)
1380 {
1381 RPC_BINDING_HANDLE BindingHandle = NULL;
1382 HSTRING_TABLE StringTable = NULL;
1383 LPWSTR lpDevInst;
1384 PLOG_CONF_INFO pLogConfInfo;
1385 CONFIGRET ret;
1386
1387 TRACE("%lx %lx %lx\n", lcLogConfToBeFreed, ulFlags, hMachine);
1388
1389 if (!pSetupIsUserAdmin())
1390 return CR_ACCESS_DENIED;
1391
1392 pLogConfInfo = (PLOG_CONF_INFO)lcLogConfToBeFreed;
1393 if (pLogConfInfo == NULL || pLogConfInfo->ulMagic != LOG_CONF_MAGIC)
1394 return CR_INVALID_LOG_CONF;
1395
1396 if (ulFlags != 0)
1397 return CR_INVALID_FLAG;
1398
1399 if (hMachine != NULL)
1400 {
1401 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
1402 if (BindingHandle == NULL)
1403 return CR_FAILURE;
1404
1405 StringTable = ((PMACHINE_INFO)hMachine)->StringTable;
1406 if (StringTable == 0)
1407 return CR_FAILURE;
1408 }
1409 else
1410 {
1411 if (!PnpGetLocalHandles(&BindingHandle, &StringTable))
1412 return CR_FAILURE;
1413 }
1414
1415 lpDevInst = pSetupStringTableStringFromId(StringTable, pLogConfInfo->dnDevInst);
1416 if (lpDevInst == NULL)
1417 return CR_INVALID_DEVNODE;
1418
1419 RpcTryExcept
1420 {
1421 ret = PNP_FreeLogConf(BindingHandle, lpDevInst, pLogConfInfo->ulFlags,
1422 pLogConfInfo->ulTag, 0);
1423 }
1424 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1425 {
1426 ret = RpcStatusToCmStatus(RpcExceptionCode());
1427 }
1428 RpcEndExcept;
1429
1430 return ret;
1431 }
1432
1433
1434 /***********************************************************************
1435 * CM_Free_Log_Conf_Handle [SETUPAPI.@]
1436 */
1437 CONFIGRET WINAPI CM_Free_Log_Conf_Handle(
1438 LOG_CONF lcLogConf)
1439 {
1440 PLOG_CONF_INFO pLogConfInfo;
1441
1442 TRACE("%lx\n", lcLogConf);
1443
1444 pLogConfInfo = (PLOG_CONF_INFO)lcLogConf;
1445 if (pLogConfInfo == NULL || pLogConfInfo->ulMagic != LOG_CONF_MAGIC)
1446 return CR_INVALID_LOG_CONF;
1447
1448 HeapFree(GetProcessHeap(), 0, pLogConfInfo);
1449
1450 return CR_SUCCESS;
1451 }
1452
1453
1454 /***********************************************************************
1455 * CM_Free_Res_Des [SETUPAPI.@]
1456 */
1457 CONFIGRET WINAPI CM_Free_Res_Des(
1458 PRES_DES prdResDes, RES_DES rdResDes, ULONG ulFlags)
1459 {
1460 TRACE("%p %p %lx\n", prdResDes, rdResDes, ulFlags);
1461 return CM_Free_Res_Des_Ex(prdResDes, rdResDes, ulFlags, NULL);
1462 }
1463
1464
1465 /***********************************************************************
1466 * CM_Free_Res_Des_Ex [SETUPAPI.@]
1467 */
1468 CONFIGRET WINAPI CM_Free_Res_Des_Ex(
1469 PRES_DES prdResDes, RES_DES rdResDes, ULONG ulFlags,
1470 HMACHINE hMachine)
1471 {
1472 FIXME("%p %p %lx %lx\n", prdResDes, rdResDes, ulFlags, hMachine);
1473
1474 return CR_CALL_NOT_IMPLEMENTED;
1475 }
1476
1477
1478 /***********************************************************************
1479 * CM_Free_Res_Des_Handle [SETUPAPI.@]
1480 */
1481 CONFIGRET WINAPI CM_Free_Res_Des_Handle(
1482 RES_DES rdResDes)
1483 {
1484 FIXME("%p\n", rdResDes);
1485
1486 return CR_CALL_NOT_IMPLEMENTED;
1487 }
1488
1489
1490 /***********************************************************************
1491 * CM_Get_Child [SETUPAPI.@]
1492 */
1493 CONFIGRET WINAPI CM_Get_Child(
1494 PDEVINST pdnDevInst, DEVINST dnDevInst, ULONG ulFlags)
1495 {
1496 TRACE("%p %p %lx\n", pdnDevInst, dnDevInst, ulFlags);
1497 return CM_Get_Child_Ex(pdnDevInst, dnDevInst, ulFlags, NULL);
1498 }
1499
1500
1501 /***********************************************************************
1502 * CM_Get_Child_Ex [SETUPAPI.@]
1503 */
1504 CONFIGRET WINAPI CM_Get_Child_Ex(
1505 PDEVINST pdnDevInst, DEVINST dnDevInst, ULONG ulFlags, HMACHINE hMachine)
1506 {
1507 WCHAR szRelatedDevInst[MAX_DEVICE_ID_LEN];
1508 RPC_BINDING_HANDLE BindingHandle = NULL;
1509 HSTRING_TABLE StringTable = NULL;
1510 LPWSTR lpDevInst;
1511 DWORD dwIndex, dwLength = MAX_DEVICE_ID_LEN;
1512 CONFIGRET ret;
1513
1514 TRACE("%p %lx %lx %lx\n", pdnDevInst, dnDevInst, ulFlags, hMachine);
1515
1516 if (pdnDevInst == NULL)
1517 return CR_INVALID_POINTER;
1518
1519 if (dnDevInst == 0)
1520 return CR_INVALID_DEVINST;
1521
1522 if (ulFlags != 0)
1523 return CR_INVALID_FLAG;
1524
1525 *pdnDevInst = -1;
1526
1527 if (hMachine != NULL)
1528 {
1529 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
1530 if (BindingHandle == NULL)
1531 return CR_FAILURE;
1532
1533 StringTable = ((PMACHINE_INFO)hMachine)->StringTable;
1534 if (StringTable == 0)
1535 return CR_FAILURE;
1536 }
1537 else
1538 {
1539 if (!PnpGetLocalHandles(&BindingHandle, &StringTable))
1540 return CR_FAILURE;
1541 }
1542
1543 lpDevInst = pSetupStringTableStringFromId(StringTable, dnDevInst);
1544 if (lpDevInst == NULL)
1545 return CR_INVALID_DEVNODE;
1546
1547 RpcTryExcept
1548 {
1549 ret = PNP_GetRelatedDeviceInstance(BindingHandle,
1550 PNP_GET_CHILD_DEVICE_INSTANCE,
1551 lpDevInst,
1552 szRelatedDevInst,
1553 &dwLength,
1554 0);
1555 }
1556 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1557 {
1558 ret = RpcStatusToCmStatus(RpcExceptionCode());
1559 }
1560 RpcEndExcept;
1561
1562 if (ret != CR_SUCCESS)
1563 return ret;
1564
1565 TRACE("szRelatedDevInst: %s\n", debugstr_w(szRelatedDevInst));
1566
1567 dwIndex = pSetupStringTableAddString(StringTable, szRelatedDevInst, 1);
1568 if (dwIndex == -1)
1569 return CR_FAILURE;
1570
1571 *pdnDevInst = dwIndex;
1572
1573 return CR_SUCCESS;
1574 }
1575
1576
1577 /***********************************************************************
1578 * CM_Get_Class_Key_NameA [SETUPAPI.@]
1579 */
1580 CONFIGRET WINAPI CM_Get_Class_Key_NameA(
1581 LPGUID ClassGuid, LPSTR pszKeyName, PULONG pulLength, ULONG ulFlags)
1582 {
1583 TRACE("%p %p %p %lx\n",
1584 ClassGuid, pszKeyName, pulLength, ulFlags);
1585 return CM_Get_Class_Key_Name_ExA(ClassGuid, pszKeyName, pulLength,
1586 ulFlags, NULL);
1587 }
1588
1589
1590 /***********************************************************************
1591 * CM_Get_Class_Key_NameW [SETUPAPI.@]
1592 */
1593 CONFIGRET WINAPI CM_Get_Class_Key_NameW(
1594 LPGUID ClassGuid, LPWSTR pszKeyName, PULONG pulLength, ULONG ulFlags)
1595 {
1596 TRACE("%p %p %p %lx\n",
1597 ClassGuid, pszKeyName, pulLength, ulFlags);
1598 return CM_Get_Class_Key_Name_ExW(ClassGuid, pszKeyName, pulLength,
1599 ulFlags, NULL);
1600 }
1601
1602
1603 /***********************************************************************
1604 * CM_Get_Class_Key_Name_ExA [SETUPAPI.@]
1605 */
1606 CONFIGRET WINAPI CM_Get_Class_Key_Name_ExA(
1607 LPGUID ClassGuid, LPSTR pszKeyName, PULONG pulLength, ULONG ulFlags,
1608 HMACHINE hMachine)
1609 {
1610 WCHAR szBuffer[MAX_GUID_STRING_LEN];
1611 CONFIGRET ret = CR_SUCCESS;
1612 ULONG ulLength;
1613 ULONG ulOrigLength;
1614
1615 TRACE("%p %p %p %lx %lx\n",
1616 ClassGuid, pszKeyName, pulLength, ulFlags, hMachine);
1617
1618 if (ClassGuid == NULL || pszKeyName == NULL || pulLength == NULL)
1619 return CR_INVALID_POINTER;
1620
1621 ulOrigLength = *pulLength;
1622 *pulLength = 0;
1623
1624 ulLength = MAX_GUID_STRING_LEN;
1625 ret = CM_Get_Class_Key_Name_ExW(ClassGuid, szBuffer, &ulLength,
1626 ulFlags, hMachine);
1627 if (ret == CR_SUCCESS)
1628 {
1629 if (WideCharToMultiByte(CP_ACP,
1630 0,
1631 szBuffer,
1632 ulLength,
1633 pszKeyName,
1634 ulOrigLength,
1635 NULL,
1636 NULL) == 0)
1637 ret = CR_FAILURE;
1638 else
1639 *pulLength = lstrlenA(pszKeyName) + 1;
1640 }
1641
1642 return CR_SUCCESS;
1643 }
1644
1645
1646 /***********************************************************************
1647 * CM_Get_Class_Key_Name_ExW [SETUPAPI.@]
1648 */
1649 CONFIGRET WINAPI CM_Get_Class_Key_Name_ExW(
1650 LPGUID ClassGuid, LPWSTR pszKeyName, PULONG pulLength, ULONG ulFlags,
1651 HMACHINE hMachine)
1652 {
1653 TRACE("%p %p %p %lx %lx\n",
1654 ClassGuid, pszKeyName, pulLength, ulFlags, hMachine);
1655
1656 if (ClassGuid == NULL || pszKeyName == NULL || pulLength == NULL)
1657 return CR_INVALID_POINTER;
1658
1659 if (ulFlags != 0)
1660 return CR_INVALID_FLAG;
1661
1662 if (*pulLength < MAX_GUID_STRING_LEN)
1663 {
1664 *pulLength = 0;
1665 return CR_BUFFER_SMALL;
1666 }
1667
1668 if (!GuidToString(ClassGuid, pszKeyName))
1669 return CR_INVALID_DATA;
1670
1671 *pulLength = MAX_GUID_STRING_LEN;
1672
1673 return CR_SUCCESS;
1674 }
1675
1676
1677 /***********************************************************************
1678 * CM_Get_Class_NameA [SETUPAPI.@]
1679 */
1680 CONFIGRET WINAPI CM_Get_Class_NameA(
1681 LPGUID ClassGuid, PCHAR Buffer, PULONG pulLength, ULONG ulFlags)
1682 {
1683 TRACE("%p %p %p %lx\n", ClassGuid, Buffer, pulLength, ulFlags);
1684 return CM_Get_Class_Name_ExA(ClassGuid, Buffer, pulLength, ulFlags,
1685 NULL);
1686 }
1687
1688
1689 /***********************************************************************
1690 * CM_Get_Class_NameW [SETUPAPI.@]
1691 */
1692 CONFIGRET WINAPI CM_Get_Class_NameW(
1693 LPGUID ClassGuid, PWCHAR Buffer, PULONG pulLength, ULONG ulFlags)
1694 {
1695 TRACE("%p %p %p %lx\n", ClassGuid, Buffer, pulLength, ulFlags);
1696 return CM_Get_Class_Name_ExW(ClassGuid, Buffer, pulLength, ulFlags,
1697 NULL);
1698 }
1699
1700
1701 /***********************************************************************
1702 * CM_Get_Class_Name_ExA [SETUPAPI.@]
1703 */
1704 CONFIGRET WINAPI CM_Get_Class_Name_ExA(
1705 LPGUID ClassGuid, PCHAR Buffer, PULONG pulLength, ULONG ulFlags,
1706 HMACHINE hMachine)
1707 {
1708 WCHAR szBuffer[MAX_CLASS_NAME_LEN];
1709 CONFIGRET ret = CR_SUCCESS;
1710 ULONG ulLength;
1711 ULONG ulOrigLength;
1712
1713 TRACE("%p %p %p %lx %lx\n",
1714 ClassGuid, Buffer, pulLength, ulFlags, hMachine);
1715
1716 if (ClassGuid == NULL || Buffer == NULL || pulLength == NULL)
1717 return CR_INVALID_POINTER;
1718
1719 ulOrigLength = *pulLength;
1720 *pulLength = 0;
1721
1722 ulLength = MAX_CLASS_NAME_LEN;
1723 ret = CM_Get_Class_Name_ExW(ClassGuid, szBuffer, &ulLength,
1724 ulFlags, hMachine);
1725 if (ret == CR_SUCCESS)
1726 {
1727 if (WideCharToMultiByte(CP_ACP,
1728 0,
1729 szBuffer,
1730 ulLength,
1731 Buffer,
1732 ulOrigLength,
1733 NULL,
1734 NULL) == 0)
1735 ret = CR_FAILURE;
1736 else
1737 *pulLength = lstrlenA(Buffer) + 1;
1738 }
1739
1740 return ret;
1741 }
1742
1743
1744 /***********************************************************************
1745 * CM_Get_Class_Name_ExW [SETUPAPI.@]
1746 */
1747 CONFIGRET WINAPI
1748 CM_Get_Class_Name_ExW(
1749 LPGUID ClassGuid, PWCHAR Buffer, PULONG pulLength, ULONG ulFlags,
1750 HMACHINE hMachine)
1751 {
1752 WCHAR szGuidString[MAX_GUID_STRING_LEN];
1753 RPC_BINDING_HANDLE BindingHandle = NULL;
1754 CONFIGRET ret;
1755
1756 TRACE("%p %p %p %lx %lx\n",
1757 ClassGuid, Buffer, pulLength, ulFlags, hMachine);
1758
1759 if (ClassGuid == NULL || Buffer == NULL || pulLength == NULL)
1760 return CR_INVALID_POINTER;
1761
1762 if (ulFlags != 0)
1763 return CR_INVALID_FLAG;
1764
1765 if (!GuidToString(ClassGuid, szGuidString))
1766 return CR_INVALID_DATA;
1767
1768 TRACE("Guid %s\n", debugstr_w(szGuidString));
1769
1770 if (hMachine != NULL)
1771 {
1772 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
1773 if (BindingHandle == NULL)
1774 return CR_FAILURE;
1775 }
1776 else
1777 {
1778 if (!PnpGetLocalHandles(&BindingHandle, NULL))
1779 return CR_FAILURE;
1780 }
1781
1782 RpcTryExcept
1783 {
1784 ret = PNP_GetClassName(BindingHandle,
1785 szGuidString,
1786 Buffer,
1787 pulLength,
1788 ulFlags);
1789 }
1790 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1791 {
1792 ret = RpcStatusToCmStatus(RpcExceptionCode());
1793 }
1794 RpcEndExcept;
1795
1796 return ret;
1797 }
1798
1799
1800 /***********************************************************************
1801 * CM_Get_Class_Registry_PropertyA [SETUPAPI.@]
1802 */
1803 CONFIGRET WINAPI CM_Get_Class_Registry_PropertyA(
1804 LPGUID ClassGuid, ULONG ulProperty, PULONG pulRegDataType,
1805 PVOID Buffer, PULONG pulLength, ULONG ulFlags, HMACHINE hMachine)
1806 {
1807 PWSTR BufferW = NULL;
1808 ULONG ulLength = 0;
1809 ULONG ulType;
1810 CONFIGRET ret;
1811
1812 TRACE("%p %lu %p %p %p %lx %lx\n",
1813 ClassGuid, ulProperty, pulRegDataType, Buffer, pulLength,
1814 ulFlags, hMachine);
1815
1816 if (pulLength == NULL)
1817 return CR_INVALID_POINTER;
1818
1819 if (ulProperty < CM_CRP_MIN || ulProperty > CM_CRP_MAX)
1820 return CR_INVALID_PROPERTY;
1821
1822 ulType = GetRegistryPropertyType(ulProperty);
1823 if (ulType == REG_SZ || ulType == REG_MULTI_SZ)
1824 {
1825 /* Get the required buffer size */
1826 ret = CM_Get_Class_Registry_PropertyW(ClassGuid, ulProperty, pulRegDataType,
1827 NULL, &ulLength, ulFlags, hMachine);
1828 if (ret != CR_BUFFER_SMALL)
1829 return ret;
1830
1831 /* Allocate the unicode buffer */
1832 BufferW = HeapAlloc(GetProcessHeap(), 0, ulLength);
1833 if (BufferW == NULL)
1834 return CR_OUT_OF_MEMORY;
1835
1836 /* Get the property */
1837 ret = CM_Get_Class_Registry_PropertyW(ClassGuid, ulProperty, pulRegDataType,
1838 BufferW, &ulLength, ulFlags, hMachine);
1839 if (ret != CR_SUCCESS)
1840 {
1841 HeapFree(GetProcessHeap(), 0, BufferW);
1842 return ret;
1843 }
1844
1845 /* Do W->A conversion */
1846 *pulLength = WideCharToMultiByte(CP_ACP,
1847 0,
1848 BufferW,
1849 lstrlenW(BufferW) + 1,
1850 Buffer,
1851 *pulLength,
1852 NULL,
1853 NULL);
1854
1855 /* Release the unicode buffer */
1856 HeapFree(GetProcessHeap(), 0, BufferW);
1857
1858 if (*pulLength == 0)
1859 ret = CR_FAILURE;
1860 }
1861 else
1862 {
1863 /* Get the property */
1864 ret = CM_Get_Class_Registry_PropertyW(ClassGuid, ulProperty, pulRegDataType,
1865 Buffer, pulLength, ulFlags, hMachine);
1866 }
1867
1868 return ret;
1869 }
1870
1871
1872 /***********************************************************************
1873 * CM_Get_Class_Registry_PropertyW [SETUPAPI.@]
1874 */
1875 CONFIGRET WINAPI CM_Get_Class_Registry_PropertyW(
1876 LPGUID ClassGuid, ULONG ulProperty, PULONG pulRegDataType,
1877 PVOID Buffer, PULONG pulLength, ULONG ulFlags, HMACHINE hMachine)
1878 {
1879 RPC_BINDING_HANDLE BindingHandle = NULL;
1880 WCHAR szGuidString[PNP_MAX_GUID_STRING_LEN + 1];
1881 ULONG ulType = 0;
1882 ULONG ulTransferLength = 0;
1883 CONFIGRET ret;
1884
1885 TRACE("%p %lu %p %p %p %lx %lx\n",
1886 ClassGuid, ulProperty, pulRegDataType, Buffer, pulLength,
1887 ulFlags, hMachine);
1888
1889 if (ClassGuid == NULL || pulLength == NULL)
1890 return CR_INVALID_POINTER;
1891
1892 if (ulFlags != 0)
1893 return CR_INVALID_FLAG;
1894
1895 if (pSetupStringFromGuid(ClassGuid,
1896 szGuidString,
1897 PNP_MAX_GUID_STRING_LEN) != 0)
1898 return CR_INVALID_DATA;
1899
1900 if (ulProperty < CM_CRP_MIN || ulProperty > CM_CRP_MAX)
1901 return CR_INVALID_PROPERTY;
1902
1903 if (hMachine != NULL)
1904 {
1905 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
1906 if (BindingHandle == NULL)
1907 return CR_FAILURE;
1908 }
1909 else
1910 {
1911 if (!PnpGetLocalHandles(&BindingHandle, NULL))
1912 return CR_FAILURE;
1913 }
1914
1915 ulTransferLength = *pulLength;
1916
1917 RpcTryExcept
1918 {
1919 ret = PNP_GetClassRegProp(BindingHandle,
1920 szGuidString,
1921 ulProperty,
1922 &ulType,
1923 Buffer,
1924 &ulTransferLength,
1925 pulLength,
1926 ulFlags);
1927 }
1928 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1929 {
1930 ret = RpcStatusToCmStatus(RpcExceptionCode());
1931 }
1932 RpcEndExcept;
1933
1934 if (ret == CR_SUCCESS)
1935 {
1936 if (pulRegDataType != NULL)
1937 *pulRegDataType = ulType;
1938 }
1939
1940 return ret;
1941 }
1942
1943
1944 /***********************************************************************
1945 * CM_Get_Depth [SETUPAPI.@]
1946 */
1947 CONFIGRET WINAPI CM_Get_Depth(
1948 PULONG pulDepth, DEVINST dnDevInst, ULONG ulFlags)
1949 {
1950 TRACE("%p %lx %lx\n", pulDepth, dnDevInst, ulFlags);
1951 return CM_Get_Depth_Ex(pulDepth, dnDevInst, ulFlags, NULL);
1952 }
1953
1954
1955 /***********************************************************************
1956 * CM_Get_Depth_Ex [SETUPAPI.@]
1957 */
1958 CONFIGRET WINAPI CM_Get_Depth_Ex(
1959 PULONG pulDepth, DEVINST dnDevInst, ULONG ulFlags, HMACHINE hMachine)
1960 {
1961 RPC_BINDING_HANDLE BindingHandle = NULL;
1962 HSTRING_TABLE StringTable = NULL;
1963 LPWSTR lpDevInst;
1964 CONFIGRET ret;
1965
1966 TRACE("%p %lx %lx %lx\n",
1967 pulDepth, dnDevInst, ulFlags, hMachine);
1968
1969 if (pulDepth == NULL)
1970 return CR_INVALID_POINTER;
1971
1972 if (dnDevInst == 0)
1973 return CR_INVALID_DEVINST;
1974
1975 if (ulFlags != 0)
1976 return CR_INVALID_FLAG;
1977
1978 if (hMachine != NULL)
1979 {
1980 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
1981 if (BindingHandle == NULL)
1982 return CR_FAILURE;
1983
1984 StringTable = ((PMACHINE_INFO)hMachine)->StringTable;
1985 if (StringTable == 0)
1986 return CR_FAILURE;
1987 }
1988 else
1989 {
1990 if (!PnpGetLocalHandles(&BindingHandle, &StringTable))
1991 return CR_FAILURE;
1992 }
1993
1994 lpDevInst = pSetupStringTableStringFromId(StringTable, dnDevInst);
1995 if (lpDevInst == NULL)
1996 return CR_INVALID_DEVNODE;
1997
1998 RpcTryExcept
1999 {
2000 ret = PNP_GetDepth(BindingHandle,
2001 lpDevInst,
2002 pulDepth,
2003 ulFlags);
2004 }
2005 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
2006 {
2007 ret = RpcStatusToCmStatus(RpcExceptionCode());
2008 }
2009 RpcEndExcept;
2010
2011 return ret;
2012 }
2013
2014
2015 /***********************************************************************
2016 * CM_Get_DevNode_Custom_PropertyA [SETUPAPI.@]
2017 */
2018 CONFIGRET WINAPI CM_Get_DevNode_Custom_PropertyA(
2019 DEVINST dnDevInst, PCSTR pszCustomPropertyName, PULONG pulRegDataType,
2020 PVOID Buffer, PULONG pulLength, ULONG ulFlags)
2021 {
2022 TRACE("%lx %s %p %p %p %lx\n", dnDevInst, pszCustomPropertyName,
2023 pulRegDataType, Buffer, pulLength, ulFlags);
2024 return CM_Get_DevNode_Custom_Property_ExA(dnDevInst, pszCustomPropertyName,
2025 pulRegDataType, Buffer,
2026 pulLength, ulFlags, NULL);
2027 }
2028
2029
2030 /***********************************************************************
2031 * CM_Get_DevNode_Custom_PropertyW [SETUPAPI.@]
2032 */
2033 CONFIGRET WINAPI CM_Get_DevNode_Custom_PropertyW(
2034 DEVINST dnDevInst, PCWSTR pszCustomPropertyName, PULONG pulRegDataType,
2035 PVOID Buffer, PULONG pulLength, ULONG ulFlags)
2036 {
2037 TRACE("%lx %s %p %p %p %lx\n", dnDevInst, debugstr_w(pszCustomPropertyName),
2038 pulRegDataType, Buffer, pulLength, ulFlags);
2039 return CM_Get_DevNode_Custom_Property_ExW(dnDevInst, pszCustomPropertyName,
2040 pulRegDataType, Buffer,
2041 pulLength, ulFlags, NULL);
2042 }
2043
2044
2045 /***********************************************************************
2046 * CM_Get_DevNode_Custom_Property_ExA [SETUPAPI.@]
2047 */
2048 CONFIGRET WINAPI CM_Get_DevNode_Custom_Property_ExA(
2049 DEVINST dnDevInst, PCSTR pszCustomPropertyName, PULONG pulRegDataType,
2050 PVOID Buffer, PULONG pulLength, ULONG ulFlags, HMACHINE hMachine)
2051 {
2052 LPWSTR pszPropertyNameW = NULL;
2053 PVOID BufferW;
2054 ULONG ulLengthW;
2055 ULONG ulDataType = REG_NONE;
2056 CONFIGRET ret;
2057
2058 TRACE("%lx %s %p %p %p %lx %p\n", dnDevInst, pszCustomPropertyName,
2059 pulRegDataType, Buffer, pulLength, ulFlags, hMachine);
2060
2061 if (!pulLength)
2062 return CR_INVALID_POINTER;
2063
2064 ulLengthW = *pulLength * sizeof(WCHAR);
2065 BufferW = HeapAlloc(GetProcessHeap(), 0, ulLengthW);
2066 if (!BufferW)
2067 return CR_OUT_OF_MEMORY;
2068
2069 pszPropertyNameW = pSetupMultiByteToUnicode(pszCustomPropertyName,
2070 CP_ACP);
2071 if (pszPropertyNameW == NULL)
2072 {
2073 HeapFree(GetProcessHeap(), 0, BufferW);
2074 return CR_OUT_OF_MEMORY;
2075 }
2076
2077 ret = CM_Get_DevNode_Custom_Property_ExW(dnDevInst,
2078 pszPropertyNameW,
2079 &ulDataType,
2080 BufferW,
2081 &ulLengthW,
2082 ulFlags,
2083 hMachine);
2084 if (ret == CR_SUCCESS)
2085 {
2086 if (ulDataType == REG_SZ ||
2087 ulDataType == REG_EXPAND_SZ ||
2088 ulDataType == REG_MULTI_SZ)
2089 {
2090 /* Do W->A conversion */
2091 *pulLength = WideCharToMultiByte(CP_ACP,
2092 0,
2093 BufferW,
2094 lstrlenW(BufferW) + 1,
2095 Buffer,
2096 *pulLength,
2097 NULL,
2098 NULL);
2099 if (*pulLength == 0)
2100 ret = CR_FAILURE;
2101 }
2102 else
2103 {
2104 /* Directly copy the value */
2105 if (ulLengthW <= *pulLength)
2106 memcpy(Buffer, BufferW, ulLengthW);
2107 else
2108 {
2109 *pulLength = ulLengthW;
2110 ret = CR_BUFFER_SMALL;
2111 }
2112 }
2113 }
2114
2115 if (pulRegDataType)
2116 *pulRegDataType = ulDataType;
2117
2118 HeapFree(GetProcessHeap(), 0, BufferW);
2119 MyFree(pszPropertyNameW);
2120
2121 return ret;
2122 }
2123
2124
2125 /***********************************************************************
2126 * CM_Get_DevNode_Custom_Property_ExW [SETUPAPI.@]
2127 */
2128 CONFIGRET WINAPI CM_Get_DevNode_Custom_Property_ExW(
2129 DEVINST dnDevInst, PCWSTR pszCustomPropertyName, PULONG pulRegDataType,
2130 PVOID Buffer, PULONG pulLength, ULONG ulFlags, HMACHINE hMachine)
2131 {
2132 RPC_BINDING_HANDLE BindingHandle = NULL;
2133 HSTRING_TABLE StringTable = NULL;
2134 LPWSTR lpDevInst;
2135 ULONG ulDataType = REG_NONE;
2136 ULONG ulTransferLength;
2137 CONFIGRET ret = CR_SUCCESS;
2138
2139 TRACE("%lx %s %p %p %p %lx %p\n", dnDevInst,
2140 debugstr_w(pszCustomPropertyName), pulRegDataType, Buffer,
2141 pulLength, ulFlags, hMachine);
2142
2143 if (dnDevInst == 0)
2144 return CR_INVALID_DEVNODE;
2145
2146 if (pszCustomPropertyName == NULL ||
2147 pulLength == NULL ||
2148 *pulLength == 0)
2149 return CR_INVALID_POINTER;
2150
2151 if (ulFlags & ~CM_CUSTOMDEVPROP_BITS)
2152 return CR_INVALID_FLAG;
2153
2154 if (hMachine != NULL)
2155 {
2156 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
2157 if (BindingHandle == NULL)
2158 return CR_FAILURE;
2159
2160 StringTable = ((PMACHINE_INFO)hMachine)->StringTable;
2161 if (StringTable == 0)
2162 return CR_FAILURE;
2163 }
2164 else
2165 {
2166 if (!PnpGetLocalHandles(&BindingHandle, &StringTable))
2167 return CR_FAILURE;
2168 }
2169
2170 lpDevInst = pSetupStringTableStringFromId(StringTable, dnDevInst);
2171 if (lpDevInst == NULL)
2172 return CR_INVALID_DEVNODE;
2173
2174 ulTransferLength = *pulLength;
2175
2176 RpcTryExcept
2177 {
2178 ret = PNP_GetCustomDevProp(BindingHandle,
2179 lpDevInst,
2180 (LPWSTR)pszCustomPropertyName,
2181 &ulDataType,
2182 Buffer,
2183 &ulTransferLength,
2184 pulLength,
2185 ulFlags);
2186 }
2187 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
2188 {
2189 ret = RpcStatusToCmStatus(RpcExceptionCode());
2190 }
2191 RpcEndExcept;
2192
2193 if (ret == CR_SUCCESS)
2194 {
2195 if (pulRegDataType != NULL)
2196 *pulRegDataType = ulDataType;
2197 }
2198
2199 return ret;
2200 }
2201
2202
2203 /***********************************************************************
2204 * CM_Get_DevNode_Registry_PropertyA [SETUPAPI.@]
2205 */
2206 CONFIGRET WINAPI CM_Get_DevNode_Registry_PropertyA(
2207 DEVINST dnDevInst, ULONG ulProperty, PULONG pulRegDataType,
2208 PVOID Buffer, PULONG pulLength, ULONG ulFlags)
2209 {
2210 TRACE("%lx %lu %p %p %p %lx\n",
2211 dnDevInst, ulProperty, pulRegDataType, Buffer, pulLength, ulFlags);
2212
2213 return CM_Get_DevNode_Registry_Property_ExA(dnDevInst, ulProperty,
2214 pulRegDataType, Buffer,
2215 pulLength, ulFlags, NULL);
2216 }
2217
2218
2219 /***********************************************************************
2220 * CM_Get_DevNode_Registry_PropertyW [SETUPAPI.@]
2221 */
2222 CONFIGRET WINAPI CM_Get_DevNode_Registry_PropertyW(
2223 DEVINST dnDevInst, ULONG ulProperty, PULONG pulRegDataType,
2224 PVOID Buffer, PULONG pulLength, ULONG ulFlags)
2225 {
2226 TRACE("%lx %lu %p %p %p %lx\n",
2227 dnDevInst, ulProperty, pulRegDataType, Buffer, pulLength, ulFlags);
2228
2229 return CM_Get_DevNode_Registry_Property_ExW(dnDevInst, ulProperty,
2230 pulRegDataType, Buffer,
2231 pulLength, ulFlags, NULL);
2232 }
2233
2234
2235 /***********************************************************************
2236 * CM_Get_DevNode_Registry_Property_ExA [SETUPAPI.@]
2237 */
2238 CONFIGRET WINAPI CM_Get_DevNode_Registry_Property_ExA(
2239 DEVINST dnDevInst, ULONG ulProperty, PULONG pulRegDataType,
2240 PVOID Buffer, PULONG pulLength, ULONG ulFlags, HMACHINE hMachine)
2241 {
2242 PVOID BufferW;
2243 ULONG LengthW;
2244 ULONG ulDataType = REG_NONE;
2245 CONFIGRET ret;
2246
2247 TRACE("%lx %lu %p %p %p %lx %lx\n",
2248 dnDevInst, ulProperty, pulRegDataType, Buffer, pulLength,
2249 ulFlags, hMachine);
2250
2251 if (!pulLength)
2252 return CR_INVALID_POINTER;
2253
2254 LengthW = *pulLength * sizeof(WCHAR);
2255 BufferW = HeapAlloc(GetProcessHeap(), 0, LengthW);
2256
2257 if (!BufferW)
2258 return CR_OUT_OF_MEMORY;
2259
2260 ret = CM_Get_DevNode_Registry_Property_ExW(dnDevInst,
2261 ulProperty,
2262 &ulDataType,
2263 BufferW,
2264 &LengthW,
2265 ulFlags,
2266 hMachine);
2267
2268 if (ret == CR_SUCCESS)
2269 {
2270 if (ulDataType == REG_SZ ||
2271 ulDataType == REG_EXPAND_SZ ||
2272 ulDataType == REG_MULTI_SZ)
2273 {
2274 /* Do W->A conversion */
2275 *pulLength = WideCharToMultiByte(CP_ACP,
2276 0,
2277 BufferW,
2278 lstrlenW(BufferW) + 1,
2279 Buffer,
2280 *pulLength,
2281 NULL,
2282 NULL);
2283 if (*pulLength == 0)
2284 ret = CR_FAILURE;
2285 }
2286 else
2287 {
2288 /* Directly copy the value */
2289 if (LengthW <= *pulLength)
2290 memcpy(Buffer, BufferW, LengthW);
2291 else
2292 {
2293 *pulLength = LengthW;
2294 ret = CR_BUFFER_SMALL;
2295 }
2296 }
2297 }
2298
2299 if (pulRegDataType)
2300 *pulRegDataType = ulDataType;
2301
2302 HeapFree(GetProcessHeap(), 0, BufferW);
2303
2304 return ret;
2305 }
2306
2307
2308 /***********************************************************************
2309 * CM_Get_DevNode_Registry_Property_ExW [SETUPAPI.@]
2310 */
2311 CONFIGRET WINAPI CM_Get_DevNode_Registry_Property_ExW(
2312 DEVINST dnDevInst, ULONG ulProperty, PULONG pulRegDataType,
2313 PVOID Buffer, PULONG pulLength, ULONG ulFlags, HMACHINE hMachine)
2314 {
2315 RPC_BINDING_HANDLE BindingHandle = NULL;
2316 HSTRING_TABLE StringTable = NULL;
2317 CONFIGRET ret = CR_SUCCESS;
2318 LPWSTR lpDevInst;
2319 ULONG ulDataType = REG_NONE;
2320 ULONG ulTransferLength = 0;
2321
2322 TRACE("%lx %lu %p %p %p %lx %lx\n",
2323 dnDevInst, ulProperty, pulRegDataType, Buffer, pulLength,
2324 ulFlags, hMachine);
2325
2326 if (dnDevInst == 0)
2327 return CR_INVALID_DEVNODE;
2328
2329 if (ulProperty < CM_DRP_MIN || ulProperty > CM_DRP_MAX)
2330 return CR_INVALID_PROPERTY;
2331
2332 /* pulRegDataType is optional */
2333
2334 /* Buffer is optional */
2335
2336 if (pulLength == NULL)
2337 return CR_INVALID_POINTER;
2338
2339 if (*pulLength == 0)
2340 return CR_INVALID_POINTER;
2341
2342 if (ulFlags != 0)
2343 return CR_INVALID_FLAG;
2344
2345 if (hMachine != NULL)
2346 {
2347 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
2348 if (BindingHandle == NULL)
2349 return CR_FAILURE;
2350
2351 StringTable = ((PMACHINE_INFO)hMachine)->StringTable;
2352 if (StringTable == 0)
2353 return CR_FAILURE;
2354 }
2355 else
2356 {
2357 if (!PnpGetLocalHandles(&BindingHandle, &StringTable))
2358 return CR_FAILURE;
2359 }
2360
2361 lpDevInst = pSetupStringTableStringFromId(StringTable, dnDevInst);
2362 if (lpDevInst == NULL)
2363 return CR_INVALID_DEVNODE;
2364
2365 ulTransferLength = *pulLength;
2366
2367 RpcTryExcept
2368 {
2369 ret = PNP_GetDeviceRegProp(BindingHandle,
2370 lpDevInst,
2371 ulProperty,
2372 &ulDataType,
2373 Buffer,
2374 &ulTransferLength,
2375 pulLength,
2376 ulFlags);
2377 }
2378 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
2379 {
2380 ret = RpcStatusToCmStatus(RpcExceptionCode());
2381 }
2382 RpcEndExcept;
2383
2384 if (ret == CR_SUCCESS)
2385 {
2386 if (pulRegDataType != NULL)
2387 *pulRegDataType = ulDataType;
2388 }
2389
2390 return ret;
2391 }
2392
2393
2394 /***********************************************************************
2395 * CM_Get_DevNode_Status [SETUPAPI.@]
2396 */
2397 CONFIGRET WINAPI CM_Get_DevNode_Status(
2398 PULONG pulStatus, PULONG pulProblemNumber, DEVINST dnDevInst,
2399 ULONG ulFlags)
2400 {
2401 TRACE("%p %p %lx %lx\n",
2402 pulStatus, pulProblemNumber, dnDevInst, ulFlags);
2403 return CM_Get_DevNode_Status_Ex(pulStatus, pulProblemNumber, dnDevInst,
2404 ulFlags, NULL);
2405 }
2406
2407
2408 /***********************************************************************
2409 * CM_Get_DevNode_Status_Ex [SETUPAPI.@]
2410 */
2411 CONFIGRET WINAPI
2412 CM_Get_DevNode_Status_Ex(
2413 PULONG pulStatus, PULONG pulProblemNumber, DEVINST dnDevInst,
2414 ULONG ulFlags, HMACHINE hMachine)
2415 {
2416 RPC_BINDING_HANDLE BindingHandle = NULL;
2417 HSTRING_TABLE StringTable = NULL;
2418 LPWSTR lpDevInst;
2419 CONFIGRET ret;
2420
2421 TRACE("%p %p %lx %lx %lx\n",
2422 pulStatus, pulProblemNumber, dnDevInst, ulFlags, hMachine);
2423
2424 if (pulStatus == NULL || pulProblemNumber == NULL)
2425 return CR_INVALID_POINTER;
2426
2427 if (dnDevInst == 0)
2428 return CR_INVALID_DEVINST;
2429
2430 if (ulFlags != 0)
2431 return CR_INVALID_FLAG;
2432
2433 if (hMachine != NULL)
2434 {
2435 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
2436 if (BindingHandle == NULL)
2437 return CR_FAILURE;
2438
2439 StringTable = ((PMACHINE_INFO)hMachine)->StringTable;
2440 if (StringTable == 0)
2441 return CR_FAILURE;
2442 }
2443 else
2444 {
2445 if (!PnpGetLocalHandles(&BindingHandle, &StringTable))
2446 return CR_FAILURE;
2447 }
2448
2449 lpDevInst = pSetupStringTableStringFromId(StringTable, dnDevInst);
2450 if (lpDevInst == NULL)
2451 return CR_INVALID_DEVNODE;
2452
2453 RpcTryExcept
2454 {
2455 ret = PNP_GetDeviceStatus(BindingHandle,
2456 lpDevInst,
2457 pulStatus,
2458 pulProblemNumber,
2459 ulFlags);
2460 }
2461 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
2462 {
2463 ret = RpcStatusToCmStatus(RpcExceptionCode());
2464 }
2465 RpcEndExcept;
2466
2467 return ret;
2468 }
2469
2470
2471 /***********************************************************************
2472 * CM_Get_Device_IDA [SETUPAPI.@]
2473 */
2474 CONFIGRET WINAPI CM_Get_Device_IDA(
2475 DEVINST dnDevInst, PCHAR Buffer, ULONG BufferLen, ULONG ulFlags)
2476 {
2477 TRACE("%lx %p %ld %ld\n",
2478 dnDevInst, Buffer, BufferLen, ulFlags);
2479 return CM_Get_Device_ID_ExA(dnDevInst, Buffer, BufferLen, ulFlags, NULL);
2480 }
2481
2482
2483 /***********************************************************************
2484 * CM_Get_Device_IDW [SETUPAPI.@]
2485 */
2486 CONFIGRET WINAPI CM_Get_Device_IDW(
2487 DEVINST dnDevInst, PWCHAR Buffer, ULONG BufferLen, ULONG ulFlags)
2488 {
2489 TRACE("%lx %p %ld %ld\n",
2490 dnDevInst, Buffer, BufferLen, ulFlags);
2491 return CM_Get_Device_ID_ExW(dnDevInst, Buffer, BufferLen, ulFlags, NULL);
2492 }
2493
2494
2495 /***********************************************************************
2496 * CM_Get_Device_ID_ExA [SETUPAPI.@]
2497 */
2498 CONFIGRET WINAPI CM_Get_Device_ID_ExA(
2499 DEVINST dnDevInst, PCHAR Buffer, ULONG BufferLen, ULONG ulFlags,
2500 HMACHINE hMachine)
2501 {
2502 WCHAR szBufferW[MAX_DEVICE_ID_LEN];
2503 CONFIGRET ret = CR_SUCCESS;
2504
2505 TRACE("%lx %p %ld %ld %lx\n",
2506 dnDevInst, Buffer, BufferLen, ulFlags, hMachine);
2507
2508 if (Buffer == NULL)
2509 return CR_INVALID_POINTER;
2510
2511 ret = CM_Get_Device_ID_ExW(dnDevInst,
2512 szBufferW,
2513 MAX_DEVICE_ID_LEN,
2514 ulFlags,
2515 hMachine);
2516 if (ret == CR_SUCCESS)
2517 {
2518 if (WideCharToMultiByte(CP_ACP,
2519 0,
2520 szBufferW,
2521 lstrlenW(szBufferW) + 1,
2522 Buffer,
2523 BufferLen,
2524 NULL,
2525 NULL) == 0)
2526 ret = CR_FAILURE;
2527 }
2528
2529 return ret;
2530 }
2531
2532
2533 /***********************************************************************
2534 * CM_Get_Device_ID_ExW [SETUPAPI.@]
2535 */
2536 CONFIGRET WINAPI CM_Get_Device_ID_ExW(
2537 DEVINST dnDevInst, PWCHAR Buffer, ULONG BufferLen, ULONG ulFlags,
2538 HMACHINE hMachine)
2539 {
2540 HSTRING_TABLE StringTable = NULL;
2541
2542 TRACE("%lx %p %ld %ld %lx\n",
2543 dnDevInst, Buffer, BufferLen, ulFlags, hMachine);
2544
2545 if (dnDevInst == 0)
2546 return CR_INVALID_DEVINST;
2547
2548 if (Buffer == NULL)
2549 return CR_INVALID_POINTER;
2550
2551 if (ulFlags != 0)
2552 return CR_INVALID_FLAG;
2553
2554 if (hMachine != NULL)
2555 {
2556 StringTable = ((PMACHINE_INFO)hMachine)->StringTable;
2557 if (StringTable == NULL)
2558 return CR_FAILURE;
2559 }
2560 else
2561 {
2562 if (!PnpGetLocalHandles(NULL, &StringTable))
2563 return CR_FAILURE;
2564 }
2565
2566 if (!pSetupStringTableStringFromIdEx(StringTable,
2567 dnDevInst,
2568 Buffer,
2569 &BufferLen))
2570 return CR_FAILURE;
2571
2572 return CR_SUCCESS;
2573 }
2574
2575
2576 /***********************************************************************
2577 * CM_Get_Device_ID_ListA [SETUPAPI.@]
2578 */
2579 CONFIGRET WINAPI CM_Get_Device_ID_ListA(
2580 PCSTR pszFilter, PCHAR Buffer, ULONG BufferLen, ULONG ulFlags)
2581 {
2582 TRACE("%p %p %ld %ld\n", pszFilter, Buffer, BufferLen, ulFlags);
2583 return CM_Get_Device_ID_List_ExA(pszFilter, Buffer, BufferLen,
2584 ulFlags, NULL);
2585 }
2586
2587
2588 /***********************************************************************
2589 * CM_Get_Device_ID_ListW [SETUPAPI.@]
2590 */
2591 CONFIGRET WINAPI CM_Get_Device_ID_ListW(
2592 PCWSTR pszFilter, PWCHAR Buffer, ULONG BufferLen, ULONG ulFlags)
2593 {
2594 TRACE("%p %p %ld %ld\n", pszFilter, Buffer, BufferLen, ulFlags);
2595 return CM_Get_Device_ID_List_ExW(pszFilter, Buffer, BufferLen,
2596 ulFlags, NULL);
2597 }
2598
2599
2600 /***********************************************************************
2601 * CM_Get_Device_ID_List_ExA [SETUPAPI.@]
2602 */
2603 CONFIGRET WINAPI CM_Get_Device_ID_List_ExA(
2604 PCSTR pszFilter, PCHAR Buffer, ULONG BufferLen, ULONG ulFlags,
2605 HMACHINE hMachine)
2606 {
2607 LPWSTR BufferW = NULL;
2608 LPWSTR pszFilterW = NULL;
2609 CONFIGRET ret = CR_SUCCESS;
2610
2611 TRACE("%p %p %ld %ld %lx\n",
2612 pszFilter, Buffer, BufferLen, ulFlags, hMachine);
2613
2614 BufferW = MyMalloc(BufferLen * sizeof(WCHAR));
2615 if (BufferW == NULL)
2616 return CR_OUT_OF_MEMORY;
2617
2618 if (pszFilter == NULL)
2619 {
2620 ret = CM_Get_Device_ID_List_ExW(NULL,
2621 BufferW,
2622 BufferLen,
2623 ulFlags,
2624 hMachine);
2625 }
2626 else
2627 {
2628 if (pSetupCaptureAndConvertAnsiArg(pszFilter, &pszFilterW))
2629 {
2630 ret = CR_INVALID_DEVICE_ID;
2631 goto Done;
2632 }
2633
2634 ret = CM_Get_Device_ID_List_ExW(pszFilterW,
2635 BufferW,
2636 BufferLen,
2637 ulFlags,
2638 hMachine);
2639
2640 MyFree(pszFilterW);
2641 }
2642
2643 if (WideCharToMultiByte(CP_ACP,
2644 0,
2645 BufferW,
2646 lstrlenW(BufferW) + 1,
2647 Buffer,
2648 BufferLen,
2649 NULL,
2650 NULL) == 0)
2651 ret = CR_FAILURE;
2652
2653 Done:
2654 MyFree(BufferW);
2655
2656 return ret;
2657 }
2658
2659
2660 /***********************************************************************
2661 * CM_Get_Device_ID_List_ExW [SETUPAPI.@]
2662 */
2663 CONFIGRET WINAPI CM_Get_Device_ID_List_ExW(
2664 PCWSTR pszFilter, PWCHAR Buffer, ULONG BufferLen, ULONG ulFlags,
2665 HMACHINE hMachine)
2666 {
2667 RPC_BINDING_HANDLE BindingHandle = NULL;
2668 CONFIGRET ret;
2669
2670 TRACE("%p %p %ld %ld %lx\n",
2671 pszFilter, Buffer, BufferLen, ulFlags, hMachine);
2672
2673 if (Buffer == NULL || BufferLen == 0)
2674 return CR_INVALID_POINTER;
2675
2676 if (ulFlags & ~CM_GETIDLIST_FILTER_BITS)
2677 return CR_INVALID_FLAG;
2678
2679 if (hMachine != NULL)
2680 {
2681 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
2682 if (BindingHandle == NULL)
2683 return CR_FAILURE;
2684 }
2685 else
2686 {
2687 if (!PnpGetLocalHandles(&BindingHandle, NULL))
2688 return CR_FAILURE;
2689 }
2690
2691 *Buffer = 0;
2692
2693 RpcTryExcept
2694 {
2695 ret = PNP_GetDeviceList(BindingHandle,
2696 (LPWSTR)pszFilter,
2697 Buffer,
2698 &BufferLen,
2699 ulFlags);
2700 }
2701 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
2702 {
2703 ret = RpcStatusToCmStatus(RpcExceptionCode());
2704 }
2705 RpcEndExcept;
2706
2707 return ret;
2708 }
2709
2710
2711 /***********************************************************************
2712 * CM_Get_Device_ID_List_SizeA [SETUPAPI.@]
2713 */
2714 CONFIGRET WINAPI CM_Get_Device_ID_List_SizeA(
2715 PULONG pulLen, PCSTR pszFilter, ULONG ulFlags)
2716 {
2717 TRACE("%p %s %ld\n", pulLen, pszFilter, ulFlags);
2718 return CM_Get_Device_ID_List_Size_ExA(pulLen, pszFilter, ulFlags, NULL);
2719 }
2720
2721
2722 /***********************************************************************
2723 * CM_Get_Device_ID_List_SizeW [SETUPAPI.@]
2724 */
2725 CONFIGRET WINAPI CM_Get_Device_ID_List_SizeW(
2726 PULONG pulLen, PCWSTR pszFilter, ULONG ulFlags)
2727 {
2728 TRACE("%p %s %ld\n", pulLen, debugstr_w(pszFilter), ulFlags);
2729 return CM_Get_Device_ID_List_Size_ExW(pulLen, pszFilter, ulFlags, NULL);
2730 }
2731
2732
2733 /***********************************************************************
2734 * CM_Get_Device_ID_List_Size_ExA [SETUPAPI.@]
2735 */
2736 CONFIGRET WINAPI CM_Get_Device_ID_List_Size_ExA(
2737 PULONG pulLen, PCSTR pszFilter, ULONG ulFlags, HMACHINE hMachine)
2738 {
2739 LPWSTR pszFilterW = NULL;
2740 CONFIGRET ret = CR_SUCCESS;
2741
2742 FIXME("%p %s %lx %lx\n", pulLen, pszFilter, ulFlags, hMachine);
2743
2744 if (pszFilter == NULL)
2745 {
2746 ret = CM_Get_Device_ID_List_Size_ExW(pulLen,
2747 NULL,
2748 ulFlags,
2749 hMachine);
2750 }
2751 else
2752 {
2753 if (pSetupCaptureAndConvertAnsiArg(pszFilter, &pszFilterW))
2754 return CR_INVALID_DEVICE_ID;
2755
2756 ret = CM_Get_Device_ID_List_Size_ExW(pulLen,
2757 pszFilterW,
2758 ulFlags,
2759 hMachine);
2760
2761 MyFree(pszFilterW);
2762 }
2763
2764 return ret;
2765 }
2766
2767
2768 /***********************************************************************
2769 * CM_Get_Device_ID_List_Size_ExW [SETUPAPI.@]
2770 */
2771 CONFIGRET WINAPI CM_Get_Device_ID_List_Size_ExW(
2772 PULONG pulLen, PCWSTR pszFilter, ULONG ulFlags, HMACHINE hMachine)
2773 {
2774 RPC_BINDING_HANDLE BindingHandle = NULL;
2775 CONFIGRET ret;
2776
2777 FIXME("%p %s %ld %lx\n", pulLen, debugstr_w(pszFilter), ulFlags, hMachine);
2778
2779 if (pulLen == NULL)
2780 return CR_INVALID_POINTER;
2781
2782 if (ulFlags & ~CM_GETIDLIST_FILTER_BITS)
2783 return CR_INVALID_FLAG;
2784
2785 if (hMachine != NULL)
2786 {
2787 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
2788 if (BindingHandle == NULL)
2789 return CR_FAILURE;
2790 }
2791 else
2792 {
2793 if (!PnpGetLocalHandles(&BindingHandle, NULL))
2794 return CR_FAILURE;
2795 }
2796
2797 *pulLen = 0;
2798
2799 RpcTryExcept
2800 {
2801 ret = PNP_GetDeviceListSize(BindingHandle,
2802 (LPWSTR)pszFilter,
2803 pulLen,
2804 ulFlags);
2805 }
2806 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
2807 {
2808 ret = RpcStatusToCmStatus(RpcExceptionCode());
2809 }
2810 RpcEndExcept;
2811
2812 return ret;
2813 }
2814
2815
2816 /***********************************************************************
2817 * CM_Get_Device_ID_Size [SETUPAPI.@]
2818 */
2819 CONFIGRET WINAPI CM_Get_Device_ID_Size(
2820 PULONG pulLen, DEVINST dnDevInst, ULONG ulFlags)
2821 {
2822 TRACE("%p %lx %lx\n", pulLen, dnDevInst, ulFlags);
2823 return CM_Get_Device_ID_Size_Ex(pulLen, dnDevInst, ulFlags, NULL);
2824 }
2825
2826
2827 /***********************************************************************
2828 * CM_Get_Device_ID_Size_Ex [SETUPAPI.@]
2829 */
2830 CONFIGRET WINAPI CM_Get_Device_ID_Size_Ex(
2831 PULONG pulLen, DEVINST dnDevInst, ULONG ulFlags, HMACHINE hMachine)
2832 {
2833 HSTRING_TABLE StringTable = NULL;
2834 LPWSTR DeviceId;
2835
2836 TRACE("%p %lx %lx %lx\n", pulLen, dnDevInst, ulFlags, hMachine);
2837
2838 if (pulLen == NULL)
2839 return CR_INVALID_POINTER;
2840
2841 if (dnDevInst == 0)
2842 return CR_INVALID_DEVINST;
2843
2844 if (ulFlags != 0)
2845 return CR_INVALID_FLAG;
2846
2847 if (hMachine != NULL)
2848 {
2849 StringTable = ((PMACHINE_INFO)hMachine)->StringTable;
2850 if (StringTable == NULL)
2851 return CR_FAILURE;
2852 }
2853 else
2854 {
2855 if (!PnpGetLocalHandles(NULL, &StringTable))
2856 return CR_FAILURE;
2857 }
2858
2859 DeviceId = pSetupStringTableStringFromId(StringTable, dnDevInst);
2860 if (DeviceId == NULL)
2861 {
2862 *pulLen = 0;
2863 return CR_SUCCESS;
2864 }
2865
2866 *pulLen = lstrlenW(DeviceId);
2867
2868 return CR_SUCCESS;
2869 }
2870
2871
2872 /***********************************************************************
2873 * CM_Get_Device_Interface_AliasA [SETUPAPI.@]
2874 */
2875 CONFIGRET WINAPI CM_Get_Device_Interface_AliasA(
2876 LPCSTR pszDeviceInterface, LPGUID AliasInterfaceGuid,
2877 LPSTR pszAliasDeviceInterface, PULONG pulLength, ULONG ulFlags)
2878 {
2879 TRACE("%p %p %p %p %lu\n", pszDeviceInterface, AliasInterfaceGuid,
2880 pszAliasDeviceInterface, pulLength, ulFlags);
2881
2882 return CM_Get_Device_Interface_Alias_ExA(pszDeviceInterface,
2883 AliasInterfaceGuid, pszAliasDeviceInterface, pulLength,
2884 ulFlags, NULL);
2885 }
2886
2887
2888 /***********************************************************************
2889 * CM_Get_Device_Interface_AliasW [SETUPAPI.@]
2890 */
2891 CONFIGRET WINAPI CM_Get_Device_Interface_AliasW(
2892 LPCWSTR pszDeviceInterface, LPGUID AliasInterfaceGuid,
2893 LPWSTR pszAliasDeviceInterface, PULONG pulLength, ULONG ulFlags)
2894 {
2895 TRACE("%p %p %p %p %lu\n", pszDeviceInterface, AliasInterfaceGuid,
2896 pszAliasDeviceInterface, pulLength, ulFlags);
2897
2898 return CM_Get_Device_Interface_Alias_ExW(pszDeviceInterface,
2899 AliasInterfaceGuid, pszAliasDeviceInterface, pulLength,
2900 ulFlags, NULL);
2901 }
2902
2903
2904 /***********************************************************************
2905 * CM_Get_Device_Interface_Alias_ExA [SETUPAPI.@]
2906 */
2907 CONFIGRET WINAPI CM_Get_Device_Interface_Alias_ExA(
2908 LPCSTR pszDeviceInterface, LPGUID AliasInterfaceGuid, LPSTR pszAliasDeviceInterface,
2909 PULONG pulLength, ULONG ulFlags, HMACHINE hMachine)
2910 {
2911 FIXME("%p %p %p %p %lu %lx\n", pszDeviceInterface, AliasInterfaceGuid,
2912 pszAliasDeviceInterface, pulLength, ulFlags, hMachine);
2913
2914 return CR_CALL_NOT_IMPLEMENTED;
2915 }
2916
2917
2918 /***********************************************************************
2919 * CM_Get_Device_Interface_Alias_ExW [SETUPAPI.@]
2920 */
2921 CONFIGRET WINAPI CM_Get_Device_Interface_Alias_ExW(
2922 LPCWSTR pszDeviceInterface, LPGUID AliasInterfaceGuid, LPWSTR pszAliasDeviceInterface,
2923 PULONG pulLength, ULONG ulFlags, HMACHINE hMachine)
2924 {
2925 RPC_BINDING_HANDLE BindingHandle = NULL;
2926 ULONG ulTransferLength;
2927 CONFIGRET ret = CR_SUCCESS;
2928
2929 TRACE("%p %p %p %p %lu %lx\n", pszDeviceInterface, AliasInterfaceGuid,
2930 pszAliasDeviceInterface, pulLength, ulFlags, hMachine);
2931
2932 if (pszDeviceInterface == NULL ||
2933 AliasInterfaceGuid == NULL ||
2934 pszAliasDeviceInterface == NULL ||
2935 pulLength == NULL)
2936 return CR_INVALID_POINTER;
2937
2938 if (ulFlags != 0)
2939 return CR_INVALID_FLAG;
2940
2941 if (hMachine != NULL)
2942 {
2943 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
2944 if (BindingHandle == NULL)
2945 return CR_FAILURE;
2946 }
2947 else
2948 {
2949 if (!PnpGetLocalHandles(&BindingHandle, NULL))
2950 return CR_FAILURE;
2951 }
2952
2953 ulTransferLength = *pulLength;
2954
2955 RpcTryExcept
2956 {
2957 ret = PNP_GetInterfaceDeviceAlias(BindingHandle,
2958 (LPWSTR)pszDeviceInterface,
2959 AliasInterfaceGuid,
2960 pszAliasDeviceInterface,
2961 pulLength,
2962 &ulTransferLength,
2963 0);
2964 }
2965 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
2966 {
2967 ret = RpcStatusToCmStatus(RpcExceptionCode());
2968 }
2969 RpcEndExcept;
2970
2971 return ret;
2972 }
2973
2974
2975 /***********************************************************************
2976 * CM_Get_Device_Interface_ListA (SETUPAPI.@)
2977 */
2978 CONFIGRET WINAPI CM_Get_Device_Interface_ListA(
2979 LPGUID InterfaceClassGuid, DEVINSTID_A pDeviceID, PCHAR Buffer,
2980 ULONG BufferLen, ULONG ulFlags)
2981 {
2982 TRACE("%s %s %p %lu 0x%08lx\n", debugstr_guid(InterfaceClassGuid),
2983 pDeviceID, Buffer, BufferLen, ulFlags);
2984
2985 return CM_Get_Device_Interface_List_ExA(InterfaceClassGuid, pDeviceID,
2986 Buffer, BufferLen, ulFlags, NULL);
2987 }
2988
2989
2990 /***********************************************************************
2991 * CM_Get_Device_Interface_ListW (SETUPAPI.@)
2992 */
2993 CONFIGRET WINAPI CM_Get_Device_Interface_ListW(
2994 LPGUID InterfaceClassGuid, DEVINSTID_W pDeviceID, PWCHAR Buffer,
2995 ULONG BufferLen, ULONG ulFlags)
2996 {
2997 TRACE("%s %s %p %lu 0x%08lx\n", debugstr_guid(InterfaceClassGuid),
2998 debugstr_w(pDeviceID), Buffer, BufferLen, ulFlags);
2999
3000 return CM_Get_Device_Interface_List_ExW(InterfaceClassGuid, pDeviceID,
3001 Buffer, BufferLen, ulFlags, NULL);
3002 }
3003
3004
3005 /***********************************************************************
3006 * CM_Get_Device_Interface_List_ExA (SETUPAPI.@)
3007 */
3008 CONFIGRET WINAPI CM_Get_Device_Interface_List_ExA(
3009 LPGUID InterfaceClassGuid, DEVINSTID_A pDeviceID, PCHAR Buffer,
3010 ULONG BufferLen, ULONG ulFlags, HMACHINE hMachine)
3011 {
3012 DEVINSTID_W pDeviceIdW = NULL;
3013 PWCHAR BufferW = NULL;
3014 CONFIGRET ret = CR_SUCCESS;
3015
3016 TRACE("%s %s %p %lu 0x%08lx %p\n", debugstr_guid(InterfaceClassGuid),
3017 pDeviceID, Buffer, BufferLen, ulFlags, hMachine);
3018
3019 if (Buffer == NULL ||
3020 BufferLen == 0)
3021 return CR_INVALID_POINTER;
3022
3023 if (pDeviceID != NULL)
3024 {
3025 if (!pSetupCaptureAndConvertAnsiArg(pDeviceID, &pDeviceIdW))
3026 return CR_INVALID_DEVICE_ID;
3027 }
3028
3029 BufferW = MyMalloc(BufferLen * sizeof(WCHAR));
3030 if (BufferW == NULL)
3031 {
3032 ret = CR_OUT_OF_MEMORY;
3033 goto Done;
3034 }
3035
3036 ret = CM_Get_Device_Interface_List_ExW(InterfaceClassGuid, pDeviceIdW,
3037 BufferW, BufferLen, ulFlags,
3038 hMachine);
3039 if (ret != CR_SUCCESS)
3040 goto Done;
3041
3042 if (WideCharToMultiByte(CP_ACP,
3043 0,
3044 BufferW,
3045 lstrlenW(BufferW) + 1,
3046 Buffer,
3047 BufferLen,
3048 NULL,
3049 NULL) == 0)
3050 ret = CR_FAILURE;
3051
3052 Done:
3053 if (BufferW != NULL)
3054 MyFree(BufferW);
3055
3056 if (pDeviceIdW != NULL)
3057 MyFree(pDeviceIdW);
3058
3059 return ret;
3060 }
3061
3062
3063 /***********************************************************************
3064 * CM_Get_Device_Interface_List_ExW (SETUPAPI.@)
3065 */
3066 CONFIGRET WINAPI CM_Get_Device_Interface_List_ExW(
3067 LPGUID InterfaceClassGuid, DEVINSTID_W pDeviceID, PWCHAR Buffer,
3068 ULONG BufferLen, ULONG ulFlags, HMACHINE hMachine)
3069 {
3070 RPC_BINDING_HANDLE BindingHandle = NULL;
3071 PNP_RPC_BUFFER_SIZE BufferSize = 0;
3072 CONFIGRET ret = CR_SUCCESS;
3073
3074 TRACE("%s %s %p %lu 0x%08lx %p\n", debugstr_guid(InterfaceClassGuid),
3075 debugstr_w(pDeviceID), Buffer, BufferLen, ulFlags, hMachine);
3076
3077 if (Buffer == NULL ||
3078 BufferLen == 0)
3079 return CR_INVALID_POINTER;
3080
3081 if (ulFlags & ~CM_GET_DEVICE_INTERFACE_LIST_BITS)
3082 return CR_INVALID_FLAG;
3083
3084 if (hMachine != NULL)
3085 {
3086 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
3087 if (BindingHandle == NULL)
3088 return CR_FAILURE;
3089 }
3090 else
3091 {
3092 if (!PnpGetLocalHandles(&BindingHandle, NULL))
3093 return CR_FAILURE;
3094 }
3095
3096 *Buffer = 0;
3097 BufferSize = BufferLen;
3098
3099 RpcTryExcept
3100 {
3101 ret = PNP_GetInterfaceDeviceList(BindingHandle,
3102 InterfaceClassGuid,
3103 pDeviceID,
3104 (LPBYTE)Buffer,
3105 &BufferSize,
3106 ulFlags);
3107 }
3108 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
3109 {
3110 ret = RpcStatusToCmStatus(RpcExceptionCode());
3111 }
3112 RpcEndExcept;
3113
3114 return ret;
3115 }
3116
3117
3118 /***********************************************************************
3119 * CM_Get_Device_Interface_List_SizeA (SETUPAPI.@)
3120 */
3121 CONFIGRET WINAPI CM_Get_Device_Interface_List_SizeA(
3122 PULONG pulLen, LPGUID InterfaceClassGuid, DEVINSTID_A pDeviceId,
3123 ULONG ulFlags)
3124 {
3125 TRACE("%p %p %s 0x%08lx\n", pulLen, InterfaceClassGuid,
3126 pDeviceId, ulFlags);
3127
3128 return CM_Get_Device_Interface_List_Size_ExA(pulLen, InterfaceClassGuid,
3129 pDeviceId, ulFlags, NULL);
3130 }
3131
3132
3133 /***********************************************************************
3134 * CM_Get_Device_Interface_List_SizeW (SETUPAPI.@)
3135 */
3136 CONFIGRET WINAPI CM_Get_Device_Interface_List_SizeW(
3137 PULONG pulLen, LPGUID InterfaceClassGuid, DEVINSTID_W pDeviceId,
3138 ULONG ulFlags)
3139 {
3140 TRACE("%p %p %s 0x%08lx\n", pulLen, InterfaceClassGuid,
3141 debugstr_w(pDeviceId), ulFlags);
3142
3143 return CM_Get_Device_Interface_List_Size_ExW(pulLen, InterfaceClassGuid,
3144 pDeviceId, ulFlags, NULL);
3145 }
3146
3147
3148 /***********************************************************************
3149 * CM_Get_Device_Interface_List_Size_ExA (SETUPAPI.@)
3150 */
3151 CONFIGRET WINAPI CM_Get_Device_Interface_List_Size_ExA(
3152 PULONG pulLen, LPGUID InterfaceClassGuid, DEVINSTID_A pDeviceId,
3153 ULONG ulFlags, HMACHINE hMachine)
3154 {
3155 DEVINSTID_W pDeviceIdW = NULL;
3156 CONFIGRET ret = CR_SUCCESS;
3157
3158 TRACE("%p %p %s 0x%08lx %p\n", pulLen, InterfaceClassGuid,
3159 pDeviceId, ulFlags, hMachine);
3160
3161 if (pulLen == NULL)
3162 return CR_INVALID_POINTER;
3163
3164 if (pDeviceId != NULL)
3165 {
3166 if (!pSetupCaptureAndConvertAnsiArg(pDeviceId, &pDeviceIdW))
3167 return CR_INVALID_DEVICE_ID;
3168 }
3169
3170 *pulLen = 0;
3171
3172 ret = CM_Get_Device_Interface_List_Size_ExW(pulLen, InterfaceClassGuid,
3173 pDeviceIdW, ulFlags, hMachine);
3174
3175 if (pDeviceIdW != NULL)
3176 MyFree(pDeviceIdW);
3177
3178 return ret;
3179 }
3180
3181
3182 /***********************************************************************
3183 * CM_Get_Device_Interface_List_Size_ExW (SETUPAPI.@)
3184 */
3185 CONFIGRET WINAPI CM_Get_Device_Interface_List_Size_ExW(
3186 PULONG pulLen, LPGUID InterfaceClassGuid, DEVINSTID_W pDeviceId,
3187 ULONG ulFlags, HMACHINE hMachine)
3188 {
3189 RPC_BINDING_HANDLE BindingHandle = NULL;
3190 CONFIGRET ret = CR_SUCCESS;
3191
3192 TRACE("%p %p %s 0x%08lx %p\n", pulLen, InterfaceClassGuid,
3193 debugstr_w(pDeviceId), ulFlags, hMachine);
3194
3195 if (pulLen == NULL)
3196 return CR_INVALID_POINTER;
3197
3198 if (ulFlags & ~CM_GET_DEVICE_INTERFACE_LIST_BITS)
3199 return CR_INVALID_FLAG;
3200
3201 if (hMachine != NULL)
3202 {
3203 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
3204 if (BindingHandle == NULL)
3205 return CR_FAILURE;
3206 }
3207 else
3208 {
3209 if (!PnpGetLocalHandles(&BindingHandle, NULL))
3210 return CR_FAILURE;
3211 }
3212
3213 *pulLen = 0;
3214
3215 RpcTryExcept
3216 {
3217 ret = PNP_GetInterfaceDeviceListSize(BindingHandle,
3218 pulLen,
3219 InterfaceClassGuid,
3220 pDeviceId,
3221 ulFlags);
3222 }
3223 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
3224 {
3225 ret = RpcStatusToCmStatus(RpcExceptionCode());
3226 }
3227 RpcEndExcept;
3228
3229 return ret;
3230 }
3231
3232
3233 /***********************************************************************
3234 * CM_Get_First_Log_Conf [SETUPAPI.@]
3235 */
3236 CONFIGRET WINAPI CM_Get_First_Log_Conf(
3237 PLOG_CONF plcLogConf, DEVINST dnDevInst, ULONG ulFlags)
3238 {
3239 TRACE("%p %lx %lx\n", plcLogConf, dnDevInst, ulFlags);
3240 return CM_Get_First_Log_Conf_Ex(plcLogConf, dnDevInst, ulFlags, NULL);
3241 }
3242
3243
3244 /***********************************************************************
3245 * CM_Get_First_Log_Conf_Ex [SETUPAPI.@]
3246 */
3247 CONFIGRET WINAPI CM_Get_First_Log_Conf_Ex(
3248 PLOG_CONF plcLogConf, DEVINST dnDevInst, ULONG ulFlags, HMACHINE hMachine)
3249 {
3250 RPC_BINDING_HANDLE BindingHandle = NULL;
3251 HSTRING_TABLE StringTable = NULL;
3252 LPWSTR lpDevInst = NULL;
3253 CONFIGRET ret = CR_SUCCESS;
3254 ULONG ulTag;
3255 PLOG_CONF_INFO pLogConfInfo;
3256
3257 FIXME("%p %lx %lx %lx\n", plcLogConf, dnDevInst, ulFlags, hMachine);
3258
3259 if (dnDevInst == 0)
3260 return CR_INVALID_DEVINST;
3261
3262 if (ulFlags & ~LOG_CONF_BITS)
3263 return CR_INVALID_FLAG;
3264
3265 if (plcLogConf)
3266 *plcLogConf = 0;
3267
3268 if (hMachine != NULL)
3269 {
3270 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
3271 if (BindingHandle == NULL)
3272 return CR_FAILURE;
3273
3274 StringTable = ((PMACHINE_INFO)hMachine)->StringTable;
3275 if (StringTable == 0)
3276 return CR_FAILURE;
3277 }
3278 else
3279 {
3280 if (!PnpGetLocalHandles(&BindingHandle, &StringTable))
3281 return CR_FAILURE;
3282 }
3283
3284 lpDevInst = pSetupStringTableStringFromId(StringTable, dnDevInst);
3285 if (lpDevInst == NULL)
3286 return CR_INVALID_DEVNODE;
3287
3288 RpcTryExcept
3289 {
3290 ret = PNP_GetFirstLogConf(BindingHandle,
3291 lpDevInst,
3292 ulFlags,
3293 &ulTag,
3294 ulFlags);
3295 }
3296 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
3297 {
3298 ret = RpcStatusToCmStatus(RpcExceptionCode());
3299 }
3300 RpcEndExcept;
3301
3302 if (ret != CR_SUCCESS)
3303 return ret;
3304
3305 if (plcLogConf)
3306 {
3307 pLogConfInfo = HeapAlloc(GetProcessHeap(), 0, sizeof(LOG_CONF_INFO));
3308 if (pLogConfInfo == NULL)
3309 return CR_OUT_OF_MEMORY;
3310
3311 pLogConfInfo->ulMagic = LOG_CONF_MAGIC;
3312 pLogConfInfo->dnDevInst = dnDevInst;
3313 pLogConfInfo->ulFlags = ulFlags;
3314 pLogConfInfo->ulTag = ulTag;
3315
3316 *plcLogConf = (LOG_CONF)pLogConfInfo;
3317 }
3318
3319 return CR_SUCCESS;
3320 }
3321
3322
3323 /***********************************************************************
3324 * CM_Get_Global_State [SETUPAPI.@]
3325 */
3326 CONFIGRET WINAPI CM_Get_Global_State(
3327 PULONG pulState, ULONG ulFlags)
3328 {
3329 TRACE("%p %lx\n", pulState, ulFlags);
3330 return CM_Get_Global_State_Ex(pulState, ulFlags, NULL);
3331 }
3332
3333
3334 /***********************************************************************
3335 * CM_Get_Global_State_Ex [SETUPAPI.@]
3336 */
3337 CONFIGRET WINAPI CM_Get_Global_State_Ex(
3338 PULONG pulState, ULONG ulFlags, HMACHINE hMachine)
3339 {
3340 RPC_BINDING_HANDLE BindingHandle = NULL;
3341 CONFIGRET ret;
3342
3343 TRACE("%p %lx %lx\n", pulState, ulFlags, hMachine);
3344
3345 if (pulState == NULL)
3346 return CR_INVALID_POINTER;
3347
3348 if (ulFlags != 0)
3349 return CR_INVALID_FLAG;
3350
3351 if (hMachine != NULL)
3352 {
3353 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
3354 if (BindingHandle == NULL)
3355 return CR_FAILURE;
3356 }
3357 else
3358 {
3359 if (!PnpGetLocalHandles(&BindingHandle, NULL))
3360 return CR_FAILURE;
3361 }
3362
3363 RpcTryExcept
3364 {
3365 ret = PNP_GetGlobalState(BindingHandle, pulState, ulFlags);
3366 }
3367 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
3368 {
3369 ret = RpcStatusToCmStatus(RpcExceptionCode());
3370 }
3371 RpcEndExcept;
3372
3373 return ret;
3374 }
3375
3376
3377 /***********************************************************************
3378 * CM_Get_HW_Prof_FlagsA [SETUPAPI.@]
3379 */
3380 CONFIGRET WINAPI CM_Get_HW_Prof_FlagsA(
3381 DEVINSTID_A szDevInstName, ULONG ulHardwareProfile, PULONG pulValue,
3382 ULONG ulFlags)
3383 {
3384 TRACE("%s %lu %p %lx\n", szDevInstName,
3385 ulHardwareProfile, pulValue, ulFlags);
3386
3387 return CM_Get_HW_Prof_Flags_ExA(szDevInstName, ulHardwareProfile,
3388 pulValue, ulFlags, NULL);
3389 }
3390
3391
3392 /***********************************************************************
3393 * CM_Get_HW_Prof_FlagsW [SETUPAPI.@]
3394 */
3395 CONFIGRET WINAPI CM_Get_HW_Prof_FlagsW(
3396 DEVINSTID_W szDevInstName, ULONG ulHardwareProfile, PULONG pulValue,
3397 ULONG ulFlags)
3398 {
3399 TRACE("%s %lu %p %lx\n", debugstr_w(szDevInstName),
3400 ulHardwareProfile, pulValue, ulFlags);
3401
3402 return CM_Get_HW_Prof_Flags_ExW(szDevInstName, ulHardwareProfile,
3403 pulValue, ulFlags, NULL);
3404 }
3405
3406
3407 /***********************************************************************
3408 * CM_Get_HW_Prof_Flags_ExA [SETUPAPI.@]
3409 */
3410 CONFIGRET WINAPI CM_Get_HW_Prof_Flags_ExA(
3411 DEVINSTID_A szDevInstName, ULONG ulHardwareProfile, PULONG pulValue,
3412 ULONG ulFlags, HMACHINE hMachine)
3413 {
3414 DEVINSTID_W pszDevIdW = NULL;
3415 CONFIGRET ret = CR_SUCCESS;
3416
3417 TRACE("%s %lu %p %lx %lx\n", szDevInstName,
3418 ulHardwareProfile, pulValue, ulFlags, hMachine);
3419
3420 if (szDevInstName != NULL)
3421 {
3422 if (pSetupCaptureAndConvertAnsiArg(szDevInstName, &pszDevIdW))
3423 return CR_INVALID_DEVICE_ID;
3424 }
3425
3426 ret = CM_Get_HW_Prof_Flags_ExW(pszDevIdW, ulHardwareProfile,
3427 pulValue, ulFlags, hMachine);
3428
3429 if (pszDevIdW != NULL)
3430 MyFree(pszDevIdW);
3431
3432 return ret;
3433 }
3434
3435
3436 /***********************************************************************
3437 * CM_Get_HW_Prof_Flags_ExW [SETUPAPI.@]
3438 */
3439 CONFIGRET WINAPI CM_Get_HW_Prof_Flags_ExW(
3440 DEVINSTID_W szDevInstName, ULONG ulHardwareProfile, PULONG pulValue,
3441 ULONG ulFlags, HMACHINE hMachine)
3442 {
3443 RPC_BINDING_HANDLE BindingHandle = NULL;
3444 CONFIGRET ret;
3445
3446 FIXME("%s %lu %p %lx %lx\n", debugstr_w(szDevInstName),
3447 ulHardwareProfile, pulValue, ulFlags, hMachine);
3448
3449 if ((szDevInstName == NULL) || (pulValue == NULL))
3450 return CR_INVALID_POINTER;
3451
3452 if (ulFlags != 0)
3453 return CR_INVALID_FLAG;
3454
3455 /* FIXME: Check whether szDevInstName is valid */
3456
3457 if (hMachine != NULL)
3458 {
3459 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
3460 if (BindingHandle == NULL)
3461 return CR_FAILURE;
3462 }
3463 else
3464 {
3465 if (!PnpGetLocalHandles(&BindingHandle, NULL))
3466 return CR_FAILURE;
3467 }
3468
3469 RpcTryExcept
3470 {
3471 ret = PNP_HwProfFlags(BindingHandle, PNP_GET_HWPROFFLAGS, szDevInstName,
3472 ulHardwareProfile, pulValue, NULL, NULL, 0, 0);
3473 }
3474 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
3475 {
3476 ret = RpcStatusToCmStatus(RpcExceptionCode());
3477 }
3478 RpcEndExcept;
3479
3480 return ret;
3481 }
3482
3483
3484 /***********************************************************************
3485 * CM_Get_Hardware_Profile_InfoA [SETUPAPI.@]
3486 */
3487 CONFIGRET WINAPI CM_Get_Hardware_Profile_InfoA(
3488 ULONG ulIndex, PHWPROFILEINFO_A pHWProfileInfo, ULONG ulFlags)
3489 {
3490 TRACE("%lu %p %lx\n", ulIndex, pHWProfileInfo, ulFlags);
3491
3492 return CM_Get_Hardware_Profile_Info_ExA(ulIndex, pHWProfileInfo,
3493 ulFlags, NULL);
3494 }
3495
3496
3497 /***********************************************************************
3498 * CM_Get_Hardware_Profile_InfoW [SETUPAPI.@]
3499 */
3500 CONFIGRET WINAPI CM_Get_Hardware_Profile_InfoW(
3501 ULONG ulIndex, PHWPROFILEINFO_W pHWProfileInfo, ULONG ulFlags)
3502 {
3503 TRACE("%lu %p %lx\n", ulIndex, pHWProfileInfo, ulFlags);
3504
3505 return CM_Get_Hardware_Profile_Info_ExW(ulIndex, pHWProfileInfo,
3506 ulFlags, NULL);
3507 }
3508
3509
3510 /***********************************************************************
3511 * CM_Get_Hardware_Profile_Info_ExA [SETUPAPI.@]
3512 */
3513 CONFIGRET WINAPI CM_Get_Hardware_Profile_Info_ExA(
3514 ULONG ulIndex, PHWPROFILEINFO_A pHWProfileInfo, ULONG ulFlags,
3515 HMACHINE hMachine)
3516 {
3517 HWPROFILEINFO_W LocalProfileInfo;
3518 CONFIGRET ret;
3519
3520 TRACE("%lu %p %lx %lx\n", ulIndex, pHWProfileInfo, ulFlags, hMachine);
3521
3522 if (pHWProfileInfo == NULL)
3523 return CR_INVALID_POINTER;
3524
3525 ret = CM_Get_Hardware_Profile_Info_ExW(ulIndex, &LocalProfileInfo,
3526 ulFlags, hMachine);
3527 if (ret == CR_SUCCESS)
3528 {
3529 pHWProfileInfo->HWPI_ulHWProfile = LocalProfileInfo.HWPI_ulHWProfile;
3530 pHWProfileInfo->HWPI_dwFlags = LocalProfileInfo.HWPI_dwFlags;
3531
3532 if (WideCharToMultiByte(CP_ACP,
3533 0,
3534 LocalProfileInfo.HWPI_szFriendlyName,
3535 lstrlenW(LocalProfileInfo.HWPI_szFriendlyName) + 1,
3536 pHWProfileInfo->HWPI_szFriendlyName,
3537 MAX_PROFILE_LEN,
3538 NULL,
3539 NULL) == 0)
3540 ret = CR_FAILURE;
3541 }
3542
3543 return ret;
3544 }
3545
3546
3547 /***********************************************************************
3548 * CM_Get_Hardware_Profile_Info_ExW [SETUPAPI.@]
3549 */
3550 CONFIGRET WINAPI CM_Get_Hardware_Profile_Info_ExW(
3551 ULONG ulIndex, PHWPROFILEINFO_W pHWProfileInfo, ULONG ulFlags,
3552 HMACHINE hMachine)
3553 {
3554 RPC_BINDING_HANDLE BindingHandle = NULL;
3555 CONFIGRET ret;
3556
3557 TRACE("%lu %p %lx %lx\n", ulIndex, pHWProfileInfo, ulFlags, hMachine);
3558
3559 if (pHWProfileInfo == NULL)
3560 return CR_INVALID_POINTER;
3561
3562 if (ulFlags != 0)
3563 return CR_INVALID_FLAG;
3564
3565 if (hMachine != NULL)
3566 {
3567 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
3568 if (BindingHandle == NULL)
3569 return CR_FAILURE;
3570 }
3571 else
3572 {
3573 if (!PnpGetLocalHandles(&BindingHandle, NULL))
3574 return CR_FAILURE;
3575 }
3576
3577 RpcTryExcept
3578 {
3579 ret = PNP_GetHwProfInfo(BindingHandle, ulIndex, pHWProfileInfo,
3580 sizeof(HWPROFILEINFO_W), 0);
3581 }
3582 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
3583 {
3584 ret = RpcStatusToCmStatus(RpcExceptionCode());
3585 }
3586 RpcEndExcept;
3587
3588 return ret;
3589 }
3590
3591
3592 /***********************************************************************
3593 * CM_Get_Log_Conf_Priority [SETUPAPI.@]
3594 */
3595 CONFIGRET WINAPI CM_Get_Log_Conf_Priority(
3596 LOG_CONF lcLogConf, PPRIORITY pPriority, ULONG ulFlags)
3597 {
3598 TRACE("%p %p %lx\n", lcLogConf, pPriority, ulFlags);
3599 return CM_Get_Log_Conf_Priority_Ex(lcLogConf, pPriority, ulFlags, NULL);
3600 }
3601
3602
3603 /***********************************************************************
3604 * CM_Get_Log_Conf_Priority_Ex [SETUPAPI.@]
3605 */
3606 CONFIGRET WINAPI CM_Get_Log_Conf_Priority_Ex(
3607 LOG_CONF lcLogConf, PPRIORITY pPriority, ULONG ulFlags,
3608 HMACHINE hMachine)
3609 {
3610 RPC_BINDING_HANDLE BindingHandle = NULL;
3611 HSTRING_TABLE StringTable = NULL;
3612 PLOG_CONF_INFO pLogConfInfo;
3613 LPWSTR lpDevInst;
3614 CONFIGRET ret;
3615
3616 FIXME("%p %p %lx %lx\n", lcLogConf, pPriority, ulFlags, hMachine);
3617
3618 pLogConfInfo = (PLOG_CONF_INFO)lcLogConf;
3619 if (pLogConfInfo == NULL || pLogConfInfo->ulMagic != LOG_CONF_MAGIC)
3620 return CR_INVALID_LOG_CONF;
3621
3622 if (pPriority == NULL)
3623 return CR_INVALID_POINTER;
3624
3625 if (ulFlags != 0)
3626 return CR_INVALID_FLAG;
3627
3628 if (hMachine != NULL)
3629 {
3630 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
3631 if (BindingHandle == NULL)
3632 return CR_FAILURE;
3633
3634 StringTable = ((PMACHINE_INFO)hMachine)->StringTable;
3635 if (StringTable == 0)
3636 return CR_FAILURE;
3637 }
3638 else
3639 {
3640 if (!PnpGetLocalHandles(&BindingHandle, &StringTable))
3641 return CR_FAILURE;
3642 }
3643
3644 lpDevInst = pSetupStringTableStringFromId(StringTable, pLogConfInfo->dnDevInst);
3645 if (lpDevInst == NULL)
3646 return CR_INVALID_DEVNODE;
3647
3648 RpcTryExcept
3649 {
3650 ret = PNP_GetLogConfPriority(BindingHandle,
3651 lpDevInst,
3652 pLogConfInfo->ulFlags,
3653 pLogConfInfo->ulTag,
3654 pPriority,
3655 0);
3656 }
3657 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
3658 {
3659 ret = RpcStatusToCmStatus(RpcExceptionCode());
3660 }
3661 RpcEndExcept;
3662
3663 return ret;
3664 }
3665
3666
3667 /***********************************************************************
3668 * CM_Get_Next_Log_Conf [SETUPAPI.@]
3669 */
3670 CONFIGRET WINAPI CM_Get_Next_Log_Conf(
3671 PLOG_CONF plcLogConf, LOG_CONF lcLogConf, ULONG ulFlags)
3672 {
3673 TRACE("%p %p %lx\n", plcLogConf, lcLogConf, ulFlags);
3674 return CM_Get_Next_Log_Conf_Ex(plcLogConf, lcLogConf, ulFlags, NULL);
3675 }
3676
3677
3678 /***********************************************************************
3679 * CM_Get_Next_Log_Conf_Ex [SETUPAPI.@]
3680 */
3681 CONFIGRET WINAPI CM_Get_Next_Log_Conf_Ex(
3682 PLOG_CONF plcLogConf, LOG_CONF lcLogConf, ULONG ulFlags,
3683 HMACHINE hMachine)
3684 {
3685 RPC_BINDING_HANDLE BindingHandle = NULL;
3686 HSTRING_TABLE StringTable = NULL;
3687 PLOG_CONF_INFO pLogConfInfo;
3688 PLOG_CONF_INFO pNewLogConfInfo;
3689 ULONG ulNewTag;
3690 LPWSTR lpDevInst;
3691 CONFIGRET ret;
3692
3693 FIXME("%p %p %lx %lx\n", plcLogConf, lcLogConf, ulFlags, hMachine);
3694
3695 if (plcLogConf)
3696 *plcLogConf = 0;
3697
3698 pLogConfInfo = (PLOG_CONF_INFO)lcLogConf;
3699 if (pLogConfInfo == NULL || pLogConfInfo->ulMagic != LOG_CONF_MAGIC)
3700 return CR_INVALID_LOG_CONF;
3701
3702 if (ulFlags != 0)
3703 return CR_INVALID_FLAG;
3704
3705 if (hMachine != NULL)
3706 {
3707 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
3708 if (BindingHandle == NULL)
3709 return CR_FAILURE;
3710
3711 StringTable = ((PMACHINE_INFO)hMachine)->StringTable;
3712 if (StringTable == 0)
3713 return CR_FAILURE;
3714 }
3715 else
3716 {
3717 if (!PnpGetLocalHandles(&BindingHandle, &StringTable))
3718 return CR_FAILURE;
3719 }
3720
3721 lpDevInst = pSetupStringTableStringFromId(StringTable, pLogConfInfo->dnDevInst);
3722 if (lpDevInst == NULL)
3723 return CR_INVALID_DEVNODE;
3724
3725 RpcTryExcept
3726 {
3727 ret = PNP_GetNextLogConf(BindingHandle,
3728 lpDevInst,
3729 pLogConfInfo->ulFlags,
3730 pLogConfInfo->ulTag,
3731 &ulNewTag,
3732 0);
3733 }
3734 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
3735 {
3736 ret = RpcStatusToCmStatus(RpcExceptionCode());
3737 }
3738 RpcEndExcept;
3739
3740 if (ret != CR_SUCCESS)
3741 return ret;
3742
3743 if (plcLogConf)
3744 {
3745 pNewLogConfInfo = HeapAlloc(GetProcessHeap(), 0, sizeof(LOG_CONF_INFO));
3746 if (pNewLogConfInfo == NULL)
3747 return CR_OUT_OF_MEMORY;
3748
3749 pNewLogConfInfo->ulMagic = LOG_CONF_MAGIC;
3750 pNewLogConfInfo->dnDevInst = pLogConfInfo->dnDevInst;
3751 pNewLogConfInfo->ulFlags = pLogConfInfo->ulFlags;
3752 pNewLogConfInfo->ulTag = ulNewTag;
3753
3754 *plcLogConf = (LOG_CONF)pNewLogConfInfo;
3755 }
3756
3757 return CR_SUCCESS;
3758 }
3759
3760
3761 /***********************************************************************
3762 * CM_Get_Next_Re_Des [SETUPAPI.@]
3763 */
3764 CONFIGRET WINAPI CM_Get_Next_Res_Des(
3765 PRES_DES prdResDes, RES_DES rdResDes, RESOURCEID ForResource,
3766 PRESOURCEID pResourceID, ULONG ulFlags)
3767 {
3768 TRACE("%p %p %lu %p %lx\n", prdResDes, rdResDes, ForResource,
3769 pResourceID, ulFlags);
3770 return CM_Get_Next_Res_Des_Ex(prdResDes, rdResDes, ForResource,
3771 pResourceID, ulFlags, NULL);
3772 }
3773
3774
3775 /***********************************************************************
3776 * CM_Get_Next_Re_Des_Ex [SETUPAPI.@]
3777 */
3778 CONFIGRET WINAPI CM_Get_Next_Res_Des_Ex(
3779 PRES_DES prdResDes, RES_DES rdResDes, RESOURCEID ForResource,
3780 PRESOURCEID pResourceID, ULONG ulFlags, HMACHINE hMachine)
3781 {
3782 FIXME("%p %p %lu %p %lx %lx\n", prdResDes, rdResDes, ForResource,
3783 pResourceID, ulFlags, hMachine);
3784
3785 return CR_CALL_NOT_IMPLEMENTED;
3786 }
3787
3788
3789 /***********************************************************************
3790 * CM_Get_Parent [SETUPAPI.@]
3791 */
3792 CONFIGRET WINAPI CM_Get_Parent(
3793 PDEVINST pdnDevInst, DEVINST dnDevInst, ULONG ulFlags)
3794 {
3795 TRACE("%p %p %lx\n", pdnDevInst, dnDevInst, ulFlags);
3796 return CM_Get_Parent_Ex(pdnDevInst, dnDevInst, ulFlags, NULL);
3797 }
3798
3799
3800 /***********************************************************************
3801 * CM_Get_Parent_Ex [SETUPAPI.@]
3802 */
3803 CONFIGRET WINAPI CM_Get_Parent_Ex(
3804 PDEVINST pdnDevInst, DEVINST dnDevInst, ULONG ulFlags, HMACHINE hMachine)
3805 {
3806 WCHAR szRelatedDevInst[MAX_DEVICE_ID_LEN];
3807 RPC_BINDING_HANDLE BindingHandle = NULL;
3808 HSTRING_TABLE StringTable = NULL;
3809 LPWSTR lpDevInst;
3810 DWORD dwIndex, dwLength = MAX_DEVICE_ID_LEN;
3811 CONFIGRET ret;
3812
3813 TRACE("%p %lx %lx %lx\n", pdnDevInst, dnDevInst, ulFlags, hMachine);
3814
3815 if (pdnDevInst == NULL)
3816 return CR_INVALID_POINTER;
3817
3818 if (dnDevInst == 0)
3819 return CR_INVALID_DEVINST;
3820
3821 if (ulFlags != 0)
3822 return CR_INVALID_FLAG;
3823
3824 *pdnDevInst = -1;
3825
3826 if (hMachine != NULL)
3827 {
3828 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
3829 if (BindingHandle == NULL)
3830 return CR_FAILURE;
3831
3832 StringTable = ((PMACHINE_INFO)hMachine)->StringTable;
3833 if (StringTable == 0)
3834 return CR_FAILURE;
3835 }
3836 else
3837 {
3838 if (!PnpGetLocalHandles(&BindingHandle, &StringTable))
3839 return CR_FAILURE;
3840 }
3841
3842 lpDevInst = pSetupStringTableStringFromId(StringTable, dnDevInst);
3843 if (lpDevInst == NULL)
3844 return CR_INVALID_DEVNODE;
3845
3846 RpcTryExcept
3847 {
3848 ret = PNP_GetRelatedDeviceInstance(BindingHandle,
3849 PNP_GET_PARENT_DEVICE_INSTANCE,
3850 lpDevInst,
3851 szRelatedDevInst,
3852 &dwLength,
3853 0);
3854 }
3855 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
3856 {
3857 ret = RpcStatusToCmStatus(RpcExceptionCode());
3858 }
3859 RpcEndExcept;
3860
3861 if (ret != CR_SUCCESS)
3862 return ret;
3863
3864 TRACE("szRelatedDevInst: %s\n", debugstr_w(szRelatedDevInst));
3865
3866 dwIndex = pSetupStringTableAddString(StringTable, szRelatedDevInst, 1);
3867 if (dwIndex == -1)
3868 return CR_FAILURE;
3869
3870 *pdnDevInst = dwIndex;
3871
3872 return CR_SUCCESS;
3873 }
3874
3875
3876 /***********************************************************************
3877 * CM_Get_Res_Des_Data [SETUPAPI.@]
3878 */
3879 CONFIGRET WINAPI CM_Get_Res_Des_Data(
3880 RES_DES rdResDes, PVOID Buffer, ULONG BufferLen, ULONG ulFlags)
3881 {
3882 TRACE("%p %p %l %lx\n", rdResDes, Buffer, BufferLen, ulFlags);
3883 return CM_Get_Res_Des_Data_Ex(rdResDes, Buffer, BufferLen, ulFlags, NULL);
3884 }
3885
3886
3887 /***********************************************************************
3888 * CM_Get_Res_Des_Data_Ex [SETUPAPI.@]
3889 */
3890 CONFIGRET WINAPI CM_Get_Res_Des_Data_Ex(
3891 RES_DES rdResDes, PVOID Buffer, ULONG BufferLen, ULONG ulFlags,
3892 HMACHINE hMachine)
3893 {
3894 FIXME("%p %p %l %lx %lx\n", rdResDes, Buffer, BufferLen, ulFlags, hMachine);
3895 return CR_CALL_NOT_IMPLEMENTED;
3896 }
3897
3898
3899 /***********************************************************************
3900 * CM_Get_Res_Des_Size [SETUPAPI.@]
3901 */
3902 CONFIGRET WINAPI CM_Get_Res_Des_Data_Size(
3903 PULONG pulSize, RES_DES rdResDes, ULONG ulFlags)
3904 {
3905 TRACE("%p %p %lx\n", pulSize, rdResDes, ulFlags);
3906 return CM_Get_Res_Des_Data_Size_Ex(pulSize, rdResDes, ulFlags, NULL);
3907 }
3908
3909
3910 /***********************************************************************
3911 * CM_Get_Res_Des_Size_Ex [SETUPAPI.@]
3912 */
3913 CONFIGRET WINAPI CM_Get_Res_Des_Data_Size_Ex(
3914 PULONG pulSize, RES_DES rdResDes, ULONG ulFlags, HMACHINE hMachine)
3915 {
3916 TRACE("%p %p %lx %lx\n", pulSize, rdResDes, ulFlags, hMachine);
3917 return CR_CALL_NOT_IMPLEMENTED;
3918 }
3919
3920
3921 /***********************************************************************
3922 * CM_Get_Sibling [SETUPAPI.@]
3923 */
3924 CONFIGRET WINAPI CM_Get_Sibling(
3925 PDEVINST pdnDevInst, DEVINST dnDevInst, ULONG ulFlags)
3926 {
3927 TRACE("%p %p %lx\n", pdnDevInst, dnDevInst, ulFlags);
3928 return CM_Get_Sibling_Ex(pdnDevInst, dnDevInst, ulFlags, NULL);
3929 }
3930
3931
3932 /***********************************************************************
3933 * CM_Get_Sibling_Ex [SETUPAPI.@]
3934 */
3935 CONFIGRET WINAPI CM_Get_Sibling_Ex(
3936 PDEVINST pdnDevInst, DEVINST dnDevInst, ULONG ulFlags, HMACHINE hMachine)
3937 {
3938 WCHAR szRelatedDevInst[MAX_DEVICE_ID_LEN];
3939 RPC_BINDING_HANDLE BindingHandle = NULL;
3940 HSTRING_TABLE StringTable = NULL;
3941 LPWSTR lpDevInst;
3942 DWORD dwIndex, dwLength = MAX_DEVICE_ID_LEN;
3943 CONFIGRET ret;
3944
3945 TRACE("%p %lx %lx %lx\n", pdnDevInst, dnDevInst, ulFlags, hMachine);
3946
3947 if (pdnDevInst == NULL)
3948 return CR_INVALID_POINTER;
3949
3950 if (dnDevInst == 0)
3951 return CR_INVALID_DEVINST;
3952
3953 if (ulFlags != 0)</