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