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;
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++;
}
#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")
#define REPORT_IGNORE 3
extern DWORD dwReporterType;
-extern DWORD hMsiHandle;
\ No newline at end of file
+extern DWORD hMsiHandle;