VirtualBox

Ignore:
Timestamp:
Sep 22, 2010 8:40:24 AM (14 years ago)
Author:
vboxsync
Message:

VBoxTray: Applied refined patch for NT4 resizing/graphics capabilities from #5232c20.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxSeamless.cpp

    r32249 r32687  
    55
    66/*
    7  * Copyright (C) 2006-2007 Oracle Corporation
     7 * Copyright (C) 2006-2010 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2323#include <VBox/VMMDev.h>
    2424#include <iprt/assert.h>
     25#include <VBoxGuestInternal.h>
    2526#include "helpers.h"
    2627
     
    6162    GetVersionEx (&OSinfo);
    6263
     64    int rc = VINF_SUCCESS;
     65
    6366    /* We have to jump out here when using NT4, otherwise it complains about
    6467       a missing API function "UnhookWinEvent" used by the dynamically loaded VBoxHook.dll below */
     
    6669    {
    6770        Log(("VBoxTray: VBoxSeamlessInit: Windows NT 4.0 or older not supported!\n"));
    68         return VERR_NOT_SUPPORTED;
    69     }
    70 
    71     /* Will fail if SetWinEventHook is not present (version < NT4 SP6 apparently) */
    72     gCtx.hModule = LoadLibrary(VBOXHOOK_DLL_NAME);
    73     if (gCtx.hModule)
    74     {
    75         *(uintptr_t *)&gCtx.pfnVBoxInstallHook = (uintptr_t)GetProcAddress(gCtx.hModule, "VBoxInstallHook");
    76         *(uintptr_t *)&gCtx.pfnVBoxRemoveHook  = (uintptr_t)GetProcAddress(gCtx.hModule, "VBoxRemoveHook");
    77 
    78         /* inform the host that we support the seamless window mode */
    79         VMMDevReqGuestCapabilities vmmreqGuestCaps = {0};
    80         vmmdevInitRequest((VMMDevRequestHeader*)&vmmreqGuestCaps, VMMDevReq_ReportGuestCapabilities);
    81         vmmreqGuestCaps.caps = VMMDEV_GUEST_SUPPORTS_SEAMLESS;
    82 
    83         DWORD cbReturned;
    84         if (!DeviceIoControl(pEnv->hDriver, VBOXGUEST_IOCTL_VMMREQUEST(sizeof(vmmreqGuestCaps)), &vmmreqGuestCaps, sizeof(vmmreqGuestCaps),
    85                              &vmmreqGuestCaps, sizeof(vmmreqGuestCaps), &cbReturned, NULL))
    86         {
    87             Log(("VBoxTray: VBoxSeamlessInit: VMMDevReq_ReportGuestCapabilities: error doing IOCTL, last error: %d\n", GetLastError()));
    88             return VERR_INVALID_PARAMETER;
    89         }
    90 
    91         *pfStartThread = true;
    92         *ppInstance = &gCtx;
    93         return VINF_SUCCESS;
     71        rc = VERR_NOT_SUPPORTED;
    9472    }
    9573    else
    9674    {
    97         Log(("VBoxTray: VBoxSeamlessInit: LoadLibrary failed with %d\n", GetLastError()));
    98         return VERR_INVALID_PARAMETER;
    99     }
    100 
    101     return VINF_SUCCESS;
     75        /* Will fail if SetWinEventHook is not present (version < NT4 SP6 apparently) */
     76        gCtx.hModule = LoadLibrary(VBOXHOOK_DLL_NAME);
     77        if (gCtx.hModule)
     78        {
     79            *(uintptr_t *)&gCtx.pfnVBoxInstallHook = (uintptr_t)GetProcAddress(gCtx.hModule, "VBoxInstallHook");
     80            *(uintptr_t *)&gCtx.pfnVBoxRemoveHook  = (uintptr_t)GetProcAddress(gCtx.hModule, "VBoxRemoveHook");
     81
     82            /* Inform the host that we support the seamless window mode. */
     83            rc = VbglR3SetGuestCaps(VMMDEV_GUEST_SUPPORTS_SEAMLESS, 0);
     84            if (RT_SUCCESS(rc))
     85            {
     86                *pfStartThread = true;
     87                *ppInstance = &gCtx;
     88            }
     89            else
     90                Log(("VBoxTray: VBoxSeamlessInit: Failed to set seamless capability\n"));
     91        }
     92        else
     93        {
     94            rc = RTErrConvertFromWin32(GetLastError());
     95            Log(("VBoxTray: VBoxSeamlessInit: LoadLibrary of \"%s\" failed with rc=%Rrc\n", VBOXHOOK_DLL_NAME, rc));
     96        }
     97    }
     98
     99    return rc;
    102100}
    103101
     
    106104{
    107105    Log(("VBoxTray: VBoxSeamlessDestroy\n"));
    108     /* inform the host that we no longer support the seamless window mode */
    109     VMMDevReqGuestCapabilities vmmreqGuestCaps = {0};
    110     vmmdevInitRequest((VMMDevRequestHeader*)&vmmreqGuestCaps, VMMDevReq_ReportGuestCapabilities);
    111     vmmreqGuestCaps.caps = 0;
    112 
    113     DWORD cbReturned;
    114     if (!DeviceIoControl(pEnv->hDriver, VBOXGUEST_IOCTL_VMMREQUEST(sizeof(vmmreqGuestCaps)), &vmmreqGuestCaps, sizeof(vmmreqGuestCaps),
    115                          &vmmreqGuestCaps, sizeof(vmmreqGuestCaps), &cbReturned, NULL))
    116     {
    117         Log(("VBoxTray: VMMDevReq_ReportGuestCapabilities: error doing IOCTL, last error: %d\n", GetLastError()));
    118     }
     106
     107    /* Inform the host that we no longer support the seamless window mode. */
     108    int rc = VbglR3SetGuestCaps(0, VMMDEV_GUEST_SUPPORTS_SEAMLESS);
     109    if (RT_FAILURE(rc))
     110        Log(("VBoxTray: VBoxSeamlessDestroy: Failed to unset seamless capability, rc=%Rrc\n", rc));
    119111
    120112    if (gCtx.pfnVBoxRemoveHook)
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