VirtualBox

Ignore:
Timestamp:
Jul 8, 2013 1:19:00 PM (11 years ago)
Author:
vboxsync
Message:

wddm: fix multimon issue

Location:
trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPMisc.cpp

    r46966 r47039  
    659659#define VBOXWDDM_REG_DISPLAYSETTINGSVIDEOKEY_SUBKEY L"\\Video"
    660660
    661 NTSTATUS vboxWddmRegQueryVideoGuidString(ULONG cbBuf, PWCHAR pBuf, PULONG pcbResult)
    662 {
    663     HANDLE hKey;
    664     NTSTATUS Status = vboxWddmRegOpenKey(&hKey, VBOXWDDM_REG_DISPLAYSETTINGSVIDEOKEY, GENERIC_READ);
     661NTSTATUS vboxWddmRegQueryVideoGuidString(PVBOXMP_DEVEXT pDevExt, ULONG cbBuf, PWCHAR pBuf, PULONG pcbResult)
     662{
     663    BOOLEAN fNewMethodSucceeded = FALSE;
     664    HANDLE hKey = NULL;
     665    NTSTATUS Status = IoOpenDeviceRegistryKey(pDevExt->pPDO, PLUGPLAY_REGKEY_DEVICE, GENERIC_READ, &hKey);
     666    if (NT_SUCCESS(Status))
     667    {
     668        struct
     669        {
     670            KEY_VALUE_PARTIAL_INFORMATION Info;
     671            UCHAR Buf[1024]; /* should be enough */
     672        } KeyData;
     673        ULONG cbResult;
     674        UNICODE_STRING RtlStr;
     675        RtlInitUnicodeString(&RtlStr, L"VideoID");
     676        Status = ZwQueryValueKey(hKey,
     677                    &RtlStr,
     678                    KeyValuePartialInformation,
     679                    &KeyData.Info,
     680                    sizeof(KeyData),
     681                    &cbResult);
     682        if (NT_SUCCESS(Status))
     683        {
     684            if (KeyData.Info.Type == REG_SZ)
     685            {
     686                fNewMethodSucceeded = TRUE;
     687                *pcbResult = KeyData.Info.DataLength + 2;
     688                if (cbBuf >= KeyData.Info.DataLength)
     689                {
     690                    memcpy(pBuf, KeyData.Info.Data, KeyData.Info.DataLength + 2);
     691                    Status = STATUS_SUCCESS;
     692                }
     693                else
     694                    Status = STATUS_BUFFER_TOO_SMALL;
     695            }
     696        }
     697        else
     698        {
     699            WARN(("ZwQueryValueKey failed, Status 0x%x", Status));
     700        }
     701
     702        NTSTATUS tmpStatus = ZwClose(hKey);
     703        Assert(tmpStatus == STATUS_SUCCESS);
     704    }
     705    else
     706    {
     707        WARN(("IoOpenDeviceRegistryKey failed Status 0x%x", Status));
     708    }
     709
     710    if (fNewMethodSucceeded)
     711        return Status;
     712    else
     713        WARN(("failed to acquire the VideoID, falling back to the old impl"));
     714
     715    Status = vboxWddmRegOpenKey(&hKey, VBOXWDDM_REG_DISPLAYSETTINGSVIDEOKEY, GENERIC_READ);
    665716    Assert(Status == STATUS_SUCCESS);
    666717    if (Status == STATUS_SUCCESS)
     
    744795}
    745796
    746 NTSTATUS vboxWddmRegOpenKey(OUT PHANDLE phKey, IN PWCHAR pName, IN ACCESS_MASK fAccess)
     797NTSTATUS vboxWddmRegOpenKeyEx(OUT PHANDLE phKey, IN HANDLE hRootKey, IN PWCHAR pName, IN ACCESS_MASK fAccess)
    747798{
    748799    OBJECT_ATTRIBUTES ObjAttr;
     
    750801
    751802    RtlInitUnicodeString(&RtlStr, pName);
    752     InitializeObjectAttributes(&ObjAttr, &RtlStr, OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, NULL, NULL);
     803    InitializeObjectAttributes(&ObjAttr, &RtlStr, OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, hRootKey, NULL);
    753804
    754805    return ZwOpenKey(phKey, fAccess, &ObjAttr);
     806}
     807
     808NTSTATUS vboxWddmRegOpenKey(OUT PHANDLE phKey, IN PWCHAR pName, IN ACCESS_MASK fAccess)
     809{
     810    return vboxWddmRegOpenKeyEx(phKey, NULL, pName, fAccess);
    755811}
    756812
     
    878934    WCHAR VideoGuidBuf[512];
    879935    ULONG cbVideoGuidBuf = sizeof (VideoGuidBuf);
    880     NTSTATUS Status = vboxWddmRegQueryVideoGuidString(cbVideoGuidBuf, VideoGuidBuf, &cbVideoGuidBuf);
     936    NTSTATUS Status = vboxWddmRegQueryVideoGuidString(pDevExt ,cbVideoGuidBuf, VideoGuidBuf, &cbVideoGuidBuf);
    881937    Assert(Status == STATUS_SUCCESS);
    882938    if (Status == STATUS_SUCCESS)
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPMisc.h

    r46757 r47039  
    9191NTSTATUS vboxWddmRegDisplaySettingsQueryRelY(HANDLE hKey, int * pResult);
    9292NTSTATUS vboxWddmDisplaySettingsQueryPos(IN PVBOXMP_DEVEXT pDeviceExtension, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId, POINT * pPos);
    93 NTSTATUS vboxWddmRegQueryVideoGuidString(ULONG cbBuf, PWCHAR pBuf, PULONG pcbResult);
     93NTSTATUS vboxWddmRegQueryVideoGuidString(PVBOXMP_DEVEXT pDevExt, ULONG cbBuf, PWCHAR pBuf, PULONG pcbResult);
    9494
    9595NTSTATUS vboxWddmRegQueryDrvKeyName(PVBOXMP_DEVEXT pDevExt, ULONG cbBuf, PWCHAR pBuf, PULONG pcbResult);
    9696
     97NTSTATUS vboxWddmRegOpenKeyEx(OUT PHANDLE phKey, IN HANDLE hRootKey, IN PWCHAR pName, IN ACCESS_MASK fAccess);
    9798NTSTATUS vboxWddmRegOpenKey(OUT PHANDLE phKey, IN PWCHAR pName, IN ACCESS_MASK fAccess);
    9899NTSTATUS vboxWddmRegQueryValueDword(IN HANDLE hKey, IN PWCHAR pName, OUT PDWORD pDword);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette