VirtualBox IGuestSession::ProcessCreate returns 0x8000FFFF (E_UNEXPECTED)

2

So I'm trying to execute a process in the guest session from the host, but I keep getting a 0x8000FFFF (E_UNEXPECTED) HRESULT from it. Since I'm getting a COM error rather than VBOX_E_IPRT_ERROR it makes me think my SAFEARRAYs are the issue and not the actual parameters if that makes sense. I'm not too familiar with COM, so it might just be a case of me using SAFEARRAY wrong. Either way, here's the code I'm trying right now:

SAFEARRAY  *args_and_env, *creation_flags;
SAFEARRAYBOUND arrayDim[1];
arrayDim[0].lLbound= 0;
arrayDim[0].cElements= 1;

args_and_env = SafeArrayCreate(VT_LPWSTR,1,arrayDim);
SafeArrayPutElement(args_and_env, 0, L"");

creation_flags = SafeArrayCreate(VT_INT, 1, arrayDim);
int flag = ProcessCreateFlag_None;
SafeArrayPutElement(creation_flags, 0, &flag);

IGuestProcess *proca;
rc = guestSession->ProcessCreate(proc, args_and_env, args_and_env, creation_flags, 0, &proca);

Documentation for IGuestSession::ProcessCreate is as following:

IGuestProcess IGuestSession::processCreate(
[in] wstring executable,
[in] wstring arguments[],
[in] wstring environmentChanges[],
[in] ProcessCreateFlag flags[],
[in] unsigned long timeoutMS)

And the function declaration is as following:

HRESULT STDMETHODCALLTYPE ProcessCreate( 
/* [in] */ BSTR aExecutable,
/* [in] */ SAFEARRAY * aArguments,
/* [in] */ SAFEARRAY * aEnvironmentChanges,
/* [in] */ SAFEARRAY * aFlags,
/* [in] */ ULONG aTimeoutMS,
/* [retval][out] */ IGuestProcess **aGuestProcess)

I've also tried passing NULL to both arguments and environmentChanges as I'm not looking to use any of them, but with the same result.

c++
com
virtualbox
safearray
asked on Stack Overflow Oct 18, 2015 by Maddnias

1 Answer

0

When i tested my task i realized that this problem can be if you use session OS without password. You have to set password and create session with password:

BSTR login = ...;
BSTR passsword = ...;
BSTR empty = SysAllocString(L"");
HRESULT rc = guest->CreateSession(login, password, empty, sessionName, &guestSession); 

And then create a guest process

answered on Stack Overflow Apr 30, 2019 by Range

User contributions licensed under CC BY-SA 3.0