/** * Shows a balloon message using VBoxTray's notification area in the * Windows task bar. * * @param hwndParent Window handle of parent. * @param string_size Size of variable string. * @param variables The actual variable string. * @param stacktop Pointer to a pointer to the current stack. */ VBOXINSTALLHELPER_EXPORT VBoxTrayShowBallonMsg(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop) { EXDLL_INIT(); VBOXTRAYIPCHEADER hdr; hdr.ulMsg = VBOXTRAYIPCMSGTYPE_SHOWBALLOONMSG; hdr.cbBody = sizeof(VBOXTRAYIPCMSG_SHOWBALLOONMSG); VBOXTRAYIPCMSG_SHOWBALLOONMSG msg; HRESULT hr = vboxPopString(msg.szContent, sizeof(msg.szContent) / sizeof(TCHAR)); if (SUCCEEDED(hr)) hr = vboxPopString(msg.szTitle, sizeof(msg.szTitle) / sizeof(TCHAR)); if (SUCCEEDED(hr)) hr = vboxPopULong(&msg.ulType); if (SUCCEEDED(hr)) hr = vboxPopULong(&msg.ulShowMS); if (SUCCEEDED(hr)) { msg.ulFlags = 0; HANDLE hPipe = vboxIPCConnect(); if (hPipe) { hr = vboxIPCWriteMessage(hPipe, (BYTE*)&hdr, sizeof(VBOXTRAYIPCHEADER)); if (SUCCEEDED(hr)) hr = vboxIPCWriteMessage(hPipe, (BYTE*)&msg, sizeof(VBOXTRAYIPCMSG_SHOWBALLOONMSG)); vboxIPCDisconnect(hPipe); } } /* Push simple return value on stack. */ SUCCEEDED(hr) ? pushstring("0") : pushstring("1"); }
/** * Shows a balloon message using VBoxTray's notification area in the * Windows task bar. * * @param hwndParent Window handle of parent. * @param string_size Size of variable string. * @param variables The actual variable string. * @param stacktop Pointer to a pointer to the current stack. */ VBOXINSTALLHELPER_EXPORT VBoxTrayShowBallonMsg(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop) { EXDLL_INIT(); char szMsg[256]; char szTitle[128]; HRESULT hr = vboxPopString(szMsg, sizeof(szMsg) / sizeof(char)); if (SUCCEEDED(hr)) hr = vboxPopString(szTitle, sizeof(szTitle) / sizeof(char)); /** @todo Do we need to restore the stack on failure? */ if (SUCCEEDED(hr)) { RTR3InitDll(0); uint32_t cbMsg = sizeof(VBOXTRAYIPCMSG_SHOWBALLOONMSG) + strlen(szMsg) + 1 /* Include terminating zero */ + strlen(szTitle) + 1; /* Dito. */ Assert(cbMsg); PVBOXTRAYIPCMSG_SHOWBALLOONMSG pIpcMsg = (PVBOXTRAYIPCMSG_SHOWBALLOONMSG)RTMemAlloc(cbMsg); if (pIpcMsg) { /* Stuff in the strings. */ memcpy(pIpcMsg->szMsgContent, szMsg, strlen(szMsg) + 1); memcpy(pIpcMsg->szMsgTitle, szTitle, strlen(szTitle) + 1); /* Pop off the values in reverse order from the stack. */ if (SUCCEEDED(hr)) hr = vboxPopULong((ULONG*)&pIpcMsg->uType); if (SUCCEEDED(hr)) hr = vboxPopULong((ULONG*)&pIpcMsg->uShowMS); if (SUCCEEDED(hr)) { RTLOCALIPCSESSION hSession = 0; int rc = vboxConnectToVBoxTray(&hSession); if (RT_SUCCESS(rc)) { VBOXTRAYIPCHEADER ipcHdr = { VBOXTRAY_IPC_HDR_MAGIC, 0 /* Header version */, VBOXTRAYIPCMSGTYPE_SHOWBALLOONMSG, cbMsg }; rc = RTLocalIpcSessionWrite(hSession, &ipcHdr, sizeof(ipcHdr)); if (RT_SUCCESS(rc)) rc = RTLocalIpcSessionWrite(hSession, pIpcMsg, cbMsg); int rc2 = RTLocalIpcSessionClose(hSession); if (RT_SUCCESS(rc)) rc = rc2; } if (RT_FAILURE(rc)) hr = __HRESULT_FROM_WIN32(ERROR_BROKEN_PIPE); } RTMemFree(pIpcMsg); } else hr = __HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY); } /* Push simple return value on stack. */ SUCCEEDED(hr) ? pushstring("0") : pushstring("1"); }