1 | /* $Id: VBoxGuestR3LibGuestCtrl.cpp 71364 2018-03-16 09:58:05Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxGuestR3Lib - Ring-3 Support Library for VirtualBox guest additions, guest control.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2010-2017 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * The contents of this file may alternatively be used under the terms
|
---|
18 | * of the Common Development and Distribution License Version 1.0
|
---|
19 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
20 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
21 | * CDDL are applicable instead of those of the GPL.
|
---|
22 | *
|
---|
23 | * You may elect to license modified versions of this file under the
|
---|
24 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
25 | */
|
---|
26 |
|
---|
27 |
|
---|
28 | /*********************************************************************************************************************************
|
---|
29 | * Header Files *
|
---|
30 | *********************************************************************************************************************************/
|
---|
31 | #include <iprt/string.h>
|
---|
32 | #include <iprt/mem.h>
|
---|
33 | #include <iprt/assert.h>
|
---|
34 | #include <iprt/cpp/autores.h>
|
---|
35 | #include <iprt/stdarg.h>
|
---|
36 | #include <VBox/log.h>
|
---|
37 | #include <VBox/HostServices/GuestControlSvc.h>
|
---|
38 |
|
---|
39 | #include "VBoxGuestR3LibInternal.h"
|
---|
40 |
|
---|
41 | using namespace guestControl;
|
---|
42 |
|
---|
43 |
|
---|
44 | /**
|
---|
45 | * Connects to the guest control service.
|
---|
46 | *
|
---|
47 | * @returns VBox status code
|
---|
48 | * @param pidClient Where to put The client ID on success. The client ID
|
---|
49 | * must be passed to all the other calls to the service.
|
---|
50 | */
|
---|
51 | VBGLR3DECL(int) VbglR3GuestCtrlConnect(uint32_t *pidClient)
|
---|
52 | {
|
---|
53 | return VbglR3HGCMConnect("VBoxGuestControlSvc", pidClient);
|
---|
54 | }
|
---|
55 |
|
---|
56 |
|
---|
57 | /**
|
---|
58 | * Disconnect from the guest control service.
|
---|
59 | *
|
---|
60 | * @returns VBox status code.
|
---|
61 | * @param idClient The client ID returned by VbglR3GuestCtrlConnect().
|
---|
62 | */
|
---|
63 | VBGLR3DECL(int) VbglR3GuestCtrlDisconnect(uint32_t idClient)
|
---|
64 | {
|
---|
65 | return VbglR3HGCMDisconnect(idClient);
|
---|
66 | }
|
---|
67 |
|
---|
68 |
|
---|
69 | /**
|
---|
70 | * Waits until a new host message arrives.
|
---|
71 | * This will block until a message becomes available.
|
---|
72 | *
|
---|
73 | * @returns VBox status code.
|
---|
74 | * @param uClientId The client ID returned by VbglR3GuestCtrlConnect().
|
---|
75 | * @param pidMsg Where to store the message id.
|
---|
76 | * @param pcParameters Where to store the number of parameters which will
|
---|
77 | * be received in a second call to the host.
|
---|
78 | */
|
---|
79 | VBGLR3DECL(int) VbglR3GuestCtrlMsgWaitFor(uint32_t uClientId, uint32_t *pidMsg, uint32_t *pcParameters)
|
---|
80 | {
|
---|
81 | AssertPtrReturn(pidMsg, VERR_INVALID_POINTER);
|
---|
82 | AssertPtrReturn(pcParameters, VERR_INVALID_POINTER);
|
---|
83 |
|
---|
84 | HGCMMsgCmdWaitFor Msg;
|
---|
85 | VBGL_HGCM_HDR_INIT(&Msg.hdr, uClientId,
|
---|
86 | GUEST_MSG_WAIT, /* Tell the host we want our next command. */
|
---|
87 | 2); /* Just peek for the next message! */
|
---|
88 | VbglHGCMParmUInt32Set(&Msg.msg, 0);
|
---|
89 | VbglHGCMParmUInt32Set(&Msg.num_parms, 0);
|
---|
90 |
|
---|
91 | /*
|
---|
92 | * We should always get a VERR_TOO_MUCH_DATA response here, see
|
---|
93 | * guestControl::HostCommand::Peek() and its caller ClientState::SendReply().
|
---|
94 | * We accept success too here, in case someone decide to make the protocol
|
---|
95 | * slightly more sane.
|
---|
96 | *
|
---|
97 | * Note! A really sane protocol design would have a separate call for getting
|
---|
98 | * info about a pending message (returning VINF_SUCCESS), and a separate
|
---|
99 | * one for retriving the actual message parameters. Not this weird
|
---|
100 | * stuff, to put it rather bluntly.
|
---|
101 | */
|
---|
102 | int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
|
---|
103 | if ( rc == VERR_TOO_MUCH_DATA
|
---|
104 | || RT_SUCCESS(rc))
|
---|
105 | {
|
---|
106 | int rc2 = VbglHGCMParmUInt32Get(&Msg.msg, pidMsg);
|
---|
107 | if (RT_SUCCESS(rc2))
|
---|
108 | {
|
---|
109 | rc2 = VbglHGCMParmUInt32Get(&Msg.num_parms, pcParameters);
|
---|
110 | if (RT_SUCCESS(rc2))
|
---|
111 | {
|
---|
112 | /* Ok, so now we know what message type and how much parameters there are. */
|
---|
113 | return rc;
|
---|
114 | }
|
---|
115 | }
|
---|
116 | rc = rc2;
|
---|
117 | }
|
---|
118 | *pidMsg = UINT32_MAX - 1;
|
---|
119 | *pcParameters = UINT32_MAX - 2;
|
---|
120 | return rc;
|
---|
121 | }
|
---|
122 |
|
---|
123 |
|
---|
124 | /**
|
---|
125 | * Asks the host guest control service to set a command filter to this
|
---|
126 | * client so that it only will receive certain commands in the future.
|
---|
127 | * The filter(s) are a bitmask for the context IDs, served from the host.
|
---|
128 | *
|
---|
129 | * @return IPRT status code.
|
---|
130 | * @param uClientId The client ID returned by VbglR3GuestCtrlConnect().
|
---|
131 | * @param uValue The value to filter messages for.
|
---|
132 | * @param uMaskAdd Filter mask to add.
|
---|
133 | * @param uMaskRemove Filter mask to remove.
|
---|
134 | */
|
---|
135 | VBGLR3DECL(int) VbglR3GuestCtrlMsgFilterSet(uint32_t uClientId, uint32_t uValue,
|
---|
136 | uint32_t uMaskAdd, uint32_t uMaskRemove)
|
---|
137 | {
|
---|
138 | HGCMMsgCmdFilterSet Msg;
|
---|
139 |
|
---|
140 | /* Tell the host we want to set a filter. */
|
---|
141 | VBGL_HGCM_HDR_INIT(&Msg.hdr, uClientId, GUEST_MSG_FILTER_SET, 4);
|
---|
142 | VbglHGCMParmUInt32Set(&Msg.value, uValue);
|
---|
143 | VbglHGCMParmUInt32Set(&Msg.mask_add, uMaskAdd);
|
---|
144 | VbglHGCMParmUInt32Set(&Msg.mask_remove, uMaskRemove);
|
---|
145 | VbglHGCMParmUInt32Set(&Msg.flags, 0 /* Flags, unused */);
|
---|
146 |
|
---|
147 | return VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
|
---|
148 | }
|
---|
149 |
|
---|
150 |
|
---|
151 | /**
|
---|
152 | * Disables a previously set message filter.
|
---|
153 | *
|
---|
154 | * @return IPRT status code.
|
---|
155 | * @param uClientId The client ID returned by VbglR3GuestCtrlConnect().
|
---|
156 | */
|
---|
157 | VBGLR3DECL(int) VbglR3GuestCtrlMsgFilterUnset(uint32_t uClientId)
|
---|
158 | {
|
---|
159 | /* Tell the host we want to unset the filter. */
|
---|
160 | HGCMMsgCmdFilterUnset Msg;
|
---|
161 | VBGL_HGCM_HDR_INIT(&Msg.hdr, uClientId, GUEST_MSG_FILTER_UNSET, 1);
|
---|
162 | VbglHGCMParmUInt32Set(&Msg.flags, 0 /* Flags, unused */);
|
---|
163 |
|
---|
164 | return VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
|
---|
165 | }
|
---|
166 |
|
---|
167 |
|
---|
168 | VBGLR3DECL(int) VbglR3GuestCtrlMsgReply(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
169 | int rc)
|
---|
170 | {
|
---|
171 | return VbglR3GuestCtrlMsgReplyEx(pCtx, rc, 0 /* uType */,
|
---|
172 | NULL /* pvPayload */, 0 /* cbPayload */);
|
---|
173 | }
|
---|
174 |
|
---|
175 |
|
---|
176 | VBGLR3DECL(int) VbglR3GuestCtrlMsgReplyEx(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
177 | int rc, uint32_t uType,
|
---|
178 | void *pvPayload, uint32_t cbPayload)
|
---|
179 | {
|
---|
180 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
181 | /* Everything else is optional. */
|
---|
182 |
|
---|
183 | HGCMMsgCmdReply Msg;
|
---|
184 | VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_REPLY, 4);
|
---|
185 | VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
|
---|
186 | VbglHGCMParmUInt32Set(&Msg.rc, (uint32_t)rc); /* int vs. uint32_t */
|
---|
187 | VbglHGCMParmUInt32Set(&Msg.type, uType);
|
---|
188 | VbglHGCMParmPtrSet(&Msg.payload, pvPayload, cbPayload);
|
---|
189 |
|
---|
190 | return VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
|
---|
191 | }
|
---|
192 |
|
---|
193 |
|
---|
194 | /**
|
---|
195 | * Tells the host service to skip the current message returned by
|
---|
196 | * VbglR3GuestCtrlMsgWaitFor().
|
---|
197 | *
|
---|
198 | * @return IPRT status code.
|
---|
199 | * @param uClientId The client ID returned by VbglR3GuestCtrlConnect().
|
---|
200 | */
|
---|
201 | VBGLR3DECL(int) VbglR3GuestCtrlMsgSkip(uint32_t uClientId)
|
---|
202 | {
|
---|
203 | HGCMMsgCmdSkip Msg;
|
---|
204 |
|
---|
205 | /* Tell the host we want to skip the current assigned command. */
|
---|
206 | VBGL_HGCM_HDR_INIT(&Msg.hdr, uClientId, GUEST_MSG_SKIP, 1);
|
---|
207 | VbglHGCMParmUInt32Set(&Msg.flags, 0 /* Flags, unused */);
|
---|
208 | return VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
|
---|
209 | }
|
---|
210 |
|
---|
211 |
|
---|
212 | /**
|
---|
213 | * Asks the host to cancel (release) all pending waits which were deferred.
|
---|
214 | *
|
---|
215 | * @returns VBox status code.
|
---|
216 | * @param uClientId The client ID returned by VbglR3GuestCtrlConnect().
|
---|
217 | */
|
---|
218 | VBGLR3DECL(int) VbglR3GuestCtrlCancelPendingWaits(uint32_t uClientId)
|
---|
219 | {
|
---|
220 | HGCMMsgCancelPendingWaits Msg;
|
---|
221 | VBGL_HGCM_HDR_INIT(&Msg.hdr, uClientId, GUEST_CANCEL_PENDING_WAITS, 0);
|
---|
222 | return VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
|
---|
223 | }
|
---|
224 |
|
---|
225 |
|
---|
226 | /**
|
---|
227 | * Asks a specific guest session to close.
|
---|
228 | *
|
---|
229 | * @return IPRT status code.
|
---|
230 | * @param pCtx Host context.
|
---|
231 | * @param fFlags Some kind of flag. Figure it out yourself.
|
---|
232 | ** @todo Docs!
|
---|
233 | */
|
---|
234 | VBGLR3DECL(int) VbglR3GuestCtrlSessionClose(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t fFlags)
|
---|
235 | {
|
---|
236 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
237 | AssertReturn(pCtx->uNumParms == 2, VERR_INVALID_PARAMETER);
|
---|
238 |
|
---|
239 | HGCMMsgSessionClose Msg;
|
---|
240 | VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_SESSION_CLOSE, pCtx->uNumParms);
|
---|
241 | VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
|
---|
242 | VbglHGCMParmUInt32Set(&Msg.flags, fFlags);
|
---|
243 |
|
---|
244 | return VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
|
---|
245 | }
|
---|
246 |
|
---|
247 |
|
---|
248 | VBGLR3DECL(int) VbglR3GuestCtrlSessionNotify(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uType, uint32_t uResult)
|
---|
249 | {
|
---|
250 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
251 |
|
---|
252 | HGCMMsgSessionNotify Msg;
|
---|
253 | VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_SESSION_NOTIFY, 3);
|
---|
254 | VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
|
---|
255 | VbglHGCMParmUInt32Set(&Msg.type, uType);
|
---|
256 | VbglHGCMParmUInt32Set(&Msg.result, uResult);
|
---|
257 |
|
---|
258 | return VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
|
---|
259 | }
|
---|
260 |
|
---|
261 |
|
---|
262 | /**
|
---|
263 | * Retrieves the request to create a new guest session.
|
---|
264 | *
|
---|
265 | * @return IPRT status code.
|
---|
266 | ** @todo Docs!
|
---|
267 | */
|
---|
268 | VBGLR3DECL(int) VbglR3GuestCtrlSessionGetOpen(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
269 | uint32_t *puProtocol,
|
---|
270 | char *pszUser, uint32_t cbUser,
|
---|
271 | char *pszPassword, uint32_t cbPassword,
|
---|
272 | char *pszDomain, uint32_t cbDomain,
|
---|
273 | uint32_t *pfFlags, uint32_t *pidSession)
|
---|
274 | {
|
---|
275 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
276 | AssertReturn(pCtx->uNumParms == 6, VERR_INVALID_PARAMETER);
|
---|
277 |
|
---|
278 | AssertPtrReturn(puProtocol, VERR_INVALID_POINTER);
|
---|
279 | AssertPtrReturn(pszUser, VERR_INVALID_POINTER);
|
---|
280 | AssertPtrReturn(pszPassword, VERR_INVALID_POINTER);
|
---|
281 | AssertPtrReturn(pszDomain, VERR_INVALID_POINTER);
|
---|
282 | AssertPtrReturn(pfFlags, VERR_INVALID_POINTER);
|
---|
283 |
|
---|
284 | HGCMMsgSessionOpen Msg;
|
---|
285 | VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
|
---|
286 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
287 | VbglHGCMParmUInt32Set(&Msg.protocol, 0);
|
---|
288 | VbglHGCMParmPtrSet(&Msg.username, pszUser, cbUser);
|
---|
289 | VbglHGCMParmPtrSet(&Msg.password, pszPassword, cbPassword);
|
---|
290 | VbglHGCMParmPtrSet(&Msg.domain, pszDomain, cbDomain);
|
---|
291 | VbglHGCMParmUInt32Set(&Msg.flags, 0);
|
---|
292 |
|
---|
293 | int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
|
---|
294 | if (RT_SUCCESS(rc))
|
---|
295 | {
|
---|
296 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
297 | Msg.protocol.GetUInt32(puProtocol);
|
---|
298 | Msg.flags.GetUInt32(pfFlags);
|
---|
299 |
|
---|
300 | if (pidSession)
|
---|
301 | *pidSession = VBOX_GUESTCTRL_CONTEXTID_GET_SESSION(pCtx->uContextID);
|
---|
302 | }
|
---|
303 |
|
---|
304 | return rc;
|
---|
305 | }
|
---|
306 |
|
---|
307 |
|
---|
308 | /**
|
---|
309 | * Retrieves the request to terminate an existing guest session.
|
---|
310 | *
|
---|
311 | * @return IPRT status code.
|
---|
312 | ** @todo Docs!
|
---|
313 | */
|
---|
314 | VBGLR3DECL(int) VbglR3GuestCtrlSessionGetClose(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *pfFlags, uint32_t *pidSession)
|
---|
315 | {
|
---|
316 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
317 | AssertReturn(pCtx->uNumParms == 2, VERR_INVALID_PARAMETER);
|
---|
318 |
|
---|
319 | AssertPtrReturn(pfFlags, VERR_INVALID_POINTER);
|
---|
320 |
|
---|
321 | HGCMMsgSessionClose Msg;
|
---|
322 | VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
|
---|
323 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
324 | VbglHGCMParmUInt32Set(&Msg.flags, 0);
|
---|
325 |
|
---|
326 | int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
|
---|
327 | if (RT_SUCCESS(rc))
|
---|
328 | {
|
---|
329 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
330 | Msg.flags.GetUInt32(pfFlags);
|
---|
331 |
|
---|
332 | if (pidSession)
|
---|
333 | *pidSession = VBOX_GUESTCTRL_CONTEXTID_GET_SESSION(pCtx->uContextID);
|
---|
334 | }
|
---|
335 |
|
---|
336 | return rc;
|
---|
337 | }
|
---|
338 |
|
---|
339 |
|
---|
340 | VBGLR3DECL(int) VbglR3GuestCtrlPathGetRename(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
341 | char *pszSource, uint32_t cbSource,
|
---|
342 | char *pszDest, uint32_t cbDest,
|
---|
343 | uint32_t *pfFlags)
|
---|
344 | {
|
---|
345 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
346 | AssertReturn(pCtx->uNumParms == 4, VERR_INVALID_PARAMETER);
|
---|
347 |
|
---|
348 | AssertPtrReturn(pszSource, VERR_INVALID_POINTER);
|
---|
349 | AssertReturn(cbSource, VERR_INVALID_PARAMETER);
|
---|
350 | AssertPtrReturn(pszDest, VERR_INVALID_POINTER);
|
---|
351 | AssertReturn(cbDest, VERR_INVALID_PARAMETER);
|
---|
352 | AssertPtrReturn(pfFlags, VERR_INVALID_POINTER);
|
---|
353 |
|
---|
354 | HGCMMsgPathRename Msg;
|
---|
355 | VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
|
---|
356 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
357 | VbglHGCMParmPtrSet(&Msg.source, pszSource, cbSource);
|
---|
358 | VbglHGCMParmPtrSet(&Msg.dest, pszDest, cbDest);
|
---|
359 | VbglHGCMParmUInt32Set(&Msg.flags, 0);
|
---|
360 |
|
---|
361 | int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
|
---|
362 | if (RT_SUCCESS(rc))
|
---|
363 | {
|
---|
364 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
365 | Msg.flags.GetUInt32(pfFlags);
|
---|
366 | }
|
---|
367 | return rc;
|
---|
368 | }
|
---|
369 |
|
---|
370 |
|
---|
371 | VBGLR3DECL(int) VbglR3GuestCtrlPathGetUserDocuments(PVBGLR3GUESTCTRLCMDCTX pCtx)
|
---|
372 | {
|
---|
373 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
374 | AssertReturn(pCtx->uNumParms == 1, VERR_INVALID_PARAMETER);
|
---|
375 |
|
---|
376 | HGCMMsgPathUserDocuments Msg;
|
---|
377 | VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
|
---|
378 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
379 |
|
---|
380 | int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
|
---|
381 | if (RT_SUCCESS(rc))
|
---|
382 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
383 |
|
---|
384 | return rc;
|
---|
385 | }
|
---|
386 |
|
---|
387 |
|
---|
388 | VBGLR3DECL(int) VbglR3GuestCtrlPathGetUserHome(PVBGLR3GUESTCTRLCMDCTX pCtx)
|
---|
389 | {
|
---|
390 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
391 | AssertReturn(pCtx->uNumParms == 1, VERR_INVALID_PARAMETER);
|
---|
392 |
|
---|
393 | HGCMMsgPathUserHome Msg;
|
---|
394 | VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
|
---|
395 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
396 |
|
---|
397 | int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
|
---|
398 | if (RT_SUCCESS(rc))
|
---|
399 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
400 |
|
---|
401 | return rc;
|
---|
402 | }
|
---|
403 |
|
---|
404 |
|
---|
405 | /**
|
---|
406 | * Allocates and gets host data, based on the message id.
|
---|
407 | *
|
---|
408 | * This will block until data becomes available.
|
---|
409 | *
|
---|
410 | * @returns VBox status code.
|
---|
411 | ** @todo Docs!
|
---|
412 | ** @todo Move the parameters in an own struct!
|
---|
413 | */
|
---|
414 | VBGLR3DECL(int) VbglR3GuestCtrlProcGetStart(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
415 | char *pszCmd, uint32_t cbCmd,
|
---|
416 | uint32_t *pfFlags,
|
---|
417 | char *pszArgs, uint32_t cbArgs, uint32_t *pcArgs,
|
---|
418 | char *pszEnv, uint32_t *pcbEnv, uint32_t *pcEnvVars,
|
---|
419 | char *pszUser, uint32_t cbUser,
|
---|
420 | char *pszPassword, uint32_t cbPassword,
|
---|
421 | uint32_t *puTimeoutMS,
|
---|
422 | uint32_t *puPriority,
|
---|
423 | uint64_t *puAffinity, uint32_t cbAffinity, uint32_t *pcAffinity)
|
---|
424 | {
|
---|
425 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
426 |
|
---|
427 | AssertPtrReturn(pszCmd, VERR_INVALID_POINTER);
|
---|
428 | AssertPtrReturn(pfFlags, VERR_INVALID_POINTER);
|
---|
429 | AssertPtrReturn(pszArgs, VERR_INVALID_POINTER);
|
---|
430 | AssertPtrReturn(pcArgs, VERR_INVALID_POINTER);
|
---|
431 | AssertPtrReturn(pszEnv, VERR_INVALID_POINTER);
|
---|
432 | AssertPtrReturn(pcbEnv, VERR_INVALID_POINTER);
|
---|
433 | AssertPtrReturn(pcEnvVars, VERR_INVALID_POINTER);
|
---|
434 | AssertPtrReturn(puTimeoutMS, VERR_INVALID_POINTER);
|
---|
435 |
|
---|
436 | HGCMMsgProcExec Msg;
|
---|
437 | VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
|
---|
438 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
439 | VbglHGCMParmPtrSet(&Msg.cmd, pszCmd, cbCmd);
|
---|
440 | VbglHGCMParmUInt32Set(&Msg.flags, 0);
|
---|
441 | VbglHGCMParmUInt32Set(&Msg.num_args, 0);
|
---|
442 | VbglHGCMParmPtrSet(&Msg.args, pszArgs, cbArgs);
|
---|
443 | VbglHGCMParmUInt32Set(&Msg.num_env, 0);
|
---|
444 | VbglHGCMParmUInt32Set(&Msg.cb_env, 0);
|
---|
445 | VbglHGCMParmPtrSet(&Msg.env, pszEnv, *pcbEnv);
|
---|
446 | if (pCtx->uProtocol < 2)
|
---|
447 | {
|
---|
448 | AssertPtrReturn(pszUser, VERR_INVALID_POINTER);
|
---|
449 | AssertReturn(cbUser, VERR_INVALID_PARAMETER);
|
---|
450 | AssertPtrReturn(pszPassword, VERR_INVALID_POINTER);
|
---|
451 | AssertReturn(pszPassword, VERR_INVALID_PARAMETER);
|
---|
452 |
|
---|
453 | VbglHGCMParmPtrSet(&Msg.u.v1.username, pszUser, cbUser);
|
---|
454 | VbglHGCMParmPtrSet(&Msg.u.v1.password, pszPassword, cbPassword);
|
---|
455 | VbglHGCMParmUInt32Set(&Msg.u.v1.timeout, 0);
|
---|
456 | }
|
---|
457 | else
|
---|
458 | {
|
---|
459 | AssertPtrReturn(puAffinity, VERR_INVALID_POINTER);
|
---|
460 | AssertReturn(cbAffinity, VERR_INVALID_PARAMETER);
|
---|
461 |
|
---|
462 | VbglHGCMParmUInt32Set(&Msg.u.v2.timeout, 0);
|
---|
463 | VbglHGCMParmUInt32Set(&Msg.u.v2.priority, 0);
|
---|
464 | VbglHGCMParmUInt32Set(&Msg.u.v2.num_affinity, 0);
|
---|
465 | VbglHGCMParmPtrSet(&Msg.u.v2.affinity, puAffinity, cbAffinity);
|
---|
466 | }
|
---|
467 |
|
---|
468 | int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
|
---|
469 | if (RT_SUCCESS(rc))
|
---|
470 | {
|
---|
471 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
472 | Msg.flags.GetUInt32(pfFlags);
|
---|
473 | Msg.num_args.GetUInt32(pcArgs);
|
---|
474 | Msg.num_env.GetUInt32(pcEnvVars);
|
---|
475 | Msg.cb_env.GetUInt32(pcbEnv);
|
---|
476 | if (pCtx->uProtocol < 2)
|
---|
477 | {
|
---|
478 | Msg.u.v1.timeout.GetUInt32(puTimeoutMS);
|
---|
479 | }
|
---|
480 | else
|
---|
481 | {
|
---|
482 | Msg.u.v2.timeout.GetUInt32(puTimeoutMS);
|
---|
483 | Msg.u.v2.priority.GetUInt32(puPriority);
|
---|
484 | Msg.u.v2.num_affinity.GetUInt32(pcAffinity);
|
---|
485 | }
|
---|
486 | }
|
---|
487 | return rc;
|
---|
488 | }
|
---|
489 |
|
---|
490 |
|
---|
491 | /**
|
---|
492 | * Allocates and gets host data, based on the message id.
|
---|
493 | *
|
---|
494 | * This will block until data becomes available.
|
---|
495 | *
|
---|
496 | * @returns VBox status code.
|
---|
497 | ** @todo Docs!
|
---|
498 | */
|
---|
499 | VBGLR3DECL(int) VbglR3GuestCtrlProcGetOutput(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
500 | uint32_t *puPID, uint32_t *puHandle, uint32_t *pfFlags)
|
---|
501 | {
|
---|
502 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
503 | AssertReturn(pCtx->uNumParms == 4, VERR_INVALID_PARAMETER);
|
---|
504 |
|
---|
505 | AssertPtrReturn(puPID, VERR_INVALID_POINTER);
|
---|
506 | AssertPtrReturn(puHandle, VERR_INVALID_POINTER);
|
---|
507 | AssertPtrReturn(pfFlags, VERR_INVALID_POINTER);
|
---|
508 |
|
---|
509 | HGCMMsgProcOutput Msg;
|
---|
510 | VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
|
---|
511 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
512 | VbglHGCMParmUInt32Set(&Msg.pid, 0);
|
---|
513 | VbglHGCMParmUInt32Set(&Msg.handle, 0);
|
---|
514 | VbglHGCMParmUInt32Set(&Msg.flags, 0);
|
---|
515 |
|
---|
516 | int rc = VbglR3HGCMCall(&Msg.hdr, RT_UOFFSETOF(HGCMMsgProcOutput, data));
|
---|
517 | if (RT_SUCCESS(rc))
|
---|
518 | {
|
---|
519 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
520 | Msg.pid.GetUInt32(puPID);
|
---|
521 | Msg.handle.GetUInt32(puHandle);
|
---|
522 | Msg.flags.GetUInt32(pfFlags);
|
---|
523 | }
|
---|
524 | return rc;
|
---|
525 | }
|
---|
526 |
|
---|
527 |
|
---|
528 | /**
|
---|
529 | * Retrieves the input data from host which then gets sent to the
|
---|
530 | * started process.
|
---|
531 | *
|
---|
532 | * This will block until data becomes available.
|
---|
533 | *
|
---|
534 | * @returns VBox status code.
|
---|
535 | ** @todo Docs!
|
---|
536 | */
|
---|
537 | VBGLR3DECL(int) VbglR3GuestCtrlProcGetInput(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
538 | uint32_t *puPID, uint32_t *pfFlags,
|
---|
539 | void *pvData, uint32_t cbData,
|
---|
540 | uint32_t *pcbSize)
|
---|
541 | {
|
---|
542 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
543 | AssertReturn(pCtx->uNumParms == 5, VERR_INVALID_PARAMETER);
|
---|
544 |
|
---|
545 | AssertPtrReturn(puPID, VERR_INVALID_POINTER);
|
---|
546 | AssertPtrReturn(pfFlags, VERR_INVALID_POINTER);
|
---|
547 | AssertPtrReturn(pvData, VERR_INVALID_POINTER);
|
---|
548 | AssertPtrReturn(pcbSize, VERR_INVALID_POINTER);
|
---|
549 |
|
---|
550 | HGCMMsgProcInput Msg;
|
---|
551 | VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
|
---|
552 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
553 | VbglHGCMParmUInt32Set(&Msg.pid, 0);
|
---|
554 | VbglHGCMParmUInt32Set(&Msg.flags, 0);
|
---|
555 | VbglHGCMParmPtrSet(&Msg.data, pvData, cbData);
|
---|
556 | VbglHGCMParmUInt32Set(&Msg.size, 0);
|
---|
557 |
|
---|
558 | int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
|
---|
559 | if (RT_SUCCESS(rc))
|
---|
560 | {
|
---|
561 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
562 | Msg.pid.GetUInt32(puPID);
|
---|
563 | Msg.flags.GetUInt32(pfFlags);
|
---|
564 | Msg.size.GetUInt32(pcbSize);
|
---|
565 | }
|
---|
566 | return rc;
|
---|
567 | }
|
---|
568 |
|
---|
569 |
|
---|
570 | VBGLR3DECL(int) VbglR3GuestCtrlDirGetRemove(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
571 | char *pszPath, uint32_t cbPath,
|
---|
572 | uint32_t *pfFlags)
|
---|
573 | {
|
---|
574 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
575 | AssertReturn(pCtx->uNumParms == 3, VERR_INVALID_PARAMETER);
|
---|
576 |
|
---|
577 | AssertPtrReturn(pszPath, VERR_INVALID_POINTER);
|
---|
578 | AssertReturn(cbPath, VERR_INVALID_PARAMETER);
|
---|
579 | AssertPtrReturn(pfFlags, VERR_INVALID_POINTER);
|
---|
580 |
|
---|
581 | HGCMMsgDirRemove Msg;
|
---|
582 | VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
|
---|
583 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
584 | VbglHGCMParmPtrSet(&Msg.path, pszPath, cbPath);
|
---|
585 | VbglHGCMParmUInt32Set(&Msg.flags, 0);
|
---|
586 |
|
---|
587 | int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
|
---|
588 | if (RT_SUCCESS(rc))
|
---|
589 | {
|
---|
590 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
591 | Msg.flags.GetUInt32(pfFlags);
|
---|
592 | }
|
---|
593 | return rc;
|
---|
594 | }
|
---|
595 |
|
---|
596 |
|
---|
597 | VBGLR3DECL(int) VbglR3GuestCtrlFileGetOpen(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
598 | char *pszFileName, uint32_t cbFileName,
|
---|
599 | char *pszAccess, uint32_t cbAccess,
|
---|
600 | char *pszDisposition, uint32_t cbDisposition,
|
---|
601 | char *pszSharing, uint32_t cbSharing,
|
---|
602 | uint32_t *puCreationMode,
|
---|
603 | uint64_t *poffAt)
|
---|
604 | {
|
---|
605 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
606 | AssertReturn(pCtx->uNumParms == 7, VERR_INVALID_PARAMETER);
|
---|
607 |
|
---|
608 | AssertPtrReturn(pszFileName, VERR_INVALID_POINTER);
|
---|
609 | AssertReturn(cbFileName, VERR_INVALID_PARAMETER);
|
---|
610 | AssertPtrReturn(pszAccess, VERR_INVALID_POINTER);
|
---|
611 | AssertReturn(cbAccess, VERR_INVALID_PARAMETER);
|
---|
612 | AssertPtrReturn(pszDisposition, VERR_INVALID_POINTER);
|
---|
613 | AssertReturn(cbDisposition, VERR_INVALID_PARAMETER);
|
---|
614 | AssertPtrReturn(pszSharing, VERR_INVALID_POINTER);
|
---|
615 | AssertReturn(cbSharing, VERR_INVALID_PARAMETER);
|
---|
616 | AssertPtrReturn(puCreationMode, VERR_INVALID_POINTER);
|
---|
617 | AssertPtrReturn(poffAt, VERR_INVALID_POINTER);
|
---|
618 |
|
---|
619 | HGCMMsgFileOpen Msg;
|
---|
620 | VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
|
---|
621 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
622 | VbglHGCMParmPtrSet(&Msg.filename, pszFileName, cbFileName);
|
---|
623 | VbglHGCMParmPtrSet(&Msg.openmode, pszAccess, cbAccess);
|
---|
624 | VbglHGCMParmPtrSet(&Msg.disposition, pszDisposition, cbDisposition);
|
---|
625 | VbglHGCMParmPtrSet(&Msg.sharing, pszSharing, cbSharing);
|
---|
626 | VbglHGCMParmUInt32Set(&Msg.creationmode, 0);
|
---|
627 | VbglHGCMParmUInt64Set(&Msg.offset, 0);
|
---|
628 |
|
---|
629 | int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
|
---|
630 | if (RT_SUCCESS(rc))
|
---|
631 | {
|
---|
632 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
633 | Msg.creationmode.GetUInt32(puCreationMode);
|
---|
634 | Msg.offset.GetUInt64(poffAt);
|
---|
635 | }
|
---|
636 | return rc;
|
---|
637 | }
|
---|
638 |
|
---|
639 |
|
---|
640 | VBGLR3DECL(int) VbglR3GuestCtrlFileGetClose(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle)
|
---|
641 | {
|
---|
642 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
643 |
|
---|
644 | AssertReturn(pCtx->uNumParms == 2, VERR_INVALID_PARAMETER);
|
---|
645 | AssertPtrReturn(puHandle, VERR_INVALID_POINTER);
|
---|
646 |
|
---|
647 | HGCMMsgFileClose Msg;
|
---|
648 | VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
|
---|
649 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
650 | VbglHGCMParmUInt32Set(&Msg.handle, 0);
|
---|
651 |
|
---|
652 | int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
|
---|
653 | if (RT_SUCCESS(rc))
|
---|
654 | {
|
---|
655 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
656 | Msg.handle.GetUInt32(puHandle);
|
---|
657 | }
|
---|
658 | return rc;
|
---|
659 | }
|
---|
660 |
|
---|
661 |
|
---|
662 | VBGLR3DECL(int) VbglR3GuestCtrlFileGetRead(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
663 | uint32_t *puHandle, uint32_t *puToRead)
|
---|
664 | {
|
---|
665 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
666 |
|
---|
667 | AssertReturn(pCtx->uNumParms == 3, VERR_INVALID_PARAMETER);
|
---|
668 | AssertPtrReturn(puHandle, VERR_INVALID_POINTER);
|
---|
669 | AssertPtrReturn(puToRead, VERR_INVALID_POINTER);
|
---|
670 |
|
---|
671 | HGCMMsgFileRead Msg;
|
---|
672 | VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
|
---|
673 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
674 | VbglHGCMParmUInt32Set(&Msg.handle, 0);
|
---|
675 | VbglHGCMParmUInt32Set(&Msg.size, 0);
|
---|
676 |
|
---|
677 | int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
|
---|
678 | if (RT_SUCCESS(rc))
|
---|
679 | {
|
---|
680 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
681 | Msg.handle.GetUInt32(puHandle);
|
---|
682 | Msg.size.GetUInt32(puToRead);
|
---|
683 | }
|
---|
684 | return rc;
|
---|
685 | }
|
---|
686 |
|
---|
687 |
|
---|
688 | VBGLR3DECL(int) VbglR3GuestCtrlFileGetReadAt(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
689 | uint32_t *puHandle, uint32_t *puToRead, uint64_t *poffAt)
|
---|
690 | {
|
---|
691 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
692 |
|
---|
693 | AssertReturn(pCtx->uNumParms == 4, VERR_INVALID_PARAMETER);
|
---|
694 | AssertPtrReturn(puHandle, VERR_INVALID_POINTER);
|
---|
695 | AssertPtrReturn(puToRead, VERR_INVALID_POINTER);
|
---|
696 |
|
---|
697 | HGCMMsgFileReadAt Msg;
|
---|
698 | VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
|
---|
699 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
700 | VbglHGCMParmUInt32Set(&Msg.handle, 0);
|
---|
701 | VbglHGCMParmUInt32Set(&Msg.offset, 0);
|
---|
702 | VbglHGCMParmUInt32Set(&Msg.size, 0);
|
---|
703 |
|
---|
704 | int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
|
---|
705 | if (RT_SUCCESS(rc))
|
---|
706 | {
|
---|
707 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
708 | Msg.handle.GetUInt32(puHandle);
|
---|
709 | Msg.offset.GetUInt64(poffAt);
|
---|
710 | Msg.size.GetUInt32(puToRead);
|
---|
711 | }
|
---|
712 | return rc;
|
---|
713 | }
|
---|
714 |
|
---|
715 |
|
---|
716 | VBGLR3DECL(int) VbglR3GuestCtrlFileGetWrite(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle,
|
---|
717 | void *pvData, uint32_t cbData, uint32_t *pcbSize)
|
---|
718 | {
|
---|
719 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
720 |
|
---|
721 | AssertReturn(pCtx->uNumParms == 4, VERR_INVALID_PARAMETER);
|
---|
722 | AssertPtrReturn(puHandle, VERR_INVALID_POINTER);
|
---|
723 | AssertPtrReturn(pvData, VERR_INVALID_POINTER);
|
---|
724 | AssertReturn(cbData, VERR_INVALID_PARAMETER);
|
---|
725 | AssertPtrReturn(pcbSize, VERR_INVALID_POINTER);
|
---|
726 |
|
---|
727 | HGCMMsgFileWrite Msg;
|
---|
728 | VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
|
---|
729 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
730 | VbglHGCMParmUInt32Set(&Msg.handle, 0);
|
---|
731 | VbglHGCMParmPtrSet(&Msg.data, pvData, cbData);
|
---|
732 | VbglHGCMParmUInt32Set(&Msg.size, 0);
|
---|
733 |
|
---|
734 | int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
|
---|
735 | if (RT_SUCCESS(rc))
|
---|
736 | {
|
---|
737 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
738 | Msg.handle.GetUInt32(puHandle);
|
---|
739 | Msg.size.GetUInt32(pcbSize);
|
---|
740 | }
|
---|
741 | return rc;
|
---|
742 | }
|
---|
743 |
|
---|
744 |
|
---|
745 | VBGLR3DECL(int) VbglR3GuestCtrlFileGetWriteAt(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle,
|
---|
746 | void *pvData, uint32_t cbData, uint32_t *pcbSize, uint64_t *poffAt)
|
---|
747 | {
|
---|
748 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
749 |
|
---|
750 | AssertReturn(pCtx->uNumParms == 5, VERR_INVALID_PARAMETER);
|
---|
751 | AssertPtrReturn(puHandle, VERR_INVALID_POINTER);
|
---|
752 | AssertPtrReturn(pvData, VERR_INVALID_POINTER);
|
---|
753 | AssertReturn(cbData, VERR_INVALID_PARAMETER);
|
---|
754 | AssertPtrReturn(pcbSize, VERR_INVALID_POINTER);
|
---|
755 |
|
---|
756 | HGCMMsgFileWriteAt Msg;
|
---|
757 | VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
|
---|
758 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
759 | VbglHGCMParmUInt32Set(&Msg.handle, 0);
|
---|
760 | VbglHGCMParmPtrSet(&Msg.data, pvData, cbData);
|
---|
761 | VbglHGCMParmUInt32Set(&Msg.size, 0);
|
---|
762 | VbglHGCMParmUInt32Set(&Msg.offset, 0);
|
---|
763 |
|
---|
764 | int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
|
---|
765 | if (RT_SUCCESS(rc))
|
---|
766 | {
|
---|
767 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
768 | Msg.handle.GetUInt32(puHandle);
|
---|
769 | Msg.size.GetUInt32(pcbSize);
|
---|
770 | Msg.offset.GetUInt64(poffAt);
|
---|
771 | }
|
---|
772 | return rc;
|
---|
773 | }
|
---|
774 |
|
---|
775 |
|
---|
776 | VBGLR3DECL(int) VbglR3GuestCtrlFileGetSeek(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
777 | uint32_t *puHandle, uint32_t *puSeekMethod, uint64_t *poffAt)
|
---|
778 | {
|
---|
779 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
780 |
|
---|
781 | AssertReturn(pCtx->uNumParms == 4, VERR_INVALID_PARAMETER);
|
---|
782 | AssertPtrReturn(puHandle, VERR_INVALID_POINTER);
|
---|
783 | AssertPtrReturn(puSeekMethod, VERR_INVALID_POINTER);
|
---|
784 | AssertPtrReturn(poffAt, VERR_INVALID_POINTER);
|
---|
785 |
|
---|
786 | HGCMMsgFileSeek Msg;
|
---|
787 | VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
|
---|
788 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
789 | VbglHGCMParmUInt32Set(&Msg.handle, 0);
|
---|
790 | VbglHGCMParmUInt32Set(&Msg.method, 0);
|
---|
791 | VbglHGCMParmUInt64Set(&Msg.offset, 0);
|
---|
792 |
|
---|
793 | int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
|
---|
794 | if (RT_SUCCESS(rc))
|
---|
795 | {
|
---|
796 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
797 | Msg.handle.GetUInt32(puHandle);
|
---|
798 | Msg.method.GetUInt32(puSeekMethod);
|
---|
799 | Msg.offset.GetUInt64(poffAt);
|
---|
800 | }
|
---|
801 | return rc;
|
---|
802 | }
|
---|
803 |
|
---|
804 |
|
---|
805 | VBGLR3DECL(int) VbglR3GuestCtrlFileGetTell(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle)
|
---|
806 | {
|
---|
807 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
808 |
|
---|
809 | AssertReturn(pCtx->uNumParms == 2, VERR_INVALID_PARAMETER);
|
---|
810 | AssertPtrReturn(puHandle, VERR_INVALID_POINTER);
|
---|
811 |
|
---|
812 | HGCMMsgFileTell Msg;
|
---|
813 | VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
|
---|
814 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
815 | VbglHGCMParmUInt32Set(&Msg.handle, 0);
|
---|
816 |
|
---|
817 | int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
|
---|
818 | if (RT_SUCCESS(rc))
|
---|
819 | {
|
---|
820 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
821 | Msg.handle.GetUInt32(puHandle);
|
---|
822 | }
|
---|
823 | return rc;
|
---|
824 | }
|
---|
825 |
|
---|
826 |
|
---|
827 | VBGLR3DECL(int) VbglR3GuestCtrlProcGetTerminate(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puPID)
|
---|
828 | {
|
---|
829 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
830 |
|
---|
831 | AssertReturn(pCtx->uNumParms == 2, VERR_INVALID_PARAMETER);
|
---|
832 | AssertPtrReturn(puPID, VERR_INVALID_POINTER);
|
---|
833 |
|
---|
834 | HGCMMsgProcTerminate Msg;
|
---|
835 | VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
|
---|
836 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
837 | VbglHGCMParmUInt32Set(&Msg.pid, 0);
|
---|
838 |
|
---|
839 | int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
|
---|
840 | if (RT_SUCCESS(rc))
|
---|
841 | {
|
---|
842 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
843 | Msg.pid.GetUInt32(puPID);
|
---|
844 | }
|
---|
845 | return rc;
|
---|
846 | }
|
---|
847 |
|
---|
848 |
|
---|
849 | VBGLR3DECL(int) VbglR3GuestCtrlProcGetWaitFor(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
850 | uint32_t *puPID, uint32_t *puWaitFlags, uint32_t *puTimeoutMS)
|
---|
851 | {
|
---|
852 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
853 |
|
---|
854 | AssertReturn(pCtx->uNumParms == 5, VERR_INVALID_PARAMETER);
|
---|
855 | AssertPtrReturn(puPID, VERR_INVALID_POINTER);
|
---|
856 |
|
---|
857 | HGCMMsgProcWaitFor Msg;
|
---|
858 | VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
|
---|
859 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
860 | VbglHGCMParmUInt32Set(&Msg.pid, 0);
|
---|
861 | VbglHGCMParmUInt32Set(&Msg.flags, 0);
|
---|
862 | VbglHGCMParmUInt32Set(&Msg.timeout, 0);
|
---|
863 |
|
---|
864 | int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
|
---|
865 | if (RT_SUCCESS(rc))
|
---|
866 | {
|
---|
867 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
868 | Msg.pid.GetUInt32(puPID);
|
---|
869 | Msg.flags.GetUInt32(puWaitFlags);
|
---|
870 | Msg.timeout.GetUInt32(puTimeoutMS);
|
---|
871 | }
|
---|
872 | return rc;
|
---|
873 | }
|
---|
874 |
|
---|
875 |
|
---|
876 | VBGLR3DECL(int) VbglR3GuestCtrlFileCbOpen(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
877 | uint32_t uRc, uint32_t uFileHandle)
|
---|
878 | {
|
---|
879 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
880 |
|
---|
881 | HGCMReplyFileNotify Msg;
|
---|
882 | VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_FILE_NOTIFY, 4);
|
---|
883 | VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
|
---|
884 | VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_OPEN);
|
---|
885 | VbglHGCMParmUInt32Set(&Msg.rc, uRc);
|
---|
886 | VbglHGCMParmUInt32Set(&Msg.u.open.handle, uFileHandle);
|
---|
887 |
|
---|
888 | return VbglR3HGCMCall(&Msg.hdr, RT_UOFFSET_AFTER(HGCMReplyFileNotify, u.open));
|
---|
889 | }
|
---|
890 |
|
---|
891 |
|
---|
892 | VBGLR3DECL(int) VbglR3GuestCtrlFileCbClose(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
893 | uint32_t uRc)
|
---|
894 | {
|
---|
895 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
896 |
|
---|
897 | HGCMReplyFileNotify Msg;
|
---|
898 | VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_FILE_NOTIFY, 3);
|
---|
899 | VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
|
---|
900 | VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_CLOSE);
|
---|
901 | VbglHGCMParmUInt32Set(&Msg.rc, uRc);
|
---|
902 |
|
---|
903 | return VbglR3HGCMCall(&Msg.hdr, RT_UOFFSETOF(HGCMReplyFileNotify, u));
|
---|
904 | }
|
---|
905 |
|
---|
906 |
|
---|
907 | VBGLR3DECL(int) VbglR3GuestCtrlFileCbError(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uRc)
|
---|
908 | {
|
---|
909 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
910 |
|
---|
911 | HGCMReplyFileNotify Msg;
|
---|
912 | VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_FILE_NOTIFY, 3);
|
---|
913 | VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
|
---|
914 | VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_ERROR);
|
---|
915 | VbglHGCMParmUInt32Set(&Msg.rc, uRc);
|
---|
916 |
|
---|
917 | return VbglR3HGCMCall(&Msg.hdr, RT_UOFFSETOF(HGCMReplyFileNotify, u));
|
---|
918 | }
|
---|
919 |
|
---|
920 |
|
---|
921 | VBGLR3DECL(int) VbglR3GuestCtrlFileCbRead(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
922 | uint32_t uRc,
|
---|
923 | void *pvData, uint32_t cbData)
|
---|
924 | {
|
---|
925 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
926 |
|
---|
927 | HGCMReplyFileNotify Msg;
|
---|
928 | VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_FILE_NOTIFY, 4);
|
---|
929 | VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
|
---|
930 | VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_READ);
|
---|
931 | VbglHGCMParmUInt32Set(&Msg.rc, uRc);
|
---|
932 | VbglHGCMParmPtrSet(&Msg.u.read.data, pvData, cbData);
|
---|
933 |
|
---|
934 | return VbglR3HGCMCall(&Msg.hdr, RT_UOFFSET_AFTER(HGCMReplyFileNotify, u.read));
|
---|
935 | }
|
---|
936 |
|
---|
937 |
|
---|
938 | VBGLR3DECL(int) VbglR3GuestCtrlFileCbWrite(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
939 | uint32_t uRc, uint32_t uWritten)
|
---|
940 | {
|
---|
941 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
942 |
|
---|
943 | HGCMReplyFileNotify Msg;
|
---|
944 | VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_FILE_NOTIFY, 4);
|
---|
945 | VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
|
---|
946 | VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_WRITE);
|
---|
947 | VbglHGCMParmUInt32Set(&Msg.rc, uRc);
|
---|
948 | VbglHGCMParmUInt32Set(&Msg.u.write.written, uWritten);
|
---|
949 |
|
---|
950 | return VbglR3HGCMCall(&Msg.hdr, RT_UOFFSET_AFTER(HGCMReplyFileNotify, u.write));
|
---|
951 | }
|
---|
952 |
|
---|
953 |
|
---|
954 | VBGLR3DECL(int) VbglR3GuestCtrlFileCbSeek(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
955 | uint32_t uRc, uint64_t uOffActual)
|
---|
956 | {
|
---|
957 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
958 |
|
---|
959 | HGCMReplyFileNotify Msg;
|
---|
960 | VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_FILE_NOTIFY, 4);
|
---|
961 | VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
|
---|
962 | VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_SEEK);
|
---|
963 | VbglHGCMParmUInt32Set(&Msg.rc, uRc);
|
---|
964 | VbglHGCMParmUInt64Set(&Msg.u.seek.offset, uOffActual);
|
---|
965 |
|
---|
966 | return VbglR3HGCMCall(&Msg.hdr, RT_UOFFSET_AFTER(HGCMReplyFileNotify, u.seek));
|
---|
967 | }
|
---|
968 |
|
---|
969 |
|
---|
970 | VBGLR3DECL(int) VbglR3GuestCtrlFileCbTell(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
971 | uint32_t uRc, uint64_t uOffActual)
|
---|
972 | {
|
---|
973 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
974 |
|
---|
975 | HGCMReplyFileNotify Msg;
|
---|
976 | VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_FILE_NOTIFY, 4);
|
---|
977 | VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
|
---|
978 | VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_TELL);
|
---|
979 | VbglHGCMParmUInt32Set(&Msg.rc, uRc);
|
---|
980 | VbglHGCMParmUInt64Set(&Msg.u.tell.offset, uOffActual);
|
---|
981 |
|
---|
982 | return VbglR3HGCMCall(&Msg.hdr, RT_UOFFSET_AFTER(HGCMReplyFileNotify, u.tell));
|
---|
983 | }
|
---|
984 |
|
---|
985 |
|
---|
986 | /**
|
---|
987 | * Callback for reporting a guest process status (along with some other stuff) to the host.
|
---|
988 | *
|
---|
989 | * @returns VBox status code.
|
---|
990 | ** @todo Docs!
|
---|
991 | */
|
---|
992 | VBGLR3DECL(int) VbglR3GuestCtrlProcCbStatus(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
993 | uint32_t uPID, uint32_t uStatus, uint32_t fFlags,
|
---|
994 | void *pvData, uint32_t cbData)
|
---|
995 | {
|
---|
996 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
997 |
|
---|
998 | HGCMMsgProcStatus Msg;
|
---|
999 | VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_EXEC_STATUS, 5);
|
---|
1000 | VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
|
---|
1001 | VbglHGCMParmUInt32Set(&Msg.pid, uPID);
|
---|
1002 | VbglHGCMParmUInt32Set(&Msg.status, uStatus);
|
---|
1003 | VbglHGCMParmUInt32Set(&Msg.flags, fFlags);
|
---|
1004 | VbglHGCMParmPtrSet(&Msg.data, pvData, cbData);
|
---|
1005 |
|
---|
1006 | return VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
|
---|
1007 | }
|
---|
1008 |
|
---|
1009 |
|
---|
1010 | /**
|
---|
1011 | * Sends output (from stdout/stderr) from a running process.
|
---|
1012 | *
|
---|
1013 | * @returns VBox status code.
|
---|
1014 | ** @todo Docs!
|
---|
1015 | */
|
---|
1016 | VBGLR3DECL(int) VbglR3GuestCtrlProcCbOutput(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
1017 | uint32_t uPID,uint32_t uHandle, uint32_t fFlags,
|
---|
1018 | void *pvData, uint32_t cbData)
|
---|
1019 | {
|
---|
1020 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
1021 |
|
---|
1022 | HGCMMsgProcOutput Msg;
|
---|
1023 | VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_EXEC_OUTPUT, 5);
|
---|
1024 | VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
|
---|
1025 | VbglHGCMParmUInt32Set(&Msg.pid, uPID);
|
---|
1026 | VbglHGCMParmUInt32Set(&Msg.handle, uHandle);
|
---|
1027 | VbglHGCMParmUInt32Set(&Msg.flags, fFlags);
|
---|
1028 | VbglHGCMParmPtrSet(&Msg.data, pvData, cbData);
|
---|
1029 |
|
---|
1030 | return VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
|
---|
1031 | }
|
---|
1032 |
|
---|
1033 |
|
---|
1034 | /**
|
---|
1035 | * Callback for reporting back the input status of a guest process to the host.
|
---|
1036 | *
|
---|
1037 | * @returns VBox status code.
|
---|
1038 | ** @todo Docs!
|
---|
1039 | */
|
---|
1040 | VBGLR3DECL(int) VbglR3GuestCtrlProcCbStatusInput(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
1041 | uint32_t uPID, uint32_t uStatus,
|
---|
1042 | uint32_t fFlags, uint32_t cbWritten)
|
---|
1043 | {
|
---|
1044 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
1045 |
|
---|
1046 | HGCMMsgProcStatusInput Msg;
|
---|
1047 | VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_EXEC_INPUT_STATUS, 5);
|
---|
1048 | VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
|
---|
1049 | VbglHGCMParmUInt32Set(&Msg.pid, uPID);
|
---|
1050 | VbglHGCMParmUInt32Set(&Msg.status, uStatus);
|
---|
1051 | VbglHGCMParmUInt32Set(&Msg.flags, fFlags);
|
---|
1052 | VbglHGCMParmUInt32Set(&Msg.written, cbWritten);
|
---|
1053 |
|
---|
1054 | return VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
|
---|
1055 | }
|
---|
1056 |
|
---|