Changeset 47232 in vbox for trunk/src/VBox/Additions/WINNT
- Timestamp:
- Jul 18, 2013 12:00:49 PM (12 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Installer/InstallHelper/VBoxGuestInstallHelper.cpp
r47212 r47232 124 124 StringCchPrintf(szErr, sizeof(szErr), "0"); 125 125 pushstring(szErr); 126 } 127 128 /** 129 * Connects to VBoxTray IPC under the behalf of the user running 130 * in the current thread context. 131 * 132 * @return IPRT status code. 133 * @param phSession Where to store the IPC session. 134 */ 135 static int vboxConnectToVBoxTray(RTLOCALIPCSESSION hSession) 136 { 137 int rc = VINF_SUCCESS; 138 139 RTUTF16 wszUserName[255]; 140 DWORD cchUserName = sizeof(wszUserName) / sizeof(RTUTF16); 141 BOOL fRc = GetUserNameW(wszUserName, &cchUserName); 142 if (!fRc) 143 rc = RTErrConvertFromWin32(GetLastError()); 144 145 if (RT_SUCCESS(rc)) 146 { 147 char *pszUserName; 148 rc = RTUtf16ToUtf8(wszUserName, &pszUserName); 149 if (RT_SUCCESS(rc)) 150 { 151 char szPipeName[255]; 152 if (RTStrPrintf(szPipeName, sizeof(szPipeName), "%s%s", 153 VBOXTRAY_IPC_PIPE_PREFIX, pszUserName)) 154 { 155 rc = RTLocalIpcSessionConnect(&hSession, szPipeName, 0 /* Flags */); 156 } 157 else 158 rc = VERR_NO_MEMORY; 159 160 RTStrFree(pszUserName); 161 } 162 } 163 164 return rc; 126 165 } 127 166 … … 437 476 { 438 477 RTLOCALIPCSESSION hSession; 439 int rc = RTLocalIpcSessionConnect(&hSession, VBOXTRAY_IPC_PIPENAME, 0 /* Flags */);478 int rc = vboxConnectToVBoxTray(hSession); 440 479 if (RT_SUCCESS(rc)) 441 480 { -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxIPC.cpp
r47211 r47232 110 110 int rc = VINF_SUCCESS; 111 111 112 /* Note: This only works up to 49.7 days (= 2^32, 32-bit counter) 113 since Windows was started. */ 112 114 LASTINPUTINFO lastInput; 113 115 lastInput.cbSize = sizeof(LASTINPUTINFO); … … 116 118 { 117 119 VBOXTRAYIPCRES_USERLASTINPUT ipcRes; 118 ipcRes.u TickCount = lastInput.dwTime; /** @sa GetTickCount(). */120 ipcRes.uLastInputMs = GetTickCount() - lastInput.dwTime; 119 121 rc = RTLocalIpcSessionWrite(hSession, &ipcRes, sizeof(ipcRes)); 120 122 } … … 143 145 *pfStartThread = false; 144 146 145 gCtx.pEnv = pEnv;146 gCtx.hServer = NIL_RTLOCALIPCSERVER;147 148 147 int rc = RTCritSectInit(&gCtx.CritSect); 149 148 if (RT_SUCCESS(rc)) 150 149 { 151 rc = RTLocalIpcServerCreate(&gCtx.hServer, VBOXTRAY_IPC_PIPENAME, 152 RTLOCALIPC_FLAGS_MULTI_SESSION); 153 if (RT_FAILURE(rc)) 154 { 155 LogRelFunc(("Creating local IPC server failed with rc=%Rrc\n", rc)); 156 return rc; 157 } 158 159 RTListInit(&gCtx.SessionList); 160 161 *pfStartThread = true; 162 } 163 150 RTUTF16 wszUserName[255]; 151 DWORD cchUserName = sizeof(wszUserName) / sizeof(RTUTF16); 152 BOOL fRc = GetUserNameW(wszUserName, &cchUserName); 153 if (!fRc) 154 rc = RTErrConvertFromWin32(GetLastError()); 155 156 if (RT_SUCCESS(rc)) 157 { 158 char *pszUserName; 159 rc = RTUtf16ToUtf8(wszUserName, &pszUserName); 160 if (RT_SUCCESS(rc)) 161 { 162 char szPipeName[255]; 163 if (RTStrPrintf(szPipeName, sizeof(szPipeName), "%s%s", 164 VBOXTRAY_IPC_PIPE_PREFIX, pszUserName)) 165 { 166 rc = RTLocalIpcServerCreate(&gCtx.hServer, szPipeName, 167 RTLOCALIPC_FLAGS_MULTI_SESSION); 168 if (RT_SUCCESS(rc)) 169 { 170 RTStrFree(pszUserName); 171 172 gCtx.pEnv = pEnv; 173 RTListInit(&gCtx.SessionList); 174 175 *ppInstance = &gCtx; 176 *pfStartThread = true; 177 178 LogRelFunc(("Local IPC server now running at \"%s\"\n", 179 szPipeName)); 180 return VINF_SUCCESS; 181 } 182 183 } 184 else 185 rc = VERR_NO_MEMORY; 186 187 RTStrFree(pszUserName); 188 } 189 } 190 191 RTCritSectDelete(&gCtx.CritSect); 192 } 193 194 LogRelFunc(("Creating local IPC server failed with rc=%Rrc\n", rc)); 164 195 return rc; 165 196 } -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxTrayMsg.h
r47213 r47232 19 19 #define ___VBOXTRAY_MSG_H 20 20 21 #define VBOXTRAY_IPC_PIPE NAME "VBoxTrayIPCSvc"21 #define VBOXTRAY_IPC_PIPE_PREFIX "VBoxTrayIPC-" 22 22 23 23 enum VBOXTRAYIPCMSGTYPE … … 29 29 /** Retrieves the current user's last input 30 30 * time. This will be the user VBoxTray is running 31 * under. */ 31 * under. No actual message for this command 32 * required. */ 32 33 VBOXTRAYIPCMSGTYPE_USERLASTINPUT = 120 33 34 }; … … 36 37 typedef struct VBOXTRAYIPCHEADER 37 38 { 39 /** @todo Add magic? */ 38 40 /** Header version, must be 0 by now. */ 39 41 uint32_t uHdrVersion; … … 84 86 typedef struct VBOXTRAYIPCRES_USERLASTINPUT 85 87 { 86 uint32_t uTickCount; 88 /** Last occurred user input event (in ms). */ 89 uint32_t uLastInputMs; 87 90 } VBOXTRAYIPCRES_USERLASTINPUT, *PVBOXTRAYIPCRES_USERLASTINPUT; 88 91
Note:
See TracChangeset
for help on using the changeset viewer.