古いバージョンの Renesas USB 3.0 Host Controller には、問題を引き起こす可能性のある問題があります。このような問題を顧客に警告するには、古いバージョンを検出する必要があります。これを行うには、Renesas USB 3.0 Host Controller Utility と同じように、実行中のドライバーのバージョンを取得したいと考えています。
質問する
502 次
1 に答える
0
OSR IrpTracker を使用して、IOCTL と構造を決定しました。各 Renesas USB Host Controller のデバイス インターフェイスを開き、バージョン番号を問い合わせるサンプル コードを次に示します。
#include <initguid.h>
#include <windows.h>
#include <setupapi.h>
#include <stdlib.h>
#include <winioctl.h>
#include <pshpack1.h>
DEFINE_GUID(GUID_DEVINTERFACE_NUSB3XHC, 0xac051b02L, 0x603b, 0x4b3c, 0xb1, 0x4b, 0x95, 0xc9, 0x26, 0x8d, 0xe0, 0x81);
struct NUSB3XHC_DRIVER_VERSION
{
UCHAR Major;
UCHAR Minor;
UCHAR Build;
UCHAR Revision;
UCHAR Unknown[2]; // no idea what this is -- {0, 0} on my machine
};
struct NUSB3XHC_FIRMWARE_VERSION
{
USHORT BcdVersion; // UI displays this as BCD
};
#define IOCTL_NUSB3XHC_GET_DRIVER_VERSION CTL_CODE(FILE_DEVICE_UNKNOWN, 0x800, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_NUSB3XHC_GET_FIRMWARE_VERSION CTL_CODE(FILE_DEVICE_UNKNOWN, 0x808, METHOD_BUFFERED, FILE_ANY_ACCESS)
#include <poppack.h>
BOOL GetVersion(LPCTSTR DevicePath, NUSB3XHC_DRIVER_VERSION* DriverVersion, NUSB3XHC_FIRMWARE_VERSION* FirmwareVersion)
{
HANDLE hDevice = CreateFile(DevicePath, GENERIC_ALL, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hDevice == NULL)
return FALSE;
BOOL success = FALSE;
DWORD returned;
if (DeviceIoControl(hDevice, IOCTL_NUSB3XHC_GET_DRIVER_VERSION, NULL, 0, DriverVersion, sizeof(NUSB3XHC_DRIVER_VERSION), &returned, NULL))
{
success = (returned == sizeof(NUSB3XHC_DRIVER_VERSION));
}
if (DeviceIoControl(hDevice, IOCTL_NUSB3XHC_GET_FIRMWARE_VERSION, NULL, 0, FirmwareVersion, sizeof(NUSB3XHC_FIRMWARE_VERSION), &returned, NULL))
{
success = success && (returned == sizeof(NUSB3XHC_FIRMWARE_VERSION));
}
CloseHandle(hDevice);
return success;
}
int _tmain(int argc, _TCHAR* argv[])
{
int crap = IOCTL_NUSB3XHC_GET_FIRMWARE_VERSION;
HDEVINFO hDevInfo = SetupDiGetClassDevs(&GUID_DEVINTERFACE_NUSB3XHC, NULL, NULL, DIGCF_DEVICEINTERFACE | DIGCF_PRESENT);
if (hDevInfo != INVALID_HANDLE_VALUE)
{
SP_DEVICE_INTERFACE_DATA devIfaceData;
devIfaceData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
DWORD Index = 0;
do
{
if (!SetupDiEnumDeviceInterfaces(hDevInfo, NULL, &GUID_DEVINTERFACE_NUSB3XHC, Index, &devIfaceData))
break; // hopefully ERROR_NO_MORE_ITEMS
DWORD requiredSize;
SetupDiGetDeviceInterfaceDetail(hDevInfo, &devIfaceData, NULL, NULL, &requiredSize, NULL);
// returns with ERROR_INSUFFICIENT_BUFFER
PSP_DEVICE_INTERFACE_DETAIL_DATA devIfaceDetailData =
(PSP_DEVICE_INTERFACE_DETAIL_DATA) malloc(requiredSize);
devIfaceDetailData->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
if (SetupDiGetDeviceInterfaceDetail(hDevInfo, &devIfaceData, devIfaceDetailData, requiredSize, NULL, NULL))
{
NUSB3XHC_DRIVER_VERSION driverVersion;
NUSB3XHC_FIRMWARE_VERSION firmwareVersion;
if (GetVersion(devIfaceDetailData->DevicePath, &driverVersion, &firmwareVersion))
{
_tprintf(_T("%s: driver version: %d.%d.%d.%d, firmware version: %x\n"), devIfaceDetailData->DevicePath,
driverVersion.Major,
driverVersion.Minor,
driverVersion.Build,
driverVersion.Revision,
firmwareVersion.BcdVersion);
}
else
{
_tprintf(_T("Failed getting version data from %s.\n"), devIfaceDetailData->DevicePath);
}
}
free(devIfaceDetailData);
++Index;
}
while(1);
}
return 0;
}
于 2012-11-27T20:31:42.070 に答える