Changeset 27741 in vbox for trunk/src/VBox
- Timestamp:
- Mar 26, 2010 1:45:10 PM (15 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/GuestImpl.cpp
r27712 r27741 32 32 33 33 #include <VBox/VMMDev.h> 34 #ifdef VBOX_WITH_GUEST_CONTROL 35 # include <VBox/HostServices/GuestControlSvc.h> 36 # include <VBox/com/array.h> 37 #endif 34 38 #include <iprt/cpp/utils.h> 35 39 … … 308 312 } 309 313 314 HRESULT Guest::prepareExecuteArgs(ComSafeArrayIn(IN_BSTR, aArguments), 315 char **ppszArgv, uint32_t *pcbList, uint32_t *pcArgs) 316 { 317 com::SafeArray<IN_BSTR> args(ComSafeArrayInArg(aArguments)); 318 char *pszArgs; 319 const char *pszCurArg; 320 321 HRESULT rc = S_OK; 322 int vrc = VINF_SUCCESS; 323 324 for (unsigned i = 0; i < args.size(); ++i) 325 { 326 if (i > 0) /* Insert space as delimiter. */ 327 vrc = RTStrAAppendN(&pszArgs, " ", 1); 328 if (RT_SUCCESS(vrc)) 329 { 330 pszCurArg = Utf8Str(args[i]).raw(); 331 vrc = RTStrAAppendN(&pszArgs, pszCurArg, strlen(pszCurArg)); 332 } 333 if (RT_FAILURE(vrc)) 334 break; 335 } 336 337 if (RT_SUCCESS(rc)) 338 { 339 *ppszArgv = pszArgs; 340 *pcArgs = args.size(); 341 *pcbList = strlen(pszArgs) + 1; /* Include zero termination. */ 342 } 343 else 344 { 345 rc = setError(E_UNEXPECTED, 346 tr("The service call failed with the error %Rrc"), 347 vrc); 348 } 349 return rc; 350 } 351 352 HRESULT Guest::prepareExecuteEnv(ComSafeArrayIn(IN_BSTR, aEnvironment), 353 void **ppvList, uint32_t *pcbList, uint32_t *pcEnv) 354 { 355 com::SafeArray<IN_BSTR> env(ComSafeArrayInArg(aEnvironment)); 356 const char *pszCurEnv; 357 for (unsigned i = 0; i < env.size(); ++i) 358 { 359 } 360 361 return S_OK; 362 } 363 310 364 STDMETHODIMP Guest::ExecuteProgram(IN_BSTR aExecName, ULONG aFlags, 311 365 ComSafeArrayIn(IN_BSTR, aArguments), ComSafeArrayIn(IN_BSTR, aEnvironment), … … 317 371 ReturnComNotImplemented(); 318 372 #else /* VBOX_WITH_GUEST_CONTROL */ 373 using namespace guestControl; 374 319 375 CheckComArgStrNotEmptyOrNull(aExecName); 320 376 CheckComArgOutPointerValid(aPID); 321 return E_NOTIMPL; 322 #endif 377 /* Flags are not supported at the moment. */ 378 if (aFlags != 0) 379 return E_INVALIDARG; 380 381 HRESULT rc = S_OK; 382 383 try 384 { 385 AutoCaller autoCaller(this); 386 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 387 388 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 389 390 /* Just be on the safe side when calling another process. */ 391 alock.leave(); 392 393 HRESULT rc = E_UNEXPECTED; 394 using namespace guestControl; 395 396 int vrc = VINF_SUCCESS; 397 Utf8Str Utf8ExecName(aExecName); 398 399 /* Prepare arguments. */ 400 char *pszArgs; 401 uint32_t cNumArgs; 402 uint32_t cbArgs; 403 rc = prepareExecuteArgs(aArguments, 404 &pszArgs, &cbArgs, &cNumArgs); 405 if (SUCCEEDED(rc)) 406 { 407 /* Prepare environment. */ 408 /** @todo */ 409 if (SUCCEEDED(rc)) 410 { 411 Utf8Str Utf8StdIn(aStdIn); 412 Utf8Str Utf8StdOut(aStdOut); 413 Utf8Str Utf8StdErr(aStdErr); 414 Utf8Str Utf8UserName(aUserName); 415 Utf8Str Utf8Password(aPassword); 416 417 /* Call the stub which does the actual work. */ 418 if (RT_SUCCESS(vrc)) 419 { 420 VBOXHGCMSVCPARM paParms[13]; 421 uint32_t cParms = 13; 422 423 /* Forward the information to the VMM device. */ 424 AssertPtr(mParent); 425 VMMDev *vmmDev = mParent->getVMMDev(); 426 if (vmmDev) 427 { 428 vrc = vmmDev->hgcmHostCall("VBoxGuestControlSvc", HOST_EXEC_CMD, 429 cParms, &paParms[0]); 430 } 431 } 432 //RTMemFree(pszEnv); 433 } 434 RTStrFree(pszArgs); 435 } 436 if (RT_SUCCESS(vrc)) 437 rc = S_OK; 438 else 439 rc = setError(E_UNEXPECTED, 440 tr("The service call failed with the error %Rrc"), 441 vrc); 442 } 443 catch (std::bad_alloc &) 444 { 445 rc = E_OUTOFMEMORY; 446 }; 447 448 return rc; 449 #endif /* VBOX_WITH_GUEST_CONTROL */ 323 450 } 324 451 -
trunk/src/VBox/Main/Makefile.kmk
r27129 r27741 65 65 $(if $(VBOX_WITH_GUEST_PROPS),VBOX_WITH_GUEST_PROPS,) \ 66 66 $(if $(VBOX_WITH_GUEST_PROPS_RDONLY_GUEST),VBOX_WITH_GUEST_PROPS_RDONLY_GUEST,) \ 67 $(if $(VBOX_WITH_GUEST_CONTROL),VBOX_WITH_GUEST_CONTROL,) \ 67 68 $(if $(VBOX_WITH_HOSTNETIF_API),VBOX_WITH_HOSTNETIF_API,) 68 69 -
trunk/src/VBox/Main/include/GuestImpl.h
r27707 r27741 92 92 private: 93 93 94 HRESULT prepareExecuteArgs(ComSafeArrayIn(IN_BSTR, aArguments), 95 char **ppszArgv, uint32_t *pcbList, uint32_t *pcArgs); 96 97 HRESULT prepareExecuteEnv(ComSafeArrayIn(IN_BSTR, aEnvironment), 98 void **ppvList, uint32_t *pcbList, uint32_t *pcEnv); 99 94 100 struct Data 95 101 {
Note:
See TracChangeset
for help on using the changeset viewer.