Changeset 96449 in vbox
- Timestamp:
- Aug 23, 2022 11:55:38 PM (2 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Installer/Loader/Makefile.kmk
r96407 r96449 29 29 include $(KBUILD_PATH)/subheader.kmk 30 30 31 ifeq ($(KBUILD_TARGET_ARCH),x86) 32 33 # This has to be 32-bit, so don't include it in the 64-bit build. 34 PROGRAMS.x86 += VBoxWindowsAdditions 31 # This has to be 32-bit. 32 PROGRAMS += VBoxWindowsAdditions 35 33 VBoxWindowsAdditions_TEMPLATE= VBoxGuestR3Exe 36 VBoxWindowsAdditions_DEFS = _WIN32_WINNT=0x0400 _UNICODE UNICODE 34 VBoxWindowsAdditions_BLD_TRG_ARCH = x86 35 VBoxWindowsAdditions_DEFS = _WIN32_WINNT=0x0400 36 VBoxWindowsAdditions_INCS = ../../include 37 37 VBoxWindowsAdditions_SOURCES = \ 38 38 VBoxWindowsAdditions.cpp \ 39 39 VBoxWindowsAdditions.rc 40 40 ifdef VBOX_WITH_NOCRT_STATIC 41 VBoxWindowsAdditions_LDFLAGS = /SubSystem:Windows 42 else 41 43 VBoxWindowsAdditions_LDFLAGS = \ 42 44 /DISALLOWLIB:msvcrt.lib \ 43 45 /DISALLOWLIB:msvcprt.lib \ 44 46 /DISALLOWLIB:libcmt.lib 45 46 47 VBoxWindowsAdditions_LIBS = \ 47 48 $(PATH_TOOL_$(TEMPLATE_VBOXR3EXE_TOOL.win.$(KBUILD_TARGET_ARCH))_LIB)/oldnames.lib \ 48 49 $(PATH_TOOL_$(TEMPLATE_VBOXR3EXE_TOOL.win.$(KBUILD_TARGET_ARCH))_LIB)/libcmt.lib \ 49 50 $(PATH_TOOL_$(TEMPLATE_VBOXR3EXE_TOOL.win.$(KBUILD_TARGET_ARCH))_LIB)/libcpmt.lib 51 endif 50 52 51 53 # Version stuff. … … 65 67 $(APPEND) $@ 'IDI_VIRTUALBOX ICON DISCARDABLE "$(subst /,\\,$(VBOX_WINDOWS_ADDITIONS_ICON_FILE))"' 66 68 67 endif # (x86 only because of the above rule)68 69 69 70 70 include $(FILE_KBUILD_SUB_FOOTER) -
trunk/src/VBox/Additions/WINNT/Installer/Loader/VBoxWindowsAdditions.cpp
r96407 r96449 38 38 #endif 39 39 40 #include <stdio.h> 41 #include <string.h> 40 #include <iprt/string.h> 41 #include <iprt/utf16.h> 42 43 #include "NoCrtOutput.h" 42 44 43 45 … … 46 48 BOOL fIsWow64 = FALSE; 47 49 typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS)(HANDLE, PBOOL); 48 LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle (L"kernel32"), "IsWow64Process");50 LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandleW(L"kernel32"), "IsWow64Process"); 49 51 if (fnIsWow64Process != NULL) 50 52 { 51 53 if (!fnIsWow64Process(GetCurrentProcess(), &fIsWow64)) 52 54 { 53 fwprintf(stderr, L"ERROR: Could not determine process type!\n");55 ErrorMsgLastErr("Unable to determine the process type!"); 54 56 55 57 /* Error in retrieving process type - assume that we're running on 32bit. */ … … 60 62 } 61 63 62 static void WaitForProcess2(HANDLE hProcess, int *piExitCode)64 static int WaitForProcess2(HANDLE hProcess) 63 65 { 64 66 /* … … 81 83 && dwRc != WAIT_OBJECT_0 + 1) 82 84 { 83 fwprintf(stderr, L"ERROR: MsgWaitForMultipleObjects failed: %lu (%lu)\n", dwRc, GetLastError());85 ErrorMsgLastErrSUR("MsgWaitForMultipleObjects failed: ", dwRc); 84 86 break; 85 87 } … … 91 93 DWORD dwExitCode; 92 94 if (GetExitCodeProcess(hProcess, &dwExitCode)) 93 *piExitCode = (int)dwExitCode; 94 else 95 { 96 fwprintf(stderr, L"ERROR: GetExitCodeProcess failed: %lu\n", GetLastError()); 97 *piExitCode = 16; 98 } 99 } 100 101 static void WaitForProcess(HANDLE hProcess, int *piExitCode) 95 return (int)dwExitCode; 96 return ErrorMsgRcLastErr(16, "GetExitCodeProcess failed"); 97 } 98 99 static int WaitForProcess(HANDLE hProcess) 102 100 { 103 101 DWORD WaitRc = WaitForSingleObjectEx(hProcess, INFINITE, TRUE); … … 109 107 DWORD dwExitCode; 110 108 if (GetExitCodeProcess(hProcess, &dwExitCode)) 111 *piExitCode = (int)dwExitCode; 112 else 113 { 114 fwprintf(stderr, L"ERROR: GetExitCodeProcess failed: %lu\n", GetLastError()); 115 *piExitCode = 16; 116 } 117 } 118 else 119 { 120 fwprintf(stderr, L"ERROR: WaitForSingleObjectEx failed: %lu (%lu)\n", WaitRc, GetLastError()); 121 *piExitCode = 16; 122 } 123 } 124 109 return (int)dwExitCode; 110 return ErrorMsgRcLastErr(16, "GetExitCodeProcess failed"); 111 } 112 return ErrorMsgRcLastErrSUR(16, "MsgWaitForMultipleObjects failed: ", WaitRc); 113 } 114 115 #ifndef IPRT_NO_CRT 125 116 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) 126 { 117 #else 118 int main() 119 #endif 120 { 121 #ifndef IPRT_NO_CRT 127 122 RT_NOREF(hInstance, hPrevInstance, lpCmdLine, nCmdShow); 123 #endif 128 124 129 125 /* 130 126 * Gather the parameters of the real installer program. 131 127 */ 132 133 128 SetLastError(NO_ERROR); 134 WCHAR wszCurDir[_MAX_PATH] = { 0 }; 135 DWORD cchCurDir = GetCurrentDirectoryW(sizeof(wszCurDir), wszCurDir); 136 if (cchCurDir == 0 || cchCurDir >= sizeof(wszCurDir)) 137 { 138 fwprintf(stderr, L"ERROR: GetCurrentDirectoryW failed: %lu (ret %lu)\n", GetLastError(), cchCurDir); 139 return 12; 140 } 129 WCHAR wszCurDir[MAX_PATH] = { 0 }; 130 DWORD cwcCurDir = GetCurrentDirectoryW(sizeof(wszCurDir), wszCurDir); 131 if (cwcCurDir == 0 || cwcCurDir >= sizeof(wszCurDir)) 132 return ErrorMsgRcLastErrSUR(12, "GetCurrentDirectoryW failed: ", cwcCurDir); 141 133 142 134 SetLastError(NO_ERROR); 143 WCHAR wszModule[_MAX_PATH] = { 0 }; 144 DWORD cchModule = GetModuleFileNameW(NULL, wszModule, sizeof(wszModule)); 145 if (cchModule == 0 || cchModule >= sizeof(wszModule)) 146 { 147 fwprintf(stderr, L"ERROR: GetModuleFileNameW failed: %lu (ret %lu)\n", GetLastError(), cchModule); 148 return 13; 149 } 150 151 /* Strip the extension off the module name and construct the arch specific 152 one of the real installer program. */ 153 DWORD off = cchModule - 1; 135 WCHAR wszExePath[MAX_PATH] = { 0 }; 136 DWORD cwcExePath = GetModuleFileNameW(NULL, wszExePath, sizeof(wszExePath)); 137 if (cwcExePath == 0 || cwcExePath >= sizeof(wszExePath)) 138 return ErrorMsgRcLastErrSUR(13, "GetModuleFileNameW failed: ", cwcExePath); 139 140 /* 141 * Strip the extension off the module name and construct the arch specific 142 * one of the real installer program. 143 */ 144 DWORD off = cwcExePath - 1; 154 145 while ( off > 0 155 && ( wsz Module[off] != '/'156 && wsz Module[off] != '\\'157 && wsz Module[off] != ':'))158 { 159 if (wsz Module[off] == '.')160 { 161 wsz Module[off] = '\0';162 c chModule= off;146 && ( wszExePath[off] != '/' 147 && wszExePath[off] != '\\' 148 && wszExePath[off] != ':')) 149 { 150 if (wszExePath[off] == '.') 151 { 152 wszExePath[off] = '\0'; 153 cwcExePath = off; 163 154 break; 164 155 } … … 167 158 168 159 WCHAR const *pwszSuff = IsWow64() ? L"-amd64.exe" : L"-x86.exe"; 169 size_t cchSuff = wcslen(pwszSuff); 170 if (cchSuff + cchModule >= sizeof(wszModule)) 171 { 172 fwprintf(stderr, L"ERROR: Real installer name is too long (%u chars)\n", (unsigned)(cchSuff + cchModule)); 173 return 14; 174 } 175 wcscpy(&wszModule[cchModule], pwszSuff); 176 cchModule += cchSuff; 177 178 /* Replace the first argument of the argument list. */ 160 int rc = RTUtf16Copy(&wszExePath[cwcExePath], RT_ELEMENTS(wszExePath) - cwcExePath, pwszSuff); 161 if (RT_FAILURE(rc)) 162 return ErrorMsgRc(14, "Real installer name is too long!"); 163 cwcExePath += RTUtf16Len(&wszExePath[cwcExePath]); 164 165 /* 166 * Replace the first argument of the argument list. 167 */ 179 168 PWCHAR pwszNewCmdLine = NULL; 180 169 LPCWSTR pwszOrgCmdLine = GetCommandLineW(); … … 209 198 pwszOrgCmdLine++; 210 199 211 /* Join up " szModule" with the remainder of the original command line. */212 size_t c chOrgCmdLine = wcslen(pwszOrgCmdLine);213 size_t c chNewCmdLine = 1 + cchModule + 1 + 1 + cchOrgCmdLine + 1;214 PWCHAR pwsz = pwszNewCmdLine = (PWCHAR)LocalAlloc(LPTR, c chNewCmdLine * sizeof(WCHAR));200 /* Join up "wszExePath" with the remainder of the original command line. */ 201 size_t cwcOrgCmdLine = RTUtf16Len(pwszOrgCmdLine); 202 size_t cwcNewCmdLine = 1 + cwcExePath + 1 + 1 + cwcOrgCmdLine + 1; 203 PWCHAR pwsz = pwszNewCmdLine = (PWCHAR)LocalAlloc(LPTR, cwcNewCmdLine * sizeof(WCHAR)); 215 204 if (!pwsz) 216 { 217 fwprintf(stderr, L"ERROR: Out of memory (%u bytes)\n", (unsigned)cchNewCmdLine); 218 return 15; 219 } 205 return ErrorMsgRcSUS(15, "Out of memory (", cwcNewCmdLine * sizeof(WCHAR), " bytes)"); 220 206 *pwsz++ = L'"'; 221 wcscpy(pwsz, wszModule);222 pwsz += c chModule;207 memcpy(pwsz, wszExePath, cwcExePath * sizeof(pwsz[0])); 208 pwsz += cwcExePath; 223 209 *pwsz++ = L'"'; 224 if (c chOrgCmdLine)210 if (cwcOrgCmdLine) 225 211 { 226 212 *pwsz++ = L' '; 227 wcscpy(pwsz, pwszOrgCmdLine);213 memcpy(pwsz, pwszOrgCmdLine, cwcOrgCmdLine * sizeof(pwsz[0])); 228 214 } 229 215 else … … 237 223 * Start the process. 238 224 */ 239 int iRet= 0;225 int rcExit = 0; 240 226 STARTUPINFOW StartupInfo = { sizeof(StartupInfo), 0 }; 241 PROCESS_INFORMATION ProcInfo = { 0 };227 PROCESS_INFORMATION ProcInfo = { 0 }; 242 228 SetLastError(740); 243 BOOL fOk = CreateProcessW(wsz Module,229 BOOL fOk = CreateProcessW(wszExePath, 244 230 pwszNewCmdLine, 245 231 NULL /*pProcessAttributes*/, … … 255 241 /* Wait for the process to finish. */ 256 242 CloseHandle(ProcInfo.hThread); 257 WaitForProcess(ProcInfo.hProcess, &iRet);243 rcExit = WaitForProcess(ProcInfo.hProcess); 258 244 CloseHandle(ProcInfo.hProcess); 259 245 } … … 273 259 ShExecInfo.hwnd = NULL; 274 260 ShExecInfo.lpVerb = L"runas" ; 275 ShExecInfo.lpFile = wsz Module;261 ShExecInfo.lpFile = wszExePath; 276 262 ShExecInfo.lpParameters = pwszOrgCmdLine; /* pass only args here!!! */ 277 263 ShExecInfo.lpDirectory = wszCurDir; … … 282 268 if (ShExecInfo.hProcess != INVALID_HANDLE_VALUE) 283 269 { 284 WaitForProcess2(ShExecInfo.hProcess, &iRet);270 rcExit = WaitForProcess2(ShExecInfo.hProcess); 285 271 CloseHandle(ShExecInfo.hProcess); 286 272 } 287 273 else 288 { 289 fwprintf(stderr, L"ERROR: ShellExecuteExW did not return a valid process handle!\n"); 290 iRet = 1; 291 } 274 rcExit = ErrorMsgRc(1, "ShellExecuteExW did not return a valid process handle!"); 292 275 } 293 276 else 294 { 295 fwprintf(stderr, L"ERROR: Failed to execute '%ws' via ShellExecuteExW: %lu\n", wszModule, GetLastError()); 296 iRet = 9; 297 } 277 rcExit = ErrorMsgRcLastErrSWSR(9, "Failed to execute '", wszExePath, "' via ShellExecuteExW!"); 298 278 } 299 279 else 300 { 301 fwprintf(stderr, L"ERROR: Failed to execute '%ws' via CreateProcessW: %lu\n", wszModule, GetLastError()); 302 iRet = 8; 303 } 280 rcExit = ErrorMsgRcLastErrSWSR(8, "Failed to execute '", wszExePath, "' via CreateProcessW!"); 304 281 305 282 if (pwszNewCmdLine) 306 283 LocalFree(pwszNewCmdLine); 307 284 308 #if 0 309 fwprintf(stderr, L"DEBUG: iRet=%d\n", iRet); 310 fflush(stderr); 311 #endif 312 return iRet; 313 } 314 285 return rcExit; 286 } 287 -
trunk/src/VBox/Additions/WINNT/Installer/Makefile.kmk
r96443 r96449 50 50 VBoxDrvInst_DEPS = $(VBOX_SVN_REV_KMK) 51 51 VBoxDrvInst_SDKS = ReorderCompilerIncs $(VBOX_WINPSDK_GST) $(VBOX_WINDDK_GST) VBOX_WIN_NEWDEV 52 VBoxDrvInst_INCS = ../include 52 53 VBoxDrvInst_LIBS = \ 53 54 $(PATH_SDK_$(VBOX_WINPSDK)_LIB)/setupapi.lib … … 380 381 PROGRAMS.win.x86 += VBoxAddInstallNt3x 381 382 ifdef VBOX_WITH_NOCRT_STATIC 383 ## @todo noCRT: the result is much too big. Got rid of log.cpp, but still pretty big. Work on reducing it. 382 384 VBoxAddInstallNt3x_TEMPLATE := VBoxGuestR3Exe 383 385 else 384 386 VBoxAddInstallNt3x_TEMPLATE := VBoxGuestR3NoCrtExe 385 387 endif 388 VBoxAddInstallNt3x_LDFLAGS := /VERBOSE 386 389 VBoxAddInstallNt3x_SOURCES := \ 387 390 VBoxAddInstallNt3x.cpp \ -
trunk/src/VBox/Additions/WINNT/Installer/VBoxDrvInst.cpp
r96437 r96449 46 46 #include <iprt/utf16.h> 47 47 48 49 /*********************************************************************************************************************************50 * Defines *51 *********************************************************************************************************************************/52 48 /* Exit codes */ 53 49 #define EXIT_OK (0) … … 56 52 #define EXIT_USAGE (3) 57 53 54 /* Must include after EXIT_FAIL was defined! Sorry for the mixing up of thing. */ 55 #include "NoCrtOutput.h" 56 57 58 /********************************************************************************************************************************* 59 * Defines * 60 *********************************************************************************************************************************/ 58 61 /* Defines */ 59 62 #define DRIVER_PACKAGE_REPAIR 0x00000001 … … 113 116 114 117 115 /** @name Output helpers116 *117 * The general ASSUMPTION here is that all strings are restricted to 7-bit118 * ASCII, with the exception of wchar_t ones.119 *120 * @note We don't use printf, RTPrintf or similar not for masochistic reasons121 * but to keep the binary small and make it easier to switch between CRT122 * and IPRT w/ no-CRT.123 *124 * @{125 */126 127 static void OutputWStr(HANDLE hDst, const wchar_t *pwszStr)128 {129 DWORD cbIgn;130 if (GetConsoleMode(hDst, &cbIgn))131 WriteConsoleW(hDst, pwszStr, (DWORD)RTUtf16Len(pwszStr), &cbIgn, NULL);132 else133 {134 char *pszTmp;135 int rc = RTUtf16ToUtf8(pwszStr, &pszTmp);136 if (RT_SUCCESS(rc))137 {138 char *pszInCodepage;139 rc = RTStrUtf8ToCurrentCP(&pszInCodepage, pszTmp);140 if (RT_SUCCESS(rc))141 {142 WriteFile(hDst, pszInCodepage, (DWORD)strlen(pszInCodepage), &cbIgn, NULL);143 RTStrFree(pszInCodepage);144 }145 else146 WriteFile(hDst, RT_STR_TUPLE("<RTStrUtf8ToCurrentCP error>"), &cbIgn, NULL);147 RTStrFree(pszTmp);148 }149 else150 WriteFile(hDst, RT_STR_TUPLE("<RTUtf16ToUtf8 error>"), &cbIgn, NULL);151 }152 }153 154 155 static void ErrorMsgBegin(const char *pszMsg)156 {157 HANDLE const hStdErr = GetStdHandle(STD_ERROR_HANDLE);158 DWORD cbIgn;159 WriteFile(hStdErr, RT_STR_TUPLE("error: "), &cbIgn, NULL);160 WriteFile(hStdErr, pszMsg, (DWORD)strlen(pszMsg), &cbIgn, NULL);161 }162 163 164 static void ErrorMsgStr(const char *pszMsg)165 {166 HANDLE const hStdErr = GetStdHandle(STD_ERROR_HANDLE);167 DWORD cbIgn;168 WriteFile(hStdErr, pszMsg, (DWORD)strlen(pszMsg), &cbIgn, NULL);169 }170 171 172 static void ErrorMsgWStr(const wchar_t *pwszStr)173 {174 OutputWStr(GetStdHandle(STD_ERROR_HANDLE), pwszStr);175 }176 177 178 static int ErrorMsgEnd(const char *pszMsg)179 {180 HANDLE const hStdErr = GetStdHandle(STD_ERROR_HANDLE);181 DWORD cbIgn;182 if (pszMsg)183 WriteFile(hStdErr, pszMsg, (DWORD)strlen(pszMsg), &cbIgn, NULL);184 WriteFile(hStdErr, RT_STR_TUPLE("\r\n"), &cbIgn, NULL);185 return EXIT_FAIL;186 }187 188 189 static void ErrorMsgU64(uint64_t uValue, bool fSigned = false)190 {191 char szVal[128];192 RTStrFormatU64(szVal, sizeof(szVal), uValue, 10, 0, 0, fSigned ? RTSTR_F_VALSIGNED : 0);193 ErrorMsgStr(szVal);194 }195 196 197 static int ErrorMsg(const char *pszMsg)198 {199 ErrorMsgBegin(pszMsg);200 return ErrorMsgEnd(NULL);201 }202 203 204 static int ErrorMsgSWS(const char *pszMsg1, const wchar_t *pwszMsg2, const char *pszMsg3)205 {206 ErrorMsgBegin(pszMsg1);207 ErrorMsgWStr(pwszMsg2);208 return ErrorMsgEnd(pszMsg3);209 }210 211 212 static int ErrorMsgSWSWS(const char *pszMsg1, const wchar_t *pwszMsg2, const char *pszMsg3,213 const wchar_t *pwszMsg4, const char *pszMsg5)214 {215 ErrorMsgBegin(pszMsg1);216 ErrorMsgWStr(pwszMsg2);217 ErrorMsgStr(pszMsg3);218 ErrorMsgWStr(pwszMsg4);219 return ErrorMsgEnd(pszMsg5);220 }221 222 223 static void ErrorMsgErrVal(uint32_t uErrVal, bool fSigned)224 {225 char szVal[128];226 ssize_t cchVal = RTStrFormatU32(szVal, sizeof(szVal) - 1, uErrVal, 10, 0, 0, fSigned ? RTSTR_F_VALSIGNED : 0);227 szVal[cchVal++] = '/';228 szVal[cchVal] = '\0';229 ErrorMsgStr(szVal);230 231 RTStrFormatU32(szVal, sizeof(szVal) - 1, uErrVal, 16, 0, 0, RTSTR_F_SPECIAL);232 ErrorMsgStr(szVal);233 }234 235 236 static int ErrorMsgErr(const char *pszMsg, uint32_t uErrVal, const char *pszErrIntro, bool fSigned)237 {238 ErrorMsgBegin(pszMsg);239 ErrorMsgStr(pszErrIntro);240 ErrorMsgErrVal(uErrVal, fSigned);241 return ErrorMsgEnd(")");242 }243 244 245 static int ErrorMsgVBoxErr(const char *pszMsg, int rc)246 {247 return ErrorMsgErr(pszMsg, rc, " (", true);248 }249 250 251 static int ErrorMsgLastErr(const char *pszMsg)252 {253 return ErrorMsgErr(pszMsg, GetLastError(), " (last error ", false);254 }255 256 257 static int ErrorMsgLastErrSWS(const char *pszMsg1, const wchar_t *pwszMsg2, const char *pszMsg3)258 {259 DWORD dwErr = GetLastError();260 ErrorMsgBegin(pszMsg1);261 ErrorMsgWStr(pwszMsg2);262 ErrorMsgStr(pszMsg3);263 ErrorMsgStr(" (last error ");264 ErrorMsgErrVal(dwErr, false);265 return ErrorMsgEnd(")");266 }267 268 static int ErrorMsgLastErrSWSWS(const char *pszMsg1, const wchar_t *pwszMsg2, const char *pszMsg3,269 const wchar_t *pwszMsg4, const char *pszMsg5)270 {271 DWORD dwErr = GetLastError();272 ErrorMsgBegin(pszMsg1);273 ErrorMsgWStr(pwszMsg2);274 ErrorMsgStr(pszMsg3);275 ErrorMsgWStr(pwszMsg4);276 ErrorMsgStr(pszMsg5);277 ErrorMsgStr(" (last error ");278 ErrorMsgErrVal(dwErr, false);279 return ErrorMsgEnd(")");280 }281 282 283 static int ErrorMsgLastErrSWSRSUS(const char *pszMsg1, const wchar_t *pwszMsg2, const char *pszMsg3, const char *pszMsg4,284 uint64_t uValue, const char *pszMsg5)285 {286 DWORD dwErr = GetLastError();287 ErrorMsgBegin(pszMsg1);288 ErrorMsgWStr(pwszMsg2);289 ErrorMsgStr(pszMsg3);290 ErrorMsgStr(" (last error ");291 ErrorMsgErrVal(dwErr, false);292 ErrorMsgStr(")");293 ErrorMsgStr(pszMsg4);294 ErrorMsgU64(uValue);295 return ErrorMsgEnd(pszMsg5);296 }297 298 299 static int ErrorMsgLastErrSSS(const char *pszMsg1, const char *pszMsg2, const char *pszMsg3)300 {301 DWORD dwErr = GetLastError();302 ErrorMsgBegin(pszMsg1);303 ErrorMsgStr(pszMsg2);304 ErrorMsgStr(pszMsg3);305 ErrorMsgStr(" (last error ");306 ErrorMsgErrVal(dwErr, false);307 return ErrorMsgEnd(")");308 }309 310 311 static int ErrorMsgLStatus(const char *pszMsg, LSTATUS lrc)312 {313 return ErrorMsgErr(pszMsg, (DWORD)lrc, " (", true);314 }315 316 317 static int ErrorMsgLStatusSWSRS(const char *pszMsg1, const wchar_t *pwszMsg2, const char *pszMsg3,318 LSTATUS lrc, const char *pszMsg4)319 {320 ErrorMsgBegin(pszMsg1);321 ErrorMsgWStr(pwszMsg2);322 ErrorMsgStr(pszMsg3);323 ErrorMsgErrVal((DWORD)lrc, true);324 return ErrorMsgEnd(pszMsg4);325 }326 327 328 static int ErrorMsgLStatusSWSWSRS(const char *pszMsg1, const wchar_t *pwszMsg2, const char *pszMsg3, const wchar_t *pwszMsg4,329 const char *pszMsg5, LSTATUS lrc, const char *pszMsg6)330 {331 ErrorMsgBegin(pszMsg1);332 ErrorMsgWStr(pwszMsg2);333 ErrorMsgStr(pszMsg3);334 ErrorMsgWStr(pwszMsg4);335 ErrorMsgStr(pszMsg5);336 ErrorMsgErrVal((DWORD)lrc, true);337 return ErrorMsgEnd(pszMsg6);338 }339 340 341 static int ErrorMsgLStatusSWSWSWSRS(const char *pszMsg1, const wchar_t *pwszMsg2, const char *pszMsg3, const wchar_t *pwszMsg4,342 const char *pszMsg5, const wchar_t *pwszMsg6, const char *pszMsg7,343 LSTATUS lrc, const char *pszMsg8)344 {345 ErrorMsgBegin(pszMsg1);346 ErrorMsgWStr(pwszMsg2);347 ErrorMsgStr(pszMsg3);348 ErrorMsgWStr(pwszMsg4);349 ErrorMsgStr(pszMsg5);350 ErrorMsgWStr(pwszMsg6);351 ErrorMsgStr(pszMsg7);352 ErrorMsgErrVal((DWORD)lrc, true);353 return ErrorMsgEnd(pszMsg8);354 }355 356 357 static int ErrorMsgLStatusSWSWSWSWSRS(const char *pszMsg1, const wchar_t *pwszMsg2, const char *pszMsg3, const wchar_t *pwszMsg4,358 const char *pszMsg5, const wchar_t *pwszMsg6, const char *pszMsg7, const wchar_t *pwszMsg8,359 const char *pszMsg9, LSTATUS lrc, const char *pszMsg10)360 {361 ErrorMsgBegin(pszMsg1);362 ErrorMsgWStr(pwszMsg2);363 ErrorMsgStr(pszMsg3);364 ErrorMsgWStr(pwszMsg4);365 ErrorMsgStr(pszMsg5);366 ErrorMsgWStr(pwszMsg6);367 ErrorMsgStr(pszMsg7);368 ErrorMsgWStr(pwszMsg8);369 ErrorMsgStr(pszMsg9);370 ErrorMsgErrVal((DWORD)lrc, true);371 return ErrorMsgEnd(pszMsg10);372 }373 374 375 static int ErrorBadArg(const char *pszName, wchar_t const *pwszArg, const char *pszValues = NULL)376 {377 ErrorMsgBegin("Bad argument '");378 ErrorMsgStr(pszName);379 ErrorMsgStr("': ");380 ErrorMsgWStr(pwszArg);381 if (pszValues)382 ErrorMsgStr(", expected: ");383 return ErrorMsgEnd(pszValues);384 }385 386 387 /** Simple fputs(stdout) replacement. */388 static void PrintStr(const char *pszMsg)389 {390 HANDLE const hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);391 DWORD cbIgn;392 WriteFile(hStdOut, pszMsg, (DWORD)strlen(pszMsg), &cbIgn, NULL);393 }394 395 396 /** Simple fputs(stdout) replacement. */397 static void PrintWStr(const wchar_t *pwszStr)398 {399 OutputWStr(GetStdHandle(STD_OUTPUT_HANDLE), pwszStr);400 }401 402 403 static void PrintX64(uint64_t uValue)404 {405 char szVal[128];406 RTStrFormatU64(szVal, sizeof(szVal), uValue, 16, 0, 0, RTSTR_F_64BIT | RTSTR_F_SPECIAL);407 PrintStr(szVal);408 }409 410 411 static void PrintSWS(const char *pszMsg1, const wchar_t *pwszMsg2, const char *pszMsg3)412 {413 PrintStr(pszMsg1);414 PrintWStr(pwszMsg2);415 PrintStr(pszMsg3);416 }417 418 419 static void PrintSWSWS(const char *pszMsg1, const wchar_t *pwszMsg2, const char *pszMsg3,420 const wchar_t *pwszMsg4, const char *pszMsg5)421 {422 PrintStr(pszMsg1);423 PrintWStr(pwszMsg2);424 PrintStr(pszMsg3);425 PrintWStr(pwszMsg4);426 PrintStr(pszMsg5);427 }428 429 430 static void PrintSWSWSWS(const char *pszMsg1, const wchar_t *pwszMsg2, const char *pszMsg3, const wchar_t *pwszMsg4,431 const char *pszMsg5, const wchar_t *pwszMsg6, const char *pszMsg7)432 {433 PrintStr(pszMsg1);434 PrintWStr(pwszMsg2);435 PrintStr(pszMsg3);436 PrintWStr(pwszMsg4);437 PrintStr(pszMsg5);438 PrintWStr(pwszMsg6);439 PrintStr(pszMsg7);440 }441 442 443 static void PrintSWSWSWSWS(const char *pszMsg1, const wchar_t *pwszMsg2, const char *pszMsg3, const wchar_t *pwszMsg4,444 const char *pszMsg5, const wchar_t *pwszMsg6, const char *pszMsg7, const wchar_t *pwszMsg8,445 const char *pszMsg9)446 {447 PrintStr(pszMsg1);448 PrintWStr(pwszMsg2);449 PrintStr(pszMsg3);450 PrintWStr(pwszMsg4);451 PrintStr(pszMsg5);452 PrintWStr(pwszMsg6);453 PrintStr(pszMsg7);454 PrintWStr(pwszMsg8);455 PrintStr(pszMsg9);456 }457 458 459 static void PrintSXS(const char *pszMsg1, uint64_t uValue, const char *pszMsg2)460 {461 PrintStr(pszMsg1);462 PrintX64(uValue);463 PrintStr(pszMsg2);464 }465 466 467 static void PrintSWSWSWSXS(const char *pszMsg1, const wchar_t *pwszMsg2, const char *pszMsg3, const wchar_t *pwszMsg4,468 const char *pszMsg5, const wchar_t *pwszMsg6, const char *pszMsg7, uint64_t uValue, const char *pszMsg8)469 {470 PrintStr(pszMsg1);471 PrintWStr(pwszMsg2);472 PrintStr(pszMsg3);473 PrintWStr(pwszMsg4);474 PrintStr(pszMsg5);475 PrintWStr(pwszMsg6);476 PrintStr(pszMsg7);477 PrintX64(uValue);478 PrintStr(pszMsg8);479 }480 481 /** @} */482 118 483 119 static char *ArgToUtf8(wchar_t const *pwszString, const char *pszArgName) -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxTray.cpp
r96407 r96449 66 66 67 67 68 static void VBoxGrapicsSetSupported(BOOL fSupported);69 70 71 68 /********************************************************************************************************************************* 72 69 * Internal Functions * 73 70 *********************************************************************************************************************************/ 71 static void VBoxGrapicsSetSupported(BOOL fSupported); 74 72 static int vboxTrayCreateTrayIcon(void); 75 73 static LRESULT CALLBACK vboxToolWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
Note:
See TracChangeset
for help on using the changeset viewer.