[SETUPAPI]
[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("%p %lu %p %p %p %lx %lx\n",
1588 ClassGuid, ulProperty, pulRegDataType, Buffer, pulLength,
1589 ulFlags, hMachine);
1590 return CR_CALL_NOT_IMPLEMENTED;
1591 }
1592
1593
1594 /***********************************************************************
1595 * CM_Get_Class_Registry_PropertyW [SETUPAPI.@]
1596 */
1597 CONFIGRET WINAPI CM_Get_Class_Registry_PropertyW(
1598 LPGUID ClassGuid, ULONG ulProperty, PULONG pulRegDataType,
1599 PVOID Buffer, PULONG pulLength, ULONG ulFlags, HMACHINE hMachine)
1600 {
1601 RPC_BINDING_HANDLE BindingHandle = NULL;
1602 WCHAR szGuidString[PNP_MAX_GUID_STRING_LEN + 1];
1603 ULONG ulType = 0;
1604 ULONG ulTransferLength = 0;
1605 CONFIGRET ret;
1606
1607 TRACE("%p %lu %p %p %p %lx %lx\n",
1608 ClassGuid, ulProperty, pulRegDataType, Buffer, pulLength,
1609 ulFlags, hMachine);
1610
1611 if (ClassGuid == NULL || pulLength == NULL)
1612 return CR_INVALID_POINTER;
1613
1614 if (ulFlags != 0)
1615 return CR_INVALID_FLAG;
1616
1617 if (pSetupStringFromGuid(ClassGuid,
1618 szGuidString,
1619 PNP_MAX_GUID_STRING_LEN) != 0)
1620 return CR_INVALID_DATA;
1621
1622 if (ulProperty < CM_CRP_MIN || ulProperty > CM_CRP_MAX)
1623 return CR_INVALID_PROPERTY;
1624
1625 if (hMachine != NULL)
1626 {
1627 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
1628 if (BindingHandle == NULL)
1629 return CR_FAILURE;
1630 }
1631 else
1632 {
1633 if (!PnpGetLocalHandles(&BindingHandle, NULL))
1634 return CR_FAILURE;
1635 }
1636
1637 ulTransferLength = *pulLength;
1638
1639 RpcTryExcept
1640 {
1641 ret = PNP_GetClassRegProp(BindingHandle,
1642 szGuidString,
1643 ulProperty,
1644 &ulType,
1645 Buffer,
1646 &ulTransferLength,
1647 pulLength,
1648 ulFlags);
1649 }
1650 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1651 {
1652 ret = RpcStatusToCmStatus(RpcExceptionCode());
1653 }
1654 RpcEndExcept;
1655
1656 if (ret == CR_SUCCESS)
1657 {
1658 if (pulRegDataType != NULL)
1659 *pulRegDataType = ulType;
1660 }
1661
1662 return ret;
1663 }
1664
1665
1666 /***********************************************************************
1667 * CM_Get_Depth [SETUPAPI.@]
1668 */
1669 CONFIGRET WINAPI CM_Get_Depth(
1670 PULONG pulDepth, DEVINST dnDevInst, ULONG ulFlags)
1671 {
1672 TRACE("%p %lx %lx\n", pulDepth, dnDevInst, ulFlags);
1673 return CM_Get_Depth_Ex(pulDepth, dnDevInst, ulFlags, NULL);
1674 }
1675
1676
1677 /***********************************************************************
1678 * CM_Get_Depth_Ex [SETUPAPI.@]
1679 */
1680 CONFIGRET WINAPI CM_Get_Depth_Ex(
1681 PULONG pulDepth, DEVINST dnDevInst, ULONG ulFlags, HMACHINE hMachine)
1682 {
1683 RPC_BINDING_HANDLE BindingHandle = NULL;
1684 HSTRING_TABLE StringTable = NULL;
1685 LPWSTR lpDevInst;
1686 CONFIGRET ret;
1687
1688 TRACE("%p %lx %lx %lx\n",
1689 pulDepth, dnDevInst, ulFlags, hMachine);
1690
1691 if (pulDepth == NULL)
1692 return CR_INVALID_POINTER;
1693
1694 if (dnDevInst == 0)
1695 return CR_INVALID_DEVINST;
1696
1697 if (ulFlags != 0)
1698 return CR_INVALID_FLAG;
1699
1700 if (hMachine != NULL)
1701 {
1702 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
1703 if (BindingHandle == NULL)
1704 return CR_FAILURE;
1705
1706 StringTable = ((PMACHINE_INFO)hMachine)->StringTable;
1707 if (StringTable == 0)
1708 return CR_FAILURE;
1709 }
1710 else
1711 {
1712 if (!PnpGetLocalHandles(&BindingHandle, &StringTable))
1713 return CR_FAILURE;
1714 }
1715
1716 lpDevInst = pSetupStringTableStringFromId(StringTable, dnDevInst);
1717 if (lpDevInst == NULL)
1718 return CR_INVALID_DEVNODE;
1719
1720 RpcTryExcept
1721 {
1722 ret = PNP_GetDepth(BindingHandle,
1723 lpDevInst,
1724 pulDepth,
1725 ulFlags);
1726 }
1727 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1728 {
1729 ret = RpcStatusToCmStatus(RpcExceptionCode());
1730 }
1731 RpcEndExcept;
1732
1733 return ret;
1734 }
1735
1736
1737 /***********************************************************************
1738 * CM_Get_DevNode_Registry_PropertyA [SETUPAPI.@]
1739 */
1740 CONFIGRET WINAPI CM_Get_DevNode_Registry_PropertyA(
1741 DEVINST dnDevInst, ULONG ulProperty, PULONG pulRegDataType,
1742 PVOID Buffer, PULONG pulLength, ULONG ulFlags)
1743 {
1744 TRACE("%lx %lu %p %p %p %lx\n",
1745 dnDevInst, ulProperty, pulRegDataType, Buffer, pulLength, ulFlags);
1746
1747 return CM_Get_DevNode_Registry_Property_ExA(dnDevInst, ulProperty,
1748 pulRegDataType, Buffer,
1749 pulLength, ulFlags, NULL);
1750 }
1751
1752
1753 /***********************************************************************
1754 * CM_Get_DevNode_Registry_PropertyW [SETUPAPI.@]
1755 */
1756 CONFIGRET WINAPI CM_Get_DevNode_Registry_PropertyW(
1757 DEVINST dnDevInst, ULONG ulProperty, PULONG pulRegDataType,
1758 PVOID Buffer, PULONG pulLength, ULONG ulFlags)
1759 {
1760 TRACE("%lx %lu %p %p %p %lx\n",
1761 dnDevInst, ulProperty, pulRegDataType, Buffer, pulLength, ulFlags);
1762
1763 return CM_Get_DevNode_Registry_Property_ExW(dnDevInst, ulProperty,
1764 pulRegDataType, Buffer,
1765 pulLength, ulFlags, NULL);
1766 }
1767
1768
1769 /***********************************************************************
1770 * CM_Get_DevNode_Registry_Property_ExA [SETUPAPI.@]
1771 */
1772 CONFIGRET WINAPI CM_Get_DevNode_Registry_Property_ExA(
1773 DEVINST dnDevInst, ULONG ulProperty, PULONG pulRegDataType,
1774 PVOID Buffer, PULONG pulLength, ULONG ulFlags, HMACHINE hMachine)
1775 {
1776 PVOID BufferW;
1777 ULONG LengthW;
1778 ULONG RegDataType = REG_NONE;
1779 CONFIGRET ret;
1780
1781 TRACE("%lx %lu %p %p %p %lx %lx\n",
1782 dnDevInst, ulProperty, pulRegDataType, Buffer, pulLength,
1783 ulFlags, hMachine);
1784
1785 if (!pulLength)
1786 return CR_INVALID_POINTER;
1787
1788 LengthW = *pulLength * sizeof(WCHAR);
1789 BufferW = HeapAlloc(GetProcessHeap(), 0, LengthW);
1790
1791 if (!BufferW)
1792 return CR_OUT_OF_MEMORY;
1793
1794 ret = CM_Get_DevNode_Registry_Property_ExW(dnDevInst,
1795 ulProperty,
1796 &RegDataType,
1797 BufferW,
1798 &LengthW,
1799 ulFlags,
1800 hMachine);
1801
1802 if (ret == CR_SUCCESS)
1803 {
1804 if (RegDataType == REG_SZ || RegDataType == REG_EXPAND_SZ)
1805 {
1806 /* Do W->A conversion */
1807 *pulLength = WideCharToMultiByte(CP_ACP,
1808 0,
1809 BufferW,
1810 lstrlenW(BufferW) + 1,
1811 Buffer,
1812 *pulLength,
1813 NULL,
1814 NULL);
1815 if (*pulLength == 0)
1816 ret = CR_FAILURE;
1817 }
1818 else
1819 {
1820 /* Directly copy the value */
1821 if (LengthW <= *pulLength)
1822 memcpy(Buffer, BufferW, LengthW);
1823 else
1824 {
1825 *pulLength = LengthW;
1826 ret = CR_BUFFER_SMALL;
1827 }
1828 }
1829 }
1830
1831 if (pulRegDataType)
1832 *pulRegDataType = RegDataType;
1833
1834 HeapFree(GetProcessHeap(), 0, BufferW);
1835
1836 return ret;
1837 }
1838
1839
1840 /***********************************************************************
1841 * CM_Get_DevNode_Registry_Property_ExW [SETUPAPI.@]
1842 */
1843 CONFIGRET WINAPI CM_Get_DevNode_Registry_Property_ExW(
1844 DEVINST dnDevInst, ULONG ulProperty, PULONG pulRegDataType,
1845 PVOID Buffer, PULONG pulLength, ULONG ulFlags, HMACHINE hMachine)
1846 {
1847 RPC_BINDING_HANDLE BindingHandle = NULL;
1848 HSTRING_TABLE StringTable = NULL;
1849 CONFIGRET ret = CR_SUCCESS;
1850 LPWSTR lpDevInst;
1851 ULONG ulDataType = 0;
1852 ULONG ulTransferLength = 0;
1853
1854 TRACE("%lx %lu %p %p %p %lx %lx\n",
1855 dnDevInst, ulProperty, pulRegDataType, Buffer, pulLength,
1856 ulFlags, hMachine);
1857
1858 if (dnDevInst == 0)
1859 return CR_INVALID_DEVNODE;
1860
1861 if (ulProperty < CM_DRP_MIN || ulProperty > CM_DRP_MAX)
1862 return CR_INVALID_PROPERTY;
1863
1864 /* pulRegDataType is optional */
1865
1866 /* Buffer is optional */
1867
1868 if (pulLength == NULL)
1869 return CR_INVALID_POINTER;
1870
1871 if (*pulLength == 0)
1872 return CR_INVALID_POINTER;
1873
1874 if (ulFlags != 0)
1875 return CR_INVALID_FLAG;
1876
1877 if (hMachine != NULL)
1878 {
1879 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
1880 if (BindingHandle == NULL)
1881 return CR_FAILURE;
1882
1883 StringTable = ((PMACHINE_INFO)hMachine)->StringTable;
1884 if (StringTable == 0)
1885 return CR_FAILURE;
1886 }
1887 else
1888 {
1889 if (!PnpGetLocalHandles(&BindingHandle, &StringTable))
1890 return CR_FAILURE;
1891 }
1892
1893 lpDevInst = pSetupStringTableStringFromId(StringTable, dnDevInst);
1894 if (lpDevInst == NULL)
1895 return CR_INVALID_DEVNODE;
1896
1897 ulTransferLength = *pulLength;
1898
1899 RpcTryExcept
1900 {
1901 ret = PNP_GetDeviceRegProp(BindingHandle,
1902 lpDevInst,
1903 ulProperty,
1904 &ulDataType,
1905 Buffer,
1906 &ulTransferLength,
1907 pulLength,
1908 ulFlags);
1909 }
1910 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1911 {
1912 ret = RpcStatusToCmStatus(RpcExceptionCode());
1913 }
1914 RpcEndExcept;
1915
1916 if (ret == CR_SUCCESS)
1917 {
1918 if (pulRegDataType != NULL)
1919 *pulRegDataType = ulDataType;
1920 }
1921
1922 return ret;
1923 }
1924
1925
1926 /***********************************************************************
1927 * CM_Get_DevNode_Status [SETUPAPI.@]
1928 */
1929 CONFIGRET WINAPI CM_Get_DevNode_Status(
1930 PULONG pulStatus, PULONG pulProblemNumber, DEVINST dnDevInst,
1931 ULONG ulFlags)
1932 {
1933 TRACE("%p %p %lx %lx\n",
1934 pulStatus, pulProblemNumber, dnDevInst, ulFlags);
1935 return CM_Get_DevNode_Status_Ex(pulStatus, pulProblemNumber, dnDevInst,
1936 ulFlags, NULL);
1937 }
1938
1939
1940 /***********************************************************************
1941 * CM_Get_DevNode_Status_Ex [SETUPAPI.@]
1942 */
1943 CONFIGRET WINAPI
1944 CM_Get_DevNode_Status_Ex(
1945 PULONG pulStatus, PULONG pulProblemNumber, DEVINST dnDevInst,
1946 ULONG ulFlags, HMACHINE hMachine)
1947 {
1948 RPC_BINDING_HANDLE BindingHandle = NULL;
1949 HSTRING_TABLE StringTable = NULL;
1950 LPWSTR lpDevInst;
1951 CONFIGRET ret;
1952
1953 TRACE("%p %p %lx %lx %lx\n",
1954 pulStatus, pulProblemNumber, dnDevInst, ulFlags, hMachine);
1955
1956 if (pulStatus == NULL || pulProblemNumber == NULL)
1957 return CR_INVALID_POINTER;
1958
1959 if (dnDevInst == 0)
1960 return CR_INVALID_DEVINST;
1961
1962 if (ulFlags != 0)
1963 return CR_INVALID_FLAG;
1964
1965 if (hMachine != NULL)
1966 {
1967 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
1968 if (BindingHandle == NULL)
1969 return CR_FAILURE;
1970
1971 StringTable = ((PMACHINE_INFO)hMachine)->StringTable;
1972 if (StringTable == 0)
1973 return CR_FAILURE;
1974 }
1975 else
1976 {
1977 if (!PnpGetLocalHandles(&BindingHandle, &StringTable))
1978 return CR_FAILURE;
1979 }
1980
1981 lpDevInst = pSetupStringTableStringFromId(StringTable, dnDevInst);
1982 if (lpDevInst == NULL)
1983 return CR_INVALID_DEVNODE;
1984
1985 RpcTryExcept
1986 {
1987 ret = PNP_GetDeviceStatus(BindingHandle,
1988 lpDevInst,
1989 pulStatus,
1990 pulProblemNumber,
1991 ulFlags);
1992 }
1993 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1994 {
1995 ret = RpcStatusToCmStatus(RpcExceptionCode());
1996 }
1997 RpcEndExcept;
1998
1999 return ret;
2000 }
2001
2002
2003 /***********************************************************************
2004 * CM_Get_Device_IDA [SETUPAPI.@]
2005 */
2006 CONFIGRET WINAPI CM_Get_Device_IDA(
2007 DEVINST dnDevInst, PCHAR Buffer, ULONG BufferLen, ULONG ulFlags)
2008 {
2009 TRACE("%lx %p %ld %ld\n",
2010 dnDevInst, Buffer, BufferLen, ulFlags);
2011 return CM_Get_Device_ID_ExA(dnDevInst, Buffer, BufferLen, ulFlags, NULL);
2012 }
2013
2014
2015 /***********************************************************************
2016 * CM_Get_Device_IDW [SETUPAPI.@]
2017 */
2018 CONFIGRET WINAPI CM_Get_Device_IDW(
2019 DEVINST dnDevInst, PWCHAR Buffer, ULONG BufferLen, ULONG ulFlags)
2020 {
2021 TRACE("%lx %p %ld %ld\n",
2022 dnDevInst, Buffer, BufferLen, ulFlags);
2023 return CM_Get_Device_ID_ExW(dnDevInst, Buffer, BufferLen, ulFlags, NULL);
2024 }
2025
2026
2027 /***********************************************************************
2028 * CM_Get_Device_ID_ExA [SETUPAPI.@]
2029 */
2030 CONFIGRET WINAPI CM_Get_Device_ID_ExA(
2031 DEVINST dnDevInst, PCHAR Buffer, ULONG BufferLen, ULONG ulFlags,
2032 HMACHINE hMachine)
2033 {
2034 WCHAR szBufferW[MAX_DEVICE_ID_LEN];
2035 CONFIGRET ret = CR_SUCCESS;
2036
2037 TRACE("%lx %p %ld %ld %lx\n",
2038 dnDevInst, Buffer, BufferLen, ulFlags, hMachine);
2039
2040 if (Buffer == NULL)
2041 return CR_INVALID_POINTER;
2042
2043 ret = CM_Get_Device_ID_ExW(dnDevInst,
2044 szBufferW,
2045 MAX_DEVICE_ID_LEN,
2046 ulFlags,
2047 hMachine);
2048 if (ret == CR_SUCCESS)
2049 {
2050 if (WideCharToMultiByte(CP_ACP,
2051 0,
2052 szBufferW,
2053 lstrlenW(szBufferW) + 1,
2054 Buffer,
2055 BufferLen,
2056 NULL,
2057 NULL) == 0)
2058 ret = CR_FAILURE;
2059 }
2060
2061 return ret;
2062 }
2063
2064
2065 /***********************************************************************
2066 * CM_Get_Device_ID_ExW [SETUPAPI.@]
2067 */
2068 CONFIGRET WINAPI CM_Get_Device_ID_ExW(
2069 DEVINST dnDevInst, PWCHAR Buffer, ULONG BufferLen, ULONG ulFlags,
2070 HMACHINE hMachine)
2071 {
2072 HSTRING_TABLE StringTable = NULL;
2073
2074 TRACE("%lx %p %ld %ld %lx\n",
2075 dnDevInst, Buffer, BufferLen, ulFlags, hMachine);
2076
2077 if (dnDevInst == 0)
2078 return CR_INVALID_DEVINST;
2079
2080 if (Buffer == NULL)
2081 return CR_INVALID_POINTER;
2082
2083 if (ulFlags != 0)
2084 return CR_INVALID_FLAG;
2085
2086 if (hMachine != NULL)
2087 {
2088 StringTable = ((PMACHINE_INFO)hMachine)->StringTable;
2089 if (StringTable == NULL)
2090 return CR_FAILURE;
2091 }
2092 else
2093 {
2094 if (!PnpGetLocalHandles(NULL, &StringTable))
2095 return CR_FAILURE;
2096 }
2097
2098 if (!pSetupStringTableStringFromIdEx(StringTable,
2099 dnDevInst,
2100 Buffer,
2101 &BufferLen))
2102 return CR_FAILURE;
2103
2104 return CR_SUCCESS;
2105 }
2106
2107
2108 /***********************************************************************
2109 * CM_Get_Device_ID_ListA [SETUPAPI.@]
2110 */
2111 CONFIGRET WINAPI CM_Get_Device_ID_ListA(
2112 PCSTR pszFilter, PCHAR Buffer, ULONG BufferLen, ULONG ulFlags)
2113 {
2114 TRACE("%p %p %ld %ld\n", pszFilter, Buffer, BufferLen, ulFlags);
2115 return CM_Get_Device_ID_List_ExA(pszFilter, Buffer, BufferLen,
2116 ulFlags, NULL);
2117 }
2118
2119
2120 /***********************************************************************
2121 * CM_Get_Device_ID_ListW [SETUPAPI.@]
2122 */
2123 CONFIGRET WINAPI CM_Get_Device_ID_ListW(
2124 PCWSTR pszFilter, PWCHAR Buffer, ULONG BufferLen, ULONG ulFlags)
2125 {
2126 TRACE("%p %p %ld %ld\n", pszFilter, Buffer, BufferLen, ulFlags);
2127 return CM_Get_Device_ID_List_ExW(pszFilter, Buffer, BufferLen,
2128 ulFlags, NULL);
2129 }
2130
2131
2132 /***********************************************************************
2133 * CM_Get_Device_ID_List_ExA [SETUPAPI.@]
2134 */
2135 CONFIGRET WINAPI CM_Get_Device_ID_List_ExA(
2136 PCSTR pszFilter, PCHAR Buffer, ULONG BufferLen, ULONG ulFlags,
2137 HMACHINE hMachine)
2138 {
2139 LPWSTR BufferW = NULL;
2140 LPWSTR pszFilterW = NULL;
2141 CONFIGRET ret = CR_SUCCESS;
2142
2143 TRACE("%p %p %ld %ld %lx\n",
2144 pszFilter, Buffer, BufferLen, ulFlags, hMachine);
2145
2146 BufferW = MyMalloc(BufferLen * sizeof(WCHAR));
2147 if (BufferW == NULL)
2148 return CR_OUT_OF_MEMORY;
2149
2150 if (pszFilter == NULL)
2151 {
2152 ret = CM_Get_Device_ID_List_ExW(NULL,
2153 BufferW,
2154 BufferLen,
2155 ulFlags,
2156 hMachine);
2157 }
2158 else
2159 {
2160 if (pSetupCaptureAndConvertAnsiArg(pszFilter, &pszFilterW))
2161 {
2162 ret = CR_INVALID_DEVICE_ID;
2163 goto Done;
2164 }
2165
2166 ret = CM_Get_Device_ID_List_ExW(pszFilterW,
2167 BufferW,
2168 BufferLen,
2169 ulFlags,
2170 hMachine);
2171
2172 MyFree(pszFilterW);
2173 }
2174
2175 if (WideCharToMultiByte(CP_ACP,
2176 0,
2177 BufferW,
2178 lstrlenW(BufferW) + 1,
2179 Buffer,
2180 BufferLen,
2181 NULL,
2182 NULL) == 0)
2183 ret = CR_FAILURE;
2184
2185 Done:
2186 MyFree(BufferW);
2187
2188 return ret;
2189 }
2190
2191
2192 /***********************************************************************
2193 * CM_Get_Device_ID_List_ExW [SETUPAPI.@]
2194 */
2195 CONFIGRET WINAPI CM_Get_Device_ID_List_ExW(
2196 PCWSTR pszFilter, PWCHAR Buffer, ULONG BufferLen, ULONG ulFlags,
2197 HMACHINE hMachine)
2198 {
2199 RPC_BINDING_HANDLE BindingHandle = NULL;
2200 CONFIGRET ret;
2201
2202 TRACE("%p %p %ld %ld %lx\n",
2203 pszFilter, Buffer, BufferLen, ulFlags, hMachine);
2204
2205 if (Buffer == NULL || BufferLen == 0)
2206 return CR_INVALID_POINTER;
2207
2208 if (ulFlags & ~CM_GETIDLIST_FILTER_BITS)
2209 return CR_INVALID_FLAG;
2210
2211 if (hMachine != NULL)
2212 {
2213 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
2214 if (BindingHandle == NULL)
2215 return CR_FAILURE;
2216 }
2217 else
2218 {
2219 if (!PnpGetLocalHandles(&BindingHandle, NULL))
2220 return CR_FAILURE;
2221 }
2222
2223 *Buffer = 0;
2224
2225 RpcTryExcept
2226 {
2227 ret = PNP_GetDeviceList(BindingHandle,
2228 (LPWSTR)pszFilter,
2229 Buffer,
2230 &BufferLen,
2231 ulFlags);
2232 }
2233 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
2234 {
2235 ret = RpcStatusToCmStatus(RpcExceptionCode());
2236 }
2237 RpcEndExcept;
2238
2239 return ret;
2240 }
2241
2242
2243 /***********************************************************************
2244 * CM_Get_Device_ID_List_SizeA [SETUPAPI.@]
2245 */
2246 CONFIGRET WINAPI CM_Get_Device_ID_List_SizeA(
2247 PULONG pulLen, PCSTR pszFilter, ULONG ulFlags)
2248 {
2249 TRACE("%p %s %ld\n", pulLen, pszFilter, ulFlags);
2250 return CM_Get_Device_ID_List_Size_ExA(pulLen, pszFilter, ulFlags, NULL);
2251 }
2252
2253
2254 /***********************************************************************
2255 * CM_Get_Device_ID_List_SizeW [SETUPAPI.@]
2256 */
2257 CONFIGRET WINAPI CM_Get_Device_ID_List_SizeW(
2258 PULONG pulLen, PCWSTR pszFilter, ULONG ulFlags)
2259 {
2260 TRACE("%p %s %ld\n", pulLen, debugstr_w(pszFilter), ulFlags);
2261 return CM_Get_Device_ID_List_Size_ExW(pulLen, pszFilter, ulFlags, NULL);
2262 }
2263
2264
2265 /***********************************************************************
2266 * CM_Get_Device_ID_List_Size_ExA [SETUPAPI.@]
2267 */
2268 CONFIGRET WINAPI CM_Get_Device_ID_List_Size_ExA(
2269 PULONG pulLen, PCSTR pszFilter, ULONG ulFlags, HMACHINE hMachine)
2270 {
2271 LPWSTR pszFilterW = NULL;
2272 CONFIGRET ret = CR_SUCCESS;
2273
2274 FIXME("%p %s %lx %lx\n", pulLen, pszFilter, ulFlags, hMachine);
2275
2276 if (pszFilter == NULL)
2277 {
2278 ret = CM_Get_Device_ID_List_Size_ExW(pulLen,
2279 NULL,
2280 ulFlags,
2281 hMachine);
2282 }
2283 else
2284 {
2285 if (pSetupCaptureAndConvertAnsiArg(pszFilter, &pszFilterW))
2286 return CR_INVALID_DEVICE_ID;
2287
2288 ret = CM_Get_Device_ID_List_Size_ExW(pulLen,
2289 pszFilterW,
2290 ulFlags,
2291 hMachine);
2292
2293 MyFree(pszFilterW);
2294 }
2295
2296 return ret;
2297 }
2298
2299
2300 /***********************************************************************
2301 * CM_Get_Device_ID_List_Size_ExW [SETUPAPI.@]
2302 */
2303 CONFIGRET WINAPI CM_Get_Device_ID_List_Size_ExW(
2304 PULONG pulLen, PCWSTR pszFilter, ULONG ulFlags, HMACHINE hMachine)
2305 {
2306 RPC_BINDING_HANDLE BindingHandle = NULL;
2307 CONFIGRET ret;
2308
2309 FIXME("%p %s %ld %lx\n", pulLen, debugstr_w(pszFilter), ulFlags, hMachine);
2310
2311 if (pulLen == NULL)
2312 return CR_INVALID_POINTER;
2313
2314 if (ulFlags & ~CM_GETIDLIST_FILTER_BITS)
2315 return CR_INVALID_FLAG;
2316
2317 if (hMachine != NULL)
2318 {
2319 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
2320 if (BindingHandle == NULL)
2321 return CR_FAILURE;
2322 }
2323 else
2324 {
2325 if (!PnpGetLocalHandles(&BindingHandle, NULL))
2326 return CR_FAILURE;
2327 }
2328
2329 *pulLen = 0;
2330
2331 RpcTryExcept
2332 {
2333 ret = PNP_GetDeviceListSize(BindingHandle,
2334 (LPWSTR)pszFilter,
2335 pulLen,
2336 ulFlags);
2337 }
2338 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
2339 {
2340 ret = RpcStatusToCmStatus(RpcExceptionCode());
2341 }
2342 RpcEndExcept;
2343
2344 return ret;
2345 }
2346
2347
2348 /***********************************************************************
2349 * CM_Get_Device_ID_Size [SETUPAPI.@]
2350 */
2351 CONFIGRET WINAPI CM_Get_Device_ID_Size(
2352 PULONG pulLen, DEVINST dnDevInst, ULONG ulFlags)
2353 {
2354 TRACE("%p %lx %lx\n", pulLen, dnDevInst, ulFlags);
2355 return CM_Get_Device_ID_Size_Ex(pulLen, dnDevInst, ulFlags, NULL);
2356 }
2357
2358
2359 /***********************************************************************
2360 * CM_Get_Device_ID_Size_Ex [SETUPAPI.@]
2361 */
2362 CONFIGRET WINAPI CM_Get_Device_ID_Size_Ex(
2363 PULONG pulLen, DEVINST dnDevInst, ULONG ulFlags, HMACHINE hMachine)
2364 {
2365 HSTRING_TABLE StringTable = NULL;
2366 LPWSTR DeviceId;
2367
2368 TRACE("%p %lx %lx %lx\n", pulLen, dnDevInst, ulFlags, hMachine);
2369
2370 if (pulLen == NULL)
2371 return CR_INVALID_POINTER;
2372
2373 if (dnDevInst == 0)
2374 return CR_INVALID_DEVINST;
2375
2376 if (ulFlags != 0)
2377 return CR_INVALID_FLAG;
2378
2379 if (hMachine != NULL)
2380 {
2381 StringTable = ((PMACHINE_INFO)hMachine)->StringTable;
2382 if (StringTable == NULL)
2383 return CR_FAILURE;
2384 }
2385 else
2386 {
2387 if (!PnpGetLocalHandles(NULL, &StringTable))
2388 return CR_FAILURE;
2389 }
2390
2391 DeviceId = pSetupStringTableStringFromId(StringTable, dnDevInst);
2392 if (DeviceId == NULL)
2393 {
2394 *pulLen = 0;
2395 return CR_SUCCESS;
2396 }
2397
2398 *pulLen = lstrlenW(DeviceId);
2399
2400 return CR_SUCCESS;
2401 }
2402
2403
2404 /***********************************************************************
2405 * CM_Get_Device_Interface_AliasA [SETUPAPI.@]
2406 */
2407 CONFIGRET WINAPI CM_Get_Device_Interface_AliasA(
2408 LPCSTR pszDeviceInterface, LPGUID AliasInterfaceGuid,
2409 LPSTR pszAliasDeviceInterface, PULONG pulLength, ULONG ulFlags)
2410 {
2411 TRACE("%p %p %p %p %lu\n", pszDeviceInterface, AliasInterfaceGuid,
2412 pszAliasDeviceInterface, pulLength, ulFlags);
2413
2414 return CM_Get_Device_Interface_Alias_ExA(pszDeviceInterface,
2415 AliasInterfaceGuid, pszAliasDeviceInterface, pulLength,
2416 ulFlags, NULL);
2417 }
2418
2419
2420 /***********************************************************************
2421 * CM_Get_Device_Interface_AliasW [SETUPAPI.@]
2422 */
2423 CONFIGRET WINAPI CM_Get_Device_Interface_AliasW(
2424 LPCWSTR pszDeviceInterface, LPGUID AliasInterfaceGuid,
2425 LPWSTR pszAliasDeviceInterface, PULONG pulLength, ULONG ulFlags)
2426 {
2427 TRACE("%p %p %p %p %lu\n", pszDeviceInterface, AliasInterfaceGuid,
2428 pszAliasDeviceInterface, pulLength, ulFlags);
2429
2430 return CM_Get_Device_Interface_Alias_ExW(pszDeviceInterface,
2431 AliasInterfaceGuid, pszAliasDeviceInterface, pulLength,
2432 ulFlags, NULL);
2433 }
2434
2435
2436 /***********************************************************************
2437 * CM_Get_Device_Interface_Alias_ExA [SETUPAPI.@]
2438 */
2439 CONFIGRET WINAPI CM_Get_Device_Interface_Alias_ExA(
2440 LPCSTR pszDeviceInterface, LPGUID AliasInterfaceGuid, LPSTR pszAliasDeviceInterface,
2441 PULONG pulLength, ULONG ulFlags, HMACHINE hMachine)
2442 {
2443 FIXME("%p %p %p %p %lu %lx\n", pszDeviceInterface, AliasInterfaceGuid,
2444 pszAliasDeviceInterface, pulLength, ulFlags, hMachine);
2445
2446 return CR_CALL_NOT_IMPLEMENTED;
2447 }
2448
2449
2450 /***********************************************************************
2451 * CM_Get_Device_Interface_Alias_ExW [SETUPAPI.@]
2452 */
2453 CONFIGRET WINAPI CM_Get_Device_Interface_Alias_ExW(
2454 LPCWSTR pszDeviceInterface, LPGUID AliasInterfaceGuid, LPWSTR pszAliasDeviceInterface,
2455 PULONG pulLength, ULONG ulFlags, HMACHINE hMachine)
2456 {
2457 RPC_BINDING_HANDLE BindingHandle = NULL;
2458 ULONG ulTransferLength;
2459 CONFIGRET ret = CR_SUCCESS;
2460
2461 TRACE("%p %p %p %p %lu %lx\n", pszDeviceInterface, AliasInterfaceGuid,
2462 pszAliasDeviceInterface, pulLength, ulFlags, hMachine);
2463
2464 if (pszDeviceInterface == NULL ||
2465 AliasInterfaceGuid == NULL ||
2466 pszAliasDeviceInterface == NULL ||
2467 pulLength == NULL)
2468 return CR_INVALID_POINTER;
2469
2470 if (ulFlags != 0)
2471 return CR_INVALID_FLAG;
2472
2473 if (hMachine != NULL)
2474 {
2475 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
2476 if (BindingHandle == NULL)
2477 return CR_FAILURE;
2478 }
2479 else
2480 {
2481 if (!PnpGetLocalHandles(&BindingHandle, NULL))
2482 return CR_FAILURE;
2483 }
2484
2485 ulTransferLength = *pulLength;
2486
2487 RpcTryExcept
2488 {
2489 ret = PNP_GetInterfaceDeviceAlias(BindingHandle,
2490 (LPWSTR)pszDeviceInterface,
2491 AliasInterfaceGuid,
2492 pszAliasDeviceInterface,
2493 pulLength,
2494 &ulTransferLength,
2495 0);
2496 }
2497 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
2498 {
2499 ret = RpcStatusToCmStatus(RpcExceptionCode());
2500 }
2501 RpcEndExcept;
2502
2503 return ret;
2504 }
2505
2506
2507 /***********************************************************************
2508 * CM_Get_Device_Interface_ListA (SETUPAPI.@)
2509 */
2510 CONFIGRET WINAPI CM_Get_Device_Interface_ListA(
2511 LPGUID InterfaceClassGuid, DEVINSTID_A pDeviceID, PCHAR Buffer,
2512 ULONG BufferLen, ULONG ulFlags)
2513 {
2514 TRACE("%s %s %p %lu 0x%08lx\n", debugstr_guid(InterfaceClassGuid),
2515 pDeviceID, Buffer, BufferLen, ulFlags);
2516
2517 return CM_Get_Device_Interface_List_ExA(InterfaceClassGuid, pDeviceID,
2518 Buffer, BufferLen, ulFlags, NULL);
2519 }
2520
2521
2522 /***********************************************************************
2523 * CM_Get_Device_Interface_ListW (SETUPAPI.@)
2524 */
2525 CONFIGRET WINAPI CM_Get_Device_Interface_ListW(
2526 LPGUID InterfaceClassGuid, DEVINSTID_W pDeviceID, PWCHAR Buffer,
2527 ULONG BufferLen, ULONG ulFlags)
2528 {
2529 TRACE("%s %s %p %lu 0x%08lx\n", debugstr_guid(InterfaceClassGuid),
2530 debugstr_w(pDeviceID), Buffer, BufferLen, ulFlags);
2531
2532 return CM_Get_Device_Interface_List_ExW(InterfaceClassGuid, pDeviceID,
2533 Buffer, BufferLen, ulFlags, NULL);
2534 }
2535
2536
2537 /***********************************************************************
2538 * CM_Get_Device_Interface_List_ExA (SETUPAPI.@)
2539 */
2540 CONFIGRET WINAPI CM_Get_Device_Interface_List_ExA(
2541 LPGUID InterfaceClassGuid, DEVINSTID_A pDeviceID, PCHAR Buffer,
2542 ULONG BufferLen, ULONG ulFlags, HMACHINE hMachine)
2543 {
2544 DEVINSTID_W pDeviceIdW = NULL;
2545 PWCHAR BufferW = NULL;
2546 CONFIGRET ret = CR_SUCCESS;
2547
2548 TRACE("%s %s %p %lu 0x%08lx %p\n", debugstr_guid(InterfaceClassGuid),
2549 pDeviceID, Buffer, BufferLen, ulFlags, hMachine);
2550
2551 if (Buffer == NULL ||
2552 BufferLen == 0)
2553 return CR_INVALID_POINTER;
2554
2555 if (pDeviceID != NULL)
2556 {
2557 if (!pSetupCaptureAndConvertAnsiArg(pDeviceID, &pDeviceIdW))
2558 return CR_INVALID_DEVICE_ID;
2559 }
2560
2561 BufferW = MyMalloc(BufferLen * sizeof(WCHAR));
2562 if (BufferW == NULL)
2563 {
2564 ret = CR_OUT_OF_MEMORY;
2565 goto Done;
2566 }
2567
2568 ret = CM_Get_Device_Interface_List_ExW(InterfaceClassGuid, pDeviceIdW,
2569 BufferW, BufferLen, ulFlags,
2570 hMachine);
2571 if (ret != CR_SUCCESS)
2572 goto Done;
2573
2574 if (WideCharToMultiByte(CP_ACP,
2575 0,
2576 BufferW,
2577 lstrlenW(BufferW) + 1,
2578 Buffer,
2579 BufferLen,
2580 NULL,
2581 NULL) == 0)
2582 ret = CR_FAILURE;
2583
2584 Done:
2585 if (BufferW != NULL)
2586 MyFree(BufferW);
2587
2588 if (pDeviceIdW != NULL)
2589 MyFree(pDeviceIdW);
2590
2591 return ret;
2592 }
2593
2594
2595 /***********************************************************************
2596 * CM_Get_Device_Interface_List_ExW (SETUPAPI.@)
2597 */
2598 CONFIGRET WINAPI CM_Get_Device_Interface_List_ExW(
2599 LPGUID InterfaceClassGuid, DEVINSTID_W pDeviceID, PWCHAR Buffer,
2600 ULONG BufferLen, ULONG ulFlags, HMACHINE hMachine)
2601 {
2602 RPC_BINDING_HANDLE BindingHandle = NULL;
2603 PNP_RPC_BUFFER_SIZE BufferSize = 0;
2604 CONFIGRET ret = CR_SUCCESS;
2605
2606 TRACE("%s %s %p %lu 0x%08lx %p\n", debugstr_guid(InterfaceClassGuid),
2607 debugstr_w(pDeviceID), Buffer, BufferLen, ulFlags, hMachine);
2608
2609 if (Buffer == NULL ||
2610 BufferLen == 0)
2611 return CR_INVALID_POINTER;
2612
2613 if (ulFlags & ~CM_GET_DEVICE_INTERFACE_LIST_BITS)
2614 return CR_INVALID_FLAG;
2615
2616 if (hMachine != NULL)
2617 {
2618 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
2619 if (BindingHandle == NULL)
2620 return CR_FAILURE;
2621 }
2622 else
2623 {
2624 if (!PnpGetLocalHandles(&BindingHandle, NULL))
2625 return CR_FAILURE;
2626 }
2627
2628 *Buffer = 0;
2629 BufferSize = BufferLen;
2630
2631 RpcTryExcept
2632 {
2633 ret = PNP_GetInterfaceDeviceList(BindingHandle,
2634 InterfaceClassGuid,
2635 pDeviceID,
2636 (LPBYTE)Buffer,
2637 &BufferSize,
2638 ulFlags);
2639 }
2640 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
2641 {
2642 ret = RpcStatusToCmStatus(RpcExceptionCode());
2643 }
2644 RpcEndExcept;
2645
2646 return ret;
2647 }
2648
2649
2650 /***********************************************************************
2651 * CM_Get_Device_Interface_List_SizeA (SETUPAPI.@)
2652 */
2653 CONFIGRET WINAPI CM_Get_Device_Interface_List_SizeA(
2654 PULONG pulLen, LPGUID InterfaceClassGuid, DEVINSTID_A pDeviceId,
2655 ULONG ulFlags)
2656 {
2657 TRACE("%p %p %s 0x%08lx\n", pulLen, InterfaceClassGuid,
2658 pDeviceId, ulFlags);
2659
2660 return CM_Get_Device_Interface_List_Size_ExA(pulLen, InterfaceClassGuid,
2661 pDeviceId, ulFlags, NULL);
2662 }
2663
2664
2665 /***********************************************************************
2666 * CM_Get_Device_Interface_List_SizeW (SETUPAPI.@)
2667 */
2668 CONFIGRET WINAPI CM_Get_Device_Interface_List_SizeW(
2669 PULONG pulLen, LPGUID InterfaceClassGuid, DEVINSTID_W pDeviceId,
2670 ULONG ulFlags)
2671 {
2672 TRACE("%p %p %s 0x%08lx\n", pulLen, InterfaceClassGuid,
2673 debugstr_w(pDeviceId), ulFlags);
2674
2675 return CM_Get_Device_Interface_List_Size_ExW(pulLen, InterfaceClassGuid,
2676 pDeviceId, ulFlags, NULL);
2677 }
2678
2679
2680 /***********************************************************************
2681 * CM_Get_Device_Interface_List_Size_ExA (SETUPAPI.@)
2682 */
2683 CONFIGRET WINAPI CM_Get_Device_Interface_List_Size_ExA(
2684 PULONG pulLen, LPGUID InterfaceClassGuid, DEVINSTID_A pDeviceId,
2685 ULONG ulFlags, HMACHINE hMachine)
2686 {
2687 DEVINSTID_W pDeviceIdW = NULL;
2688 CONFIGRET ret = CR_SUCCESS;
2689
2690 TRACE("%p %p %s 0x%08lx %p\n", pulLen, InterfaceClassGuid,
2691 pDeviceId, ulFlags, hMachine);
2692
2693 if (pulLen == NULL)
2694 return CR_INVALID_POINTER;
2695
2696 if (pDeviceId != NULL)
2697 {
2698 if (!pSetupCaptureAndConvertAnsiArg(pDeviceId, &pDeviceIdW))
2699 return CR_INVALID_DEVICE_ID;
2700 }
2701
2702 *pulLen = 0;
2703
2704 ret = CM_Get_Device_Interface_List_Size_ExW(pulLen, InterfaceClassGuid,
2705 pDeviceIdW, ulFlags, hMachine);
2706
2707 if (pDeviceIdW != NULL)
2708 MyFree(pDeviceIdW);
2709
2710 return ret;
2711 }
2712
2713
2714 /***********************************************************************
2715 * CM_Get_Device_Interface_List_Size_ExW (SETUPAPI.@)
2716 */
2717 CONFIGRET WINAPI CM_Get_Device_Interface_List_Size_ExW(
2718 PULONG pulLen, LPGUID InterfaceClassGuid, DEVINSTID_W pDeviceId,
2719 ULONG ulFlags, HMACHINE hMachine)
2720 {
2721 RPC_BINDING_HANDLE BindingHandle = NULL;
2722 CONFIGRET ret = CR_SUCCESS;
2723
2724 TRACE("%p %p %s 0x%08lx %p\n", pulLen, InterfaceClassGuid,
2725 debugstr_w(pDeviceId), ulFlags, hMachine);
2726
2727 if (pulLen == NULL)
2728 return CR_INVALID_POINTER;
2729
2730 if (ulFlags & ~CM_GET_DEVICE_INTERFACE_LIST_BITS)
2731 return CR_INVALID_FLAG;
2732
2733 if (hMachine != NULL)
2734 {
2735 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
2736 if (BindingHandle == NULL)
2737 return CR_FAILURE;
2738 }
2739 else
2740 {
2741 if (!PnpGetLocalHandles(&BindingHandle, NULL))
2742 return CR_FAILURE;
2743 }
2744
2745 *pulLen = 0;
2746
2747 RpcTryExcept
2748 {
2749 ret = PNP_GetInterfaceDeviceListSize(BindingHandle,
2750 pulLen,
2751 InterfaceClassGuid,
2752 pDeviceId,
2753 ulFlags);
2754 }
2755 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
2756 {
2757 ret = RpcStatusToCmStatus(RpcExceptionCode());
2758 }
2759 RpcEndExcept;
2760
2761 return ret;
2762 }
2763
2764
2765 /***********************************************************************
2766 * CM_Get_First_Log_Conf [SETUPAPI.@]
2767 */
2768 CONFIGRET WINAPI CM_Get_First_Log_Conf(
2769 PLOG_CONF plcLogConf, DEVINST dnDevInst, ULONG ulFlags)
2770 {
2771 TRACE("%p %lx %lx\n", plcLogConf, dnDevInst, ulFlags);
2772 return CM_Get_First_Log_Conf_Ex(plcLogConf, dnDevInst, ulFlags, NULL);
2773 }
2774
2775
2776 /***********************************************************************
2777 * CM_Get_First_Log_Conf_Ex [SETUPAPI.@]
2778 */
2779 CONFIGRET WINAPI CM_Get_First_Log_Conf_Ex(
2780 PLOG_CONF plcLogConf, DEVINST dnDevInst, ULONG ulFlags, HMACHINE hMachine)
2781 {
2782 RPC_BINDING_HANDLE BindingHandle = NULL;
2783 HSTRING_TABLE StringTable = NULL;
2784 LPWSTR lpDevInst = NULL;
2785 CONFIGRET ret = CR_SUCCESS;
2786 ULONG ulTag;
2787 PLOG_CONF_INFO pLogConfInfo;
2788
2789 FIXME("%p %lx %lx %lx\n", plcLogConf, dnDevInst, ulFlags, hMachine);
2790
2791 if (dnDevInst == 0)
2792 return CR_INVALID_DEVINST;
2793
2794 if (ulFlags & ~LOG_CONF_BITS)
2795 return CR_INVALID_FLAG;
2796
2797 if (plcLogConf)
2798 *plcLogConf = 0;
2799
2800 if (hMachine != NULL)
2801 {
2802 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
2803 if (BindingHandle == NULL)
2804 return CR_FAILURE;
2805
2806 StringTable = ((PMACHINE_INFO)hMachine)->StringTable;
2807 if (StringTable == 0)
2808 return CR_FAILURE;
2809 }
2810 else
2811 {
2812 if (!PnpGetLocalHandles(&BindingHandle, &StringTable))
2813 return CR_FAILURE;
2814 }
2815
2816 lpDevInst = pSetupStringTableStringFromId(StringTable, dnDevInst);
2817 if (lpDevInst == NULL)
2818 return CR_INVALID_DEVNODE;
2819
2820 RpcTryExcept
2821 {
2822 ret = PNP_GetFirstLogConf(BindingHandle,
2823 lpDevInst,
2824 ulFlags,
2825 &ulTag,
2826 ulFlags);
2827 }
2828 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
2829 {
2830 ret = RpcStatusToCmStatus(RpcExceptionCode());
2831 }
2832 RpcEndExcept;
2833
2834 if (ret != CR_SUCCESS)
2835 return ret;
2836
2837 if (plcLogConf)
2838 {
2839 pLogConfInfo = HeapAlloc(GetProcessHeap(), 0, sizeof(LOG_CONF_INFO));
2840 if (pLogConfInfo == NULL)
2841 return CR_OUT_OF_MEMORY;
2842
2843 pLogConfInfo->ulMagic = LOG_CONF_MAGIC;
2844 pLogConfInfo->dnDevInst = dnDevInst;
2845 pLogConfInfo->ulFlags = ulFlags;
2846 pLogConfInfo->ulTag = ulTag;
2847
2848 *plcLogConf = (LOG_CONF)pLogConfInfo;
2849 }
2850
2851 return CR_SUCCESS;
2852 }
2853
2854
2855 /***********************************************************************
2856 * CM_Get_Global_State [SETUPAPI.@]
2857 */
2858 CONFIGRET WINAPI CM_Get_Global_State(
2859 PULONG pulState, ULONG ulFlags)
2860 {
2861 TRACE("%p %lx\n", pulState, ulFlags);
2862 return CM_Get_Global_State_Ex(pulState, ulFlags, NULL);
2863 }
2864
2865
2866 /***********************************************************************
2867 * CM_Get_Global_State_Ex [SETUPAPI.@]
2868 */
2869 CONFIGRET WINAPI CM_Get_Global_State_Ex(
2870 PULONG pulState, ULONG ulFlags, HMACHINE hMachine)
2871 {
2872 RPC_BINDING_HANDLE BindingHandle = NULL;
2873 CONFIGRET ret;
2874
2875 TRACE("%p %lx %lx\n", pulState, ulFlags, hMachine);
2876
2877 if (pulState == NULL)
2878 return CR_INVALID_POINTER;
2879
2880 if (ulFlags != 0)
2881 return CR_INVALID_FLAG;
2882
2883 if (hMachine != NULL)
2884 {
2885 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
2886 if (BindingHandle == NULL)
2887 return CR_FAILURE;
2888 }
2889 else
2890 {
2891 if (!PnpGetLocalHandles(&BindingHandle, NULL))
2892 return CR_FAILURE;
2893 }
2894
2895 RpcTryExcept
2896 {
2897 ret = PNP_GetGlobalState(BindingHandle, pulState, ulFlags);
2898 }
2899 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
2900 {
2901 ret = RpcStatusToCmStatus(RpcExceptionCode());
2902 }
2903 RpcEndExcept;
2904
2905 return ret;
2906 }
2907
2908
2909 /***********************************************************************
2910 * CM_Get_HW_Prof_FlagsA [SETUPAPI.@]
2911 */
2912 CONFIGRET WINAPI CM_Get_HW_Prof_FlagsA(
2913 DEVINSTID_A szDevInstName, ULONG ulHardwareProfile, PULONG pulValue,
2914 ULONG ulFlags)
2915 {
2916 TRACE("%s %lu %p %lx\n", szDevInstName,
2917 ulHardwareProfile, pulValue, ulFlags);
2918
2919 return CM_Get_HW_Prof_Flags_ExA(szDevInstName, ulHardwareProfile,
2920 pulValue, ulFlags, NULL);
2921 }
2922
2923
2924 /***********************************************************************
2925 * CM_Get_HW_Prof_FlagsW [SETUPAPI.@]
2926 */
2927 CONFIGRET WINAPI CM_Get_HW_Prof_FlagsW(
2928 DEVINSTID_W szDevInstName, ULONG ulHardwareProfile, PULONG pulValue,
2929 ULONG ulFlags)
2930 {
2931 TRACE("%s %lu %p %lx\n", debugstr_w(szDevInstName),
2932 ulHardwareProfile, pulValue, ulFlags);
2933
2934 return CM_Get_HW_Prof_Flags_ExW(szDevInstName, ulHardwareProfile,
2935 pulValue, ulFlags, NULL);
2936 }
2937
2938
2939 /***********************************************************************
2940 * CM_Get_HW_Prof_Flags_ExA [SETUPAPI.@]
2941 */
2942 CONFIGRET WINAPI CM_Get_HW_Prof_Flags_ExA(
2943 DEVINSTID_A szDevInstName, ULONG ulHardwareProfile, PULONG pulValue,
2944 ULONG ulFlags, HMACHINE hMachine)
2945 {
2946 DEVINSTID_W pszDevIdW = NULL;
2947 CONFIGRET ret = CR_SUCCESS;
2948
2949 TRACE("%s %lu %p %lx %lx\n", szDevInstName,
2950 ulHardwareProfile, pulValue, ulFlags, hMachine);
2951
2952 if (szDevInstName != NULL)
2953 {
2954 if (pSetupCaptureAndConvertAnsiArg(szDevInstName, &pszDevIdW))
2955 return CR_INVALID_DEVICE_ID;
2956 }
2957
2958 ret = CM_Get_HW_Prof_Flags_ExW(pszDevIdW, ulHardwareProfile,
2959 pulValue, ulFlags, hMachine);
2960
2961 if (pszDevIdW != NULL)
2962 MyFree(pszDevIdW);
2963
2964 return ret;
2965 }
2966
2967
2968 /***********************************************************************
2969 * CM_Get_HW_Prof_Flags_ExW [SETUPAPI.@]
2970 */
2971 CONFIGRET WINAPI CM_Get_HW_Prof_Flags_ExW(
2972 DEVINSTID_W szDevInstName, ULONG ulHardwareProfile, PULONG pulValue,
2973 ULONG ulFlags, HMACHINE hMachine)
2974 {
2975 RPC_BINDING_HANDLE BindingHandle = NULL;
2976 CONFIGRET ret;
2977
2978 FIXME("%s %lu %p %lx %lx\n", debugstr_w(szDevInstName),
2979 ulHardwareProfile, pulValue, ulFlags, hMachine);
2980
2981 if ((szDevInstName == NULL) || (pulValue == NULL))
2982 return CR_INVALID_POINTER;
2983
2984 if (ulFlags != 0)
2985 return CR_INVALID_FLAG;
2986
2987 /* FIXME: Check whether szDevInstName is valid */
2988
2989 if (hMachine != NULL)
2990 {
2991 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
2992 if (BindingHandle == NULL)
2993 return CR_FAILURE;
2994 }
2995 else
2996 {
2997 if (!PnpGetLocalHandles(&BindingHandle, NULL))
2998 return CR_FAILURE;
2999 }
3000
3001 RpcTryExcept
3002 {
3003 ret = PNP_HwProfFlags(BindingHandle, PNP_GET_HWPROFFLAGS, szDevInstName,
3004 ulHardwareProfile, pulValue, NULL, NULL, 0, 0);
3005 }
3006 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
3007 {
3008 ret = RpcStatusToCmStatus(RpcExceptionCode());
3009 }
3010 RpcEndExcept;
3011
3012 return ret;
3013 }
3014
3015
3016 /***********************************************************************
3017 * CM_Get_Hardware_Profile_InfoA [SETUPAPI.@]
3018 */
3019 CONFIGRET WINAPI CM_Get_Hardware_Profile_InfoA(
3020 ULONG ulIndex, PHWPROFILEINFO_A pHWProfileInfo, ULONG ulFlags)
3021 {
3022 TRACE("%lu %p %lx\n", ulIndex, pHWProfileInfo, ulFlags);
3023
3024 return CM_Get_Hardware_Profile_Info_ExA(ulIndex, pHWProfileInfo,
3025 ulFlags, NULL);
3026 }
3027
3028
3029 /***********************************************************************
3030 * CM_Get_Hardware_Profile_InfoW [SETUPAPI.@]
3031 */
3032 CONFIGRET WINAPI CM_Get_Hardware_Profile_InfoW(
3033 ULONG ulIndex, PHWPROFILEINFO_W pHWProfileInfo, ULONG ulFlags)
3034 {
3035 TRACE("%lu %p %lx\n", ulIndex, pHWProfileInfo, ulFlags);
3036
3037 return CM_Get_Hardware_Profile_Info_ExW(ulIndex, pHWProfileInfo,
3038 ulFlags, NULL);
3039 }
3040
3041
3042 /***********************************************************************
3043 * CM_Get_Hardware_Profile_Info_ExA [SETUPAPI.@]
3044 */
3045 CONFIGRET WINAPI CM_Get_Hardware_Profile_Info_ExA(
3046 ULONG ulIndex, PHWPROFILEINFO_A pHWProfileInfo, ULONG ulFlags,
3047 HMACHINE hMachine)
3048 {
3049 HWPROFILEINFO_W LocalProfileInfo;
3050 CONFIGRET ret;
3051
3052 TRACE("%lu %p %lx %lx\n", ulIndex, pHWProfileInfo, ulFlags, hMachine);
3053
3054 if (pHWProfileInfo == NULL)
3055 return CR_INVALID_POINTER;
3056
3057 ret = CM_Get_Hardware_Profile_Info_ExW(ulIndex, &LocalProfileInfo,
3058 ulFlags, hMachine);
3059 if (ret == CR_SUCCESS)
3060 {
3061 pHWProfileInfo->HWPI_ulHWProfile = LocalProfileInfo.HWPI_ulHWProfile;
3062 pHWProfileInfo->HWPI_dwFlags = LocalProfileInfo.HWPI_dwFlags;
3063
3064 if (WideCharToMultiByte(CP_ACP,
3065 0,
3066 LocalProfileInfo.HWPI_szFriendlyName,
3067 lstrlenW(LocalProfileInfo.HWPI_szFriendlyName) + 1,
3068 pHWProfileInfo->HWPI_szFriendlyName,
3069 MAX_PROFILE_LEN,
3070 NULL,
3071 NULL) == 0)
3072 ret = CR_FAILURE;
3073 }
3074
3075 return ret;
3076 }
3077
3078
3079 /***********************************************************************
3080 * CM_Get_Hardware_Profile_Info_ExW [SETUPAPI.@]
3081 */
3082 CONFIGRET WINAPI CM_Get_Hardware_Profile_Info_ExW(
3083 ULONG ulIndex, PHWPROFILEINFO_W pHWProfileInfo, ULONG ulFlags,
3084 HMACHINE hMachine)
3085 {
3086 RPC_BINDING_HANDLE BindingHandle = NULL;
3087 CONFIGRET ret;
3088
3089 TRACE("%lu %p %lx %lx\n", ulIndex, pHWProfileInfo, ulFlags, hMachine);
3090
3091 if (pHWProfileInfo == NULL)
3092 return CR_INVALID_POINTER;
3093
3094 if (ulFlags != 0)
3095 return CR_INVALID_FLAG;
3096
3097 if (hMachine != NULL)
3098 {
3099 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
3100 if (BindingHandle == NULL)
3101 return CR_FAILURE;
3102 }
3103 else
3104 {
3105 if (!PnpGetLocalHandles(&BindingHandle, NULL))
3106 return CR_FAILURE;
3107 }
3108
3109 RpcTryExcept
3110 {
3111 ret = PNP_GetHwProfInfo(BindingHandle, ulIndex, pHWProfileInfo,
3112 sizeof(HWPROFILEINFO_W), 0);
3113 }
3114 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
3115 {
3116 ret = RpcStatusToCmStatus(RpcExceptionCode());
3117 }
3118 RpcEndExcept;
3119
3120 return ret;
3121 }
3122
3123
3124 /***********************************************************************
3125 * CM_Get_Log_Conf_Priority [SETUPAPI.@]
3126 */
3127 CONFIGRET WINAPI CM_Get_Log_Conf_Priority(
3128 LOG_CONF lcLogConf, PPRIORITY pPriority, ULONG ulFlags)
3129 {
3130 TRACE("%p %p %lx\n", lcLogConf, pPriority, ulFlags);
3131 return CM_Get_Log_Conf_Priority_Ex(lcLogConf, pPriority, ulFlags, NULL);
3132 }
3133
3134
3135 /***********************************************************************
3136 * CM_Get_Log_Conf_Priority_Ex [SETUPAPI.@]
3137 */
3138 CONFIGRET WINAPI CM_Get_Log_Conf_Priority_Ex(
3139 LOG_CONF lcLogConf, PPRIORITY pPriority, ULONG ulFlags,
3140 HMACHINE hMachine)
3141 {
3142 RPC_BINDING_HANDLE BindingHandle = NULL;
3143 HSTRING_TABLE StringTable = NULL;
3144 PLOG_CONF_INFO pLogConfInfo;
3145 LPWSTR lpDevInst;
3146 CONFIGRET ret;
3147
3148 FIXME("%p %p %lx %lx\n", lcLogConf, pPriority, ulFlags, hMachine);
3149
3150 pLogConfInfo = (PLOG_CONF_INFO)lcLogConf;
3151 if (pLogConfInfo == NULL || pLogConfInfo->ulMagic != LOG_CONF_MAGIC)
3152 return CR_INVALID_LOG_CONF;
3153
3154 if (pPriority == NULL)
3155 return CR_INVALID_POINTER;
3156
3157 if (ulFlags != 0)
3158 return CR_INVALID_FLAG;
3159
3160 if (hMachine != NULL)
3161 {
3162 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
3163 if (BindingHandle == NULL)
3164 return CR_FAILURE;
3165
3166 StringTable = ((PMACHINE_INFO)hMachine)->StringTable;
3167 if (StringTable == 0)
3168 return CR_FAILURE;
3169 }
3170 else
3171 {
3172 if (!PnpGetLocalHandles(&BindingHandle, &StringTable))
3173 return CR_FAILURE;
3174 }
3175
3176 lpDevInst = pSetupStringTableStringFromId(StringTable, pLogConfInfo->dnDevInst);
3177 if (lpDevInst == NULL)
3178 return CR_INVALID_DEVNODE;
3179
3180 RpcTryExcept
3181 {
3182 ret = PNP_GetLogConfPriority(BindingHandle,
3183 lpDevInst,
3184 pLogConfInfo->ulFlags,
3185 pLogConfInfo->ulTag,
3186 pPriority,
3187 0);
3188 }
3189 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
3190 {
3191 ret = RpcStatusToCmStatus(RpcExceptionCode());
3192 }
3193 RpcEndExcept;
3194
3195 return ret;
3196 }
3197
3198
3199 /***********************************************************************
3200 * CM_Get_Next_Log_Conf [SETUPAPI.@]
3201 */
3202 CONFIGRET WINAPI CM_Get_Next_Log_Conf(
3203 PLOG_CONF plcLogConf, LOG_CONF lcLogConf, ULONG ulFlags)
3204 {
3205 TRACE("%p %p %lx\n", plcLogConf, lcLogConf, ulFlags);
3206 return CM_Get_Next_Log_Conf_Ex(plcLogConf, lcLogConf, ulFlags, NULL);
3207 }
3208
3209
3210 /***********************************************************************
3211 * CM_Get_Next_Log_Conf_Ex [SETUPAPI.@]
3212 */
3213 CONFIGRET WINAPI CM_Get_Next_Log_Conf_Ex(
3214 PLOG_CONF plcLogConf, LOG_CONF lcLogConf, ULONG ulFlags,
3215 HMACHINE hMachine)
3216 {
3217 RPC_BINDING_HANDLE BindingHandle = NULL;
3218 HSTRING_TABLE StringTable = NULL;
3219 PLOG_CONF_INFO pLogConfInfo;
3220 PLOG_CONF_INFO pNewLogConfInfo;
3221 ULONG ulNewTag;
3222 LPWSTR lpDevInst;
3223 CONFIGRET ret;
3224
3225 FIXME("%p %p %lx %lx\n", plcLogConf, lcLogConf, ulFlags, hMachine);
3226
3227 if (plcLogConf)
3228 *plcLogConf = 0;
3229
3230 pLogConfInfo = (PLOG_CONF_INFO)lcLogConf;
3231 if (pLogConfInfo == NULL || pLogConfInfo->ulMagic != LOG_CONF_MAGIC)
3232 return CR_INVALID_LOG_CONF;
3233
3234 if (ulFlags != 0)
3235 return CR_INVALID_FLAG;
3236
3237 if (hMachine != NULL)
3238 {
3239 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
3240 if (BindingHandle == NULL)
3241 return CR_FAILURE;
3242
3243 StringTable = ((PMACHINE_INFO)hMachine)->StringTable;
3244 if (StringTable == 0)
3245 return CR_FAILURE;
3246 }
3247 else
3248 {
3249 if (!PnpGetLocalHandles(&BindingHandle, &StringTable))
3250 return CR_FAILURE;
3251 }
3252
3253 lpDevInst = pSetupStringTableStringFromId(StringTable, pLogConfInfo->dnDevInst);
3254 if (lpDevInst == NULL)
3255 return CR_INVALID_DEVNODE;
3256
3257 RpcTryExcept
3258 {
3259 ret = PNP_GetNextLogConf(BindingHandle,
3260 lpDevInst,
3261 pLogConfInfo->ulFlags,
3262 pLogConfInfo->ulTag,
3263 &ulNewTag,
3264 0);
3265 }
3266 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
3267 {
3268 ret = RpcStatusToCmStatus(RpcExceptionCode());
3269 }
3270 RpcEndExcept;
3271
3272 if (ret != CR_SUCCESS)
3273 return ret;
3274
3275 if (plcLogConf)
3276 {
3277 pNewLogConfInfo = HeapAlloc(GetProcessHeap(), 0, sizeof(LOG_CONF_INFO));
3278 if (pNewLogConfInfo == NULL)
3279 return CR_OUT_OF_MEMORY;
3280
3281 pNewLogConfInfo->ulMagic = LOG_CONF_MAGIC;
3282 pNewLogConfInfo->dnDevInst = pLogConfInfo->dnDevInst;
3283 pNewLogConfInfo->ulFlags = pLogConfInfo->ulFlags;
3284 pNewLogConfInfo->ulTag = ulNewTag;
3285
3286 *plcLogConf = (LOG_CONF)pNewLogConfInfo;
3287 }
3288
3289 return CR_SUCCESS;
3290 }
3291
3292
3293 /***********************************************************************
3294 * CM_Get_Next_Re_Des [SETUPAPI.@]
3295 */
3296 CONFIGRET WINAPI CM_Get_Next_Res_Des(
3297 PRES_DES prdResDes, RES_DES rdResDes, RESOURCEID ForResource,
3298 PRESOURCEID pResourceID, ULONG ulFlags)
3299 {
3300 TRACE("%p %p %lu %p %lx\n", prdResDes, rdResDes, ForResource,
3301 pResourceID, ulFlags);
3302 return CM_Get_Next_Res_Des_Ex(prdResDes, rdResDes, ForResource,
3303 pResourceID, ulFlags, NULL);
3304 }
3305
3306
3307 /***********************************************************************
3308 * CM_Get_Next_Re_Des_Ex [SETUPAPI.@]
3309 */
3310 CONFIGRET WINAPI CM_Get_Next_Res_Des_Ex(
3311 PRES_DES prdResDes, RES_DES rdResDes, RESOURCEID ForResource,
3312 PRESOURCEID pResourceID, ULONG ulFlags, HMACHINE hMachine)
3313 {
3314 FIXME("%p %p %lu %p %lx %lx\n", prdResDes, rdResDes, ForResource,
3315 pResourceID, ulFlags, hMachine);
3316
3317 return CR_CALL_NOT_IMPLEMENTED;
3318 }
3319
3320
3321 /***********************************************************************
3322 * CM_Get_Parent [SETUPAPI.@]
3323 */
3324 CONFIGRET WINAPI CM_Get_Parent(
3325 PDEVINST pdnDevInst, DEVINST dnDevInst, ULONG ulFlags)
3326 {
3327 TRACE("%p %p %lx\n", pdnDevInst, dnDevInst, ulFlags);
3328 return CM_Get_Parent_Ex(pdnDevInst, dnDevInst, ulFlags, NULL);
3329 }
3330
3331
3332 /***********************************************************************
3333 * CM_Get_Parent_Ex [SETUPAPI.@]
3334 */
3335 CONFIGRET WINAPI CM_Get_Parent_Ex(
3336 PDEVINST pdnDevInst, DEVINST dnDevInst, ULONG ulFlags, HMACHINE hMachine)
3337 {
3338 WCHAR szRelatedDevInst[MAX_DEVICE_ID_LEN];
3339 RPC_BINDING_HANDLE BindingHandle = NULL;
3340 HSTRING_TABLE StringTable = NULL;
3341 LPWSTR lpDevInst;
3342 DWORD dwIndex, dwLength = MAX_DEVICE_ID_LEN;
3343 CONFIGRET ret;
3344
3345 TRACE("%p %lx %lx %lx\n", pdnDevInst, dnDevInst, ulFlags, hMachine);
3346
3347 if (pdnDevInst == NULL)
3348 return CR_INVALID_POINTER;
3349
3350 if (dnDevInst == 0)
3351 return CR_INVALID_DEVINST;
3352
3353 if (ulFlags != 0)
3354 return CR_INVALID_FLAG;
3355
3356 *pdnDevInst = -1;
3357
3358 if (hMachine != NULL)
3359 {
3360 BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
3361 if (BindingHandle == NULL)
3362 return CR_FAILURE;
3363
3364 StringTable = ((PMACHINE_INFO)hMachine)->StringTable;
3365 if (StringTable == 0)
3366 return CR_FAILURE;
3367 }
3368 else
3369 {
3370 if (!PnpGetLocalHandles(&BindingHandle, &StringTable))
3371 return CR_FAILURE;
3372 }
3373
3374 lpDevInst = pSetupStringTableStringFromId(StringTable, dnDevInst);
3375 if (lpDevInst == NULL)
3376 return CR_INVALID_DEVNODE;
3377
3378 RpcTryExcept
3379 {
3380 ret = PNP_GetRelatedDeviceInstance(BindingHandle,
3381 PNP_GET_PARENT_DEVICE_INSTANCE,
3382 lpDevInst,
3383 szRelatedDevInst,