1 |
|
---|
2 | /* $Id: GuestProcessImpl.cpp 42105 2012-07-11 11:53:22Z vboxsync $ */
|
---|
3 | /** @file
|
---|
4 | * VirtualBox Main - XXX.
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2012 Oracle Corporation
|
---|
9 | *
|
---|
10 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | * available from http://www.virtualbox.org. This file is free software;
|
---|
12 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | * General Public License (GPL) as published by the Free Software
|
---|
14 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | */
|
---|
18 |
|
---|
19 |
|
---|
20 | /*******************************************************************************
|
---|
21 | * Header Files *
|
---|
22 | *******************************************************************************/
|
---|
23 | #include "GuestProcessImpl.h"
|
---|
24 |
|
---|
25 | #include "Global.h"
|
---|
26 | #include "AutoCaller.h"
|
---|
27 | #include "Logging.h"
|
---|
28 |
|
---|
29 |
|
---|
30 | // constructor / destructor
|
---|
31 | /////////////////////////////////////////////////////////////////////////////
|
---|
32 |
|
---|
33 | DEFINE_EMPTY_CTOR_DTOR(GuestProcess)
|
---|
34 |
|
---|
35 | HRESULT GuestProcess::FinalConstruct(void)
|
---|
36 | {
|
---|
37 | LogFlowThisFunc(("\n"));
|
---|
38 | return BaseFinalConstruct();
|
---|
39 | }
|
---|
40 |
|
---|
41 | void GuestProcess::FinalRelease(void)
|
---|
42 | {
|
---|
43 | LogFlowThisFuncEnter();
|
---|
44 | uninit();
|
---|
45 | BaseFinalRelease();
|
---|
46 | LogFlowThisFuncLeave();
|
---|
47 | }
|
---|
48 |
|
---|
49 | // public initializer/uninitializer for internal purposes only
|
---|
50 | /////////////////////////////////////////////////////////////////////////////
|
---|
51 |
|
---|
52 | int GuestProcess::init(GuestSession *pSession,
|
---|
53 | const Utf8Str &aCommand, ComSafeArrayIn(Utf8Str, aArguments), ComSafeArrayIn(Utf8Str, aEnvironment),
|
---|
54 | ComSafeArrayIn(ProcessCreateFlag_T, aFlags), ULONG aTimeoutMS,
|
---|
55 | ProcessPriority_T aPriority, ComSafeArrayIn(LONG, aAffinity))
|
---|
56 | {
|
---|
57 | /* Enclose the state transition NotReady->InInit->Ready. */
|
---|
58 | AutoInitSpan autoInitSpan(this);
|
---|
59 | AssertReturn(autoInitSpan.isOk(), VERR_OBJECT_DESTROYED);
|
---|
60 |
|
---|
61 | int rc = VINF_SUCCESS;
|
---|
62 |
|
---|
63 | mData.mParent = pSession;
|
---|
64 |
|
---|
65 | /* Confirm a successful initialization when it's the case. */
|
---|
66 | if (RT_SUCCESS(rc))
|
---|
67 | autoInitSpan.setSucceeded();
|
---|
68 |
|
---|
69 | return S_OK;
|
---|
70 | }
|
---|
71 |
|
---|
72 | /**
|
---|
73 | * Uninitializes the instance.
|
---|
74 | * Called from FinalRelease().
|
---|
75 | */
|
---|
76 | void GuestProcess::uninit(void)
|
---|
77 | {
|
---|
78 | LogFlowThisFunc(("\n"));
|
---|
79 |
|
---|
80 | /* Enclose the state transition Ready->InUninit->NotReady. */
|
---|
81 | AutoUninitSpan autoUninitSpan(this);
|
---|
82 | if (autoUninitSpan.uninitDone())
|
---|
83 | return;
|
---|
84 | }
|
---|
85 |
|
---|
86 | // implementation of public getters/setters for attributes
|
---|
87 | /////////////////////////////////////////////////////////////////////////////
|
---|
88 |
|
---|
89 | STDMETHODIMP GuestProcess::COMGETTER(Arguments)(ComSafeArrayOut(BSTR, aArguments))
|
---|
90 | {
|
---|
91 | #ifndef VBOX_WITH_GUEST_CONTROL
|
---|
92 | ReturnComNotImplemented();
|
---|
93 | #else
|
---|
94 | AutoCaller autoCaller(this);
|
---|
95 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
96 |
|
---|
97 | CheckComArgOutSafeArrayPointerValid(aArguments);
|
---|
98 |
|
---|
99 | ReturnComNotImplemented();
|
---|
100 | #endif /* VBOX_WITH_GUEST_CONTROL */
|
---|
101 | }
|
---|
102 |
|
---|
103 | STDMETHODIMP GuestProcess::COMGETTER(Environment)(ComSafeArrayOut(BSTR, aEnvironment))
|
---|
104 | {
|
---|
105 | #ifndef VBOX_WITH_GUEST_CONTROL
|
---|
106 | ReturnComNotImplemented();
|
---|
107 | #else
|
---|
108 | AutoCaller autoCaller(this);
|
---|
109 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
110 |
|
---|
111 | CheckComArgOutSafeArrayPointerValid(aEnvironment);
|
---|
112 |
|
---|
113 | ReturnComNotImplemented();
|
---|
114 | #endif /* VBOX_WITH_GUEST_CONTROL */
|
---|
115 | }
|
---|
116 |
|
---|
117 | STDMETHODIMP GuestProcess::COMGETTER(ExecutablePath)(BSTR *aExecutablePath)
|
---|
118 | {
|
---|
119 | #ifndef VBOX_WITH_GUEST_CONTROL
|
---|
120 | ReturnComNotImplemented();
|
---|
121 | #else
|
---|
122 | AutoCaller autoCaller(this);
|
---|
123 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
124 |
|
---|
125 | ReturnComNotImplemented();
|
---|
126 | #endif /* VBOX_WITH_GUEST_CONTROL */
|
---|
127 | }
|
---|
128 |
|
---|
129 | STDMETHODIMP GuestProcess::COMGETTER(ExitCode)(LONG *aExitCode)
|
---|
130 | {
|
---|
131 | #ifndef VBOX_WITH_GUEST_CONTROL
|
---|
132 | ReturnComNotImplemented();
|
---|
133 | #else
|
---|
134 | AutoCaller autoCaller(this);
|
---|
135 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
136 |
|
---|
137 | ReturnComNotImplemented();
|
---|
138 | #endif /* VBOX_WITH_GUEST_CONTROL */
|
---|
139 | }
|
---|
140 |
|
---|
141 | STDMETHODIMP GuestProcess::COMGETTER(Pid)(ULONG *aPID)
|
---|
142 | {
|
---|
143 | #ifndef VBOX_WITH_GUEST_CONTROL
|
---|
144 | ReturnComNotImplemented();
|
---|
145 | #else
|
---|
146 | AutoCaller autoCaller(this);
|
---|
147 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
148 |
|
---|
149 | ReturnComNotImplemented();
|
---|
150 | #endif /* VBOX_WITH_GUEST_CONTROL */
|
---|
151 | }
|
---|
152 |
|
---|
153 | STDMETHODIMP GuestProcess::COMGETTER(Status)(ProcessStatus_T *aStatus)
|
---|
154 | {
|
---|
155 | #ifndef VBOX_WITH_GUEST_CONTROL
|
---|
156 | ReturnComNotImplemented();
|
---|
157 | #else
|
---|
158 | AutoCaller autoCaller(this);
|
---|
159 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
160 |
|
---|
161 | ReturnComNotImplemented();
|
---|
162 | #endif /* VBOX_WITH_GUEST_CONTROL */
|
---|
163 | }
|
---|
164 |
|
---|
165 | // implementation of public methods
|
---|
166 | /////////////////////////////////////////////////////////////////////////////
|
---|
167 |
|
---|
168 | STDMETHODIMP GuestProcess::Read(ULONG aHandle, ULONG aSize, ULONG aTimeoutMS, ComSafeArrayOut(BYTE, aData))
|
---|
169 | {
|
---|
170 | #ifndef VBOX_WITH_GUEST_CONTROL
|
---|
171 | ReturnComNotImplemented();
|
---|
172 | #else
|
---|
173 | AutoCaller autoCaller(this);
|
---|
174 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
175 |
|
---|
176 | ReturnComNotImplemented();
|
---|
177 | #endif /* VBOX_WITH_GUEST_CONTROL */
|
---|
178 | }
|
---|
179 |
|
---|
180 | STDMETHODIMP GuestProcess::Terminate(void)
|
---|
181 | {
|
---|
182 | #ifndef VBOX_WITH_GUEST_CONTROL
|
---|
183 | ReturnComNotImplemented();
|
---|
184 | #else
|
---|
185 | AutoCaller autoCaller(this);
|
---|
186 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
187 |
|
---|
188 | ReturnComNotImplemented();
|
---|
189 | #endif /* VBOX_WITH_GUEST_CONTROL */
|
---|
190 | }
|
---|
191 |
|
---|
192 | STDMETHODIMP GuestProcess::WaitFor(ComSafeArrayIn(ProcessWaitForFlag_T, aFlags), ULONG aTimeoutMS, ProcessWaitReason_T *aReason)
|
---|
193 | {
|
---|
194 | #ifndef VBOX_WITH_GUEST_CONTROL
|
---|
195 | ReturnComNotImplemented();
|
---|
196 | #else
|
---|
197 | AutoCaller autoCaller(this);
|
---|
198 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
199 |
|
---|
200 | ReturnComNotImplemented();
|
---|
201 | #endif /* VBOX_WITH_GUEST_CONTROL */
|
---|
202 | }
|
---|
203 |
|
---|
204 | STDMETHODIMP GuestProcess::Write(ULONG aHandle, ComSafeArrayIn(BYTE, aData), ULONG aTimeoutMS, ULONG *aWritten)
|
---|
205 | {
|
---|
206 | #ifndef VBOX_WITH_GUEST_CONTROL
|
---|
207 | ReturnComNotImplemented();
|
---|
208 | #else
|
---|
209 | AutoCaller autoCaller(this);
|
---|
210 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
211 |
|
---|
212 | ReturnComNotImplemented();
|
---|
213 | #endif /* VBOX_WITH_GUEST_CONTROL */
|
---|
214 | }
|
---|
215 |
|
---|