Changeset 52163 in vbox
- Timestamp:
- Jul 24, 2014 11:35:26 AM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 95205
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/nt/nt.h
r52139 r52163 1117 1117 typedef FILE_FS_ATTRIBUTE_INFORMATION *PFILE_FS_ATTRIBUTE_INFORMATION; 1118 1118 1119 NTSYSAPI NTSTATUS NTAPI NtOpenProcess(PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES, PCLIENT_ID); 1119 1120 NTSYSAPI NTSTATUS NTAPI NtOpenProcessToken(HANDLE, ACCESS_MASK, PHANDLE); 1121 NTSYSAPI NTSTATUS NTAPI NtOpenThread(PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES, PCLIENT_ID); 1120 1122 NTSYSAPI NTSTATUS NTAPI NtOpenThreadToken(HANDLE, ACCESS_MASK, BOOLEAN, PHANDLE); 1121 1123 … … 1641 1643 typedef RTNT_SYSTEM_PROCESS_INFORMATION *PRTNT_SYSTEM_PROCESS_INFORMATION; 1642 1644 #ifndef IPRT_NT_USE_WINTERNL 1643 typedef RTNT_SYSTEM_PROCESS_INFORMATION SYSTEM_PROCESS_INFORMATION 1645 typedef RTNT_SYSTEM_PROCESS_INFORMATION SYSTEM_PROCESS_INFORMATION; 1644 1646 typedef SYSTEM_PROCESS_INFORMATION *PSYSTEM_PROCESS_INFORMATION; 1645 1647 #endif … … 1704 1706 NTSYSAPI NTSTATUS NTAPI NtYieldExecution(void); 1705 1707 #ifndef IPRT_NT_USE_WINTERNL 1706 NTSYSAPI NTSTATUS NTAPI NtWaitForSingleObject(HANDLE, BOOLEAN PLARGE_INTERGER); 1707 #endif 1708 NTSYSAPI NTSTATUS NTAPI NtWaitForSingleObject(HANDLE, BOOLEAN PLARGE_INTEGER); 1709 #endif 1710 typedef enum _OBJECT_WAIT_TYPE { WaitAllObjects = 0, WaitAnyObject = 1, ObjectWaitTypeHack = 0x7fffffff } OBJECT_WAIT_TYPE; 1711 NTSYSAPI NTSTATUS NTAPI NtWaitForMultipleObjects(ULONG, PHANDLE, OBJECT_WAIT_TYPE, BOOLEAN, PLARGE_INTEGER); 1708 1712 1709 1713 -
trunk/src/VBox/HostDrivers/Support/SUPR3HardenedMain.cpp
r52160 r52163 38 38 39 39 #elif RT_OS_WINDOWS 40 # include < Windows.h>40 # include <iprt/nt/nt-and-windows.h> 41 41 42 42 #else /* UNIXes */ … … 230 230 { 231 231 #ifdef RT_OS_WINDOWS 232 DWORD cbWrittenIgn; 233 WriteFile(GetStdHandle(STD_ERROR_HANDLE), pch, (DWORD)cch, &cbWrittenIgn, NULL); 232 HANDLE hStdOut = NtCurrentPeb()->ProcessParameters->StandardOutput; 233 if (hStdOut != NULL) 234 { 235 IO_STATUS_BLOCK Ios = RTNT_IO_STATUS_BLOCK_INITIALIZER; 236 NtWriteFile(hStdOut, NULL /*Event*/, NULL /*ApcRoutine*/, NULL /*ApcContext*/, 237 &Ios, (PVOID)pch, cch, NULL /*ByteOffset*/, NULL /*Key*/); 238 } 234 239 #else 235 240 (void)write(2, pch, cch); -
trunk/src/VBox/HostDrivers/Support/SUPR3HardenedVerify.cpp
r52160 r52163 40 40 41 41 #elif defined(RT_OS_WINDOWS) 42 # include < Windows.h>42 # include <iprt/nt/nt-and-windows.h> 43 43 # ifndef IN_SUP_HARDENED_R3 44 44 # include <stdio.h> … … 781 781 #if defined(RT_OS_WINDOWS) 782 782 LPSTR pszIgnored; 783 char szName2[RTPATH_MAX]; 783 char szName2[RTPATH_MAX]; /** @todo Must use UTF-16 here! Code is mixing UTF-8 and native. */ 784 784 if ( GetFullPathName(szName, RT_ELEMENTS(szName2), &szName2[0], &pszIgnored) 785 785 && GetFullPathName(pszFilename, RT_ELEMENTS(szName), &szName[0], &pszIgnored)) … … 1713 1713 rc = RTErrInfoSetF(pErrInfo, rc, "Error converting '%s' to UTF-16: %Rrc", pszFilename, rc); 1714 1714 } 1715 else if (!DuplicateHandle(GetCurrentProcess(), (HANDLE)hNativeFile, GetCurrentProcess(), &hVerify, 1716 GENERIC_READ, false /*bInheritHandle*/, 0 /*dwOptions*/)) 1717 hVerify = INVALID_HANDLE_VALUE; 1715 else 1716 { 1717 NTSTATUS rcNt = NtDuplicateObject(NtCurrentProcess(), (HANDLE)hNativeFile, NtCurrentProcess(), &hVerify, 1718 GENERIC_READ, 0 /*HandleAttributes*/, 0 /*Options*/); 1719 if (!NT_SUCCESS(rcNt)) 1720 hVerify = INVALID_HANDLE_VALUE; 1721 } 1718 1722 if (hVerify != INVALID_HANDLE_VALUE) 1719 1723 { -
trunk/src/VBox/HostDrivers/Support/win/SUPR3HardenedMain-win.cpp
r52160 r52163 964 964 * notifications from ending up in the debugger. 965 965 */ 966 rcNt = NtSetInformationThread( GetCurrentThread(), ThreadHideFromDebugger, NULL, 0);966 rcNt = NtSetInformationThread(NtCurrentThread(), ThreadHideFromDebugger, NULL, 0); 967 967 if (!NT_SUCCESS(rcNt)) 968 968 supR3HardenedFatalMsg("supR3HardenedWinInstallHooks", kSupInitOp_Misc, VERR_GENERAL_FAILURE, … … 1064 1064 1065 1065 DWORD dwOldProt; 1066 SUPR3HARDENED_ASSERT_WIN32_SUCCESS(VirtualProtectEx( GetCurrentProcess(), pbNtCreateSection, 16,1066 SUPR3HARDENED_ASSERT_WIN32_SUCCESS(VirtualProtectEx(NtCurrentProcess(), pbNtCreateSection, 16, 1067 1067 PAGE_EXECUTE_READWRITE, &dwOldProt)); 1068 1068 pbNtCreateSection[0] = 0xff; … … 1070 1070 *(uint32_t *)&pbNtCreateSection[2] = (uint32_t)((uintptr_t)puJmpTab - (uintptr_t)&pbNtCreateSection[2+4]); 1071 1071 1072 SUPR3HARDENED_ASSERT_WIN32_SUCCESS(VirtualProtectEx( GetCurrentProcess(), pbNtCreateSection, 16,1072 SUPR3HARDENED_ASSERT_WIN32_SUCCESS(VirtualProtectEx(NtCurrentProcess(), pbNtCreateSection, 16, 1073 1073 PAGE_EXECUTE_READ, &dwOldProt)); 1074 1074 return; … … 1142 1142 1143 1143 DWORD dwOldProt; 1144 SUPR3HARDENED_ASSERT_WIN32_SUCCESS(VirtualProtectEx( GetCurrentProcess(), pbNtCreateSection, 16,1144 SUPR3HARDENED_ASSERT_WIN32_SUCCESS(VirtualProtectEx(NtCurrentProcess(), pbNtCreateSection, 16, 1145 1145 PAGE_EXECUTE_READWRITE, &dwOldProt)); 1146 1146 pbNtCreateSection[0] = 0xe9; … … 1148 1148 - (uintptr_t)&pbNtCreateSection[1+4]; 1149 1149 1150 SUPR3HARDENED_ASSERT_WIN32_SUCCESS(VirtualProtectEx( GetCurrentProcess(), pbNtCreateSection, 16,1150 SUPR3HARDENED_ASSERT_WIN32_SUCCESS(VirtualProtectEx(NtCurrentProcess(), pbNtCreateSection, 16, 1151 1151 PAGE_EXECUTE_READ, &dwOldProt)); 1152 1152 return; … … 1173 1173 { 1174 1174 RTErrInfoInitStatic(&g_ErrInfoStatic); 1175 int rc = supHardenedWinVerifyProcess( GetCurrentProcess(), GetCurrentThread(), &g_ErrInfoStatic.Core);1175 int rc = supHardenedWinVerifyProcess(NtCurrentProcess(), NtCurrentThread(), &g_ErrInfoStatic.Core); 1176 1176 if (RT_FAILURE(rc)) 1177 1177 supR3HardenedFatalMsg("supR3HardenedWinVerifyProcess", kSupInitOp_Integrity, rc, … … 1192 1192 { 1193 1193 HANDLE hToken; 1194 SUPR3HARDENED_ASSERT_NT_SUCCESS(NtOpenProcessToken( GetCurrentProcess(), TOKEN_QUERY, &hToken));1194 SUPR3HARDENED_ASSERT_NT_SUCCESS(NtOpenProcessToken(NtCurrentProcess(), TOKEN_QUERY, &hToken)); 1195 1195 union 1196 1196 { … … 1359 1359 1360 1360 /** 1361 * Construct the new command line. Since argc/argv are both derived from 1362 * GetCommandLineW (see suplibHardenedWindowsMain), we skip the argument 1363 * by argument UTF-8 -> UTF-16 conversion and quoting by going to the 1364 * original source. 1361 * Construct the new command line. 1362 * 1363 * Since argc/argv are both derived from GetCommandLineW (see 1364 * suplibHardenedWindowsMain), we skip the argument by argument UTF-8 -> UTF-16 1365 * conversion and quoting by going to the original source. 1365 1366 * 1366 1367 * The executable name, though, is replaced in case it's not a fullly … … 1384 1385 * Get the command line and skip the executable name. 1385 1386 */ 1386 PCRTUTF16 pwszArgs = GetCommandLineW(); 1387 PUNICODE_STRING pCmdLineStr = &NtCurrentPeb()->ProcessParameters->CommandLine; 1388 PCRTUTF16 pawcArgs = pCmdLineStr->Buffer; 1389 uint32_t cwcArgs = pCmdLineStr->Length / sizeof(WCHAR); 1387 1390 1388 1391 /* Skip leading space (shouldn't be any, but whatever). */ 1389 while ( suplibCommandLineIsArgSeparator(*pwszArgs))1390 pwszArgs++;1391 SUPR3HARDENED_ASSERT( *pwszArgs != '\0');1392 while (cwcArgs > 0 && suplibCommandLineIsArgSeparator(*pawcArgs) ) 1393 cwcArgs--, pawcArgs++; 1394 SUPR3HARDENED_ASSERT(cwcArgs > 0 && *pawcArgs != '\0'); 1392 1395 1393 1396 /* Walk to the end of it. */ … … 1395 1398 do 1396 1399 { 1397 if (*p wszArgs == '"')1400 if (*pawcArgs == '"') 1398 1401 { 1399 1402 fQuoted = !fQuoted; 1400 pwszArgs++;1403 cwcArgs--; pawcArgs++; 1401 1404 } 1402 else if (*p wszArgs != '\\' || (pwszArgs[1] != '\\' && pwszArgs[1] != '"'))1403 pwszArgs++;1405 else if (*pawcArgs != '\\' || (pawcArgs[1] != '\\' && pawcArgs[1] != '"')) 1406 cwcArgs--, pawcArgs++; 1404 1407 else 1405 1408 { 1406 1409 unsigned cSlashes = 0; 1407 1410 do 1411 { 1408 1412 cSlashes++; 1409 while (*++pwszArgs == '\\'); 1410 if (*pwszArgs == '"' && (cSlashes & 1)) 1411 pwszArgs++; /* odd number of slashes == escaped quote */ 1413 cwcArgs--; 1414 pawcArgs++; 1415 } 1416 while (cwcArgs > 0 && *pawcArgs == '\\'); 1417 if (cwcArgs > 0 && *pawcArgs == '"' && (cSlashes & 1)) 1418 cwcArgs--, pawcArgs++; /* odd number of slashes == escaped quote */ 1412 1419 } 1413 } while ( *pwszArgs && (fQuoted || !suplibCommandLineIsArgSeparator(*pwszArgs)));1420 } while (cwcArgs > 0 && (fQuoted || !suplibCommandLineIsArgSeparator(*pawcArgs))); 1414 1421 1415 1422 /* Skip trailing spaces. */ 1416 while ( suplibCommandLineIsArgSeparator(*pwszArgs))1417 pwszArgs++;1423 while (cwcArgs > 0 && suplibCommandLineIsArgSeparator(*pawcArgs)) 1424 cwcArgs--, pawcArgs++; 1418 1425 1419 1426 /* … … 1421 1428 */ 1422 1429 AssertCompile(sizeof(SUPR3_RESPAWN_1_ARG0) == sizeof(SUPR3_RESPAWN_2_ARG0)); 1423 size_t cwcArgs = suplibHardenedWStrLen(pwszArgs);1424 1430 size_t cwcCmdLine = (sizeof(SUPR3_RESPAWN_1_ARG0) - 1) / sizeof(SUPR3_RESPAWN_1_ARG0[0]) /* Respawn exe name. */ 1425 1431 + !!cwcArgs + cwcArgs; /* if arguments present, add space + arguments. */ … … 1441 1447 { 1442 1448 *pwszDst++ = ' '; 1443 suplibHardenedMemCopy(pwszDst, p wszArgs, cwcArgs * sizeof(RTUTF16));1449 suplibHardenedMemCopy(pwszDst, pawcArgs, cwcArgs * sizeof(RTUTF16)); 1444 1450 pwszDst += cwcArgs; 1445 1451 } … … 2115 2121 * Does the actually respawning. 2116 2122 * 2117 * @returns Exit code (if we get that far). 2123 * @returns Never, will call exit or raise fatal error. 2124 * @param iWhich Which respawn we're to check for, 1 being the 2125 * first one, and 2 the second and final. 2126 * 2127 * @todo Split up this function. 2118 2128 */ 2119 2129 static int supR3HardenedWinDoReSpawn(int iWhich) 2120 2130 { 2131 NTSTATUS rcNt; 2132 PPEB pPeb = NtCurrentPeb(); 2133 PRTL_USER_PROCESS_PARAMETERS pParentProcParams = pPeb->ProcessParameters; 2134 2121 2135 SUPR3HARDENED_ASSERT(g_cSuplibHardenedWindowsMainCalls == 1); 2122 2136 … … 2150 2164 2151 2165 SiEx.StartupInfo.dwFlags |= STARTF_USESTDHANDLES; 2152 SiEx.StartupInfo.hStdInput = GetStdHandle(STD_INPUT_HANDLE);2153 SiEx.StartupInfo.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);2154 SiEx.StartupInfo.hStdError = GetStdHandle(STD_ERROR_HANDLE);2166 SiEx.StartupInfo.hStdInput = pParentProcParams->StandardInput; 2167 SiEx.StartupInfo.hStdOutput = pParentProcParams->StandardOutput; 2168 SiEx.StartupInfo.hStdError = pParentProcParams->StandardError; 2155 2169 2156 2170 /* … … 2205 2219 2206 2220 /** @todo this doesn't work. :-( */ 2207 PPEB pPeb = NtCurrentPeb();2208 PRTL_USER_PROCESS_PARAMETERS pParentProcParams = pPeb->ProcessParameters;2209 2221 pProcParams->ConsoleHandle = pParentProcParams->ConsoleHandle; 2210 2222 pProcParams->ConsoleFlags = pParentProcParams->ConsoleFlags; … … 2214 2226 2215 2227 RTL_USER_PROCESS_INFORMATION ProcessInfoNt = { sizeof(ProcessInfoNt) }; 2216 NTSTATUSrcNt = RtlCreateUserProcess(&g_SupLibHardenedExeNtPath.UniStr,2217 2218 2219 2220 2221 2222 2223 2224 2225 2228 rcNt = RtlCreateUserProcess(&g_SupLibHardenedExeNtPath.UniStr, 2229 OBJ_INHERIT | OBJ_CASE_INSENSITIVE /*Attributes*/, 2230 pProcParams, 2231 NULL, //&ProcessSecAttrs, 2232 NULL, //&ThreadSecAttrs, 2233 NtCurrentProcess() /* ParentProcess */, 2234 FALSE /*fInheritHandles*/, 2235 NULL /* DebugPort */, 2236 NULL /* ExceptionPort */, 2237 &ProcessInfoNt); 2226 2238 if (!NT_SUCCESS(rcNt)) 2227 2239 supR3HardenedFatalMsg("supR3HardenedWinReSpawn", kSupInitOp_Misc, VERR_INVALID_NAME, … … 2259 2271 SUPR3HARDENED_ASSERT_NT_SUCCESS(NtClose(hThread)); 2260 2272 2273 PROCESS_BASIC_INFORMATION BasicInfo; 2261 2274 HANDLE hProcWait; 2262 DWORD dwRights = SYNCHRONIZE;2275 ULONG fRights = SYNCHRONIZE; 2263 2276 if (g_uNtVerCombined >= SUP_MAKE_NT_VER_SIMPLE(6, 0)) /* Introduced in Vista. */ 2264 dwRights |= PROCESS_QUERY_LIMITED_INFORMATION;2277 fRights |= PROCESS_QUERY_LIMITED_INFORMATION; 2265 2278 else 2266 dwRights |= PROCESS_QUERY_INFORMATION; 2267 if (!DuplicateHandle(GetCurrentProcess(), 2268 hProcess, 2269 GetCurrentProcess(), 2270 &hProcWait, 2271 SYNCHRONIZE, 2272 FALSE /*fInheritHandle*/, 2273 0)) 2274 { 2275 /* This is unacceptable, kill the process. */ 2279 fRights |= PROCESS_QUERY_INFORMATION; 2280 rcNt = NtDuplicateObject(NtCurrentProcess(), hProcess, 2281 NtCurrentProcess(), &hProcWait, 2282 fRights, 0 /*HandleAttributes*/, 0); 2283 if (rcNt == STATUS_ACCESS_DENIED) 2284 rcNt = NtDuplicateObject(NtCurrentProcess(), hProcess, 2285 NtCurrentProcess(), &hProcWait, 2286 SYNCHRONIZE, 0 /*HandleAttributes*/, 0); 2287 if (!NT_SUCCESS(rcNt)) 2288 { 2289 /* Failure is unacceptable, kill the process. */ 2276 2290 DWORD dwErr = GetLastError(); 2277 2291 NtTerminateProcess(hProcess, RTEXITCODE_FAILURE); 2278 supR3HardenedError(dwErr, false /*fFatal*/, "DuplicateHandle failed on child process handle: %u\n", dwErr); 2279 2280 DWORD dwExit; 2281 BOOL fExitOk = GetExitCodeProcess(hProcess, &dwExit) 2282 && dwExit != STILL_ACTIVE; 2292 supR3HardenedError(dwErr, false /*fFatal*/, "NtDuplicateObject failed on child process handle: %u\n", dwErr); 2293 2294 NTSTATUS rcNtExit = NtQueryInformationProcess(hProcess, ProcessBasicInformation, &BasicInfo, sizeof(BasicInfo), NULL); 2295 bool fExitOk = NT_SUCCESS(rcNtExit) && BasicInfo.ExitStatus != STATUS_PENDING; 2283 2296 if (!fExitOk) 2284 2297 { 2298 NTSTATUS rcNtWait; 2285 2299 DWORD dwStartTick = GetTickCount(); 2286 DWORD dwWait;2287 2300 do 2288 2301 { 2289 2302 NtTerminateProcess(hProcess, DBG_TERMINATE_PROCESS); 2290 dwWait = WaitForSingleObject(hProcess, 1000); 2291 fExitOk = GetExitCodeProcess(hProcess, &dwExit) 2292 && dwExit != STILL_ACTIVE; 2303 2304 LARGE_INTEGER Timeout; 2305 Timeout.QuadPart = -20000000; /* 2 second */ 2306 rcNtWait = NtWaitForSingleObject(hProcess, TRUE /*Alertable*/, &Timeout); 2307 2308 rcNtExit = NtQueryInformationProcess(hProcess, ProcessBasicInformation, &BasicInfo, sizeof(BasicInfo), NULL); 2309 fExitOk = NT_SUCCESS(rcNtExit) && BasicInfo.ExitStatus != STATUS_PENDING; 2293 2310 } while ( !fExitOk 2294 && (dwWait == WAIT_TIMEOUT || dwWait == WAIT_IO_COMPLETION) 2311 && ( rcNtWait == STATUS_TIMEOUT 2312 || rcNtWait == STATUS_USER_APC 2313 || rcNtWait == STATUS_ALERTED) 2295 2314 && GetTickCount() - dwStartTick < 60 * 1000); 2296 2315 if (fExitOk) 2297 2316 supR3HardenedError(dwErr, false /*fFatal*/, 2298 " DuplicateHandle failed and we failed to kill child: dwErr=%u dwWait=%u err=%u hProcess=%p\n",2299 dwErr, dwWait, GetLastError(), hProcess);2317 "NtDuplicateObject failed and we failed to kill child: rcNt=%u rcNtWait=%u hProcess=%p\n", 2318 rcNt, rcNtWait, hProcess); 2300 2319 } 2301 2320 supR3HardenedFatalMsg("supR3HardenedWinReSpawn", kSupInitOp_Misc, VERR_INVALID_NAME, 2302 " DuplicateHandle failed on child process handle: %u\n", dwErr);2321 "NtDuplicateObject failed on child process handle: %#x\n", rcNt); 2303 2322 } 2304 2323 … … 2307 2326 2308 2327 /* 2309 * Wait for the process to terminate and proxy the termination code. 2310 */ 2311 for (;;) 2312 { 2313 SetLastError(NO_ERROR); 2314 DWORD dwWait = WaitForSingleObject(hProcWait, INFINITE); 2315 if ( dwWait == WAIT_OBJECT_0 2316 || dwWait == WAIT_ABANDONED_0) 2317 break; 2318 if ( dwWait != WAIT_TIMEOUT 2319 && dwWait != WAIT_IO_COMPLETION) 2320 supR3HardenedFatal("WaitForSingleObject returned %#x (last error %#x)\n", dwWait, GetLastError()); 2321 } 2322 2323 DWORD dwExit; 2324 if ( !GetExitCodeProcess(hProcWait, &dwExit) 2325 || dwExit == STILL_ACTIVE) 2326 dwExit = RTEXITCODE_FAILURE; 2328 * If this is the middle process, wait for both parent and child to quit. 2329 */ 2330 HANDLE hParent = NULL; 2331 if (iWhich > 1) 2332 { 2333 rcNt = NtQueryInformationProcess(NtCurrentProcess(), ProcessBasicInformation, &BasicInfo, sizeof(BasicInfo), NULL); 2334 if (NT_SUCCESS(rcNt)) 2335 { 2336 OBJECT_ATTRIBUTES ObjAttr; 2337 InitializeObjectAttributes(&ObjAttr, NULL, 0, NULL /*hRootDir*/, NULL /*pSecDesc*/); 2338 2339 CLIENT_ID ClientId; 2340 ClientId.UniqueProcess = (HANDLE)BasicInfo.InheritedFromUniqueProcessId; 2341 ClientId.UniqueThread = NULL; 2342 2343 rcNt = NtOpenProcess(&hParent, SYNCHRONIZE | PROCESS_QUERY_INFORMATION, &ObjAttr, &ClientId); 2344 } 2345 #ifdef DEBUG 2346 SUPR3HARDENED_ASSERT_NT_SUCCESS(rcNt); 2347 #endif 2348 } 2349 2350 if (hParent != NULL) 2351 { 2352 for (;;) 2353 { 2354 HANDLE ahHandles[2] = { hProcWait, hParent }; 2355 rcNt = NtWaitForMultipleObjects(2, &ahHandles[0], WaitAnyObject, TRUE /*Alertable*/, NULL /*pTimeout*/); 2356 if ( rcNt == STATUS_WAIT_0 2357 || rcNt == STATUS_WAIT_0 + 1 2358 || rcNt == STATUS_ABANDONED_WAIT_0 2359 || rcNt == STATUS_ABANDONED_WAIT_0 + 1) 2360 break; 2361 if ( rcNt != STATUS_TIMEOUT 2362 && rcNt != STATUS_USER_APC 2363 && rcNt != STATUS_ALERTED) 2364 supR3HardenedFatal("NtWaitForMultipleObjects returned %#x\n", rcNt); 2365 } 2366 NtClose(hParent); 2367 } 2368 else 2369 { 2370 /* 2371 * Wait for the process to terminate. 2372 */ 2373 for (;;) 2374 { 2375 rcNt = NtWaitForSingleObject(hProcWait, TRUE /*Alertable*/, NULL /*pTimeout*/); 2376 if ( rcNt == STATUS_WAIT_0 2377 || rcNt == STATUS_ABANDONED_WAIT_0) 2378 break; 2379 if ( rcNt != STATUS_TIMEOUT 2380 && rcNt != STATUS_USER_APC 2381 && rcNt != STATUS_ALERTED) 2382 supR3HardenedFatal("NtWaitForSingleObject returned %#x\n", rcNt); 2383 } 2384 } 2385 2386 /* 2387 * Proxy the termination code of the child, if it exited already. 2388 */ 2389 rcNt = NtQueryInformationProcess(hProcWait, ProcessBasicInformation, &BasicInfo, sizeof(BasicInfo), NULL); 2390 if ( !NT_SUCCESS(rcNt) 2391 || BasicInfo.ExitStatus == STATUS_PENDING) 2392 BasicInfo.ExitStatus = RTEXITCODE_FAILURE; 2327 2393 2328 2394 NtClose(hProcWait); 2329 suplibHardenedExit((RTEXITCODE) dwExit);2395 suplibHardenedExit((RTEXITCODE)BasicInfo.ExitStatus); 2330 2396 } 2331 2397 … … 2587 2653 * 2588 2654 * @returns Pointer to the argument array. 2589 * @param pwszCmdLine The UTF-16 windows command line to parse. 2655 * @param pawcCmdLine The UTF-16 windows command line to parse. 2656 * @param cwcCmdLine The length of the command line. 2590 2657 * @param pcArgs Where to return the number of arguments. 2591 2658 */ 2592 static char **suplibCommandLineToArgvWStub(PCRTUTF16 p wszCmdLine, int *pcArgs)2659 static char **suplibCommandLineToArgvWStub(PCRTUTF16 pawcCmdLine, size_t cwcCmdLine, int *pcArgs) 2593 2660 { 2594 2661 /* 2595 2662 * Convert the command line string to UTF-8. 2596 2663 */ 2597 char *pszCmdLine ;2598 SUPR3HARDENED_ASSERT(RT_SUCCESS(RTUtf16ToUtf8 (pwszCmdLine, &pszCmdLine)));2664 char *pszCmdLine = NULL; 2665 SUPR3HARDENED_ASSERT(RT_SUCCESS(RTUtf16ToUtf8Ex(pawcCmdLine, cwcCmdLine, &pszCmdLine, 0, NULL))); 2599 2666 2600 2667 /* … … 2725 2792 * Convert the arguments to UTF-8 and call the C/C++ main function. 2726 2793 */ 2727 int cArgs; 2728 char **papszArgs = suplibCommandLineToArgvWStub(GetCommandLineW(), &cArgs); 2794 PUNICODE_STRING pCmdLineStr = &NtCurrentPeb()->ProcessParameters->CommandLine; 2795 int cArgs; 2796 char **papszArgs = suplibCommandLineToArgvWStub(pCmdLineStr->Buffer, pCmdLineStr->Length / sizeof(WCHAR), &cArgs); 2729 2797 2730 2798 rcExit = (RTEXITCODE)main(cArgs, papszArgs, NULL); -
trunk/src/VBox/Runtime/r3/win/ntdll-mini-implib.def
r52139 r52163 45 45 NtOpenProcess ;;= _NtOpenProcess@16 46 46 NtOpenProcessToken ;;= _NtOpenProcessToken@12 47 NtOpenThread ;;= _NtOpenThread@16 47 48 NtOpenThreadToken ;;= _NtOpenThreadToken@16 48 49 NtProtectVirtualMemory ;;= _NtProtectVirtualMemory@20 … … 73 74 NtUnmapViewOfSection ;;= _NtUnmapViewOfSection@8 74 75 NtWaitForSingleObject ;;= _NtWaitForSingleObject@12 76 NtWaitForMultipleObjects ;;= _NtWaitForMultipleObjects@20 75 77 NtWriteFile ;;= _NtWriteFile@36 76 78 NtWriteVirtualMemory ;;= _NtWriteVirtualMemory@20
Note:
See TracChangeset
for help on using the changeset viewer.