From: Asanka Herath Date: Tue, 24 May 2005 06:12:19 +0000 (+0000) Subject: windows-loopback-20050524 X-Git-Tag: openafs-devel-1_5_0~552 X-Git-Url: https://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=280e10315e00d9f3545bb5176f08c58512385571 windows-loopback-20050524 Find the loopback adapter installer by hardware ID instead of English name. --- diff --git a/src/WINNT/install/loopback/loopbackutils.cpp b/src/WINNT/install/loopback/loopbackutils.cpp index b3eebe3..72256a5 100644 --- a/src/WINNT/install/loopback/loopbackutils.cpp +++ b/src/WINNT/install/loopback/loopbackutils.cpp @@ -237,6 +237,10 @@ extern "C" DWORD InstallLoopBack(LPCTSTR pConnectionName, LPCTSTR ip, LPCTSTR ma BOOL found = FALSE; BOOL registered = FALSE; BOOL destroyList = FALSE; + PSP_DRVINFO_DETAIL_DATA pDriverInfoDetail; + DWORD detailBuf[2048]; // for our purposes, 8k buffer is more + // than enough to obtain the hardware ID + // of the loopback driver. HKEY hkey = NULL; DWORD cbSize; @@ -294,21 +298,43 @@ extern "C" DWORD InstallLoopBack(LPCTSTR pConnectionName, LPCTSTR ip, LPCTSTR ma destroyList = TRUE; // enumerate the driver info list - while (SetupDiEnumDriverInfo(hDeviceInfo, &DeviceInfoData, - SPDIT_CLASSDRIVER, index, &DriverInfoData)) + while (TRUE) { - // if the manufacture is microsoft - if (_tcsicmp(DriverInfoData.MfgName, MANUFACTURE) == 0) - { - // case insensitive search for loopback - _tcscpy(temp, DriverInfoData.Description); - _tcslwr(temp); - if( _tcsstr(temp, DRIVER)) - { - found = TRUE; - break; - } - } + BOOL ret; + + ret = SetupDiEnumDriverInfo(hDeviceInfo, &DeviceInfoData, + SPDIT_CLASSDRIVER, index, &DriverInfoData); + + // if the function failed and GetLastError() returned + // ERROR_NO_MORE_ITEMS, then we have reached the end of the + // list. Othewise there was something wrong with this + // particular driver. + if(!ret) { + if(GetLastError() == ERROR_NO_MORE_ITEMS) + break; + else { + index++; + continue; + } + } + + pDriverInfoDetail = (PSP_DRVINFO_DETAIL_DATA) detailBuf; + pDriverInfoDetail->cbSize = sizeof(SP_DRVINFO_DETAIL_DATA); + + // if we successfully find the hardware ID and it turns out to + // be the one for the loopback driver, then we are done. + if(SetupDiGetDriverInfoDetail(hDeviceInfo, + &DeviceInfoData, + &DriverInfoData, + pDriverInfoDetail, + sizeof(detailBuf), + NULL) && + !_tcsicmp(pDriverInfoDetail->HardwareID, DRIVERHWID)) { + + found = TRUE; + break; + } + index++; } diff --git a/src/WINNT/install/loopback/loopbackutils.h b/src/WINNT/install/loopback/loopbackutils.h index 74b83fe..a627aca 100644 --- a/src/WINNT/install/loopback/loopbackutils.h +++ b/src/WINNT/install/loopback/loopbackutils.h @@ -41,6 +41,7 @@ void SetMsiReporter(LPCSTR strAction, LPCSTR strDesc, DWORD h); #define DRIVER_DESC "Microsoft Loopback Adapter" #define DRIVER _T("loopback") +#define DRIVERHWID _T("*msloop") #define MANUFACTURE _T("microsoft") #define DEFAULT_NAME _T("AFS") #define DEFAULT_IP _T("10.254.254.253") @@ -71,4 +72,4 @@ void SetMsiReporter(LPCSTR strAction, LPCSTR strDesc, DWORD h); #define REPORT_IGNORE 3 extern DWORD dwReporterType; -extern DWORD hMsiHandle; \ No newline at end of file +extern DWORD hMsiHandle;