Changeset 33931 in vbox
- Timestamp:
- Nov 10, 2010 10:22:24 AM (14 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxUhgsmiKmt.cpp
r33929 r33931 637 637 } 638 638 639 ReleaseDC(NULL,OpenAdapterData.hDc);639 DeleteDC(OpenAdapterData.hDc); 640 640 } 641 641 … … 651 651 if (!Status) 652 652 { 653 ReleaseDC(NULL,pAdapter->hDc);653 DeleteDC(pAdapter->hDc); 654 654 return S_OK; 655 655 } -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDispIf.cpp
r33929 r33931 107 107 } 108 108 109 typedef DECLCALLBACK(BOOLEAN) FNVBOXDISPIFWDDM_ADAPTEROP(PCVBOXDISPIF pIf, D3DKMT_HANDLE hAdapter, LPCWSTR pDevName, PVOID pContext); 109 static DWORD vboxDispIfWDDMAdpHdcCreate(int iDisplay, HDC *phDc, DISPLAY_DEVICE *pDev) 110 { 111 DWORD winEr = ERROR_INVALID_STATE; 112 memset(pDev, 0, sizeof (*pDev)); 113 pDev->cb = sizeof (*pDev); 114 115 for (int i = 0; ; ++i) 116 { 117 if (EnumDisplayDevices(NULL, /* LPCTSTR lpDevice */ i, /* DWORD iDevNum */ 118 pDev, 0 /* DWORD dwFlags*/)) 119 { 120 if (i == iDisplay || (iDisplay < 0 && pDev->StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)) 121 { 122 HDC hDc = CreateDC(NULL, pDev->DeviceName, NULL, NULL); 123 if (hDc) 124 { 125 *phDc = hDc; 126 return NO_ERROR; 127 } 128 else 129 { 130 winEr = GetLastError(); 131 Assert(0); 132 break; 133 } 134 } 135 } 136 else 137 { 138 winEr = GetLastError(); 139 Assert(0); 140 break; 141 } 142 } 143 144 return winEr; 145 } 146 147 148 typedef DECLCALLBACK(BOOLEAN) FNVBOXDISPIFWDDM_ADAPTEROP(PCVBOXDISPIF pIf, D3DKMT_HANDLE hAdapter, DISPLAY_DEVICE *pDev, PVOID pContext); 110 149 typedef FNVBOXDISPIFWDDM_ADAPTEROP *PFNVBOXDISPIFWDDM_ADAPTEROP; 111 static DWORD vboxDispIfWDDMAdapterOp(PCVBOXDISPIF pIf, LPCWSTR pDevName, PFNVBOXDISPIFWDDM_ADAPTEROP pfnOp, PVOID pContext) 112 { 113 D3DKMT_OPENADAPTERFROMGDIDISPLAYNAME OpenAdapterData = {0}; 114 wcsncpy(OpenAdapterData.DeviceName, pDevName, RT_ELEMENTS(OpenAdapterData.DeviceName) - 1 /* the last one is always \0 */); 115 DWORD err = NO_ERROR; 116 NTSTATUS Status = pIf->modeData.wddm.pfnD3DKMTOpenAdapterFromGdiDisplayName(&OpenAdapterData); 117 Assert(!Status); 118 if (!Status) 119 { 120 BOOLEAN bCloseAdapter = pfnOp(pIf, OpenAdapterData.hAdapter, OpenAdapterData.DeviceName, pContext); 121 122 if (bCloseAdapter) 123 { 124 D3DKMT_CLOSEADAPTER ClosaAdapterData = {0}; 125 ClosaAdapterData.hAdapter = OpenAdapterData.hAdapter; 126 Status = pIf->modeData.wddm.pfnD3DKMTCloseAdapter(&ClosaAdapterData); 127 if (Status) 128 { 129 Log((__FUNCTION__": pfnD3DKMTCloseAdapter failed, Status (0x%x)\n", Status)); 130 /* ignore */ 131 Status = 0; 132 } 133 } 134 } 135 else 136 { 137 Log((__FUNCTION__": pfnD3DKMTOpenAdapterFromGdiDisplayName failed, Status (0x%x)\n", Status)); 138 err = ERROR_GEN_FAILURE; 150 static DWORD vboxDispIfWDDMAdapterOp(PCVBOXDISPIF pIf, int iDisplay, PFNVBOXDISPIFWDDM_ADAPTEROP pfnOp, PVOID pContext) 151 { 152 D3DKMT_OPENADAPTERFROMHDC OpenAdapterData = {0}; 153 DISPLAY_DEVICE DDev; 154 DWORD err = vboxDispIfWDDMAdpHdcCreate(iDisplay, &OpenAdapterData.hDc, &DDev); 155 Assert(err == NO_ERROR); 156 if (err == NO_ERROR) 157 { 158 NTSTATUS Status = pIf->modeData.wddm.pfnD3DKMTOpenAdapterFromHdc(&OpenAdapterData); 159 Assert(!Status); 160 if (!Status) 161 { 162 BOOLEAN bCloseAdapter = pfnOp(pIf, OpenAdapterData.hAdapter, &DDev, pContext); 163 164 if (bCloseAdapter) 165 { 166 D3DKMT_CLOSEADAPTER ClosaAdapterData = {0}; 167 ClosaAdapterData.hAdapter = OpenAdapterData.hAdapter; 168 Status = pIf->modeData.wddm.pfnD3DKMTCloseAdapter(&ClosaAdapterData); 169 if (Status) 170 { 171 Log((__FUNCTION__": pfnD3DKMTCloseAdapter failed, Status (0x%x)\n", Status)); 172 } 173 } 174 } 175 else 176 { 177 Log((__FUNCTION__": pfnD3DKMTOpenAdapterFromGdiDisplayName failed, Status (0x%x)\n", Status)); 178 err = ERROR_GEN_FAILURE; 179 } 180 181 DeleteDC(OpenAdapterData.hDc); 139 182 } 140 183 … … 149 192 } VBOXDISPIFWDDM_ESCAPEOP_CONTEXT, *PVBOXDISPIFWDDM_ESCAPEOP_CONTEXT; 150 193 151 DECLCALLBACK(BOOLEAN) vboxDispIfEscapeWDDMOp(PCVBOXDISPIF pIf, D3DKMT_HANDLE hAdapter, LPCWSTR pDevName, PVOID pContext)194 DECLCALLBACK(BOOLEAN) vboxDispIfEscapeWDDMOp(PCVBOXDISPIF pIf, D3DKMT_HANDLE hAdapter, DISPLAY_DEVICE *pDev, PVOID pContext) 152 195 { 153 196 PVBOXDISPIFWDDM_ESCAPEOP_CONTEXT pCtx = (PVBOXDISPIFWDDM_ESCAPEOP_CONTEXT)pContext; … … 172 215 Ctx.pEscape = pEscape; 173 216 Ctx.cbData = cbData; 174 DWORD err = vboxDispIfWDDMAdapterOp(pIf, L"\\\\.\\DISPLAY1", vboxDispIfEscapeWDDMOp, &Ctx);217 DWORD err = vboxDispIfWDDMAdapterOp(pIf, -1 /* iDisplay, -1 means primary */, vboxDispIfEscapeWDDMOp, &Ctx); 175 218 if (err == NO_ERROR) 176 219 { … … 198 241 } VBOXDISPIFWDDM_RESIZEOP_CONTEXT, *PVBOXDISPIFWDDM_RESIZEOP_CONTEXT; 199 242 200 DECLCALLBACK(BOOLEAN) vboxDispIfResizeWDDMOp(PCVBOXDISPIF pIf, D3DKMT_HANDLE hAdapter, LPCWSTR pDevName, PVOID pContext)243 DECLCALLBACK(BOOLEAN) vboxDispIfResizeWDDMOp(PCVBOXDISPIF pIf, D3DKMT_HANDLE hAdapter, DISPLAY_DEVICE *pDev, PVOID pContext) 201 244 { 202 245 PVBOXDISPIFWDDM_RESIZEOP_CONTEXT pCtx = (PVBOXDISPIFWDDM_RESIZEOP_CONTEXT)pContext; … … 237 280 Ctx.Info.Height = Height; 238 281 Ctx.Info.BitsPerPixel = BitsPerPixel; 239 DWORD err = vboxDispIfWDDMAdapterOp(pIf, L"\\\\.\\DISPLAY1", vboxDispIfResizeWDDMOp, &Ctx);282 DWORD err = vboxDispIfWDDMAdapterOp(pIf, (int)Id, vboxDispIfResizeWDDMOp, &Ctx); 240 283 if (err == NO_ERROR) 241 284 {
Note:
See TracChangeset
for help on using the changeset viewer.