VirtualBox

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

Last change on this file since 80396 was 80396, checked in by vboxsync, 5 years ago

Devices/DevVGA, Main: Get rid of obsolete code enclosed by VBOX_WITH_CRHGSMI, bugref:9529

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 20.6 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
458/** Service specific extension callback.
459 * This callback is called by the service to perform service specific operation.
460 *
461 * @param pvExtension The extension pointer.
462 * @param u32Function What the callback is supposed to do.
463 * @param pvParm The function parameters.
464 * @param cbParm The size of the function parameters.
465 */
466typedef DECLCALLBACK(int) FNHGCMSVCEXT(void *pvExtension, uint32_t u32Function, void *pvParm, uint32_t cbParms);
467typedef FNHGCMSVCEXT *PFNHGCMSVCEXT;
468
469/**
470 * Notification event.
471 */
472typedef enum HGCMNOTIFYEVENT
473{
474 HGCMNOTIFYEVENT_INVALID = 0,
475 HGCMNOTIFYEVENT_POWER_ON,
476 HGCMNOTIFYEVENT_RESUME,
477 HGCMNOTIFYEVENT_SUSPEND,
478 HGCMNOTIFYEVENT_RESET,
479 HGCMNOTIFYEVENT_POWER_OFF,
480 HGCMNOTIFYEVENT_END,
481 HGCMNOTIFYEVENT_32BIT_HACK = 0x7fffffff
482} HGCMNOTIFYEVENT;
483
484
485/** The Service DLL entry points.
486 *
487 * HGCM will call the DLL "VBoxHGCMSvcLoad"
488 * function and the DLL must fill in the VBOXHGCMSVCFNTABLE
489 * with function pointers.
490 *
491 * @note The structure is used in separately compiled binaries so an explicit
492 * packing is required.
493 */
494typedef struct VBOXHGCMSVCFNTABLE
495{
496 /** @name Filled by HGCM
497 * @{ */
498
499 /** Size of the structure. */
500 uint32_t cbSize;
501
502 /** Version of the structure, including the helpers. */
503 uint32_t u32Version;
504
505 PVBOXHGCMSVCHELPERS pHelpers;
506 /** @} */
507
508 /** @name Filled in by the service.
509 * @{ */
510
511 /** Size of client information the service want to have. */
512 uint32_t cbClient;
513#if ARCH_BITS == 64
514 /** Ensure that the following pointers are properly aligned on 64-bit system. */
515 uint32_t u32Alignment0;
516#endif
517
518 /** Uninitialize service */
519 DECLR3CALLBACKMEMBER(int, pfnUnload, (void *pvService));
520
521 /** Inform the service about a client connection. */
522 DECLR3CALLBACKMEMBER(int, pfnConnect, (void *pvService, uint32_t u32ClientID, void *pvClient, uint32_t fRequestor, bool fRestoring));
523
524 /** Inform the service that the client wants to disconnect. */
525 DECLR3CALLBACKMEMBER(int, pfnDisconnect, (void *pvService, uint32_t u32ClientID, void *pvClient));
526
527 /** Service entry point.
528 * Return code is passed to pfnCallComplete callback.
529 */
530 DECLR3CALLBACKMEMBER(void, pfnCall, (void *pvService, VBOXHGCMCALLHANDLE callHandle, uint32_t u32ClientID, void *pvClient,
531 uint32_t function, uint32_t cParms, VBOXHGCMSVCPARM paParms[], uint64_t tsArrival));
532 /** Informs the service that a call was cancelled by the guest (optional).
533 *
534 * This is called for guest calls, connect requests and disconnect requests.
535 * There is unfortunately no way of obtaining the call handle for a guest call
536 * or otherwise identify the request, so that's left to the service to figure
537 * out using VBOXHGCMSVCHELPERS::pfnIsCallCancelled. Because this is an
538 * asynchronous call, the service may have completed the request already.
539 */
540 DECLR3CALLBACKMEMBER(void, pfnCancelled, (void *pvService, uint32_t idClient, void *pvClient));
541
542 /** Host Service entry point meant for privileged features invisible to the guest.
543 * Return code is passed to pfnCallComplete callback.
544 */
545 DECLR3CALLBACKMEMBER(int, pfnHostCall, (void *pvService, uint32_t function, uint32_t cParms, VBOXHGCMSVCPARM paParms[]));
546
547 /** Inform the service about a VM save operation. */
548 DECLR3CALLBACKMEMBER(int, pfnSaveState, (void *pvService, uint32_t u32ClientID, void *pvClient, PSSMHANDLE pSSM));
549
550 /** Inform the service about a VM load operation. */
551 DECLR3CALLBACKMEMBER(int, pfnLoadState, (void *pvService, uint32_t u32ClientID, void *pvClient, PSSMHANDLE pSSM,
552 uint32_t uVersion));
553
554 /** Register a service extension callback. */
555 DECLR3CALLBACKMEMBER(int, pfnRegisterExtension, (void *pvService, PFNHGCMSVCEXT pfnExtension, void *pvExtension));
556
557 /** Notification (VM state). */
558 DECLR3CALLBACKMEMBER(void, pfnNotify, (void *pvService, HGCMNOTIFYEVENT enmEvent));
559
560 /** User/instance data pointer for the service. */
561 void *pvService;
562
563 /** @} */
564} VBOXHGCMSVCFNTABLE;
565
566
567/** @name HGCM saved state
568 * @note Need to be here so we can add saved to service which doesn't have it.
569 * @{ */
570/** HGCM saved state version. */
571#define HGCM_SAVED_STATE_VERSION 3
572/** HGCM saved state version w/o client state indicators. */
573#define HGCM_SAVED_STATE_VERSION_V2 2
574/** @} */
575
576
577/** Service initialization entry point. */
578typedef DECLCALLBACK(int) VBOXHGCMSVCLOAD(VBOXHGCMSVCFNTABLE *ptable);
579typedef VBOXHGCMSVCLOAD *PFNVBOXHGCMSVCLOAD;
580#define VBOX_HGCM_SVCLOAD_NAME "VBoxHGCMSvcLoad"
581
582#endif /* !VBOX_INCLUDED_hgcmsvc_h */
583
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