ReactOS 0.4.16-dev-2332-g4cba65d
driver.c
Go to the documentation of this file.
1/*
2 * SetupAPI driver-related functions
3 *
4 * Copyright 2005-2006 Hervé Poussineau (hpoussin@reactos.org)
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21#include "setupapi_private.h"
22
23/* Unicode constants */
24static const WCHAR BackSlash[] = {'\\',0};
25static const WCHAR ClassGUID[] = {'C','l','a','s','s','G','U','I','D',0};
26static const WCHAR DotCoInstallers[] = {'.','C','o','I','n','s','t','a','l','l','e','r','s',0};
27static const WCHAR InfDirectory[] = {'i','n','f','\\',0};
28static const WCHAR Version[] = {'V','e','r','s','i','o','n',0};
29
30static const WCHAR INF_MANUFACTURER[] = {'M','a','n','u','f','a','c','t','u','r','e','r',0};
31static const WCHAR INF_PROVIDER[] = {'P','r','o','v','i','d','e','r',0};
32static const WCHAR INF_DRIVER_VER[] = {'D','r','i','v','e','r','V','e','r',0};
33
34
35/***********************************************************************
36 * struct InfFileDetails management
37 */
38static VOID
40{
42}
43
44VOID
46{
47 if (InterlockedDecrement(&infFile->References) == 0)
48 {
49 SetupCloseInfFile(infFile->hInf);
50 HeapFree(GetProcessHeap(), 0, infFile);
51 }
52}
53
54struct InfFileDetails *
56 IN LPCWSTR FullInfFileName)
57{
58 struct InfFileDetails *details;
60 DWORD Needed;
61
62 Needed = FIELD_OFFSET(struct InfFileDetails, szData)
63 + strlenW(FullInfFileName) * sizeof(WCHAR) + sizeof(UNICODE_NULL);
64
65 details = HeapAlloc(GetProcessHeap(), 0, Needed);
66 if (!details)
67 {
69 return NULL;
70 }
71
72 memset(details, 0, Needed);
73 strcpyW(details->szData, FullInfFileName);
74 last = strrchrW(details->szData, '\\');
75 if (last)
76 {
77 details->DirectoryName = details->szData;
78 details->FileName = last + 1;
79 *last = '\0';
80 }
81 else
82 details->FileName = details->szData;
84 details->hInf = SetupOpenInfFileW(FullInfFileName, NULL, INF_STYLE_WIN4, NULL);
85 if (details->hInf == INVALID_HANDLE_VALUE)
86 {
88 return NULL;
89 }
90 return details;
91}
92
93BOOL
95{
97 HeapFree(GetProcessHeap(), 0, driverInfo->MatchingId);
98 HeapFree(GetProcessHeap(), 0, driverInfo);
99 return TRUE;
100}
101
102/***********************************************************************
103 * Helper functions for SetupDiBuildDriverInfoList
104 */
105static BOOL
107 IN PLIST_ENTRY DriverListHead,
108 IN DWORD DriverType, /* SPDIT_CLASSDRIVER or SPDIT_COMPATDRIVER */
109 IN LPGUID ClassGuid,
111 IN LPCWSTR InfFile,
112 IN LPCWSTR SectionName,
113 IN LPCWSTR DriverDescription,
114 IN LPCWSTR ProviderName,
115 IN LPCWSTR ManufacturerName,
116 IN LPCWSTR MatchingId,
117 IN FILETIME DriverDate,
118 IN DWORDLONG DriverVersion,
119 IN DWORD Rank)
120{
121 struct DriverInfoElement *driverInfo = NULL;
123 BOOL Result = FALSE;
124 PLIST_ENTRY PreviousEntry;
125 BOOL ret = FALSE;
126
127 driverInfo = HeapAlloc(GetProcessHeap(), 0, sizeof(struct DriverInfoElement));
128 if (!driverInfo)
129 {
131 goto cleanup;
132 }
133 memset(driverInfo, 0, sizeof(struct DriverInfoElement));
134
135 driverInfo->Params.cbSize = sizeof(SP_DRVINSTALL_PARAMS);
136 driverInfo->Params.Reserved = (ULONG_PTR)driverInfo;
137
138 driverInfo->Details.cbSize = sizeof(SP_DRVINFO_DETAIL_DATA_W);
139 driverInfo->Details.Reserved = (ULONG_PTR)driverInfo;
140
141 /* Copy InfFileName field */
142 lstrcpynW(driverInfo->Details.InfFileName, InfFile, MAX_PATH - 1);
143 driverInfo->Details.InfFileName[MAX_PATH - 1] = '\0';
144
145 /* Fill InfDate field */
147 InfFile,
149 NULL, OPEN_EXISTING, 0, NULL);
151 goto cleanup;
152 Result = GetFileTime(hFile, NULL, NULL, &driverInfo->Details.InfDate);
153 if (!Result)
154 goto cleanup;
155
156 /* Fill SectionName field */
157 lstrcpynW(driverInfo->Details.SectionName, SectionName, LINE_LEN);
158
159 /* Fill DrvDescription field */
160 lstrcpynW(driverInfo->Details.DrvDescription, DriverDescription, LINE_LEN);
161
162 /* Copy MatchingId information */
163 if (MatchingId)
164 {
165 driverInfo->MatchingId = HeapAlloc(GetProcessHeap(), 0, (strlenW(MatchingId) + 1) * sizeof(WCHAR));
166 if (!driverInfo->MatchingId)
167 {
169 goto cleanup;
170 }
171 RtlCopyMemory(driverInfo->MatchingId, MatchingId, (strlenW(MatchingId) + 1) * sizeof(WCHAR));
172 }
173 else
174 driverInfo->MatchingId = NULL;
175
176 TRACE("Adding driver '%s' [%s/%s] (Rank 0x%lx)\n",
177 debugstr_w(driverInfo->Details.DrvDescription), debugstr_w(InfFile),
178 debugstr_w(SectionName), Rank);
179
180 driverInfo->Params.Rank = Rank;
181 memcpy(&driverInfo->DriverDate, &DriverDate, sizeof(FILETIME));
182 memcpy(&driverInfo->ClassGuid, ClassGuid, sizeof(GUID));
183 driverInfo->Info.DriverType = DriverType;
184 driverInfo->Info.Reserved = (ULONG_PTR)driverInfo;
185 lstrcpynW(driverInfo->Info.Description, driverInfo->Details.DrvDescription, LINE_LEN - 1);
186 driverInfo->Info.Description[LINE_LEN - 1] = '\0';
187 lstrcpynW(driverInfo->Info.MfgName, ManufacturerName, LINE_LEN - 1);
188 driverInfo->Info.MfgName[LINE_LEN - 1] = '\0';
189 if (ProviderName)
190 {
191 lstrcpynW(driverInfo->Info.ProviderName, ProviderName, LINE_LEN - 1);
192 driverInfo->Info.ProviderName[LINE_LEN - 1] = '\0';
193 }
194 else
195 driverInfo->Info.ProviderName[0] = '\0';
196 driverInfo->Info.DriverDate = DriverDate;
197 driverInfo->Info.DriverVersion = DriverVersion;
199 driverInfo->InfFileDetails = InfFileDetails;
200
201 /* Insert current driver in driver list, according to its rank */
202 PreviousEntry = DriverListHead->Flink;
203 while (PreviousEntry != DriverListHead)
204 {
205 struct DriverInfoElement *CurrentDriver;
206 CurrentDriver = CONTAINING_RECORD(PreviousEntry, struct DriverInfoElement, ListEntry);
207 if (CurrentDriver->Params.Rank > Rank ||
208 (CurrentDriver->Params.Rank == Rank && CurrentDriver->DriverDate.QuadPart < driverInfo->DriverDate.QuadPart))
209 {
210 /* Insert before the current item */
211 InsertHeadList(PreviousEntry->Blink, &driverInfo->ListEntry);
212 break;
213 }
214 PreviousEntry = PreviousEntry->Flink;
215 }
216 if (PreviousEntry == DriverListHead)
217 {
218 /* Insert at the end of the list */
219 InsertTailList(DriverListHead, &driverInfo->ListEntry);
220 }
221
222 ret = TRUE;
223
224cleanup:
225 if (!ret)
226 {
227 if (driverInfo)
228 HeapFree(GetProcessHeap(), 0, driverInfo->MatchingId);
229 HeapFree(GetProcessHeap(), 0, driverInfo);
230 }
233
234 return ret;
235}
236
237static BOOL
239 IN PLIST_ENTRY DriverListHead,
240 IN DWORD DriverType, /* SPDIT_CLASSDRIVER or SPDIT_COMPATDRIVER */
242 IN INFCONTEXT ContextDevice,
244 IN LPCWSTR InfFile,
245 IN LPCWSTR ProviderName,
246 IN LPCWSTR ManufacturerName,
249 IN DWORDLONG DriverVersion,
250 IN DWORD Rank)
251{
252 LPWSTR SectionName = NULL;
253 LPWSTR DriverDescription = NULL;
254 BOOL Result;
255 BOOL ret = FALSE;
256
257 /* Read SectionName */
258 SectionName = MyMalloc(LINE_LEN);
259 if (!SectionName)
260 {
262 goto cleanup;
263 }
264 ZeroMemory(SectionName, LINE_LEN);
266 &ContextDevice,
267 1,
268 SectionName,
269 LINE_LEN,
270 NULL);
271 if (!Result)
272 goto cleanup;
273
274 /* Read DriverDescription */
275 DriverDescription = MyMalloc(LINE_LEN);
276 if (!DriverDescription)
277 {
279 goto cleanup;
280 }
281 ZeroMemory(DriverDescription, LINE_LEN);
283 &ContextDevice,
284 0, /* Field index */
285 DriverDescription, LINE_LEN,
286 NULL);
287
289 DriverListHead,
291 ClassGuid,
293 InfFile,
294 SectionName,
295 DriverDescription,
296 ProviderName,
297 ManufacturerName,
300 DriverVersion,
301 Rank);
302
303cleanup:
304 MyFree(SectionName);
305 MyFree(DriverDescription);
306
307 return ret;
308}
309
310static BOOL
312 IN HINF hInf,
314 OUT LPWSTR* pProviderName,
316 OUT DWORDLONG* DriverVersion)
317{
319 WCHAR guidW[MAX_GUID_STRING_LEN + 1];
320 LPWSTR DriverVer = NULL;
321 LPWSTR ProviderName = NULL;
322 LPWSTR pComma; /* Points into DriverVer */
323 LPWSTR pVersion = NULL; /* Points into DriverVer */
324 SYSTEMTIME SystemTime;
325 BOOL Result;
326 BOOL ret = FALSE; /* Final result */
327
328 /* Get class Guid */
330 NULL, /* Context */
331 hInf,
333 guidW, sizeof(guidW),
334 NULL /* Required size */))
335 {
336 goto cleanup;
337 }
338 guidW[37] = '\0'; /* Replace the } by a NULL character */
339 if (UuidFromStringW(&guidW[1], ClassGuid) != RPC_S_OK)
340 {
342 goto cleanup;
343 }
344
345 /* Get provider name */
347 NULL, /* Context */
348 hInf, Version, INF_PROVIDER,
349 NULL, 0,
350 &RequiredSize);
351 if (Result)
352 {
353 /* We know the needed buffer size */
354 ProviderName = HeapAlloc(GetProcessHeap(), 0, RequiredSize * sizeof(WCHAR));
355 if (!ProviderName)
356 {
358 goto cleanup;
359 }
361 NULL, /* Context */
362 hInf, Version, INF_PROVIDER,
363 ProviderName, RequiredSize,
364 &RequiredSize);
365 }
366 if (!Result)
367 goto cleanup;
368 *pProviderName = ProviderName;
369
370 /* Read the "DriverVer" value */
372 NULL, /* Context */
373 hInf, Version, INF_DRIVER_VER,
374 NULL, 0,
375 &RequiredSize);
376 if (Result)
377 {
378 /* We know know the needed buffer size */
379 DriverVer = HeapAlloc(GetProcessHeap(), 0, RequiredSize * sizeof(WCHAR));
380 if (!DriverVer)
381 {
383 goto cleanup;
384 }
386 NULL, /* Context */
387 hInf, Version, INF_DRIVER_VER,
388 DriverVer, RequiredSize,
389 &RequiredSize);
390 }
391 else
392 {
393 /* windows sets default date of 00/00/0000 when this directive is missing*/
394 memset(DriverDate, 0, sizeof(FILETIME));
395 *DriverVersion = 0;
396 return TRUE;
397 }
398
399 /* Get driver date and driver version, by analyzing the "DriverVer" value */
400 pComma = strchrW(DriverVer, ',');
401 if (pComma != NULL)
402 {
403 *pComma = UNICODE_NULL;
404 pVersion = pComma + 1;
405 }
406 /* Get driver date version. Invalid date = 00/00/00 */
407 memset(DriverDate, 0, sizeof(FILETIME));
408 if (strlenW(DriverVer) == 10
409 && (DriverVer[2] == '-' || DriverVer[2] == '/')
410 && (DriverVer[5] == '-' || DriverVer[5] == '/'))
411 {
412 memset(&SystemTime, 0, sizeof(SYSTEMTIME));
413 DriverVer[2] = DriverVer[5] = UNICODE_NULL;
414 SystemTime.wMonth = ((DriverVer[0] - '0') * 10) + DriverVer[1] - '0';
415 SystemTime.wDay = ((DriverVer[3] - '0') * 10) + DriverVer[4] - '0';
416 SystemTime.wYear = ((DriverVer[6] - '0') * 1000) + ((DriverVer[7] - '0') * 100) + ((DriverVer[8] - '0') * 10) + DriverVer[9] - '0';
417 SystemTimeToFileTime(&SystemTime, DriverDate);
418 }
419 /* Get driver version. Invalid version = 0.0.0.0 */
420 *DriverVersion = 0;
421 if (pVersion)
422 {
423 WORD Major, Minor = 0, Revision = 0, Build = 0;
424 LPWSTR pMinor = NULL, pRevision = NULL, pBuild = NULL;
425 LARGE_INTEGER fullVersion;
426
427 pMinor = strchrW(pVersion, '.');
428 if (pMinor)
429 {
430 *pMinor = 0;
431 pRevision = strchrW(++pMinor, '.');
432 Minor = atoiW(pMinor);
433 }
434 if (pRevision)
435 {
436 *pRevision = 0;
437 pBuild = strchrW(++pRevision, '.');
438 Revision = atoiW(pRevision);
439 }
440 if (pBuild)
441 {
442 *pBuild = 0;
443 pBuild++;
444 Build = atoiW(pBuild);
445 }
446 Major = atoiW(pVersion);
447 fullVersion.u.HighPart = Major << 16 | Minor;
448 fullVersion.u.LowPart = Revision << 16 | Build;
449 memcpy(DriverVersion, &fullVersion, sizeof(LARGE_INTEGER));
450 }
451
452 ret = TRUE;
453
454cleanup:
455 if (!ret)
456 {
457 HeapFree(GetProcessHeap(), 0, ProviderName);
458 *pProviderName = NULL;
459 }
460 HeapFree(GetProcessHeap(), 0, DriverVer);
461
462 return ret;
463}
464
465static BOOL
469 OUT LPWSTR *pHardwareIDs OPTIONAL,
470 OUT LPDWORD pHardwareIDsRequiredSize OPTIONAL,
471 OUT LPWSTR *pCompatibleIDs OPTIONAL,
472 OUT LPDWORD pCompatibleIDsRequiredSize OPTIONAL)
473{
474 LPWSTR HardwareIDs = NULL;
475 LPWSTR CompatibleIDs = NULL;
477 BOOL Result;
478
479 /* Get hardware IDs list */
480 Result = FALSE;
481 RequiredSize = 512; /* Initial buffer size */
484 {
485 MyFree(HardwareIDs);
486 HardwareIDs = MyMalloc(RequiredSize);
487 if (!HardwareIDs)
488 {
490 goto done;
491 }
496 NULL,
497 (PBYTE)HardwareIDs,
499 &RequiredSize);
500 }
501 if (!Result)
502 {
504 {
505 /* No hardware ID for this device */
506 MyFree(HardwareIDs);
507 HardwareIDs = NULL;
508 RequiredSize = 0;
509 }
510 else
511 goto done;
512 }
513 if (pHardwareIDs)
514 *pHardwareIDs = HardwareIDs;
515 if (pHardwareIDsRequiredSize)
516 *pHardwareIDsRequiredSize = RequiredSize;
517
518 /* Get compatible IDs list */
519 Result = FALSE;
520 RequiredSize = 512; /* Initial buffer size */
523 {
524 MyFree(CompatibleIDs);
525 CompatibleIDs = MyMalloc(RequiredSize);
526 if (!CompatibleIDs)
527 {
529 goto done;
530 }
535 NULL,
536 (PBYTE)CompatibleIDs,
538 &RequiredSize);
539 }
540 if (!Result)
541 {
543 {
544 /* No compatible ID for this device */
545 MyFree(CompatibleIDs);
546 CompatibleIDs = NULL;
547 RequiredSize = 0;
548 }
549 else
550 goto done;
551 }
552 if (pCompatibleIDs)
553 *pCompatibleIDs = CompatibleIDs;
554 if (pCompatibleIDsRequiredSize)
555 *pCompatibleIDsRequiredSize = RequiredSize;
556
557 Result = TRUE;
558
559done:
560 if (!Result)
561 {
562 MyFree(HardwareIDs);
563 MyFree(CompatibleIDs);
564 }
565 return Result;
566}
567
568/***********************************************************************
569 * SetupDiBuildDriverInfoList (SETUPAPI.@)
570 */
576{
577 struct DeviceInfoSet *list;
579 PVOID Buffer = NULL;
580 struct InfFileDetails *currentInfFileDetails = NULL;
581 LPWSTR ProviderName = NULL;
582 LPWSTR ManufacturerName = NULL;
583 WCHAR ManufacturerSection[LINE_LEN + 1];
584 LPWSTR HardwareIDs = NULL;
585 LPWSTR CompatibleIDs = NULL;
586 LPWSTR FullInfFileName = NULL;
587 LPWSTR ExcludeFromSelect = NULL;
588 FILETIME DriverDate;
589 DWORDLONG DriverVersion = 0;
591 BOOL ret = FALSE;
592
594
595 if (!DeviceInfoSet)
597 else if ((list = (struct DeviceInfoSet *)DeviceInfoSet)->magic != SETUP_DEVICE_INFO_SET_MAGIC)
599 else if (list->HKLM != HKEY_LOCAL_MACHINE)
605 else if (DeviceInfoData && DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA))
607 else
608 {
609 PLIST_ENTRY pDriverListHead = &list->DriverListHead;
610 BOOL Result;
611
612 InstallParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS_W);
614 if (!Result)
615 goto done;
616
617 if (DeviceInfoData)
618 {
619 struct DeviceInfo *devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
621 pDriverListHead = &devInfo->DriverListHead;
622 }
623
625 {
626 /* Get hardware and compatible IDs lists */
630 &HardwareIDs,
631 NULL,
632 &CompatibleIDs,
633 NULL);
634 if (!Result)
635 goto done;
636 if (!HardwareIDs && !CompatibleIDs)
637 {
639 goto done;
640 }
641 }
642
643 if (InstallParams.FlagsEx & DI_FLAGSEX_INSTALLEDDRIVER)
644 {
645 HKEY hDriverKey;
646 WCHAR InfFileName[MAX_PATH];
647 WCHAR InfFileSection[MAX_PATH];
649 struct DeviceInfo *devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
650 struct InfFileDetails *infFileDetails = NULL;
651 FILETIME DriverDate;
652 LONG rc;
653 DWORD len;
654
655 /* Prepend inf directory name to file name */
656 len = sizeof(InfFileName) / sizeof(InfFileName[0]);
658 if (RequiredSize == 0 || RequiredSize >= len)
659 goto done;
660 if (*InfFileName && InfFileName[strlenW(InfFileName) - 1] != '\\')
661 strcatW(InfFileName, BackSlash);
662 strcatW(InfFileName, InfDirectory);
663
664 /* Read some information from registry, before creating the driver structure */
665 hDriverKey = SETUPDI_OpenDrvKey(((struct DeviceInfoSet *)DeviceInfoSet)->HKLM, devInfo, KEY_QUERY_VALUE);
666 if (hDriverKey == INVALID_HANDLE_VALUE)
667 goto done;
668 RequiredSize = (len - strlenW(InfFileName)) * sizeof(WCHAR);
669 rc = RegGetValueW(
670 hDriverKey,
671 NULL,
674 NULL,
675 &InfFileName[strlenW(InfFileName)],
676 &RequiredSize);
677 if (rc != ERROR_SUCCESS)
678 {
679 SetLastError(rc);
680 CloseHandle(hDriverKey);
681 goto done;
682 }
683 RequiredSize = sizeof(InfFileSection);
684 rc = RegGetValueW(
685 hDriverKey,
686 NULL,
689 NULL,
690 InfFileSection,
691 &RequiredSize);
692 if (rc != ERROR_SUCCESS)
693 {
694 SetLastError(rc);
695 CloseHandle(hDriverKey);
696 goto done;
697 }
698 TRACE("Current driver in %s/%s\n", debugstr_w(InfFileName), debugstr_w(InfFileSection));
699 infFileDetails = CreateInfFileDetails(InfFileName);
700 if (!infFileDetails)
701 {
702 CloseHandle(hDriverKey);
703 goto done;
704 }
705 DriverDate.dwLowDateTime = DriverDate.dwHighDateTime = 0; /* FIXME */
706 CloseHandle(hDriverKey);
708 pDriverListHead,
710 &devInfo->ClassGuid,
711 infFileDetails,
712 InfFileName,
713 InfFileSection, /* Yes, we don't care of section extension */
714 L"DriverDescription", /* FIXME */
715 L"ProviderName", /* FIXME */
716 L"ManufacturerName", /* FIXME */
717 L"MatchingId", /* FIXME */
718 DriverDate,
719 0, /* FIXME: DriverVersion */
720 0);
721 if (!ret)
722 DereferenceInfFile(infFileDetails);
723 Result = FALSE;
724 }
726 {
727 /* InstallParams.DriverPath contains the name of a .inf file */
730 if (!Buffer)
731 {
733 goto done;
734 }
736 ((LPWSTR)Buffer)[RequiredSize - 1] = 0;
737 Result = TRUE;
738 }
739 else
740 {
741 /* Enumerate .inf files */
742 Result = FALSE;
743 RequiredSize = 32768; /* Initial buffer size */
746 {
749 if (!Buffer)
750 {
751 Result = FALSE;
753 break;
754 }
759 &RequiredSize);
760 }
762 {
763 /* No .inf file in specified directory. So, we should
764 * success as we created an empty driver info list.
765 */
766 ret = TRUE;
767 goto done;
768 }
769 }
770 if (Result)
771 {
773 LPWSTR pFullFilename;
774
776 {
777 /* Only a filename */
778 FullInfFileName = HeapAlloc(GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR));
779 if (!FullInfFileName)
780 goto done;
781 pFullFilename = &FullInfFileName[0];
782 }
783 else if (*InstallParams.DriverPath)
784 {
785 /* Directory name specified */
786 DWORD len;
788 if (len == 0)
789 goto done;
790 FullInfFileName = HeapAlloc(GetProcessHeap(), 0, (len + 1 + MAX_PATH) * sizeof(WCHAR));
791 if (!FullInfFileName)
792 goto done;
793 len = GetFullPathNameW(InstallParams.DriverPath, len, FullInfFileName, NULL);
794 if (len == 0)
795 goto done;
796 if (*FullInfFileName && FullInfFileName[strlenW(FullInfFileName) - 1] != '\\')
797 strcatW(FullInfFileName, BackSlash);
798 pFullFilename = &FullInfFileName[strlenW(FullInfFileName)];
799 }
800 else
801 {
802 /* Nothing specified ; need to get the %SYSTEMROOT%\ directory */
803 DWORD len;
805 if (len == 0)
806 goto done;
807 FullInfFileName = HeapAlloc(GetProcessHeap(), 0, (len + 1 + strlenW(InfDirectory) + MAX_PATH) * sizeof(WCHAR));
808 if (!FullInfFileName)
809 goto done;
810 len = GetSystemWindowsDirectoryW(FullInfFileName, len);
811 if (len == 0)
812 goto done;
813 if (*FullInfFileName && FullInfFileName[strlenW(FullInfFileName) - 1] != '\\')
814 strcatW(FullInfFileName, BackSlash);
815 strcatW(FullInfFileName, InfDirectory);
816 pFullFilename = &FullInfFileName[strlenW(FullInfFileName)];
817 }
818
820 {
821 INFCONTEXT ContextManufacturer, ContextDevice;
823
824 strcpyW(pFullFilename, filename);
825 TRACE("Opening file %s\n", debugstr_w(FullInfFileName));
826
827 currentInfFileDetails = CreateInfFileDetails(FullInfFileName);
828 if (!currentInfFileDetails)
829 continue;
830
832 currentInfFileDetails->hInf,
833 &ClassGuid,
834 &ProviderName,
835 &DriverDate,
836 &DriverVersion))
837 {
838 DereferenceInfFile(currentInfFileDetails);
839 currentInfFileDetails = NULL;
840 continue;
841 }
842
844 {
845 /* Check if the ClassGuid in this .inf file is corresponding with our needs */
846 if (!IsEqualIID(&list->ClassGuid, &GUID_NULL) && !IsEqualIID(&list->ClassGuid, &ClassGuid))
847 {
848 goto next;
849 }
850 }
851
853 {
854 /* Read ExcludeFromSelect control flags */
855 /* FIXME */
856 }
857 else
858 FIXME("ExcludeFromSelect list ignored\n");
859
860 /* Get the manufacturers list */
861 Result = SetupFindFirstLineW(currentInfFileDetails->hInf, INF_MANUFACTURER, NULL, &ContextManufacturer);
862 while (Result)
863 {
865 &ContextManufacturer,
866 0, /* Field index */
867 NULL, 0,
868 &RequiredSize);
869 if (Result)
870 {
871 /* We got the needed size for the buffer */
872 ManufacturerName = HeapAlloc(GetProcessHeap(), 0, RequiredSize * sizeof(WCHAR));
873 if (!ManufacturerName)
874 {
876 goto done;
877 }
879 &ContextManufacturer,
880 0, /* Field index */
881 ManufacturerName, RequiredSize,
882 &RequiredSize);
883 }
884 /* Get manufacturer section name */
886 &ContextManufacturer,
887 1, /* Field index */
888 ManufacturerSection, LINE_LEN,
889 &RequiredSize);
890 if (Result)
891 {
892 ManufacturerSection[RequiredSize] = 0; /* Final NULL char */
893 /* Add (possible) extension to manufacturer section name */
895 currentInfFileDetails->hInf, ManufacturerSection, ManufacturerSection, LINE_LEN, NULL, NULL);
896 if (Result)
897 {
898 TRACE("Enumerating devices in manufacturer %s\n", debugstr_w(ManufacturerSection));
899 Result = SetupFindFirstLineW(currentInfFileDetails->hInf, ManufacturerSection, NULL, &ContextDevice);
900 }
901 }
902 while (Result)
903 {
905 {
906 /* FIXME: Check ExcludeFromSelect list */
907 if (!AddDriverToList(
908 pDriverListHead,
910 &ClassGuid,
911 ContextDevice,
912 currentInfFileDetails,
913 FullInfFileName,
914 ProviderName,
915 ManufacturerName,
916 NULL,
917 DriverDate, DriverVersion,
918 0))
919 {
920 break;
921 }
922 }
923 else /* DriverType = SPDIT_COMPATDRIVER */
924 {
925 /* 1. Get all fields */
926 DWORD FieldCount = SetupGetFieldCount(&ContextDevice);
927 DWORD DriverRank;
928 DWORD i;
929 LPCWSTR currentId;
930 BOOL DriverAlreadyAdded;
931
932 for (i = 2; i <= FieldCount; i++)
933 {
934 LPWSTR DeviceId = NULL;
935 Result = FALSE;
936 RequiredSize = 128; /* Initial buffer size */
939 {
940 HeapFree(GetProcessHeap(), 0, DeviceId);
941 DeviceId = HeapAlloc(GetProcessHeap(), 0, RequiredSize * sizeof(WCHAR));
942 if (!DeviceId)
943 {
945 goto done;
946 }
948 &ContextDevice,
949 i,
950 DeviceId, RequiredSize,
951 &RequiredSize);
952 }
953 if (!Result)
954 {
955 HeapFree(GetProcessHeap(), 0, DeviceId);
956 goto done;
957 }
958 /* FIXME: Check ExcludeFromSelect list */
959 DriverAlreadyAdded = FALSE;
960 if (HardwareIDs)
961 {
962 for (DriverRank = 0, currentId = (LPCWSTR)HardwareIDs; !DriverAlreadyAdded && *currentId; currentId += strlenW(currentId) + 1, DriverRank++)
963 {
964 if (strcmpiW(DeviceId, currentId) == 0)
965 {
967 pDriverListHead,
969 &ClassGuid,
970 ContextDevice,
971 currentInfFileDetails,
972 FullInfFileName,
973 ProviderName,
974 ManufacturerName,
975 currentId,
976 DriverDate, DriverVersion,
977 DriverRank + (i == 2 ? 0 : 0x1000 + i - 3));
978 DriverAlreadyAdded = TRUE;
979 }
980 }
981 }
982 if (CompatibleIDs)
983 {
984 for (DriverRank = 0, currentId = (LPCWSTR)CompatibleIDs; !DriverAlreadyAdded && *currentId; currentId += strlenW(currentId) + 1, DriverRank++)
985 {
986 if (strcmpiW(DeviceId, currentId) == 0)
987 {
989 pDriverListHead,
991 &ClassGuid,
992 ContextDevice,
993 currentInfFileDetails,
994 FullInfFileName,
995 ProviderName,
996 ManufacturerName,
997 currentId,
998 DriverDate, DriverVersion,
999 DriverRank + (i == 2 ? 0x2000 : 0x3000 + i - 3));
1000 DriverAlreadyAdded = TRUE;
1001 }
1002 }
1003 }
1004 HeapFree(GetProcessHeap(), 0, DeviceId);
1005 }
1006 }
1007 Result = SetupFindNextLine(&ContextDevice, &ContextDevice);
1008 }
1009
1010 HeapFree(GetProcessHeap(), 0, ManufacturerName);
1011 ManufacturerName = NULL;
1012 Result = SetupFindNextLine(&ContextManufacturer, &ContextManufacturer);
1013 }
1014
1015 ret = TRUE;
1016next:
1017 HeapFree(GetProcessHeap(), 0, ProviderName);
1018 HeapFree(GetProcessHeap(), 0, ExcludeFromSelect);
1019 ProviderName = ExcludeFromSelect = NULL;
1020
1021 DereferenceInfFile(currentInfFileDetails);
1022 currentInfFileDetails = NULL;
1023 }
1024 ret = TRUE;
1025 }
1026 }
1027
1028done:
1029 if (ret)
1030 {
1031 if (DeviceInfoData)
1032 {
1035 }
1036 else
1037 {
1040 }
1042 }
1043
1044 HeapFree(GetProcessHeap(), 0, ProviderName);
1045 HeapFree(GetProcessHeap(), 0, ManufacturerName);
1046 MyFree(HardwareIDs);
1047 MyFree(CompatibleIDs);
1048 HeapFree(GetProcessHeap(), 0, FullInfFileName);
1049 HeapFree(GetProcessHeap(), 0, ExcludeFromSelect);
1050 if (currentInfFileDetails)
1051 DereferenceInfFile(currentInfFileDetails);
1053
1054 TRACE("Returning %d\n", ret);
1055 return ret;
1056}
1057
1058/***********************************************************************
1059 * SetupDiDestroyDriverInfoList (SETUPAPI.@)
1060 */
1066{
1067 struct DeviceInfoSet *list;
1068 BOOL ret = FALSE;
1069
1070 TRACE("%p %p 0x%lx\n", DeviceInfoSet, DeviceInfoData, DriverType);
1071
1072 if (!DeviceInfoSet)
1080 else if (DeviceInfoData && DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA))
1082 else
1083 {
1084 PLIST_ENTRY ListEntry;
1085 struct DriverInfoElement *driverInfo;
1086 SP_DEVINSTALL_PARAMS_W InstallParams;
1087
1088 InstallParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS_W);
1090 goto done;
1091
1092 if (!DeviceInfoData)
1093 /* Fall back to destroying class driver list */
1095
1097 {
1098 while (!IsListEmpty(&list->DriverListHead))
1099 {
1100 ListEntry = RemoveHeadList(&list->DriverListHead);
1102 DestroyDriverInfoElement(driverInfo);
1103 }
1104 InstallParams.ClassInstallReserved = 0;
1105 InstallParams.Flags &= ~(DI_DIDCLASS | DI_MULTMFGS);
1106 InstallParams.FlagsEx &= ~DI_FLAGSEX_DIDINFOLIST;
1108 }
1109 else
1110 {
1111 SP_DEVINSTALL_PARAMS_W InstallParamsSet;
1112 struct DeviceInfo *deviceInfo;
1113
1114 InstallParamsSet.cbSize = sizeof(SP_DEVINSTALL_PARAMS_W);
1115 if (!SetupDiGetDeviceInstallParamsW(DeviceInfoSet, NULL, &InstallParamsSet))
1116 goto done;
1117 deviceInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
1118 while (!IsListEmpty(&deviceInfo->DriverListHead))
1119 {
1120 ListEntry = RemoveHeadList(&deviceInfo->DriverListHead);
1122 if ((PVOID)InstallParamsSet.ClassInstallReserved == driverInfo)
1123 {
1124 InstallParamsSet.ClassInstallReserved = 0;
1126 }
1127 DestroyDriverInfoElement(driverInfo);
1128 }
1130 InstallParams.Flags &= ~DI_DIDCOMPAT;
1131 InstallParams.FlagsEx &= ~DI_FLAGSEX_DIDCOMPATINFO;
1133 }
1134 }
1135
1136done:
1137 TRACE("Returning %d\n", ret);
1138 return ret;
1139}
1140
1141/***********************************************************************
1142 * SetupDiEnumDriverInfoA (SETUPAPI.@)
1143 */
1149 IN DWORD MemberIndex,
1150 OUT PSP_DRVINFO_DATA_A DriverInfoData)
1151{
1152 SP_DRVINFO_DATA_V2_W driverInfoData2W;
1153 BOOL ret = FALSE;
1154
1155 TRACE("%p %p 0x%lx %ld %p\n", DeviceInfoSet, DeviceInfoData,
1156 DriverType, MemberIndex, DriverInfoData);
1157
1158 if (DriverInfoData == NULL)
1160 else if (DriverInfoData->cbSize != sizeof(SP_DRVINFO_DATA_V1_A) && DriverInfoData->cbSize != sizeof(SP_DRVINFO_DATA_V2_A))
1162 else
1163 {
1164 driverInfoData2W.cbSize = sizeof(SP_DRVINFO_DATA_V2_W);
1166 DriverType, MemberIndex, &driverInfoData2W);
1167
1168 if (ret)
1169 {
1170 /* Do W->A conversion */
1171 DriverInfoData->DriverType = driverInfoData2W.DriverType;
1172 DriverInfoData->Reserved = driverInfoData2W.Reserved;
1173 if (WideCharToMultiByte(CP_ACP, 0, driverInfoData2W.Description, -1,
1174 DriverInfoData->Description, LINE_LEN, NULL, NULL) == 0)
1175 {
1176 DriverInfoData->Description[0] = '\0';
1177 ret = FALSE;
1178 }
1179 if (WideCharToMultiByte(CP_ACP, 0, driverInfoData2W.MfgName, -1,
1180 DriverInfoData->MfgName, LINE_LEN, NULL, NULL) == 0)
1181 {
1182 DriverInfoData->MfgName[0] = '\0';
1183 ret = FALSE;
1184 }
1185 if (WideCharToMultiByte(CP_ACP, 0, driverInfoData2W.ProviderName, -1,
1186 DriverInfoData->ProviderName, LINE_LEN, NULL, NULL) == 0)
1187 {
1188 DriverInfoData->ProviderName[0] = '\0';
1189 ret = FALSE;
1190 }
1191 if (DriverInfoData->cbSize == sizeof(SP_DRVINFO_DATA_V2_A))
1192 {
1193 /* Copy more fields */
1194 DriverInfoData->DriverDate = driverInfoData2W.DriverDate;
1195 DriverInfoData->DriverVersion = driverInfoData2W.DriverVersion;
1196 }
1197 }
1198 }
1199
1200 TRACE("Returning %d\n", ret);
1201 return ret;
1202}
1203
1204
1205/***********************************************************************
1206 * SetupDiEnumDriverInfoW (SETUPAPI.@)
1207 */
1213 IN DWORD MemberIndex,
1214 OUT PSP_DRVINFO_DATA_W DriverInfoData)
1215{
1216 PLIST_ENTRY ListHead;
1217 BOOL ret = FALSE;
1218
1219 TRACE("%p %p 0x%lx %ld %p\n", DeviceInfoSet, DeviceInfoData,
1220 DriverType, MemberIndex, DriverInfoData);
1221
1222 if (!DeviceInfoSet || !DriverInfoData)
1226 else if (((struct DeviceInfoSet *)DeviceInfoSet)->magic != SETUP_DEVICE_INFO_SET_MAGIC)
1232 else if (DriverInfoData->cbSize != sizeof(SP_DRVINFO_DATA_V1_W) && DriverInfoData->cbSize != sizeof(SP_DRVINFO_DATA_V2_W))
1234 else
1235 {
1236 struct DeviceInfo *devInfo = NULL;
1237 PLIST_ENTRY ItemList;
1238 if (DeviceInfoData)
1239 devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
1240 if (!devInfo || (devInfo->CreationFlags & DICD_INHERIT_CLASSDRVS))
1241 {
1242 ListHead = &((struct DeviceInfoSet *)DeviceInfoSet)->DriverListHead;
1243 }
1244 else
1245 {
1246 ListHead = &devInfo->DriverListHead;
1247 }
1248
1249 ItemList = ListHead->Flink;
1250 while (ItemList != ListHead && MemberIndex-- > 0)
1251 ItemList = ItemList->Flink;
1252 if (ItemList == ListHead)
1254 else
1255 {
1256 struct DriverInfoElement *DrvInfo = CONTAINING_RECORD(ItemList, struct DriverInfoElement, ListEntry);
1257
1258 memcpy(
1259 &DriverInfoData->DriverType,
1260 &DrvInfo->Info.DriverType,
1261 DriverInfoData->cbSize - FIELD_OFFSET(SP_DRVINFO_DATA_W, DriverType));
1262 ret = TRUE;
1263 }
1264 }
1265
1266 TRACE("Returning %d\n", ret);
1267 return ret;
1268}
1269
1270/***********************************************************************
1271 * SetupDiGetSelectedDriverA (SETUPAPI.@)
1272 */
1277 OUT PSP_DRVINFO_DATA_A DriverInfoData)
1278{
1279 SP_DRVINFO_DATA_V2_W driverInfoData2W;
1280 BOOL ret = FALSE;
1281
1282 if (DriverInfoData == NULL)
1284 else if (DriverInfoData->cbSize != sizeof(SP_DRVINFO_DATA_V1_A) && DriverInfoData->cbSize != sizeof(SP_DRVINFO_DATA_V2_A))
1286 else
1287 {
1288 driverInfoData2W.cbSize = sizeof(SP_DRVINFO_DATA_V2_W);
1289
1292 &driverInfoData2W);
1293
1294 if (ret)
1295 {
1296 /* Do W->A conversion */
1297 DriverInfoData->DriverType = driverInfoData2W.DriverType;
1298 DriverInfoData->Reserved = driverInfoData2W.Reserved;
1299 if (WideCharToMultiByte(CP_ACP, 0, driverInfoData2W.Description, -1,
1300 DriverInfoData->Description, LINE_LEN, NULL, NULL) == 0)
1301 {
1302 DriverInfoData->Description[0] = '\0';
1303 ret = FALSE;
1304 }
1305 if (WideCharToMultiByte(CP_ACP, 0, driverInfoData2W.MfgName, -1,
1306 DriverInfoData->MfgName, LINE_LEN, NULL, NULL) == 0)
1307 {
1308 DriverInfoData->MfgName[0] = '\0';
1309 ret = FALSE;
1310 }
1311 if (WideCharToMultiByte(CP_ACP, 0, driverInfoData2W.ProviderName, -1,
1312 DriverInfoData->ProviderName, LINE_LEN, NULL, NULL) == 0)
1313 {
1314 DriverInfoData->ProviderName[0] = '\0';
1315 ret = FALSE;
1316 }
1317 if (DriverInfoData->cbSize == sizeof(SP_DRVINFO_DATA_V2_A))
1318 {
1319 /* Copy more fields */
1320 DriverInfoData->DriverDate = driverInfoData2W.DriverDate;
1321 DriverInfoData->DriverVersion = driverInfoData2W.DriverVersion;
1322 }
1323 }
1324 }
1325
1326 return ret;
1327}
1328
1329/***********************************************************************
1330 * SetupDiGetSelectedDriverW (SETUPAPI.@)
1331 */
1336 OUT PSP_DRVINFO_DATA_W DriverInfoData)
1337{
1338 BOOL ret = FALSE;
1339
1340 TRACE("%p %p %p\n", DeviceInfoSet, DeviceInfoData, DriverInfoData);
1341
1342 if (!DeviceInfoSet || !DriverInfoData)
1346 else if (((struct DeviceInfoSet *)DeviceInfoSet)->magic != SETUP_DEVICE_INFO_SET_MAGIC)
1348 else if (DeviceInfoData && DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA))
1350 else if (DriverInfoData->cbSize != sizeof(SP_DRVINFO_DATA_V1_W) && DriverInfoData->cbSize != sizeof(SP_DRVINFO_DATA_V2_W))
1352 else
1353 {
1354 SP_DEVINSTALL_PARAMS InstallParams;
1355
1356 InstallParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS_W);
1358 {
1359 struct DriverInfoElement *driverInfo;
1360 driverInfo = (struct DriverInfoElement *)InstallParams.ClassInstallReserved;
1361 if (driverInfo == NULL)
1363 else
1364 {
1365 memcpy(
1366 &DriverInfoData->DriverType,
1367 &driverInfo->Info.DriverType,
1368 DriverInfoData->cbSize - FIELD_OFFSET(SP_DRVINFO_DATA_W, DriverType));
1369 ret = TRUE;
1370 }
1371 }
1372 }
1373
1374 TRACE("Returning %d\n", ret);
1375 return ret;
1376}
1377
1378/***********************************************************************
1379 * SetupDiSetSelectedDriverA (SETUPAPI.@)
1380 */
1385 IN OUT PSP_DRVINFO_DATA_A DriverInfoData OPTIONAL)
1386{
1387 SP_DRVINFO_DATA_V1_W DriverInfoDataW;
1388 PSP_DRVINFO_DATA_W pDriverInfoDataW = NULL;
1389 BOOL ret = FALSE;
1390
1391 if (DriverInfoData != NULL)
1392 {
1393 if (DriverInfoData->cbSize != sizeof(SP_DRVINFO_DATA_V2_A) &&
1394 DriverInfoData->cbSize != sizeof(SP_DRVINFO_DATA_V1_A))
1395 {
1397 return FALSE;
1398 }
1399
1400 DriverInfoDataW.cbSize = sizeof(SP_DRVINFO_DATA_V1_W);
1401 DriverInfoDataW.Reserved = DriverInfoData->Reserved;
1402
1403 if (DriverInfoDataW.Reserved == 0)
1404 {
1405 DriverInfoDataW.DriverType = DriverInfoData->DriverType;
1406
1407 /* convert the strings to unicode */
1409 0,
1410 DriverInfoData->Description,
1411 LINE_LEN,
1412 DriverInfoDataW.Description,
1413 LINE_LEN) ||
1415 0,
1416 DriverInfoData->ProviderName,
1417 LINE_LEN,
1418 DriverInfoDataW.ProviderName,
1419 LINE_LEN))
1420 {
1421 return FALSE;
1422 }
1423 }
1424
1425 pDriverInfoDataW = (PSP_DRVINFO_DATA_W)&DriverInfoDataW;
1426 }
1427
1430 pDriverInfoDataW);
1431
1432 if (ret && pDriverInfoDataW != NULL)
1433 {
1434 DriverInfoData->Reserved = DriverInfoDataW.Reserved;
1435 }
1436
1437 return ret;
1438}
1439
1440/***********************************************************************
1441 * SetupDiSetSelectedDriverW (SETUPAPI.@)
1442 */
1447 IN OUT PSP_DRVINFO_DATA_W DriverInfoData OPTIONAL)
1448{
1449 BOOL ret = FALSE;
1450
1451 TRACE("%p %p %p\n", DeviceInfoSet, DeviceInfoData, DriverInfoData);
1452
1453 if (!DeviceInfoSet)
1457 else if (((struct DeviceInfoSet *)DeviceInfoSet)->magic != SETUP_DEVICE_INFO_SET_MAGIC)
1459 else if (DeviceInfoData && DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA))
1461 else if (DriverInfoData && DriverInfoData->cbSize != sizeof(SP_DRVINFO_DATA_V1_W) && DriverInfoData->cbSize != sizeof(SP_DRVINFO_DATA_V2_W))
1463 else
1464 {
1465 struct DriverInfoElement **pDriverInfo;
1466 PLIST_ENTRY ListHead, ItemList;
1467
1468 if (DeviceInfoData)
1469 {
1470 pDriverInfo = (struct DriverInfoElement **)&((struct DeviceInfo *)DeviceInfoData->Reserved)->InstallParams.ClassInstallReserved;
1471 ListHead = &((struct DeviceInfo *)DeviceInfoData->Reserved)->DriverListHead;
1472 }
1473 else
1474 {
1475 pDriverInfo = (struct DriverInfoElement **)&((struct DeviceInfoSet *)DeviceInfoSet)->InstallParams.ClassInstallReserved;
1476 ListHead = &((struct DeviceInfoSet *)DeviceInfoSet)->DriverListHead;
1477 }
1478
1479 if (!DriverInfoData)
1480 {
1481 *pDriverInfo = NULL;
1482 ret = TRUE;
1483 }
1484 else
1485 {
1486 /* Search selected driver in list */
1487 ItemList = ListHead->Flink;
1488 while (ItemList != ListHead)
1489 {
1490 if (DriverInfoData->Reserved != 0)
1491 {
1492 if (DriverInfoData->Reserved == (ULONG_PTR)ItemList)
1493 break;
1494 }
1495 else
1496 {
1497 /* The caller wants to compare only DriverType, Description and ProviderName fields */
1498 struct DriverInfoElement *driverInfo = CONTAINING_RECORD(ItemList, struct DriverInfoElement, ListEntry);
1499 if (driverInfo->Info.DriverType == DriverInfoData->DriverType
1500 && strcmpW(driverInfo->Info.Description, DriverInfoData->Description) == 0
1501 && strcmpW(driverInfo->Info.ProviderName, DriverInfoData->ProviderName) == 0)
1502 {
1503 break;
1504 }
1505 }
1506 ItemList = ItemList->Flink;
1507 }
1508 if (ItemList == ListHead)
1510 else
1511 {
1512 *pDriverInfo = CONTAINING_RECORD(ItemList, struct DriverInfoElement, ListEntry);
1513 DriverInfoData->Reserved = (ULONG_PTR)ItemList;
1514 ret = TRUE;
1515 TRACE("Choosing driver whose rank is 0x%lx\n",
1516 (*pDriverInfo)->Params.Rank);
1517 if (DeviceInfoData)
1518 memcpy(&DeviceInfoData->ClassGuid, &(*pDriverInfo)->ClassGuid, sizeof(GUID));
1519 }
1520 }
1521 }
1522
1523 TRACE("Returning %d\n", ret);
1524 return ret;
1525}
1526
1527/***********************************************************************
1528 * SetupDiGetDriverInfoDetailA (SETUPAPI.@)
1529 */
1534 IN PSP_DRVINFO_DATA_A DriverInfoData,
1535 IN OUT PSP_DRVINFO_DETAIL_DATA_A DriverInfoDetailData OPTIONAL,
1536 IN DWORD DriverInfoDetailDataSize,
1538{
1539 SP_DRVINFO_DATA_V2_W DriverInfoDataW;
1540 PSP_DRVINFO_DETAIL_DATA_W DriverInfoDetailDataW = NULL;
1541 DWORD BufSize = 0;
1542 DWORD HardwareIDLen = 0;
1543 BOOL ret = FALSE;
1544
1545 /* do some sanity checks, the unicode version might do more thorough checks */
1546 if (DriverInfoData == NULL ||
1547 (DriverInfoDetailData == NULL && DriverInfoDetailDataSize != 0) ||
1548 (DriverInfoDetailData != NULL &&
1549 (DriverInfoDetailDataSize < FIELD_OFFSET(SP_DRVINFO_DETAIL_DATA_A, HardwareID) + sizeof(CHAR) ||
1550 DriverInfoDetailData->cbSize != sizeof(SP_DRVINFO_DETAIL_DATA_A))))
1551 {
1553 goto Cleanup;
1554 }
1555
1556 /* make sure we support both versions of the SP_DRVINFO_DATA structure */
1557 if (DriverInfoData->cbSize == sizeof(SP_DRVINFO_DATA_V1_A))
1558 {
1559 DriverInfoDataW.cbSize = sizeof(SP_DRVINFO_DATA_V1_W);
1560 }
1561 else if (DriverInfoData->cbSize == sizeof(SP_DRVINFO_DATA_V2_A))
1562 {
1563 DriverInfoDataW.cbSize = sizeof(SP_DRVINFO_DATA_V2_W);
1564 }
1565 else
1566 {
1568 goto Cleanup;
1569 }
1570 DriverInfoDataW.DriverType = DriverInfoData->DriverType;
1571 DriverInfoDataW.Reserved = DriverInfoData->Reserved;
1572
1573 /* convert the strings to unicode */
1575 0,
1576 DriverInfoData->Description,
1577 LINE_LEN,
1578 DriverInfoDataW.Description,
1579 LINE_LEN) &&
1581 0,
1582 DriverInfoData->MfgName,
1583 LINE_LEN,
1584 DriverInfoDataW.MfgName,
1585 LINE_LEN) &&
1587 0,
1588 DriverInfoData->ProviderName,
1589 LINE_LEN,
1590 DriverInfoDataW.ProviderName,
1591 LINE_LEN))
1592 {
1593 if (DriverInfoDataW.cbSize == sizeof(SP_DRVINFO_DATA_V2_W))
1594 {
1595 DriverInfoDataW.DriverDate = ((PSP_DRVINFO_DATA_V2_A)DriverInfoData)->DriverDate;
1596 DriverInfoDataW.DriverVersion = ((PSP_DRVINFO_DATA_V2_A)DriverInfoData)->DriverVersion;
1597 }
1598
1599 if (DriverInfoDetailData != NULL)
1600 {
1601 /* calculate the unicode buffer size from the ansi buffer size */
1602 HardwareIDLen = DriverInfoDetailDataSize - FIELD_OFFSET(SP_DRVINFO_DETAIL_DATA_A, HardwareID);
1604 (HardwareIDLen * sizeof(WCHAR));
1605
1606 DriverInfoDetailDataW = MyMalloc(BufSize);
1607 if (DriverInfoDetailDataW == NULL)
1608 {
1610 goto Cleanup;
1611 }
1612
1613 /* initialize the buffer */
1614 ZeroMemory(DriverInfoDetailDataW,
1615 BufSize);
1616 DriverInfoDetailDataW->cbSize = sizeof(SP_DRVINFO_DETAIL_DATA_W);
1617 }
1618
1619 /* call the unicode version */
1622 &DriverInfoDataW,
1623 DriverInfoDetailDataW,
1624 BufSize,
1625 RequiredSize);
1626
1627 if (ret)
1628 {
1629 if (DriverInfoDetailDataW != NULL)
1630 {
1631 /* convert the SP_DRVINFO_DETAIL_DATA_W structure to ansi */
1632 DriverInfoDetailData->cbSize = sizeof(SP_DRVINFO_DETAIL_DATA_A);
1633 DriverInfoDetailData->InfDate = DriverInfoDetailDataW->InfDate;
1634 DriverInfoDetailData->Reserved = DriverInfoDetailDataW->Reserved;
1636 0,
1637 DriverInfoDetailDataW->SectionName,
1638 LINE_LEN,
1639 DriverInfoDetailData->SectionName,
1640 LINE_LEN,
1641 NULL,
1642 NULL) &&
1644 0,
1645 DriverInfoDetailDataW->InfFileName,
1646 MAX_PATH,
1647 DriverInfoDetailData->InfFileName,
1648 MAX_PATH,
1649 NULL,
1650 NULL) &&
1652 0,
1653 DriverInfoDetailDataW->DrvDescription,
1654 LINE_LEN,
1655 DriverInfoDetailData->DrvDescription,
1656 LINE_LEN,
1657 NULL,
1658 NULL) &&
1660 0,
1661 DriverInfoDetailDataW->HardwareID,
1662 HardwareIDLen,
1663 DriverInfoDetailData->HardwareID,
1664 HardwareIDLen,
1665 NULL,
1666 NULL))
1667 {
1668 DWORD len, cnt = 0;
1669 DWORD hwidlen = HardwareIDLen;
1670 CHAR *s = DriverInfoDetailData->HardwareID;
1671
1672 /* count the strings in the list */
1673 while (*s != '\0')
1674 {
1675 len = lstrlenA(s) + 1;
1676 if (hwidlen > len)
1677 {
1678 cnt++;
1679 s += len;
1680 hwidlen -= len;
1681 }
1682 else
1683 {
1684 /* looks like the string list wasn't terminated... */
1686 ret = FALSE;
1687 break;
1688 }
1689 }
1690
1691 /* make sure CompatIDsOffset points to the second string in the
1692 list, if present */
1693 if (cnt > 1)
1694 {
1695 DriverInfoDetailData->CompatIDsOffset = lstrlenA(DriverInfoDetailData->HardwareID) + 1;
1696 DriverInfoDetailData->CompatIDsLength = (DWORD)(s - DriverInfoDetailData->HardwareID) -
1697 DriverInfoDetailData->CompatIDsOffset + 1;
1698 }
1699 else
1700 {
1701 DriverInfoDetailData->CompatIDsOffset = 0;
1702 DriverInfoDetailData->CompatIDsLength = 0;
1703 }
1704 }
1705 else
1706 {
1707 ret = FALSE;
1708 }
1709 }
1710
1711 if (RequiredSize != NULL)
1712 {
1714 (((*RequiredSize) - FIELD_OFFSET(SP_DRVINFO_DETAIL_DATA_W, HardwareID)) / sizeof(WCHAR));
1715 }
1716 }
1717 }
1718
1719Cleanup:
1720 if (DriverInfoDetailDataW != NULL)
1721 {
1722 MyFree(DriverInfoDetailDataW);
1723 }
1724
1725 return ret;
1726}
1727
1728/***********************************************************************
1729 * SetupDiGetDriverInfoDetailW (SETUPAPI.@)
1730 */
1735 IN PSP_DRVINFO_DATA_W DriverInfoData,
1736 IN OUT PSP_DRVINFO_DETAIL_DATA_W DriverInfoDetailData OPTIONAL,
1737 IN DWORD DriverInfoDetailDataSize,
1739{
1740 BOOL ret = FALSE;
1741
1742 TRACE("%p %p %p %p %lu %p\n", DeviceInfoSet, DeviceInfoData,
1743 DriverInfoData, DriverInfoDetailData,
1744 DriverInfoDetailDataSize, RequiredSize);
1745
1746 if (!DeviceInfoSet)
1750 else if (((struct DeviceInfoSet *)DeviceInfoSet)->magic != SETUP_DEVICE_INFO_SET_MAGIC)
1752 else if (DeviceInfoData && DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA))
1754 else if (!DriverInfoData)
1756 else if (!DriverInfoDetailData && DriverInfoDetailDataSize != 0)
1758 else if (DriverInfoDetailData && DriverInfoDetailDataSize < sizeof(SP_DRVINFO_DETAIL_DATA_W))
1760 else if (DriverInfoDetailData && DriverInfoDetailData->cbSize != sizeof(SP_DRVINFO_DETAIL_DATA_W))
1762 else if (DriverInfoData->Reserved == 0)
1764 else
1765 {
1766 struct DriverInfoElement *driverInfoElement;
1767 LPWSTR HardwareIDs = NULL;
1768 LPWSTR CompatibleIDs = NULL;
1771 ULONG HardwareIDsSize, CompatibleIDsSize;
1772 ULONG sizeNeeded, sizeLeft, size;
1773 BOOL Result;
1774
1775 driverInfoElement = (struct DriverInfoElement *)DriverInfoData->Reserved;
1776
1777 /* Get hardware and compatible IDs lists */
1781 &HardwareIDs, &HardwareIDsSize,
1782 &CompatibleIDs, &CompatibleIDsSize);
1783 if (!Result)
1784 goto done;
1785
1787 + HardwareIDsSize + CompatibleIDsSize;
1788 if (RequiredSize)
1789 *RequiredSize = sizeNeeded;
1790
1791 if (!DriverInfoDetailData)
1792 {
1793 ret = TRUE;
1794 goto done;
1795 }
1796
1797 memcpy(
1798 DriverInfoDetailData,
1799 &driverInfoElement->Details,
1800 driverInfoElement->Details.cbSize);
1801 DriverInfoDetailData->CompatIDsOffset = 0;
1802 DriverInfoDetailData->CompatIDsLength = 0;
1803
1804 sizeLeft = (DriverInfoDetailDataSize - FIELD_OFFSET(SP_DRVINFO_DETAIL_DATA_W, HardwareID)) / sizeof(WCHAR);
1805 pBuffer = DriverInfoDetailData->HardwareID;
1806 /* Add as many as possible HardwareIDs in the list */
1807 DeviceID = HardwareIDs;
1808 while (DeviceID && *DeviceID && (size = wcslen(DeviceID)) + 1 < sizeLeft)
1809 {
1810 TRACE("Adding %s to list\n", debugstr_w(DeviceID));
1812 DeviceID += size + 1;
1813 pBuffer += size + 1;
1814 sizeLeft -= size + 1;
1815 DriverInfoDetailData->CompatIDsOffset += size + 1;
1816 }
1817 if (sizeLeft > 0)
1818 {
1820 sizeLeft--;
1821 DriverInfoDetailData->CompatIDsOffset++;
1822 }
1823 /* Add as many as possible CompatibleIDs in the list */
1824 DeviceID = CompatibleIDs;
1825 while (DeviceID && *DeviceID && (size = wcslen(DeviceID)) + 1 < sizeLeft)
1826 {
1827 TRACE("Adding %s to list\n", debugstr_w(DeviceID));
1829 DeviceID += size + 1;
1830 pBuffer += size + 1;
1831 sizeLeft -= size + 1;
1832 DriverInfoDetailData->CompatIDsLength += size + 1;
1833 }
1834 if (sizeLeft > 0)
1835 {
1837 sizeLeft--;
1838 DriverInfoDetailData->CompatIDsLength++;
1839 }
1840
1841 if (sizeNeeded > DriverInfoDetailDataSize)
1843 else
1844 ret = TRUE;
1845
1846done:
1847 MyFree(HardwareIDs);
1848 MyFree(CompatibleIDs);
1849 }
1850
1851 TRACE("Returning %d\n", ret);
1852 return ret;
1853}
1854
1855/***********************************************************************
1856 * SetupDiGetDriverInstallParamsW (SETUPAPI.@)
1857 */
1862 IN PSP_DRVINFO_DATA_W DriverInfoData,
1863 OUT PSP_DRVINSTALL_PARAMS DriverInstallParams)
1864{
1865 BOOL ret = FALSE;
1866
1867 TRACE("%p %p %p %p\n", DeviceInfoSet, DeviceInfoData, DriverInfoData, DriverInstallParams);
1868
1869 if (!DeviceInfoSet || !DriverInfoData || !DriverInstallParams)
1873 else if (((struct DeviceInfoSet *)DeviceInfoSet)->magic != SETUP_DEVICE_INFO_SET_MAGIC)
1875 else if (DeviceInfoData && DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA))
1877 else if (DriverInfoData->cbSize != sizeof(SP_DRVINFO_DATA_V1_W) && DriverInfoData->cbSize != sizeof(SP_DRVINFO_DATA_V2_W))
1879 else if (DriverInstallParams->cbSize != sizeof(SP_DRVINSTALL_PARAMS))
1881 else
1882 {
1883 SP_DEVINSTALL_PARAMS InstallParams;
1884
1885 InstallParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS_W);
1887 {
1888 struct DriverInfoElement *driverInfo;
1889 driverInfo = (struct DriverInfoElement *)InstallParams.ClassInstallReserved;
1890 if (driverInfo == NULL)
1892 else
1893 {
1894 memcpy(
1895 DriverInstallParams,
1896 &driverInfo->Params,
1897 DriverInstallParams->cbSize);
1898 ret = TRUE;
1899 }
1900 }
1901 }
1902
1903 TRACE("Returning %d\n", ret);
1904 return ret;
1905}
1906
1907/***********************************************************************
1908 * SetupDiSelectBestCompatDrv (SETUPAPI.@)
1909 */
1914{
1915 SP_DRVINFO_DATA_W drvInfoData;
1916 BOOL ret;
1917
1918 TRACE("%p %p\n", DeviceInfoSet, DeviceInfoData);
1919
1920 /* Drivers are sorted by rank in the driver list, so
1921 * the first driver in the list is the best one.
1922 */
1923 drvInfoData.cbSize = sizeof(SP_DRVINFO_DATA_W);
1928 0, /* Member index */
1929 &drvInfoData);
1930
1931 if (ret)
1932 {
1936 &drvInfoData);
1937 }
1938
1939 TRACE("Returning %d\n", ret);
1940 return ret;
1941}
1942
1943/***********************************************************************
1944 * SetupDiInstallDriverFiles (SETUPAPI.@)
1945 */
1950{
1951 BOOL ret = FALSE;
1952
1953 TRACE("%p %p\n", DeviceInfoSet, DeviceInfoData);
1954
1955 if (!DeviceInfoSet)
1959 else if (((struct DeviceInfoSet *)DeviceInfoSet)->magic != SETUP_DEVICE_INFO_SET_MAGIC)
1961 else if (DeviceInfoData && DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA))
1963 else if (DeviceInfoData && ((struct DeviceInfo *)DeviceInfoData->Reserved)->InstallParams.ClassInstallReserved == 0)
1965 else if (!DeviceInfoData && ((struct DeviceInfoSet *)DeviceInfoSet)->InstallParams.ClassInstallReserved == 0)
1967 else
1968 {
1969 SP_DEVINSTALL_PARAMS_W InstallParams;
1970 struct DriverInfoElement *SelectedDriver;
1971 WCHAR SectionName[MAX_PATH];
1972 DWORD SectionNameLength = 0;
1973 PVOID InstallMsgHandler;
1974 PVOID InstallMsgHandlerContext;
1975 PVOID Context = NULL;
1976
1977 InstallParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS_W);
1979 if (!ret)
1980 goto done;
1981
1982 SelectedDriver = (struct DriverInfoElement *)InstallParams.ClassInstallReserved;
1983 if (!SelectedDriver)
1984 {
1986 goto done;
1987 }
1988
1990 SelectedDriver->InfFileDetails->hInf,
1991 SelectedDriver->Details.SectionName,
1992 SectionName, MAX_PATH - strlenW(DotCoInstallers), &SectionNameLength, NULL);
1993 if (!ret)
1994 goto done;
1995
1996 if (InstallParams.InstallMsgHandler)
1997 {
1998 InstallMsgHandler = InstallParams.InstallMsgHandler;
1999 InstallMsgHandlerContext = InstallParams.InstallMsgHandlerContext;
2000 }
2001 else
2002 {
2004 if (!Context)
2005 goto cleanup;
2006 InstallMsgHandler = SetupDefaultQueueCallbackW;
2007 InstallMsgHandlerContext = Context;
2008 }
2010 SelectedDriver->InfFileDetails->hInf, SectionName,
2011 SPINST_FILES, NULL, SelectedDriver->InfFileDetails->DirectoryName, SP_COPY_NEWER,
2012 InstallMsgHandler, InstallMsgHandlerContext,
2014 if (!ret)
2015 goto done;
2016
2017 /* Install files from .CoInstallers section */
2018 lstrcatW(SectionName, DotCoInstallers);
2020 SelectedDriver->InfFileDetails->hInf, SectionName,
2021 SPINST_FILES, NULL, SelectedDriver->InfFileDetails->DirectoryName, SP_COPY_NEWER,
2022 InstallMsgHandler, InstallMsgHandlerContext,
2024 if (!ret)
2025 goto done;
2026
2027 /* Set the DI_NOFILECOPY flag to prevent another
2028 * installation during SetupDiInstallDevice */
2029 InstallParams.Flags |= DI_NOFILECOPY;
2031
2032cleanup:
2033 if (Context)
2035 }
2036
2037done:
2038 TRACE("Returning %d\n", ret);
2039 return ret;
2040}
#define BufSize
Definition: FsRtlTunnel.c:28
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define FIXME(fmt,...)
Definition: precomp.h:53
while(CdLookupNextInitialFileDirent(IrpContext, Fcb, FileContext))
Definition: bufpool.h:45
Definition: list.h:37
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define MAX_GUID_STRING_LEN
Definition: apphelp.c:29
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:1931
#define CloseHandle
Definition: compat.h:739
#define GetProcessHeap()
Definition: compat.h:736
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:109
#define OPEN_EXISTING
Definition: compat.h:775
#define SetLastError(x)
Definition: compat.h:752
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define HeapAlloc
Definition: compat.h:733
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:105
#define GENERIC_READ
Definition: compat.h:135
#define MAX_PATH
Definition: compat.h:34
#define HeapFree(x, y, z)
Definition: compat.h:735
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define CreateFileW
Definition: compat.h:741
#define WideCharToMultiByte
Definition: compat.h:111
#define MultiByteToWideChar
Definition: compat.h:110
#define FILE_SHARE_READ
Definition: compat.h:136
#define lstrcpynW
Definition: compat.h:738
static void cleanup(void)
Definition: main.c:1335
BOOL WINAPI GetFileTime(IN HANDLE hFile, OUT LPFILETIME lpCreationTime OPTIONAL, OUT LPFILETIME lpLastAccessTime OPTIONAL, OUT LPFILETIME lpLastWriteTime OPTIONAL)
Definition: fileinfo.c:880
UINT WINAPI GetSystemWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2316
DWORD WINAPI GetFullPathNameW(IN LPCWSTR lpFileName, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart)
Definition: path.c:1106
BOOL WINAPI SystemTimeToFileTime(IN CONST SYSTEMTIME *lpSystemTime, OUT LPFILETIME lpFileTime)
Definition: time.c:158
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2983
BOOL WINAPI SetupDiSetDeviceInstallParamsW(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL, IN PSP_DEVINSTALL_PARAMS_W DeviceInstallParams)
Definition: devinst.c:4558
BOOL WINAPI SetupDiGetDeviceInstallParamsW(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL, OUT PSP_DEVINSTALL_PARAMS_W DeviceInstallParams)
Definition: devinst.c:4451
BOOL WINAPI SetupDiGetActualSectionToInstallW(HINF InfHandle, PCWSTR InfSectionName, PWSTR InfSectionWithExt, DWORD InfSectionWithExtSize, PDWORD RequiredSize, PWSTR *Extension)
Definition: devinst.c:1980
BOOL WINAPI SetupDiGetDeviceRegistryPropertyW(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Property, PDWORD PropertyRegDataType, PBYTE PropertyBuffer, DWORD PropertyBufferSize, PDWORD RequiredSize)
Definition: devinst.c:3224
HKEY SETUPDI_OpenDrvKey(HKEY RootKey, struct DeviceInfo *devInfo, REGSAM samDesired)
Definition: devinst.c:5857
static const WCHAR INF_DRIVER_VER[]
Definition: driver.c:32
BOOL WINAPI SetupDiSetSelectedDriverA(IN HDEVINFO DeviceInfoSet, IN OUT PSP_DEVINFO_DATA DeviceInfoData OPTIONAL, IN OUT PSP_DRVINFO_DATA_A DriverInfoData OPTIONAL)
Definition: driver.c:1382
static const WCHAR ClassGUID[]
Definition: driver.c:25
BOOL WINAPI SetupDiGetSelectedDriverW(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL, OUT PSP_DRVINFO_DATA_W DriverInfoData)
Definition: driver.c:1333
static const WCHAR INF_PROVIDER[]
Definition: driver.c:31
BOOL WINAPI SetupDiGetDriverInstallParamsW(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL, IN PSP_DRVINFO_DATA_W DriverInfoData, OUT PSP_DRVINSTALL_PARAMS DriverInstallParams)
Definition: driver.c:1859
BOOL WINAPI SetupDiEnumDriverInfoA(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL, IN DWORD DriverType, IN DWORD MemberIndex, OUT PSP_DRVINFO_DATA_A DriverInfoData)
Definition: driver.c:1145
static BOOL AddKnownDriverToList(IN PLIST_ENTRY DriverListHead, IN DWORD DriverType, IN LPGUID ClassGuid, IN struct InfFileDetails *InfFileDetails, IN LPCWSTR InfFile, IN LPCWSTR SectionName, IN LPCWSTR DriverDescription, IN LPCWSTR ProviderName, IN LPCWSTR ManufacturerName, IN LPCWSTR MatchingId, IN FILETIME DriverDate, IN DWORDLONG DriverVersion, IN DWORD Rank)
Definition: driver.c:106
static const WCHAR INF_MANUFACTURER[]
Definition: driver.c:30
BOOL WINAPI SetupDiInstallDriverFiles(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData)
Definition: driver.c:1947
static const WCHAR BackSlash[]
Definition: driver.c:24
struct InfFileDetails * CreateInfFileDetails(IN LPCWSTR FullInfFileName)
Definition: driver.c:55
BOOL DestroyDriverInfoElement(struct DriverInfoElement *driverInfo)
Definition: driver.c:94
BOOL WINAPI SetupDiSetSelectedDriverW(IN HDEVINFO DeviceInfoSet, IN OUT PSP_DEVINFO_DATA DeviceInfoData OPTIONAL, IN OUT PSP_DRVINFO_DATA_W DriverInfoData OPTIONAL)
Definition: driver.c:1444
static BOOL GetHardwareAndCompatibleIDsLists(IN HDEVINFO DeviceInfoSet, IN OUT PSP_DEVINFO_DATA DeviceInfoData, OUT LPWSTR *pHardwareIDs OPTIONAL, OUT LPDWORD pHardwareIDsRequiredSize OPTIONAL, OUT LPWSTR *pCompatibleIDs OPTIONAL, OUT LPDWORD pCompatibleIDsRequiredSize OPTIONAL)
Definition: driver.c:466
static VOID ReferenceInfFile(struct InfFileDetails *infFile)
Definition: driver.c:39
BOOL WINAPI SetupDiBuildDriverInfoList(IN HDEVINFO DeviceInfoSet, IN OUT PSP_DEVINFO_DATA DeviceInfoData OPTIONAL, IN DWORD DriverType)
Definition: driver.c:572
BOOL WINAPI SetupDiGetDriverInfoDetailW(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL, IN PSP_DRVINFO_DATA_W DriverInfoData, IN OUT PSP_DRVINFO_DETAIL_DATA_W DriverInfoDetailData OPTIONAL, IN DWORD DriverInfoDetailDataSize, OUT PDWORD RequiredSize OPTIONAL)
Definition: driver.c:1732
BOOL WINAPI SetupDiGetSelectedDriverA(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL, OUT PSP_DRVINFO_DATA_A DriverInfoData)
Definition: driver.c:1274
static BOOL AddDriverToList(IN PLIST_ENTRY DriverListHead, IN DWORD DriverType, IN LPGUID ClassGuid, IN INFCONTEXT ContextDevice, IN struct InfFileDetails *InfFileDetails, IN LPCWSTR InfFile, IN LPCWSTR ProviderName, IN LPCWSTR ManufacturerName, IN LPCWSTR MatchingId, IN FILETIME DriverDate, IN DWORDLONG DriverVersion, IN DWORD Rank)
Definition: driver.c:238
BOOL WINAPI SetupDiGetDriverInfoDetailA(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL, IN PSP_DRVINFO_DATA_A DriverInfoData, IN OUT PSP_DRVINFO_DETAIL_DATA_A DriverInfoDetailData OPTIONAL, IN DWORD DriverInfoDetailDataSize, OUT PDWORD RequiredSize OPTIONAL)
Definition: driver.c:1531
BOOL WINAPI SetupDiEnumDriverInfoW(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL, IN DWORD DriverType, IN DWORD MemberIndex, OUT PSP_DRVINFO_DATA_W DriverInfoData)
Definition: driver.c:1209
static const WCHAR InfDirectory[]
Definition: driver.c:27
BOOL WINAPI SetupDiSelectBestCompatDrv(IN HDEVINFO DeviceInfoSet, IN OUT PSP_DEVINFO_DATA DeviceInfoData OPTIONAL)
Definition: driver.c:1911
BOOL WINAPI SetupDiDestroyDriverInfoList(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL, IN DWORD DriverType)
Definition: driver.c:1062
static BOOL GetVersionInformationFromInfFile(IN HINF hInf, OUT LPGUID ClassGuid, OUT LPWSTR *pProviderName, OUT FILETIME *DriverDate, OUT DWORDLONG *DriverVersion)
Definition: driver.c:311
VOID DereferenceInfFile(struct InfFileDetails *infFile)
Definition: driver.c:45
static const WCHAR DotCoInstallers[]
Definition: driver.c:26
BOOL WINAPI SetupInstallFromInfSectionW(HWND owner, HINF hinf, PCWSTR section, UINT flags, HKEY key_root, PCWSTR src_root, UINT copy_flags, PSP_FILE_CALLBACK_W callback, PVOID context, HDEVINFO devinfo, PSP_DEVINFO_DATA devinfo_data)
Definition: install.c:1330
LPVOID WINAPI MyMalloc(DWORD dwSize)
Definition: misc.c:147
VOID WINAPI MyFree(LPVOID lpMem)
Definition: misc.c:128
HINF WINAPI SetupOpenInfFileW(PCWSTR name, PCWSTR class, DWORD style, UINT *error)
Definition: parser.c:1229
BOOL WINAPI SetupGetInfFileListW(IN PCWSTR DirectoryPath OPTIONAL, IN DWORD InfStyle, IN OUT PWSTR ReturnBuffer OPTIONAL, IN DWORD ReturnBufferSize OPTIONAL, OUT PDWORD RequiredSize OPTIONAL)
Definition: parser.c:2146
BOOL WINAPI SetupGetLineTextW(PINFCONTEXT context, HINF hinf, PCWSTR section_name, PCWSTR key_name, PWSTR buffer, DWORD size, PDWORD required)
Definition: parser.c:1763
UINT WINAPI SetupDefaultQueueCallbackW(PVOID context, UINT notification, UINT_PTR param1, UINT_PTR param2)
Definition: queue.c:1729
void WINAPI SetupTermDefaultQueueCallback(PVOID context)
Definition: queue.c:1656
PVOID WINAPI SetupInitDefaultQueueCallback(HWND owner)
Definition: queue.c:1629
static const WCHAR Cleanup[]
Definition: register.c:80
return ret
Definition: mutex.c:146
#define L(x)
Definition: resources.c:13
#define ULONG_PTR
Definition: config.h:101
#define InsertTailList(ListHead, Entry)
#define InsertHeadList(ListHead, Entry)
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define RemoveHeadList(ListHead)
Definition: env_spec_w32.h:964
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLdouble s
Definition: gl.h:2039
GLsizeiptr size
Definition: glext.h:5919
GLenum GLsizei len
Definition: glext.h:6722
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define INF_STYLE_WIN4
Definition: infsupp.h:43
unsigned long long DWORDLONG
Definition: intsafe.h:93
const char * filename
Definition: ioapi.h:137
#define debugstr_w
Definition: kernel32.h:32
#define GUID_NULL
Definition: ks.h:106
if(dx< 0)
Definition: linetemp.h:194
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define ZeroMemory
Definition: minwinbase.h:31
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
static UINT UINT last
Definition: font.c:45
int details
Definition: msacm.c:1366
_In_ HANDLE hFile
Definition: mswsock.h:90
_In_ ULONG Revision
Definition: rtlfuncs.h:1162
#define KEY_QUERY_VALUE
Definition: nt_native.h:1019
#define DWORD
Definition: nt_native.h:44
#define UNICODE_NULL
BYTE * PBYTE
Definition: pedump.c:66
DWORD * PDWORD
Definition: pedump.c:68
long LONG
Definition: pedump.c:60
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
static unsigned __int64 next
Definition: rand_nt.c:6
PVOID pBuffer
static const WCHAR HKLM[]
Definition: reginf.c:58
#define REGSTR_VAL_INFPATH
Definition: regstr.h:439
#define REGSTR_VAL_INFSECTION
Definition: regstr.h:440
#define list
Definition: rosglue.h:35
#define RPC_S_OK
Definition: rpcnterr.h:22
RPC_STATUS WINAPI UuidFromStringW(RPC_WSTR s, UUID *uuid)
Definition: rpcrt4_main.c:655
wcscpy
#define memset(x, y, z)
Definition: compat.h:39
struct _SP_DRVINFO_DATA_V1_W SP_DRVINFO_DATA_V1_W
#define DI_DIDCOMPAT
Definition: setupapi.h:50
#define SPDIT_CLASSDRIVER
Definition: setupapi.h:506
#define LINE_LEN
Definition: setupapi.h:20
#define SPDRP_COMPATIBLEIDS
Definition: setupapi.h:510
#define DI_FLAGSEX_DIDCOMPATINFO
Definition: setupapi.h:81
struct _SP_DRVINFO_DETAIL_DATA_W SP_DRVINFO_DETAIL_DATA_W
#define DI_ENUMSINGLEINF
Definition: setupapi.h:62
#define ERROR_NO_DRIVER_SELECTED
Definition: setupapi.h:300
SP_DRVINFO_DATA_V2_W SP_DRVINFO_DATA_W
Definition: setupapi.h:1054
struct _SP_DEVINSTALL_PARAMS_W SP_DEVINSTALL_PARAMS_W
_In_opt_ PSP_DEVINFO_DATA DeviceInfoData
Definition: setupapi.h:1529
struct _SP_DRVINSTALL_PARAMS SP_DRVINSTALL_PARAMS
struct _SP_DRVINFO_DATA_V2_A * PSP_DRVINFO_DATA_V2_A
#define DI_FLAGSEX_DIDINFOLIST
Definition: setupapi.h:80
SP_DRVINFO_DATA_V2_W * PSP_DRVINFO_DATA_W
Definition: setupapi.h:1054
#define DI_MULTMFGS
Definition: setupapi.h:56
#define DI_NOFILECOPY
Definition: setupapi.h:69
#define SPINST_FILES
Definition: setupapi.h:593
struct _SP_DRVINFO_DETAIL_DATA_A SP_DRVINFO_DETAIL_DATA_A
#define DI_FLAGSEX_ALLOWEXCLUDEDDRVS
Definition: setupapi.h:87
#define SPDRP_HARDWAREID
Definition: setupapi.h:509
struct _SP_DRVINFO_DATA_V2_W SP_DRVINFO_DATA_V2_W
#define DICD_INHERIT_CLASSDRVS
Definition: setupapi.h:111
#define DI_DIDCLASS
Definition: setupapi.h:51
#define SPDIT_COMPATDRIVER
Definition: setupapi.h:507
#define SP_COPY_NEWER
Definition: setupapi.h:479
#define SETUP_DEVICE_INFO_SET_MAGIC
#define TRACE(s)
Definition: solgame.cpp:4
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
_In_ PVOID Context
Definition: storport.h:2269
SP_DEVINSTALL_PARAMS_W InstallParams
LIST_ENTRY ListHead
SP_DEVINSTALL_PARAMS_W InstallParams
LIST_ENTRY ListEntry
LIST_ENTRY DriverListHead
struct InfFileDetails * InfFileDetails
SP_DRVINFO_DETAIL_DATA_W Details
SP_DRVINFO_DATA_V2_W Info
ULARGE_INTEGER DriverDate
SP_DRVINSTALL_PARAMS Params
WCHAR szData[ANYSIZE_ARRAY]
DWORD dwHighDateTime
Definition: mapidefs.h:66
DWORD dwLowDateTime
Definition: mapidefs.h:65
Definition: typedefs.h:120
struct _LIST_ENTRY * Blink
Definition: typedefs.h:122
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
ULONG_PTR Reserved
Definition: setupapi.h:839
ULONG_PTR ClassInstallReserved
Definition: setupapi.h:887
ULONG_PTR ClassInstallReserved
Definition: setupapi.h:899
PVOID InstallMsgHandlerContext
Definition: setupapi.h:897
PSP_FILE_CALLBACK_W InstallMsgHandler
Definition: setupapi.h:896
WCHAR DriverPath[MAX_PATH]
Definition: setupapi.h:901
WCHAR ProviderName[LINE_LEN]
Definition: setupapi.h:1037
WCHAR Description[LINE_LEN]
Definition: setupapi.h:1035
WCHAR ProviderName[LINE_LEN]
Definition: setupapi.h:1019
WCHAR MfgName[LINE_LEN]
Definition: setupapi.h:1018
DWORDLONG DriverVersion
Definition: setupapi.h:1021
WCHAR Description[LINE_LEN]
Definition: setupapi.h:1017
WCHAR DrvDescription[LINE_LEN]
Definition: setupapi.h:1079
WCHAR HardwareID[ANYSIZE_ARRAY]
Definition: setupapi.h:1080
WCHAR SectionName[LINE_LEN]
Definition: setupapi.h:1077
WCHAR InfFileName[MAX_PATH]
Definition: setupapi.h:1078
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
uint32_t * LPDWORD
Definition: typedefs.h:59
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
uint16_t * PWCHAR
Definition: typedefs.h:56
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
struct _LARGE_INTEGER::@2464 u
BOOL WINAPI SetupGetStringFieldW(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT PWSTR ReturnBuffer, IN ULONG ReturnBufferSize, OUT PULONG RequiredSize)
Definition: infsupp.c:186
BOOL WINAPI SetupFindFirstLineW(IN HINF InfHandle, IN PCWSTR Section, IN PCWSTR Key, IN OUT PINFCONTEXT Context)
Definition: infsupp.c:56
ULONG WINAPI SetupGetFieldCount(IN PINFCONTEXT Context)
Definition: infsupp.c:93
BOOL WINAPI SetupFindNextLine(IN PINFCONTEXT ContextIn, OUT PINFCONTEXT ContextOut)
Definition: infsupp.c:82
VOID WINAPI SetupCloseInfFile(IN HINF InfHandle)
Definition: infsupp.c:45
_In_ size_t cnt
Definition: wcstombs.cpp:43
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG RequiredSize
Definition: wdfdevice.h:4445
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE _In_ USHORT _In_ USHORT Version
Definition: wdffdo.h:469
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PCUNICODE_STRING HardwareID
Definition: wdfpdo.h:340
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PCUNICODE_STRING DeviceID
Definition: wdfpdo.h:278
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define WINAPI
Definition: msvc.h:6
#define atoiW(s)
Definition: unicode.h:60
#define strcmpW(s1, s2)
Definition: unicode.h:44
#define strchrW(s, c)
Definition: unicode.h:40
#define strcmpiW(s1, s2)
Definition: unicode.h:45
#define strlenW(s)
Definition: unicode.h:34
#define strrchrW(s, c)
Definition: unicode.h:41
#define strcatW(d, s)
Definition: unicode.h:36
#define strcpyW(d, s)
Definition: unicode.h:35
#define ERROR_INVALID_USER_BUFFER
Definition: winerror.h:1448
#define ERROR_GEN_FAILURE
Definition: winerror.h:256
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define RRF_RT_REG_SZ
Definition: winreg.h:58
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
_Out_opt_ PULONG Minor
Definition: cmfuncs.h:44
@ DriverType
Definition: cmtypes.h:987
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
char CHAR
Definition: xmlstorage.h:175