HRESULT vboxUhgsmiKmtDestroy(PVBOXUHGSMI_PRIVATE_KMT pHgsmi) { HRESULT hr = vboxDispKmtDestroyContext(&pHgsmi->Context); Assert(hr == S_OK); if (hr == S_OK) { hr = vboxDispKmtDestroyDevice(&pHgsmi->Device); Assert(hr == S_OK); if (hr == S_OK) { hr = vboxDispKmtCloseAdapter(&pHgsmi->Adapter); Assert(hr == S_OK); if (hr == S_OK) { hr = vboxDispKmtCallbacksTerm(&pHgsmi->Callbacks); Assert(hr == S_OK); if (hr == S_OK) { #ifdef DEBUG_misha memset(pHgsmi, 0, sizeof (*pHgsmi)); #endif return S_OK; } } } } return hr; }
static PVBOXDISPMPLOGGER vboxDispMpLoggerGet() { if (ASMAtomicCmpXchgU32((volatile uint32_t *)&g_VBoxDispMpLogger.enmState, VBOXDISPMPLOGGER_STATE_INITIALIZING, VBOXDISPMPLOGGER_STATE_UNINITIALIZED)) { HRESULT hr = vboxDispKmtCallbacksInit(&g_VBoxDispMpLogger.KmtCallbacks); if (hr == S_OK) { /* we are on Vista+ * check if we can Open Adapter, i.e. WDDM driver is installed */ VBOXDISPKMT_ADAPTER Adapter; hr = vboxDispKmtOpenAdapter(&g_VBoxDispMpLogger.KmtCallbacks, &Adapter); if (hr == S_OK) { ASMAtomicWriteU32((volatile uint32_t *)&g_VBoxDispMpLogger.enmState, VBOXDISPMPLOGGER_STATE_INITIALIZED); vboxDispKmtCloseAdapter(&Adapter); return &g_VBoxDispMpLogger; } vboxDispKmtCallbacksTerm(&g_VBoxDispMpLogger.KmtCallbacks); } } else if (ASMAtomicReadU32((volatile uint32_t *)&g_VBoxDispMpLogger.enmState) == VBOXDISPMPLOGGER_STATE_INITIALIZED) { return &g_VBoxDispMpLogger; } return NULL; }
VBOXDISPMPLOGGER_DECL(int) VBoxDispMpLoggerTerm(void) { if (ASMAtomicCmpXchgU32((volatile uint32_t *)&g_VBoxDispMpLogger.enmState, VBOXDISPMPLOGGER_STATE_UNINITIALIZING, VBOXDISPMPLOGGER_STATE_INITIALIZED)) { vboxDispKmtCallbacksTerm(&g_VBoxDispMpLogger.KmtCallbacks); ASMAtomicWriteU32((volatile uint32_t *)&g_VBoxDispMpLogger.enmState, VBOXDISPMPLOGGER_STATE_UNINITIALIZED); return S_OK; } else if (ASMAtomicReadU32((volatile uint32_t *)&g_VBoxDispMpLogger.enmState) == VBOXDISPMPLOGGER_STATE_UNINITIALIZED) { return S_OK; } return VERR_NOT_SUPPORTED; }
static HRESULT vboxUhgsmiKmtEngineCreate(PVBOXUHGSMI_PRIVATE_KMT pHgsmi, BOOL bD3D) { HRESULT hr = vboxDispKmtCallbacksInit(&pHgsmi->Callbacks); if (hr == S_OK) { hr = vboxDispKmtOpenAdapter(&pHgsmi->Callbacks, &pHgsmi->Adapter); if (hr == S_OK) { hr = vboxDispKmtCreateDevice(&pHgsmi->Adapter, &pHgsmi->Device); if (hr == S_OK) { hr = vboxDispKmtCreateContext(&pHgsmi->Device, &pHgsmi->Context, bD3D ? VBOXWDDM_CONTEXT_TYPE_CUSTOM_UHGSMI_3D : VBOXWDDM_CONTEXT_TYPE_CUSTOM_UHGSMI_GL, CR_PROTOCOL_VERSION_MAJOR, CR_PROTOCOL_VERSION_MINOR, NULL, 0); if (hr == S_OK) { return S_OK; } else { WARN(("vboxDispKmtCreateContext failed, hr(0x%x)", hr)); } vboxDispKmtDestroyDevice(&pHgsmi->Device); } else { WARN(("vboxDispKmtCreateDevice failed, hr(0x%x)", hr)); } vboxDispKmtCloseAdapter(&pHgsmi->Adapter); } else { // WARN(("vboxDispKmtOpenAdapter failed, hr(0x%x)", hr)); } vboxDispKmtCallbacksTerm(&pHgsmi->Callbacks); } else { WARN(("vboxDispKmtCallbacksInit failed, hr(0x%x)", hr)); } return hr; }
VBOXCRHGSMI_DECL(int) VBoxCrHgsmiTerm() { #if 0 PVBOXUHGSMI_PRIVATE_KMT pHgsmiGL = gt_pHgsmiGL; if (pHgsmiGL) { g_VBoxCrHgsmiCallbacks.pfnClientDestroy(pHgsmiGL->BasePrivate.hClient); vboxUhgsmiKmtDestroy(pHgsmiGL); gt_pHgsmiGL = NULL; } if (g_pfnVBoxDispCrHgsmiTerm) g_pfnVBoxDispCrHgsmiTerm(); #endif if (g_bVBoxKmtCallbacksInited > 0) { vboxDispKmtCallbacksTerm(&g_VBoxCrHgsmiKmtCallbacks); } return VINF_SUCCESS; }
static int vboxCrHgsmiInitPerform(VBOXDISPKMT_CALLBACKS *pCallbacks) { HRESULT hr = vboxDispKmtCallbacksInit(pCallbacks); /*Assert(hr == S_OK);*/ if (hr == S_OK) { /* check if we can create the hgsmi */ PVBOXUHGSMI pHgsmi = VBoxCrHgsmiCreate(); if (pHgsmi) { /* yes, we can, so this is wddm mode */ VBoxCrHgsmiDestroy(pHgsmi); Log(("CrHgsmi: WDDM mode supported\n")); return 1; } vboxDispKmtCallbacksTerm(pCallbacks); } Log(("CrHgsmi: unsupported\n")); return -1; }
HRESULT vboxUhgsmiKmtDestroy(PVBOXUHGSMI_PRIVATE_KMT pHgsmi) { HRESULT hr = vboxDispKmtDestroyContext(&pHgsmi->Context); Assert(hr == S_OK); if (hr == S_OK) { hr = vboxDispKmtDestroyDevice(&pHgsmi->Device); Assert(hr == S_OK); if (hr == S_OK) { hr = vboxDispKmtCloseAdapter(&pHgsmi->Adapter); Assert(hr == S_OK); if (hr == S_OK) { hr = vboxDispKmtCallbacksTerm(&pHgsmi->Callbacks); Assert(hr == S_OK); if (hr == S_OK) return S_OK; } } } return hr; }