MCPcopy Create free account
hub / github.com/NullArray/WinKernel-Resources / FindCurrentDriver

Function FindCurrentDriver

Drivers/Driver-SRC/setup/devcon/dump.cpp:446–674  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

444}
445
446BOOL FindCurrentDriver(_In_ HDEVINFO Devs, _In_ PSP_DEVINFO_DATA DevInfo, _In_ PSP_DRVINFO_DATA DriverInfoData)
447/*++
448
449Routine 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
455Arguments:
456
457 Devs )_ uniquely identify device
458 DevInfo )
459
460Return 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;

Callers 1

DumpDeviceDriverFilesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected