| 444 | } |
| 445 | |
| 446 | BOOL FindCurrentDriver(_In_ HDEVINFO Devs, _In_ PSP_DEVINFO_DATA DevInfo, _In_ PSP_DRVINFO_DATA DriverInfoData) |
| 447 | /*++ |
| 448 | |
| 449 | Routine Description: |
| 450 | |
| 451 | Find the driver that is associated with the current device |
| 452 | We can do this either the quick way (available in WinXP) |
| 453 | or the long way that works in Win2k. |
| 454 | |
| 455 | Arguments: |
| 456 | |
| 457 | Devs )_ uniquely identify device |
| 458 | DevInfo ) |
| 459 | |
| 460 | Return Value: |
| 461 | |
| 462 | TRUE if we managed to determine and select current driver |
| 463 | |
| 464 | --*/ |
| 465 | { |
| 466 | SP_DEVINSTALL_PARAMS deviceInstallParams; |
| 467 | WCHAR SectionName[LINE_LEN]; |
| 468 | WCHAR DrvDescription[LINE_LEN]; |
| 469 | WCHAR MfgName[LINE_LEN]; |
| 470 | WCHAR ProviderName[LINE_LEN]; |
| 471 | HKEY hKey = NULL; |
| 472 | DWORD RegDataLength; |
| 473 | DWORD RegDataType; |
| 474 | DWORD c; |
| 475 | BOOL match = FALSE; |
| 476 | long regerr; |
| 477 | |
| 478 | ZeroMemory(&deviceInstallParams, sizeof(deviceInstallParams)); |
| 479 | deviceInstallParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS); |
| 480 | |
| 481 | if(!SetupDiGetDeviceInstallParams(Devs, DevInfo, &deviceInstallParams)) { |
| 482 | return FALSE; |
| 483 | } |
| 484 | |
| 485 | #ifdef DI_FLAGSEX_INSTALLEDDRIVER |
| 486 | // |
| 487 | // Set the flags that tell SetupDiBuildDriverInfoList to just put the |
| 488 | // currently installed driver node in the list, and that it should allow |
| 489 | // excluded drivers. This flag introduced in WinXP. |
| 490 | // |
| 491 | deviceInstallParams.FlagsEx |= (DI_FLAGSEX_INSTALLEDDRIVER | DI_FLAGSEX_ALLOWEXCLUDEDDRVS); |
| 492 | |
| 493 | if(SetupDiSetDeviceInstallParams(Devs, DevInfo, &deviceInstallParams)) { |
| 494 | // |
| 495 | // we were able to specify this flag, so proceed the easy way |
| 496 | // we should get a list of no more than 1 driver |
| 497 | // |
| 498 | if(!SetupDiBuildDriverInfoList(Devs, DevInfo, SPDIT_CLASSDRIVER)) { |
| 499 | return FALSE; |
| 500 | } |
| 501 | if (!SetupDiEnumDriverInfo(Devs, DevInfo, SPDIT_CLASSDRIVER, |
| 502 | 0, DriverInfoData)) { |
| 503 | return FALSE; |
no outgoing calls
no test coverage detected