Changeset 27475 in vbox for trunk/src/VBox/Runtime/r3/win/process-win.cpp
- Timestamp:
- Mar 18, 2010 11:04:07 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/win/process-win.cpp
r27473 r27475 94 94 LPSTARTUPINFOW, 95 95 LPPROCESS_INFORMATION); 96 97 96 typedef CREATEPROCESSWITHLOGON *PCREATEPROCESSWITHLOGON; 98 97 … … 322 321 if (fRc) 323 322 { 324 PROFILEINFOW profileInfo; 325 RT_ZERO(profileInfo); 326 profileInfo.dwSize = sizeof(PROFILEINFOW); 327 profileInfo.lpUserName = pwszUser; 328 fRc = LoadUserProfileW(hToken, &profileInfo); 329 if (fRc) 323 fRc = CreateProcessAsUserW(hToken, 324 pwszExec, 325 pwszCmdLine, 326 NULL, /* pProcessAttributes */ 327 NULL, /* pThreadAttributes */ 328 TRUE, /* fInheritHandles */ 329 CREATE_UNICODE_ENVIRONMENT, /* dwCreationFlags */ 330 pwszzBlock, 331 NULL, /* pCurrentDirectory */ 332 &StartupInfo, 333 &ProcInfo); 334 if (!fRc) 330 335 { 331 fRc = CreateProcessAsUserW(hToken, 332 pwszExec, 333 pwszCmdLine, 334 NULL, /* pProcessAttributes */ 335 NULL, /* pThreadAttributes */ 336 TRUE, /* fInheritHandles */ 337 CREATE_UNICODE_ENVIRONMENT, /* dwCreationFlags */ 338 pwszzBlock, 339 NULL, /* pCurrentDirectory */ 340 &StartupInfo, 341 &ProcInfo); 342 if (!fRc) 336 DWORD dwErr = GetLastError(); 337 338 /* 339 * If we don't hold enough priviledges to spawn a new 340 * process with different credentials we have to use 341 * CreateProcessWithLogonW here. 342 * 343 * Note that NT4 does *not* support this API, thus we have 344 * to load it dynamically (W2K+) to not blow up things. 345 * 346 * @todo Use fFlags to either use this feature or just fail. 347 */ 348 if (ERROR_PRIVILEGE_NOT_HELD == dwErr) 343 349 { 344 DWORD dwErr = GetLastError(); 345 346 /* 347 * If we don't hold enough priviledges to spawn a new 348 * process with different credentials we have to use 349 * CreateProcessWithLogonW here. 350 * 351 * Note that NT4 does *not* support this API, thus we have 352 * to load it dynamically (W2K+) to not blow up things. 353 * 354 * @todo Use fFlags to either use this feature or just fail. 355 */ 356 if (ERROR_PRIVILEGE_NOT_HELD == dwErr) 350 #if 0 351 PROFILEINFOW profileInfo; 352 RT_ZERO(profileInfo); 353 profileInfo.dwSize = sizeof(PROFILEINFOW); 354 profileInfo.lpUserName = pwszUser; 355 fRc = LoadUserProfileW(hToken, &profileInfo); 356 357 RTLDRMOD modAdvAPI32; 358 rc = RTLdrLoad("Advapi32.dll", &modAdvAPI32); 359 PCREATEPROCESSWITHLOGON pfnCreateProcessWithLogonW; 360 if (RT_SUCCESS(rc)) 357 361 { 358 #if 0 359 RTLDRMOD modAdvAPI32; 360 rc = RTLdrLoad("Advapi32.dll", &modAdvAPI32); 361 PCREATEPROCESSWITHLOGON pfnCreateProcessWithLogonW; 362 rc = RTLdrGetSymbol(modAdvAPI32, "CreateProcessWithLogonW", (void**)&pfnCreateProcessWithLogonW); 362 363 if (RT_SUCCESS(rc)) 363 364 { 364 rc = RTLdrGetSymbol(modAdvAPI32, "CreateProcessWithLogonW", (void**)&pfnCreateProcessWithLogonW); 365 if (RT_SUCCESS(rc)) 365 #endif 366 fRc = ImpersonateLoggedOnUser(hToken); 367 if (fRc) 366 368 { 369 fRc = CreateProcessW(pwszExec, 370 pwszCmdLine, 371 NULL, /* pProcessAttributes */ 372 NULL, /* pThreadAttributes */ 373 TRUE, /* fInheritHandles */ 374 CREATE_UNICODE_ENVIRONMENT, /* dwCreationFlags */ 375 pwszzBlock, 376 NULL, /* pCurrentDirectory */ 377 &StartupInfo, 378 &ProcInfo); 379 RevertToSelf(); 380 } 381 #if 0 382 fRc = pfnCreateProcessWithLogonW(pwszUser, 383 NULL, /* lpDomain*/ 384 pwszPassword, 385 0 /*LOGON_WITH_PROFILE*/, /* dwLogonFlags */ 386 pwszExec, 387 pwszCmdLine, 388 CREATE_UNICODE_ENVIRONMENT, /* dwCreationFlags */ 389 pwszzBlock, 390 NULL, /* pCurrentDirectory */ 391 &StartupInfo, 392 &ProcInfo); 393 } 394 RTLdrClose(modAdvAPI32); 395 } 367 396 #endif 368 fRc = ImpersonateLoggedOnUser(hToken);369 if (fRc)370 {371 fRc = CreateProcessW(pwszExec,372 pwszCmdLine,373 NULL, /* pProcessAttributes */374 NULL, /* pThreadAttributes */375 TRUE, /* fInheritHandles */376 CREATE_UNICODE_ENVIRONMENT, /* dwCreationFlags */377 pwszzBlock,378 NULL, /* pCurrentDirectory */379 &StartupInfo,380 &ProcInfo);381 RevertToSelf();382 }383 #if 0384 fRc = pfnCreateProcessWithLogonW(pwszUser,385 NULL, /* lpDomain*/386 pwszPassword,387 0 /*LOGON_WITH_PROFILE*/, /* dwLogonFlags */388 pwszExec,389 pwszCmdLine,390 CREATE_UNICODE_ENVIRONMENT, /* dwCreationFlags */391 pwszzBlock,392 NULL, /* pCurrentDirectory */393 &StartupInfo,394 &ProcInfo);395 }396 RTLdrClose(modAdvAPI32);397 }398 #endif399 }400 397 } 401 398 }
Note:
See TracChangeset
for help on using the changeset viewer.