VirtualBox

Changeset 34357 in vbox for trunk/src/VBox/Additions


Ignore:
Timestamp:
Nov 25, 2010 10:24:41 AM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
68120
Message:

VBoxTray/InstallHelper: IPC Update.

Location:
trunk/src/VBox/Additions/WINNT
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Installer/InstallHelper/VBoxGuestInstallHelper.cpp

    r34117 r34357  
    146146    VBOXTRAYIPCHEADER hdr;
    147147    hdr.ulMsg = VBOXTRAYIPCMSGTYPE_SHOWBALLOONMSG;
     148    hdr.cbBody = sizeof(VBOXTRAYIPCMSG_SHOWBALLOONMSG);
    148149
    149150    VBOXTRAYIPCMSG_SHOWBALLOONMSG msg;
    150     HRESULT hr = VBoxPopString(msg.szBody, sizeof(msg.szBody) / sizeof(TCHAR));
     151    HRESULT hr = VBoxPopString(msg.szContent, sizeof(msg.szContent) / sizeof(TCHAR));
    151152    if (SUCCEEDED(hr))
    152153        hr = VBoxPopString(msg.szTitle, sizeof(msg.szTitle) / sizeof(TCHAR));
  • trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxIPC.cpp

    r34117 r34357  
    2626#include <VBoxGuestInternal.h>
    2727
     28
    2829typedef struct _VBOXIPCCONTEXT
    2930{
     
    3536static VBOXIPCCONTEXT gCtx = {0};
    3637
     38
     39/**
     40 * Reads an IPC message from a connected client, represented by the IPC
     41 * context.
     42 *
     43 * @return  IPRT status code.
     44 * @param   pCtx                    The IPC context.
     45 * @param   pMessage                Buffer for receiving the message to be read.
     46 * @param   cbMessage               Size (in bytes) of buffer for received message.
     47 */
    3748int VBoxIPCReadMessage(PVBOXIPCCONTEXT pCtx, BYTE *pMessage, DWORD cbMessage)
    3849{
     
    5768}
    5869
     70/**
     71 * Skips an IPC message by reading out the outstanding message
     72 * body to discard it.
     73 *
     74 * @return  IPRT status code.
     75 * @param   pCtx                    The IPC context.
     76 * @param   pHdr                    The header of message to skip.
     77 */
     78int VBoxIPCSkipMessage(PVBOXIPCCONTEXT pCtx, PVBOXTRAYIPCHEADER pHdr)
     79{
     80    Assert(pHdr->cbBody);
     81    BYTE *pbBuf = (BYTE*)RTMemAlloc(pHdr->cbBody);
     82    if (!pbBuf)
     83        return VERR_NO_MEMORY;
     84    int rc = VBoxIPCReadMessage(pCtx, pbBuf, pHdr->cbBody);
     85    RTMemFree(pbBuf);
     86    return rc;
     87}
     88
     89/**
     90 * Writes an IPC message to the IPC context's client.
     91 *
     92 * @return  IPRT status code.
     93 * @param   pCtx                    The IPC context.
     94 * @param   pMessage                Pointer to message to send.
     95 * @param   cbMessage               Size (in bytes) of message to send.
     96 */
    5997int VBoxIPCWriteMessage(PVBOXIPCCONTEXT pCtx, BYTE *pMessage, DWORD cbMessage)
    6098{
     
    82120 *
    83121 * @return  IPRT status code.
    84  * @param   pCtx
    85  * @param   wParam
    86  * @param   lParam
     122 * @param   pCtx                    IPC context of the caller.
     123 * @param   wParam                  wParam of received IPC message.
     124 * @param   lParam                  lParam of received IPC message.
    87125 */
    88126int VBoxIPCMsgShowBalloonMsg(PVBOXIPCCONTEXT pCtx, UINT wParam, UINT lParam)
     
    93131    {
    94132        hlpShowBalloonTip(gInstance, gToolWindow, ID_TRAYICON,
    95                           msg.szBody, msg.szTitle,
     133                          msg.szContent, msg.szTitle,
    96134                          msg.ulShowMS, msg.ulType);
    97135    }
     
    99137}
    100138
     139/**
     140 * Takes action to restart VBoxTray (this application).
     141 *
     142 * @return  IPRT status code.
     143 * @param   pCtx                    IPC context of the caller.
     144 * @param   wParam                  wParam of received IPC message.
     145 * @param   lParam                  lParam of received IPC message.
     146 */
     147int VBoxIPCMsgRestart(PVBOXIPCCONTEXT pCtx, UINT wParam, UINT lParam)
     148{
     149    return 0;
     150}
     151
     152/**
     153 * Initializes the IPC communication.
     154 *
     155 * @return  IPRT status code.
     156 * @param   pEnv                        The IPC service's environment.
     157 * @param   ppInstance                  The instance pointer which refer to this object.
     158 * @param   pfStartThread               Pointer to flag whether the IPC service can be started or not.
     159 */
    101160int VBoxIPCInit(const VBOXSERVICEENV *pEnv, void **ppInstance, bool *pfStartThread)
    102161{
     
    203262            if (SUCCEEDED(dwErr))
    204263            {
     264                Log(("VBoxTray: VBoxIPCThread: Received message %ld ...\n", hdr.ulMsg));
    205265                switch (hdr.ulMsg)
    206266                {
     267                    case VBOXTRAYIPCMSGTYPE_QUIT:
     268                        fTerminate = true;
     269                        break;
     270
     271                    case VBOXTRAYIPCMSGTYPE_RESTART:
     272                        rc = VBoxIPCMsgRestart(pCtx, hdr.wParam, hdr.lParam);
     273                        if (RT_SUCCESS(rc))
     274                            fTerminate = true;
     275                        break;
     276
    207277                    case VBOXTRAYIPCMSGTYPE_SHOWBALLOONMSG:
    208278                        rc = VBoxIPCMsgShowBalloonMsg(pCtx, hdr.wParam, hdr.lParam);
    209279                        break;
    210280
    211                     /* Someone asked us to quit ... */
    212                     case VBOXTRAYIPCMSGTYPE_QUIT:
    213                         fTerminate = true;
    214                         break;
    215 
    216281                    default:
     282                        /* Unknown message received, try to receive the body and
     283                         * just skip it. */
     284                        Log(("VBoxTray: VBoxIPCThread: Unknown message %ld, skipping ...\n", hdr.ulMsg));
     285                        if (hdr.cbBody)
     286                            rc = VBoxIPCSkipMessage(pCtx, &hdr);
    217287                        break;
    218288                }
     
    227297        /* Sleep a bit to not eat too much CPU in case the above call always fails. */
    228298        if (WaitForSingleObject(pCtx->pEnv->hStopEvent, 10) == WAIT_OBJECT_0)
    229         {
    230299            fTerminate = true;
    231             break;
    232         }
     300        if (fTerminate)
     301            Log(("VBoxTray: VBoxIPCThread: Terminating ...\n"));
    233302    } while (!fTerminate);
    234303
  • trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxTrayMsg.h

    r34117 r34357  
    2626    /** Asks the IPC thread to quit. */
    2727    VBOXTRAYIPCMSGTYPE_QUIT           = 10,
    28     /** TODO */
     28    /** Restarts VBoxTray. */
     29    VBOXTRAYIPCMSGTYPE_RESTART        = 11,
     30    /** Shows a balloon message in the tray area. */
    2931    VBOXTRAYIPCMSGTYPE_SHOWBALLOONMSG = 100
    3032};
     
    3537    /** Message type. */
    3638    ULONG ulMsg;
     39    /** Size of message body
     40     *  (without this header). */
     41    ULONG cbBody;
    3742    /** User-supplied wParam. */
    3843    ULONG wParam;
     
    4348typedef struct _VBOXTRAYIPCMSG_SHOWBALLOONMSG
    4449{
    45     /** Message body. */
    46     TCHAR    szBody[256];
    47     /** Message body. */
     50    /** Message content. */
     51    TCHAR    szContent[256];
     52    /** Message title. */
    4853    TCHAR    szTitle[64];
    4954    /** Message type. */
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette