VirtualBox

source: vbox/trunk/include/VBox/hgcmsvc.h@ 80331

Last change on this file since 80331 was 77243, checked in by vboxsync, 6 years ago

HGCM,SharedFolders: Added new variation on the HGCM page list type that does not use a bounce buffer. bugref:9172

  • Added VMMDevHGCMParmType_NoBouncePageList.
  • Made VMMDevHGCMParmType_Embedded
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 20.8 KB
Line 
1/** @file
2 * Host-Guest Communication Manager (HGCM) - Service library definitions.
3 */
4
5/*
6 * Copyright (C) 2006-2019 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef VBOX_INCLUDED_hgcmsvc_h
27#define VBOX_INCLUDED_hgcmsvc_h
28#ifndef RT_WITHOUT_PRAGMA_ONCE
29# pragma once
30#endif
31
32#include <iprt/assert.h>
33#include <iprt/stdarg.h>
34#include <iprt/string.h>
35#include <VBox/cdefs.h>
36#include <VBox/types.h>
37#include <iprt/err.h>
38#ifdef IN_RING3
39# include <VBox/vmm/stam.h>
40# include <VBox/vmm/dbgf.h>
41#endif
42#ifdef VBOX_TEST_HGCM_PARMS
43# include <iprt/test.h>
44#endif
45
46/** @todo proper comments. */
47
48/**
49 * Service interface version.
50 *
51 * Includes layout of both VBOXHGCMSVCFNTABLE and VBOXHGCMSVCHELPERS.
52 *
53 * A service can work with these structures if major version
54 * is equal and minor version of service is <= version of the
55 * structures.
56 *
57 * For example when a new helper is added at the end of helpers
58 * structure, then the minor version will be increased. All older
59 * services still can work because they have their old helpers
60 * unchanged.
61 *
62 * Revision history.
63 * 1.1->2.1 Because the pfnConnect now also has the pvClient parameter.
64 * 2.1->2.2 Because pfnSaveState and pfnLoadState were added
65 * 2.2->3.1 Because pfnHostCall is now synchronous, returns rc, and parameters were changed
66 * 3.1->3.2 Because pfnRegisterExtension was added
67 * 3.2->3.3 Because pfnDisconnectClient helper was added
68 * 3.3->4.1 Because the pvService entry and parameter was added
69 * 4.1->4.2 Because the VBOX_HGCM_SVC_PARM_CALLBACK parameter type was added
70 * 4.2->5.1 Removed the VBOX_HGCM_SVC_PARM_CALLBACK parameter type, as
71 * this problem is already solved by service extension callbacks
72 * 5.1->6.1 Because pfnCall got a new parameter. Also new helpers. (VBox 6.0)
73 * 6.1->6.2 Because pfnCallComplete starts returning a status code (VBox 6.0).
74 * 6.2->6.3 Because pfnGetRequestor was added (VBox 6.0).
75 * 6.3->6.4 Bacause pfnConnect got an additional parameter (VBox 6.0).
76 * 6.4->6.5 Bacause pfnGetVMMDevSessionId was added pfnLoadState got the version
77 * parameter (VBox 6.0).
78 * 6.5->7.1 Because pfnNotify was added (VBox 6.0).
79 * 7.1->8.1 Because pfnCancelled & pfnIsCallCancelled were added (VBox 6.0).
80 */
81#define VBOX_HGCM_SVC_VERSION_MAJOR (0x0008)
82#define VBOX_HGCM_SVC_VERSION_MINOR (0x0001)
83#define VBOX_HGCM_SVC_VERSION ((VBOX_HGCM_SVC_VERSION_MAJOR << 16) + VBOX_HGCM_SVC_VERSION_MINOR)
84
85
86/** Typed pointer to distinguish a call to service. */
87struct VBOXHGCMCALLHANDLE_TYPEDEF;
88typedef struct VBOXHGCMCALLHANDLE_TYPEDEF *VBOXHGCMCALLHANDLE;
89
90/** Service helpers pointers table. */
91typedef struct VBOXHGCMSVCHELPERS
92{
93 /** The service has processed the Call request. */
94 DECLR3CALLBACKMEMBER(int, pfnCallComplete, (VBOXHGCMCALLHANDLE callHandle, int32_t rc));
95
96 void *pvInstance;
97
98 /** The service disconnects the client. */
99 DECLR3CALLBACKMEMBER(void, pfnDisconnectClient, (void *pvInstance, uint32_t u32ClientID));
100
101 /**
102 * Check if the @a callHandle is for a call restored and re-submitted from saved state.
103 *
104 * @returns true if restored, false if not.
105 * @param callHandle The call we're checking up on.
106 */
107 DECLR3CALLBACKMEMBER(bool, pfnIsCallRestored, (VBOXHGCMCALLHANDLE callHandle));
108
109 /**
110 * Check if the @a callHandle is for a cancelled call.
111 *
112 * @returns true if cancelled, false if not.
113 * @param callHandle The call we're checking up on.
114 */
115 DECLR3CALLBACKMEMBER(bool, pfnIsCallCancelled, (VBOXHGCMCALLHANDLE callHandle));
116
117 /** Access to STAMR3RegisterV. */
118 DECLR3CALLBACKMEMBER(int, pfnStamRegisterV,(void *pvInstance, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
119 STAMUNIT enmUnit, const char *pszDesc, const char *pszName, va_list va)
120 RT_IPRT_FORMAT_ATTR(7, 0));
121 /** Access to STAMR3DeregisterV. */
122 DECLR3CALLBACKMEMBER(int, pfnStamDeregisterV,(void *pvInstance, const char *pszPatFmt, va_list va) RT_IPRT_FORMAT_ATTR(2, 0));
123
124 /** Access to DBGFR3InfoRegisterExternal. */
125 DECLR3CALLBACKMEMBER(int, pfnInfoRegister,(void *pvInstance, const char *pszName, const char *pszDesc,
126 PFNDBGFHANDLEREXT pfnHandler, void *pvUser));
127 /** Access to DBGFR3InfoDeregisterExternal. */
128 DECLR3CALLBACKMEMBER(int, pfnInfoDeregister,(void *pvInstance, const char *pszName));
129
130 /**
131 * Retrieves the VMMDevRequestHeader::fRequestor value.
132 *
133 * @returns The field value, VMMDEV_REQUESTOR_LEGACY if not supported by the
134 * guest, VMMDEV_REQUESTOR_LOWEST if invalid call.
135 * @param hCall The call we're checking up on.
136 */
137 DECLR3CALLBACKMEMBER(uint32_t, pfnGetRequestor, (VBOXHGCMCALLHANDLE hCall));
138
139 /**
140 * Retrieves VMMDevState::idSession.
141 *
142 * @returns current VMMDev session ID value.
143 */
144 DECLR3CALLBACKMEMBER(uint64_t, pfnGetVMMDevSessionId, (void *pvInstance));
145
146} VBOXHGCMSVCHELPERS;
147
148typedef VBOXHGCMSVCHELPERS *PVBOXHGCMSVCHELPERS;
149
150#if defined(IN_RING3) || defined(IN_SLICKEDIT)
151
152/** Wrapper around STAMR3RegisterF. */
153DECLINLINE(int) RT_IPRT_FORMAT_ATTR(7, 8)
154HGCMSvcHlpStamRegister(PVBOXHGCMSVCHELPERS pHlp, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
155 STAMUNIT enmUnit, const char *pszDesc, const char *pszName, ...)
156{
157 int rc;
158 va_list va;
159 va_start(va, pszName);
160 rc = pHlp->pfnStamRegisterV(pHlp->pvInstance, pvSample, enmType, enmVisibility, enmUnit, pszDesc, pszName, va);
161 va_end(va);
162 return rc;
163}
164
165/** Wrapper around STAMR3RegisterV. */
166DECLINLINE(int) RT_IPRT_FORMAT_ATTR(7, 0)
167HGCMSvcHlpStamRegisterV(PVBOXHGCMSVCHELPERS pHlp, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
168 STAMUNIT enmUnit, const char *pszDesc, const char *pszName, va_list va)
169{
170 return pHlp->pfnStamRegisterV(pHlp->pvInstance, pvSample, enmType, enmVisibility, enmUnit, pszDesc, pszName, va);
171}
172
173/** Wrapper around STAMR3DeregisterF. */
174DECLINLINE(int) RT_IPRT_FORMAT_ATTR(2, 3) HGCMSvcHlpStamDeregister(PVBOXHGCMSVCHELPERS pHlp, const char *pszPatFmt, ...)
175{
176 int rc;
177 va_list va;
178 va_start(va, pszPatFmt);
179 rc = pHlp->pfnStamDeregisterV(pHlp->pvInstance, pszPatFmt, va);
180 va_end(va);
181 return rc;
182}
183
184/** Wrapper around STAMR3DeregisterV. */
185DECLINLINE(int) RT_IPRT_FORMAT_ATTR(2, 0) HGCMSvcHlpStamDeregisterV(PVBOXHGCMSVCHELPERS pHlp, const char *pszPatFmt, va_list va)
186{
187 return pHlp->pfnStamDeregisterV(pHlp->pvInstance, pszPatFmt, va);
188}
189
190/** Wrapper around DBGFR3InfoRegisterExternal. */
191DECLINLINE(int) HGCMSvcHlpInfoRegister(PVBOXHGCMSVCHELPERS pHlp, const char *pszName, const char *pszDesc,
192 PFNDBGFHANDLEREXT pfnHandler, void *pvUser)
193{
194 return pHlp->pfnInfoRegister(pHlp->pvInstance, pszName, pszDesc, pfnHandler, pvUser);
195}
196
197/** Wrapper around DBGFR3InfoDeregisterExternal. */
198DECLINLINE(int) HGCMSvcHlpInfoDeregister(PVBOXHGCMSVCHELPERS pHlp, const char *pszName)
199{
200 return pHlp->pfnInfoDeregister(pHlp->pvInstance, pszName);
201}
202
203#endif /* IN_RING3 */
204
205
206#define VBOX_HGCM_SVC_PARM_INVALID (0U)
207#define VBOX_HGCM_SVC_PARM_32BIT (1U)
208#define VBOX_HGCM_SVC_PARM_64BIT (2U)
209#define VBOX_HGCM_SVC_PARM_PTR (3U)
210#define VBOX_HGCM_SVC_PARM_PAGES (4U)
211
212/** VBOX_HGCM_SVC_PARM_PAGES specific data. */
213typedef struct VBOXHGCMSVCPARMPAGES
214{
215 uint32_t cb;
216 uint16_t cPages;
217 uint16_t u16Padding;
218 void **papvPages;
219} VBOXHGCMSVCPARMPAGES;
220typedef VBOXHGCMSVCPARMPAGES *PVBOXHGCMSVCPARMPAGES;
221
222typedef struct VBOXHGCMSVCPARM
223{
224 /** VBOX_HGCM_SVC_PARM_* values. */
225 uint32_t type;
226
227 union
228 {
229 uint32_t uint32;
230 uint64_t uint64;
231 struct
232 {
233 uint32_t size;
234 void *addr;
235 } pointer;
236 /** VBOX_HGCM_SVC_PARM_PAGES */
237 VBOXHGCMSVCPARMPAGES Pages;
238 } u;
239} VBOXHGCMSVCPARM;
240
241/** Extract an uint32_t value from an HGCM parameter structure. */
242DECLINLINE(int) HGCMSvcGetU32(VBOXHGCMSVCPARM *pParm, uint32_t *pu32)
243{
244 int rc = VINF_SUCCESS;
245 AssertPtrReturn(pParm, VERR_INVALID_POINTER);
246 AssertPtrReturn(pParm, VERR_INVALID_POINTER);
247 AssertPtrReturn(pu32, VERR_INVALID_POINTER);
248 if (pParm->type != VBOX_HGCM_SVC_PARM_32BIT)
249 rc = VERR_INVALID_PARAMETER;
250 if (RT_SUCCESS(rc))
251 *pu32 = pParm->u.uint32;
252 return rc;
253}
254
255/** Extract an uint64_t value from an HGCM parameter structure. */
256DECLINLINE(int) HGCMSvcGetU64(VBOXHGCMSVCPARM *pParm, uint64_t *pu64)
257{
258 int rc = VINF_SUCCESS;
259 AssertPtrReturn(pParm, VERR_INVALID_POINTER);
260 AssertPtrReturn(pParm, VERR_INVALID_POINTER);
261 AssertPtrReturn(pu64, VERR_INVALID_POINTER);
262 if (pParm->type != VBOX_HGCM_SVC_PARM_64BIT)
263 rc = VERR_INVALID_PARAMETER;
264 if (RT_SUCCESS(rc))
265 *pu64 = pParm->u.uint64;
266 return rc;
267}
268
269/** Extract an pointer value from an HGCM parameter structure. */
270DECLINLINE(int) HGCMSvcGetPv(VBOXHGCMSVCPARM *pParm, void **ppv, uint32_t *pcb)
271{
272 AssertPtrReturn(pParm, VERR_INVALID_POINTER);
273 AssertPtrReturn(ppv, VERR_INVALID_POINTER);
274 AssertPtrReturn(pcb, VERR_INVALID_POINTER);
275 if (pParm->type == VBOX_HGCM_SVC_PARM_PTR)
276 {
277 *ppv = pParm->u.pointer.addr;
278 *pcb = pParm->u.pointer.size;
279 return VINF_SUCCESS;
280 }
281
282 return VERR_INVALID_PARAMETER;
283}
284
285/** Extract a constant pointer value from an HGCM parameter structure. */
286DECLINLINE(int) HGCMSvcGetPcv(VBOXHGCMSVCPARM *pParm, const void **ppv, uint32_t *pcb)
287{
288 AssertPtrReturn(pParm, VERR_INVALID_POINTER);
289 AssertPtrReturn(ppv, VERR_INVALID_POINTER);
290 AssertPtrReturn(pcb, VERR_INVALID_POINTER);
291 if (pParm->type == VBOX_HGCM_SVC_PARM_PTR)
292 {
293 *ppv = (const void *)pParm->u.pointer.addr;
294 *pcb = pParm->u.pointer.size;
295 return VINF_SUCCESS;
296 }
297
298 return VERR_INVALID_PARAMETER;
299}
300
301/** Extract a valid pointer to a non-empty buffer from an HGCM parameter
302 * structure. */
303DECLINLINE(int) HGCMSvcGetBuf(VBOXHGCMSVCPARM *pParm, void **ppv, uint32_t *pcb)
304{
305 AssertPtrReturn(pParm, VERR_INVALID_POINTER);
306 AssertPtrReturn(ppv, VERR_INVALID_POINTER);
307 AssertPtrReturn(pcb, VERR_INVALID_POINTER);
308 if ( pParm->type == VBOX_HGCM_SVC_PARM_PTR
309 && VALID_PTR(pParm->u.pointer.addr)
310 && pParm->u.pointer.size > 0)
311 {
312 *ppv = pParm->u.pointer.addr;
313 *pcb = pParm->u.pointer.size;
314 return VINF_SUCCESS;
315 }
316
317 return VERR_INVALID_PARAMETER;
318}
319
320/** Extract a valid pointer to a non-empty constant buffer from an HGCM
321 * parameter structure. */
322DECLINLINE(int) HGCMSvcGetCBuf(VBOXHGCMSVCPARM *pParm, const void **ppv, uint32_t *pcb)
323{
324 AssertPtrReturn(pParm, VERR_INVALID_POINTER);
325 AssertPtrReturn(ppv, VERR_INVALID_POINTER);
326 AssertPtrReturn(pcb, VERR_INVALID_POINTER);
327 if ( pParm->type == VBOX_HGCM_SVC_PARM_PTR
328 && VALID_PTR(pParm->u.pointer.addr)
329 && pParm->u.pointer.size > 0)
330 {
331 *ppv = (const void *)pParm->u.pointer.addr;
332 *pcb = pParm->u.pointer.size;
333 return VINF_SUCCESS;
334 }
335
336 return VERR_INVALID_PARAMETER;
337}
338
339/** Extract a string value from an HGCM parameter structure. */
340DECLINLINE(int) HGCMSvcGetStr(VBOXHGCMSVCPARM *pParm, char **ppch, uint32_t *pcb)
341{
342 AssertPtrReturn(pParm, VERR_INVALID_POINTER);
343 AssertPtrReturn(ppch, VERR_INVALID_POINTER);
344 AssertPtrReturn(pcb, VERR_INVALID_POINTER);
345 if ( pParm->type == VBOX_HGCM_SVC_PARM_PTR
346 && VALID_PTR(pParm->u.pointer.addr)
347 && pParm->u.pointer.size > 0)
348 {
349 int rc = RTStrValidateEncodingEx((char *)pParm->u.pointer.addr,
350 pParm->u.pointer.size,
351 RTSTR_VALIDATE_ENCODING_ZERO_TERMINATED);
352 if (RT_FAILURE(rc))
353 return rc;
354 *ppch = (char *)pParm->u.pointer.addr;
355 *pcb = pParm->u.pointer.size;
356 return VINF_SUCCESS;
357 }
358
359 return VERR_INVALID_PARAMETER;
360}
361
362/** Extract a constant string value from an HGCM parameter structure. */
363DECLINLINE(int) HGCMSvcGetCStr(VBOXHGCMSVCPARM *pParm, const char **ppch, uint32_t *pcb)
364{
365 AssertPtrReturn(pParm, VERR_INVALID_POINTER);
366 AssertPtrReturn(ppch, VERR_INVALID_POINTER);
367 AssertPtrReturn(pcb, VERR_INVALID_POINTER);
368 if ( pParm->type == VBOX_HGCM_SVC_PARM_PTR
369 && VALID_PTR(pParm->u.pointer.addr)
370 && pParm->u.pointer.size > 0)
371 {
372 int rc = RTStrValidateEncodingEx((char *)pParm->u.pointer.addr,
373 pParm->u.pointer.size,
374 RTSTR_VALIDATE_ENCODING_ZERO_TERMINATED);
375 if (RT_FAILURE(rc))
376 return rc;
377 *ppch = (char *)pParm->u.pointer.addr;
378 *pcb = pParm->u.pointer.size;
379 return VINF_SUCCESS;
380 }
381
382 return VERR_INVALID_PARAMETER;
383}
384
385/** Extract a constant string value from an HGCM parameter structure. */
386DECLINLINE(int) HGCMSvcGetPsz(VBOXHGCMSVCPARM *pParm, const char **ppch, uint32_t *pcb)
387{
388 AssertPtrReturn(pParm, VERR_INVALID_POINTER);
389 AssertPtrReturn(ppch, VERR_INVALID_POINTER);
390 AssertPtrReturn(pcb, VERR_INVALID_POINTER);
391 if ( pParm->type == VBOX_HGCM_SVC_PARM_PTR
392 && VALID_PTR(pParm->u.pointer.addr)
393 && pParm->u.pointer.size > 0)
394 {
395 int rc = RTStrValidateEncodingEx((const char *)pParm->u.pointer.addr,
396 pParm->u.pointer.size,
397 RTSTR_VALIDATE_ENCODING_ZERO_TERMINATED);
398 if (RT_FAILURE(rc))
399 return rc;
400 *ppch = (const char *)pParm->u.pointer.addr;
401 *pcb = pParm->u.pointer.size;
402 return VINF_SUCCESS;
403 }
404
405 return VERR_INVALID_PARAMETER;
406}
407
408/** Set a uint32_t value to an HGCM parameter structure */
409DECLINLINE(void) HGCMSvcSetU32(VBOXHGCMSVCPARM *pParm, uint32_t u32)
410{
411 AssertPtr(pParm);
412 pParm->type = VBOX_HGCM_SVC_PARM_32BIT;
413 pParm->u.uint32 = u32;
414}
415
416/** Set a uint64_t value to an HGCM parameter structure */
417DECLINLINE(void) HGCMSvcSetU64(VBOXHGCMSVCPARM *pParm, uint64_t u64)
418{
419 AssertPtr(pParm);
420 pParm->type = VBOX_HGCM_SVC_PARM_64BIT;
421 pParm->u.uint64 = u64;
422}
423
424/** Set a pointer value to an HGCM parameter structure */
425DECLINLINE(void) HGCMSvcSetPv(VBOXHGCMSVCPARM *pParm, void *pv, uint32_t cb)
426{
427 AssertPtr(pParm);
428 pParm->type = VBOX_HGCM_SVC_PARM_PTR;
429 pParm->u.pointer.addr = pv;
430 pParm->u.pointer.size = cb;
431}
432
433/** Set a pointer value to an HGCM parameter structure */
434DECLINLINE(void) HGCMSvcSetStr(VBOXHGCMSVCPARM *pParm, const char *psz)
435{
436 AssertPtr(pParm);
437 pParm->type = VBOX_HGCM_SVC_PARM_PTR;
438 pParm->u.pointer.addr = (void *)psz;
439 pParm->u.pointer.size = (uint32_t)strlen(psz) + 1;
440}
441
442#ifdef __cplusplus
443# ifdef IPRT_INCLUDED_cpp_ministring_h
444/** Set a const string value to an HGCM parameter structure */
445DECLINLINE(void) HGCMSvcSetRTCStr(VBOXHGCMSVCPARM *pParm, const RTCString &rString)
446{
447 AssertPtr(pParm);
448 pParm->type = VBOX_HGCM_SVC_PARM_PTR;
449 pParm->u.pointer.addr = (void *)rString.c_str();
450 pParm->u.pointer.size = (uint32_t)rString.length() + 1;
451}
452# endif
453#endif
454
455typedef VBOXHGCMSVCPARM *PVBOXHGCMSVCPARM;
456
457#ifdef VBOX_WITH_CRHGSMI
458typedef void * HGCMCVSHANDLE;
459
460typedef DECLCALLBACK(void) HGCMHOSTFASTCALLCB (int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam, void *pvContext);
461typedef HGCMHOSTFASTCALLCB *PHGCMHOSTFASTCALLCB;
462#endif
463
464
465/** Service specific extension callback.
466 * This callback is called by the service to perform service specific operation.
467 *
468 * @param pvExtension The extension pointer.
469 * @param u32Function What the callback is supposed to do.
470 * @param pvParm The function parameters.
471 * @param cbParm The size of the function parameters.
472 */
473typedef DECLCALLBACK(int) FNHGCMSVCEXT(void *pvExtension, uint32_t u32Function, void *pvParm, uint32_t cbParms);
474typedef FNHGCMSVCEXT *PFNHGCMSVCEXT;
475
476/**
477 * Notification event.
478 */
479typedef enum HGCMNOTIFYEVENT
480{
481 HGCMNOTIFYEVENT_INVALID = 0,
482 HGCMNOTIFYEVENT_POWER_ON,
483 HGCMNOTIFYEVENT_RESUME,
484 HGCMNOTIFYEVENT_SUSPEND,
485 HGCMNOTIFYEVENT_RESET,
486 HGCMNOTIFYEVENT_POWER_OFF,
487 HGCMNOTIFYEVENT_END,
488 HGCMNOTIFYEVENT_32BIT_HACK = 0x7fffffff
489} HGCMNOTIFYEVENT;
490
491
492/** The Service DLL entry points.
493 *
494 * HGCM will call the DLL "VBoxHGCMSvcLoad"
495 * function and the DLL must fill in the VBOXHGCMSVCFNTABLE
496 * with function pointers.
497 *
498 * @note The structure is used in separately compiled binaries so an explicit
499 * packing is required.
500 */
501typedef struct VBOXHGCMSVCFNTABLE
502{
503 /** @name Filled by HGCM
504 * @{ */
505
506 /** Size of the structure. */
507 uint32_t cbSize;
508
509 /** Version of the structure, including the helpers. */
510 uint32_t u32Version;
511
512 PVBOXHGCMSVCHELPERS pHelpers;
513 /** @} */
514
515 /** @name Filled in by the service.
516 * @{ */
517
518 /** Size of client information the service want to have. */
519 uint32_t cbClient;
520#if ARCH_BITS == 64
521 /** Ensure that the following pointers are properly aligned on 64-bit system. */
522 uint32_t u32Alignment0;
523#endif
524
525 /** Uninitialize service */
526 DECLR3CALLBACKMEMBER(int, pfnUnload, (void *pvService));
527
528 /** Inform the service about a client connection. */
529 DECLR3CALLBACKMEMBER(int, pfnConnect, (void *pvService, uint32_t u32ClientID, void *pvClient, uint32_t fRequestor, bool fRestoring));
530
531 /** Inform the service that the client wants to disconnect. */
532 DECLR3CALLBACKMEMBER(int, pfnDisconnect, (void *pvService, uint32_t u32ClientID, void *pvClient));
533
534 /** Service entry point.
535 * Return code is passed to pfnCallComplete callback.
536 */
537 DECLR3CALLBACKMEMBER(void, pfnCall, (void *pvService, VBOXHGCMCALLHANDLE callHandle, uint32_t u32ClientID, void *pvClient,
538 uint32_t function, uint32_t cParms, VBOXHGCMSVCPARM paParms[], uint64_t tsArrival));
539 /** Informs the service that a call was cancelled by the guest (optional).
540 *
541 * This is called for guest calls, connect requests and disconnect requests.
542 * There is unfortunately no way of obtaining the call handle for a guest call
543 * or otherwise identify the request, so that's left to the service to figure
544 * out using VBOXHGCMSVCHELPERS::pfnIsCallCancelled. Because this is an
545 * asynchronous call, the service may have completed the request already.
546 */
547 DECLR3CALLBACKMEMBER(void, pfnCancelled, (void *pvService, uint32_t idClient, void *pvClient));
548
549 /** Host Service entry point meant for privileged features invisible to the guest.
550 * Return code is passed to pfnCallComplete callback.
551 */
552 DECLR3CALLBACKMEMBER(int, pfnHostCall, (void *pvService, uint32_t function, uint32_t cParms, VBOXHGCMSVCPARM paParms[]));
553
554 /** Inform the service about a VM save operation. */
555 DECLR3CALLBACKMEMBER(int, pfnSaveState, (void *pvService, uint32_t u32ClientID, void *pvClient, PSSMHANDLE pSSM));
556
557 /** Inform the service about a VM load operation. */
558 DECLR3CALLBACKMEMBER(int, pfnLoadState, (void *pvService, uint32_t u32ClientID, void *pvClient, PSSMHANDLE pSSM,
559 uint32_t uVersion));
560
561 /** Register a service extension callback. */
562 DECLR3CALLBACKMEMBER(int, pfnRegisterExtension, (void *pvService, PFNHGCMSVCEXT pfnExtension, void *pvExtension));
563
564 /** Notification (VM state). */
565 DECLR3CALLBACKMEMBER(void, pfnNotify, (void *pvService, HGCMNOTIFYEVENT enmEvent));
566
567 /** User/instance data pointer for the service. */
568 void *pvService;
569
570 /** @} */
571} VBOXHGCMSVCFNTABLE;
572
573
574/** @name HGCM saved state
575 * @note Need to be here so we can add saved to service which doesn't have it.
576 * @{ */
577/** HGCM saved state version. */
578#define HGCM_SAVED_STATE_VERSION 3
579/** HGCM saved state version w/o client state indicators. */
580#define HGCM_SAVED_STATE_VERSION_V2 2
581/** @} */
582
583
584/** Service initialization entry point. */
585typedef DECLCALLBACK(int) VBOXHGCMSVCLOAD(VBOXHGCMSVCFNTABLE *ptable);
586typedef VBOXHGCMSVCLOAD *PFNVBOXHGCMSVCLOAD;
587#define VBOX_HGCM_SVCLOAD_NAME "VBoxHGCMSvcLoad"
588
589#endif /* !VBOX_INCLUDED_hgcmsvc_h */
590
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette