VBoxTray.cpp revision b357df727b216b85d4517efecf466a7b14c2e80c
b63da7c87ee97d237d799dc5d275a70a546b5588vboxsync * VBoxTray - Guest Additions Tray Application
b63da7c87ee97d237d799dc5d275a70a546b5588vboxsync * Copyright (C) 2006-2007 Sun Microsystems, Inc.
b63da7c87ee97d237d799dc5d275a70a546b5588vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
b63da7c87ee97d237d799dc5d275a70a546b5588vboxsync * available from http://www.virtualbox.org. This file is free software;
b63da7c87ee97d237d799dc5d275a70a546b5588vboxsync * you can redistribute it and/or modify it under the terms of the GNU
b63da7c87ee97d237d799dc5d275a70a546b5588vboxsync * General Public License (GPL) as published by the Free Software
b63da7c87ee97d237d799dc5d275a70a546b5588vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
b63da7c87ee97d237d799dc5d275a70a546b5588vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
b63da7c87ee97d237d799dc5d275a70a546b5588vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
b63da7c87ee97d237d799dc5d275a70a546b5588vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
b63da7c87ee97d237d799dc5d275a70a546b5588vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
b63da7c87ee97d237d799dc5d275a70a546b5588vboxsync * additional information or have any questions.
b63da7c87ee97d237d799dc5d275a70a546b5588vboxsync/* global variables */
b63da7c87ee97d237d799dc5d275a70a546b5588vboxsync/* prototypes */
b63da7c87ee97d237d799dc5d275a70a546b5588vboxsyncLRESULT CALLBACK VBoxToolWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
b63da7c87ee97d237d799dc5d275a70a546b5588vboxsync * Helper function to send a message to WinDbg
b63da7c87ee97d237d799dc5d275a70a546b5588vboxsync * @param String message string
b63da7c87ee97d237d799dc5d275a70a546b5588vboxsync VMMDevReqLogString *pReq = (VMMDevReqLogString *)Buffer;
b63da7c87ee97d237d799dc5d275a70a546b5588vboxsync vmmdevInitRequest(&pReq->header, VMMDevReq_LogString);
b63da7c87ee97d237d799dc5d275a70a546b5588vboxsync RTStrPrintfV(pReq->szString, sizeof(Buffer)-sizeof(*pReq), String, va);
b63da7c87ee97d237d799dc5d275a70a546b5588vboxsync /* Does maybe not work on Vista (write protection when starting without admin rights),
b63da7c87ee97d237d799dc5d275a70a546b5588vboxsync so do this check! */
b63da7c87ee97d237d799dc5d275a70a546b5588vboxsync DeviceIoControl(gVBoxDriver, VBOXGUEST_IOCTL_VMMREQUEST, pReq, pReq->header.size,
b63da7c87ee97d237d799dc5d275a70a546b5588vboxsync/* The service table. */
b63da7c87ee97d237d799dc5d275a70a546b5588vboxsync "Shared Clipboard",
#ifdef VBOX_WITH_MANAGEMENT
return VERR_NOT_SUPPORTED;
bool fStartThread = false;
unsigned threadid;
&threadid);
pTable++;
return VINF_SUCCESS;
pTable++;
NULL,
NULL);
dprintf(("VBoxTray: could not open VBox Guest Additions driver! Please install / start it first! rc = %d\n", GetLastError()));
if (!gToolWindow)
/* We need to setup a security descriptor to allow other processes modify access to the seamless notification event semaphore */
if (!ret)
dprintf(("VBoxTray: Windows version major %d minor %d\n", info.dwMajorVersion, info.dwMinorVersion));
BOOL (WINAPI * pfnConvertStringSecurityDescriptorToSecurityDescriptorA)(LPCSTR StringSecurityDescriptor, DWORD StringSDRevision, PSECURITY_DESCRIPTOR *SecurityDescriptor, PULONG SecurityDescriptorSize);
if (hModule)
*(uintptr_t *)&pfnConvertStringSecurityDescriptorToSecurityDescriptorA = (uintptr_t)GetProcAddress(hModule, "ConvertStringSecurityDescriptorToSecurityDescriptorA");
dprintf(("pfnConvertStringSecurityDescriptorToSecurityDescriptorA = %x\n", pfnConvertStringSecurityDescriptorToSecurityDescriptorA));
ret = pfnConvertStringSecurityDescriptorToSecurityDescriptorA("S:(ML;;NW;;;LW)", /* this means "low integrity" */
if (!ret)
if (!ret)
if (!ret)
sprintf(ndata.szTip, "Sun xVM VirtualBox Guest Additions %d.%d.%dr%d", VBOX_VERSION_MAJOR, VBOX_VERSION_MINOR, VBOX_VERSION_BUILD, VBOX_SVN_REV);
/* Boost thread priority to make sure we wake up early for seamless window notifications (not sure if it actually makes any difference though) */
if (0 == ghSeamlessNotifyEvent) /* If seamless mode is not active / supported, reduce event array count */
if (waitResult == 0)
else if ((waitResult == 1) && (ghSeamlessNotifyEvent!=0)) /* Only jump in, if seamless is active! */
if (!fTrayIconCreated)
/* Do not use a global namespace ("Global\\") for mutex name here, will blow up NT4 compatibility! */
switch (msg)
case WM_CLOSE:
case WM_DESTROY:
case WM_VBOX_SEAMLESS_UPDATE:
case WM_VBOX_RESTORED:
case WM_VBOX_CHECK_VRDP: