0

現在、x64 用と x86 用の 2 つのスタンドアロン インストーラーを介して再配布されている UMDF ドライバーがあります。

インストール ドライバー関数は、devcon からコピーされた次の関数です。

bool InstallDriver(const TCHAR* InfPath, const wchar_t* TargetID)
{
#define MAX_CLASS_NAME_LEN    32
    GUID ClassGUID = {};
    TCHAR ClassName[MAX_CLASS_NAME_LEN] = {};
    TCHAR hwIdList[LINE_LEN + 4] = {};

    //
    // List of hardware ID's must be double zero-terminated
    //
    ZeroMemory(hwIdList, sizeof(hwIdList));
    if (FAILED(StringCchCopy(hwIdList, LINE_LEN, TargetID)))
    {
        return false;
    }


//
// Use the INF File to extract the Class GUID.
//
    if (!SetupDiGetINFClass(InfPath, &ClassGUID, ClassName, sizeof(ClassName) / sizeof(ClassName[0]), 0))
    {
        return false;
    }
//
// Create the container for the to-be-created Device Information Element.
//
    HDEVINFO DeviceInfoSet = INVALID_HANDLE_VALUE;
    DeviceInfoSet = SetupDiCreateDeviceInfoList(&ClassGUID, 0);
    if (DeviceInfoSet == INVALID_HANDLE_VALUE)
    {
        return false;
    }


//
// Now create the element.
// Use the Class GUID and Name from the INF file.
//
    SP_DEVINFO_DATA DeviceInfoData;
    DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
    if (!SetupDiCreateDeviceInfo(DeviceInfoSet,
        ClassName,
        &ClassGUID,
        NULL,
        0,
        DICD_GENERATE_ID,
        &DeviceInfoData))
    {
        SetupDiDestroyDeviceInfoList(DeviceInfoSet);
        return false;
    }

//
// Add the HardwareID to the Device's HardwareID property.
//
    if (!SetupDiSetDeviceRegistryProperty(DeviceInfoSet,
        &DeviceInfoData,
        SPDRP_HARDWAREID,
        (LPBYTE)hwIdList,
        (lstrlen(hwIdList) + 1 + 1) * sizeof(TCHAR)))
    {
        SetupDiDestroyDeviceInfoList(DeviceInfoSet);
        return false;
    }

//
// Transform the registry element into an actual devnode
// in the PnP HW tree.
//
    if (!SetupDiCallClassInstaller(DIF_REGISTERDEVICE,
        DeviceInfoSet,
        &DeviceInfoData))
    {
        SetupDiDestroyDeviceInfoList(DeviceInfoSet);
        return false;
    }

//
// update the driver for the device we just created
//
    if (!UpdateDriverForPlugAndPlayDevices(0, TargetID, InfPath, INSTALLFLAG_FORCE, 0))
    {
        int y = GetLastError();
        if (y == ERROR_IN_WOW64 || y == ERROR_NO_SUCH_DEVINST || y == ERROR_NO_SUCH_DEVINST || y == ERROR_FILE_NOT_FOUND)
        {

        }
        SetupDiDestroyDeviceInfoList(DeviceInfoSet);
        return false;
    }


    SetupDiDestroyDeviceInfoList(DeviceInfoSet);
    return true;
}

これは問題なく動作しますが、x86 ドライバーと x64 ドライバーの両方を含み、WOW64 で実行されているかどうかを検出して x64 ドライバーをインストールする単一の x86 再頒布可能パッケージが必要です。

今回はInstallDriver、この呼び出しで関数が失敗します。

if (!SetupDiCallClassInstaller(DIF_REGISTERDEVICE,
    DeviceInfoSet,
    &DeviceInfoData))
{
    SetupDiDestroyDeviceInfoList(DeviceInfoSet);
    return false;
}

最後のエラー 3758096949。

そのエラーに関する詳細情報を見つけることができませんでした。さらに、RegCreateKeyEx の KEY_WOW64_64KEY フラグのように、レジストリを x64 に設定するためのヒントがSetupDiSetDeviceRegistryPropertyに表示されませんでした。

2つの実行可能ファイルを回避する方法はありますか?

4

0 に答える 0