Changeset 105495 in vbox
- Timestamp:
- Jul 24, 2024 6:35:43 PM (4 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceDisplayConfig.cpp
r105015 r105495 31 31 #include "VBoxServiceUtils.h" 32 32 33 #undef NTDDI_VERSION 34 #define NTDDI_VERSION NTDDI_LONGHORN 35 #include <iprt/win/d3dkmthk.h> 36 37 #define VBOX_WITH_WDDM 38 #include <VBoxDisplay.h> 39 33 40 34 41 /********************************************************************************************************************************* … … 36 43 *********************************************************************************************************************************/ 37 44 45 static PFND3DKMT_ENUMADAPTERS g_pfnD3DKMTEnumAdapters; 46 static PFND3DKMT_OPENADAPTERFROMLUID g_pfnD3DKMTOpenAdapterFromLuid; 47 static PFND3DKMT_CLOSEADAPTER g_pfnD3DKMTCloseAdapter; 48 static PFND3DKMT_ESCAPE g_pfnD3DKMTEscape; 49 38 50 /** 39 51 * @interface_method_impl{VBOXSERVICE,pfnInit} … … 41 53 static DECLCALLBACK(int) vgsvcDisplayConfigInit(void) 42 54 { 55 RTLDRMOD hLdrMod; 56 int rc = RTLdrLoadSystem("gdi32.dll", true /*fNoUnload*/, &hLdrMod); 57 if (RT_SUCCESS(rc)) 58 { 59 rc = RTLdrGetSymbol(hLdrMod, "D3DKMTEnumAdapters", (void **)&g_pfnD3DKMTEnumAdapters); 60 if (RT_SUCCESS(rc)) 61 rc = RTLdrGetSymbol(hLdrMod, "D3DKMTOpenAdapterFromLuid", (void **)&g_pfnD3DKMTOpenAdapterFromLuid); 62 if (RT_SUCCESS(rc)) 63 rc = RTLdrGetSymbol(hLdrMod, "D3DKMTCloseAdapter", (void **)&g_pfnD3DKMTCloseAdapter); 64 if (RT_SUCCESS(rc)) 65 rc = RTLdrGetSymbol(hLdrMod, "D3DKMTEscape", (void **)&g_pfnD3DKMTEscape); 66 AssertRC(rc); 67 RTLdrClose(hLdrMod); 68 } 69 70 VGSvcVerbose(2, "DXGK d3dkmthk callbacks are %s\n", RT_SUCCESS(rc) ? "Ok" : "Fail"); 71 43 72 return VINF_SUCCESS; 73 } 74 75 void ReplugDisplays(uint32_t cDisplays, VMMDevDisplayDef *paDisplays) 76 { 77 RT_NOREF2(cDisplays, paDisplays); 78 D3DKMT_HANDLE hAdapter; 79 D3DKMT_ENUMADAPTERS EnumAdapters = {0}; 80 NTSTATUS rcNt; 81 ULONG id = 0; 82 83 EnumAdapters.NumAdapters = RT_ELEMENTS(EnumAdapters.Adapters); 84 rcNt = g_pfnD3DKMTEnumAdapters(&EnumAdapters); 85 86 VGSvcVerbose(2, "D3DKMTEnumAdapters rcNt=%#x NumAdapters=%d\n", rcNt, EnumAdapters.NumAdapters); 87 88 for(id = 0; id < EnumAdapters.NumAdapters; id++) 89 { 90 D3DKMT_ADAPTERINFO *pAdapterInfo = &EnumAdapters.Adapters[id]; 91 VGSvcVerbose(2, "#%d: NumOfSources=%d hAdapter=0x%p Luid(%u, %u)\n", id, 92 pAdapterInfo->NumOfSources, pAdapterInfo->hAdapter, pAdapterInfo->AdapterLuid.HighPart, pAdapterInfo->AdapterLuid.LowPart); 93 } 94 95 D3DKMT_OPENADAPTERFROMLUID OpenAdapterData; 96 RT_ZERO(OpenAdapterData); 97 OpenAdapterData.AdapterLuid = EnumAdapters.Adapters[0].AdapterLuid; 98 rcNt = g_pfnD3DKMTOpenAdapterFromLuid(&OpenAdapterData); 99 VGSvcVerbose(2, "D3DKMTOpenAdapterFromLuid rcNt=%#x hAdapter=0x%p\n", rcNt, OpenAdapterData.hAdapter); 100 101 hAdapter = OpenAdapterData.hAdapter; 102 103 if (hAdapter) 104 { 105 VBOXDISPIFESCAPE EscapeHdr = {0}; 106 EscapeHdr.escapeCode = VBOXESC_CONFIGURETARGETS; 107 EscapeHdr.u32CmdSpecific = 0; 108 109 D3DKMT_ESCAPE EscapeData = {0}; 110 EscapeData.hAdapter = hAdapter; 111 EscapeData.Type = D3DKMT_ESCAPE_DRIVERPRIVATE; 112 EscapeData.Flags.HardwareAccess = 1; 113 EscapeData.pPrivateDriverData = &EscapeHdr; 114 EscapeData.PrivateDriverDataSize = sizeof (EscapeHdr); 115 116 rcNt = g_pfnD3DKMTEscape(&EscapeData); 117 VGSvcVerbose(2, "D3DKMTEscape rcNt=%#x\n", rcNt); 118 119 D3DKMT_CLOSEADAPTER CloseAdapter; 120 CloseAdapter.hAdapter = hAdapter; 121 122 rcNt = g_pfnD3DKMTCloseAdapter(&CloseAdapter); 123 VGSvcVerbose(2, "D3DKMTCloseAdapter rcNt=%#x\n", rcNt); 124 } 44 125 } 45 126 … … 81 162 if (cDisplays > 0) 82 163 { 164 ReplugDisplays(cDisplays, &aDisplays[0]); 83 165 VGSvcVerbose(2, "Display[0] (%dx%d)\n", aDisplays[0].cx, aDisplays[0].cy); 84 166 }
Note:
See TracChangeset
for help on using the changeset viewer.