Changeset 27385 in vbox for trunk/src/VBox/Runtime/r3
- Timestamp:
- Mar 15, 2010 10:14:14 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/win/process-win.cpp
r27348 r27385 40 40 41 41 #include <iprt/process.h> 42 #include "internal/iprt.h" 43 42 44 #include <iprt/assert.h> 45 #include <iprt/file.h> 43 46 #include <iprt/err.h> 44 47 #include <iprt/env.h> 48 #include <iprt/getopt.h> 49 #include <iprt/pipe.h> 50 #include <iprt/string.h> 45 51 46 52 … … 165 171 PRTPROCESS phProcess) 166 172 { 167 #if 0/* needs more work... dinner time. */173 #if 1 /* needs more work... dinner time. */ 168 174 int rc; 169 175 … … 190 196 StartupInfo.dwFlags = STARTF_USESTDHANDLES; 191 197 #if 1 /* The CRT should keep the standard handles up to date. */ 192 StartupInfo.hStdIn 193 StartupInfo.hStdOut 194 StartupInfo.hStdError = GetStdHandle(STD_ERROR_HANDLE);198 StartupInfo.hStdInput = GetStdHandle(STD_INPUT_HANDLE); 199 StartupInfo.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE); 200 StartupInfo.hStdError = GetStdHandle(STD_ERROR_HANDLE); 195 201 #else 196 StartupInfo.hStdIn 197 StartupInfo.hStdOut 198 StartupInfo.hStdError = _get_osfhandle(2);202 StartupInfo.hStdInput = _get_osfhandle(0); 203 StartupInfo.hStdOutput = _get_osfhandle(1); 204 StartupInfo.hStdError = _get_osfhandle(2); 199 205 #endif 200 206 PCRTHANDLE paHandles[3] = { phStdIn, phStdOut, phStdErr }; 201 HANDLE *aphStds[3] = { &StartupInfo.hStdIn , &StartupInfo.hStdOut, &StartupInfo.hStdError };207 HANDLE *aphStds[3] = { &StartupInfo.hStdInput, &StartupInfo.hStdOutput, &StartupInfo.hStdError }; 202 208 for (int i = 0; i < 3; i++) 203 209 { … … 208 214 { 209 215 case RTHANDLETYPE_FILE: 210 aphStds[i] = paHandles[i]->u.hFile != NIL_RTFILE211 ? (HANDLE)RTFileToNative(paHandles[i]->u.hFile)212 : INVALID_HANDLE_VALUE;216 *aphStds[i] = paHandles[i]->u.hFile != NIL_RTFILE 217 ? (HANDLE)RTFileToNative(paHandles[i]->u.hFile) 218 : INVALID_HANDLE_VALUE; 213 219 break; 214 220 215 221 case RTHANDLETYPE_PIPE: 216 aphStds[i] = paHandles[i]->u.hPipe != NIL_RTPIPE217 ? (HANDLE)RTPipeToNative(paHandles[i]->u.hPipe)218 : INVALID_HANDLE_VALUE;222 *aphStds[i] = paHandles[i]->u.hPipe != NIL_RTPIPE 223 ? (HANDLE)RTPipeToNative(paHandles[i]->u.hPipe) 224 : INVALID_HANDLE_VALUE; 219 225 break; 220 226 221 227 //case RTHANDLETYPE_SOCKET: 222 // aphStds[i] = paHandles[i]->u.hSocket != NIL_RTSOCKET223 // ? (HANDLE)RTTcpToNative(paHandles[i]->u.hSocket)224 // : INVALID_HANDLE_VALUE;228 // *aphStds[i] = paHandles[i]->u.hSocket != NIL_RTSOCKET 229 // ? (HANDLE)RTTcpToNative(paHandles[i]->u.hSocket) 230 // : INVALID_HANDLE_VALUE; 225 231 // break; 226 232 … … 236 242 */ 237 243 PRTUTF16 pwszzBlock; 238 rc = RTEnvQueryUtf16Block(hEnv );244 rc = RTEnvQueryUtf16Block(hEnv, &pwszzBlock); 239 245 if (RT_SUCCESS(rc)) 240 246 { … … 250 256 if (pszAsUser) 251 257 { 252 /** @todo - Maybe use CreateProcessWithLoginW? */ 258 /** @todo - Maybe use CreateProcessWithLoginW? That'll require a password, but 259 * we may need that anyway because it looks like LogonUserW is the only 260 * way to get a hToken. FIXME */ 253 261 rc = VERR_NOT_IMPLEMENTED; 254 262 } … … 261 269 RT_ZERO(ProcInfo); 262 270 BOOL fRc; 263 if ( !pwszAsUser)271 if (hToken == INVALID_HANDLE_VALUE) 264 272 fRc = CreateProcessW(pwszExec, 265 273 pwszCmdLine, 266 274 NULL, /* pProcessAttributes */ 267 275 NULL, /* pThreadAttributes */ 268 TRUE, /* bInheritHandles */276 TRUE, /* fInheritHandles */ 269 277 CREATE_UNICODE_ENVIRONMENT, /* dwCreationFlags */ 270 278 pwszzBlock, 271 cwd,279 NULL, /* pCurrentDirectory */ 272 280 &StartupInfo, 273 281 &ProcInfo); … … 278 286 NULL, /* pProcessAttributes */ 279 287 NULL, /* pThreadAttributes */ 280 TRUE, /* bInheritHandles */288 TRUE, /* fInheritHandles */ 281 289 CREATE_UNICODE_ENVIRONMENT, /* dwCreationFlags */ 282 290 pwszzBlock, 283 cwd,291 NULL, /* pCurrentDirectory */ 284 292 &StartupInfo, 285 293 &ProcInfo); … … 287 295 if (fRc) 288 296 { 289 //DWORD dwErr; 290 //DWORD dwExitCode; 291 // 292 //CloseHandle(ProcInfo.hThread); 293 //dwErr = WaitForSingleObject(ProcInfo.hProcess, INFINITE); 294 //assert(dwErr == WAIT_OBJECT_0); 295 // 296 //if (GetExitCodeProcess(ProcInfo.hProcess, &dwExitCode)) 297 //{ 298 // CloseHandle(ProcInfo.hProcess); 299 // _exit(dwExitCode); 300 //} 301 //errno = EINVAL; 297 CloseHandle(ProcInfo.hThread); 298 CloseHandle(ProcInfo.hProcess); 299 if (phProcess) 300 *phProcess = ProcInfo.dwProcessId; 301 rc = VINF_SUCCESS; 302 302 } 303 else 304 rc = RTErrConvertFromWin32(GetLastError()); 303 305 304 306 if (hToken == INVALID_HANDLE_VALUE)
Note:
See TracChangeset
for help on using the changeset viewer.