VirtualBox

source: vbox/trunk/include/VBox/VBoxGuest.h@ 4636

Last change on this file since 4636 was 4611, checked in by vboxsync, 18 years ago

Updates

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 47.6 KB
Line 
1/** @file
2 * VBoxGuest - VirtualBox Guest Additions interface
3 */
4
5/*
6 * Copyright (C) 2006-2007 innotek GmbH
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 as published by the Free Software Foundation,
12 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
13 * distribution. VirtualBox OSE is distributed in the hope that it will
14 * be useful, but WITHOUT ANY WARRANTY of any kind.
15 */
16
17#ifndef ___VBox_VBoxGuest_h
18#define ___VBox_VBoxGuest_h
19
20#include <iprt/cdefs.h>
21#include <iprt/types.h>
22#include <VBox/err.h>
23#include <VBox/ostypes.h>
24
25/*******************************************************************************
26* Defined Constants And Macros *
27*******************************************************************************/
28
29/** @todo The following is a temporary fix for the problem of accessing
30 hypervisor pointers from within guest additions */
31
32/** Hypervisor linear pointer size type */
33typedef uint32_t vmmDevHypPtr;
34/** Hypervisor physical pointer size type */
35typedef uint32_t vmmDevHypPhys;
36
37#if defined(RT_OS_LINUX)
38/** The support device name. */
39# define VBOXGUEST_DEVICE_NAME "/dev/vboxadd"
40
41#elif defined(RT_OS_OS2)
42/** The support device name. */
43# define VBOXGUEST_DEVICE_NAME "\\Dev\\VBoxGst$"
44
45#elif defined(RT_OS_WINDOWS)
46/** The support service name. */
47# define VBOXGUEST_SERVICE_NAME "VBoxGuest"
48/** Win32 Device name. */
49# define VBOXGUEST_DEVICE_NAME "\\\\.\\VBoxGuest"
50/** Global name for Win2k+ */
51# define VBOXGUEST_DEVICE_NAME_GLOBAL "\\\\.\\Global\\VBoxGuest"
52/** Win32 driver name */
53# define VBOXGUEST_DEVICE_NAME_NT L"\\Device\\VBoxGuest"
54/** device name */
55# define VBOXGUEST_DEVICE_NAME_DOS L"\\DosDevices\\VBoxGuest"
56
57#else
58/* PORTME */
59#endif
60
61/** VirtualBox vendor ID */
62#define VBOX_PCI_VENDORID (0x80ee)
63
64/** VMMDev PCI card identifiers */
65#define VMMDEV_VENDORID VBOX_PCI_VENDORID
66#define VMMDEV_DEVICEID (0xcafe)
67
68/** VirtualBox graphics card identifiers */
69#define VBOX_VENDORID VBOX_PCI_VENDORID
70#define VBOX_VESA_VENDORID VBOX_PCI_VENDORID
71#define VBOX_DEVICEID (0xbeef)
72#define VBOX_VESA_DEVICEID (0xbeef)
73
74/**
75 * VBoxGuest port definitions
76 * @{
77 */
78
79/** guest can (== wants to) handle absolute coordinates */
80#define VBOXGUEST_MOUSE_GUEST_CAN_ABSOLUTE BIT(0)
81/** host can (== wants to) send absolute coordinates */
82#define VBOXGUEST_MOUSE_HOST_CAN_ABSOLUTE BIT(1)
83/** guest can *NOT* switch to software cursor and therefore depends on the host cursor */
84#define VBOXGUEST_MOUSE_GUEST_NEEDS_HOST_CURSOR BIT(2)
85/** host does NOT provide support for drawing the cursor itself (e.g. L4 console) */
86#define VBOXGUEST_MOUSE_HOST_CANNOT_HWPOINTER BIT(3)
87
88/** fictive start address of the hypervisor physical memory for MmMapIoSpace */
89#define HYPERVISOR_PHYSICAL_START 0xf8000000
90
91/*
92 * VMMDev Generic Request Interface
93 */
94
95/** port for generic request interface */
96#define PORT_VMMDEV_REQUEST_OFFSET 0
97
98/** Current version of the VMMDev interface.
99 *
100 * Additions are allowed to work only if
101 * additions_major == vmmdev_current && additions_minor <= vmmdev_current.
102 * Additions version is reported to host (VMMDev) by VMMDevReq_ReportGuestInfo.
103 *
104 * @remark These defines also live in the 16-bit and assembly versions of this header.
105 */
106#define VMMDEV_VERSION_MAJOR (0x1)
107#define VMMDEV_VERSION_MINOR (0x4)
108#define VMMDEV_VERSION ((VMMDEV_VERSION_MAJOR << 16) | VMMDEV_VERSION_MINOR)
109
110/**
111 * VMMDev request types.
112 * @note when updating this, adjust vmmdevGetRequestSize() as well
113 */
114typedef enum
115{
116 VMMDevReq_InvalidRequest = 0,
117 VMMDevReq_GetMouseStatus = 1,
118 VMMDevReq_SetMouseStatus = 2,
119 VMMDevReq_SetPointerShape = 3,
120 /** @todo implement on host side */
121 VMMDevReq_GetHostVersion = 4,
122 VMMDevReq_Idle = 5,
123 VMMDevReq_GetHostTime = 10,
124 VMMDevReq_GetHypervisorInfo = 20,
125 VMMDevReq_SetHypervisorInfo = 21,
126 VMMDevReq_SetPowerStatus = 30,
127 VMMDevReq_AcknowledgeEvents = 41,
128 VMMDevReq_CtlGuestFilterMask = 42,
129 VMMDevReq_ReportGuestInfo = 50,
130 VMMDevReq_GetDisplayChangeRequest = 51,
131 VMMDevReq_VideoModeSupported = 52,
132 VMMDevReq_GetHeightReduction = 53,
133 VMMDevReq_GetDisplayChangeRequest2 = 54,
134 VMMDevReq_ReportGuestCapabilities = 55,
135#ifdef VBOX_HGCM
136 VMMDevReq_HGCMConnect = 60,
137 VMMDevReq_HGCMDisconnect = 61,
138 VMMDevReq_HGCMCall = 62,
139#endif
140 VMMDevReq_VideoAccelEnable = 70,
141 VMMDevReq_VideoAccelFlush = 71,
142 VMMDevReq_VideoSetVisibleRegion = 72,
143 VMMDevReq_GetSeamlessChangeRequest = 73,
144 VMMDevReq_QueryCredentials = 100,
145 VMMDevReq_ReportCredentialsJudgement = 101,
146 VMMDevReq_ReportGuestStats = 110,
147 VMMDevReq_GetMemBalloonChangeRequest = 111,
148 VMMDevReq_GetStatisticsChangeRequest = 112,
149 VMMDevReq_ChangeMemBalloon = 113,
150 VMMDevReq_GetVRDPChangeRequest = 150,
151 VMMDevReq_LogString = 200,
152 VMMDevReq_SizeHack = 0x7fffffff
153} VMMDevRequestType;
154
155/** Version of VMMDevRequestHeader structure. */
156#define VMMDEV_REQUEST_HEADER_VERSION (0x10001)
157
158#pragma pack(4)
159/** generic VMMDev request header */
160typedef struct
161{
162 /** size of the structure in bytes (including body). Filled by caller */
163 uint32_t size;
164 /** version of the structure. Filled by caller */
165 uint32_t version;
166 /** type of the request */
167 VMMDevRequestType requestType;
168 /** return code. Filled by VMMDev */
169 int32_t rc;
170 /** reserved fields */
171 uint32_t reserved1;
172 uint32_t reserved2;
173} VMMDevRequestHeader;
174
175/** mouse status request structure */
176typedef struct
177{
178 /** header */
179 VMMDevRequestHeader header;
180 /** mouse feature mask */
181 uint32_t mouseFeatures;
182 /** mouse x position */
183 uint32_t pointerXPos;
184 /** mouse y position */
185 uint32_t pointerYPos;
186} VMMDevReqMouseStatus;
187
188/** Note VBOX_MOUSE_POINTER_* flags are used in guest video driver,
189 * values must be <= 0x8000 and must not be changed.
190 */
191
192/** pointer is visible */
193#define VBOX_MOUSE_POINTER_VISIBLE (0x0001)
194/** pointer has alpha channel */
195#define VBOX_MOUSE_POINTER_ALPHA (0x0002)
196/** pointerData contains new pointer shape */
197#define VBOX_MOUSE_POINTER_SHAPE (0x0004)
198
199/** mouse pointer shape/visibility change request */
200typedef struct
201{
202 /** header */
203 VMMDevRequestHeader header;
204 /** VBOX_MOUSE_POINTER_* bit flags */
205 uint32_t fFlags;
206 /** x coordinate of hot spot */
207 uint32_t xHot;
208 /** y coordinate of hot spot */
209 uint32_t yHot;
210 /** width of the pointer in pixels */
211 uint32_t width;
212 /** height of the pointer in scanlines */
213 uint32_t height;
214 /** Pointer data.
215 *
216 ****
217 * The data consists of 1 bpp AND mask followed by 32 bpp XOR (color) mask.
218 *
219 * For pointers without alpha channel the XOR mask pixels are 32 bit values: (lsb)BGR0(msb).
220 * For pointers with alpha channel the XOR mask consists of (lsb)BGRA(msb) 32 bit values.
221 *
222 * Guest driver must create the AND mask for pointers with alpha channel, so if host does not
223 * support alpha, the pointer could be displayed as a normal color pointer. The AND mask can
224 * be constructed from alpha values. For example alpha value >= 0xf0 means bit 0 in the AND mask.
225 *
226 * The AND mask is 1 bpp bitmap with byte aligned scanlines. Size of AND mask,
227 * therefore, is cbAnd = (width + 7) / 8 * height. The padding bits at the
228 * end of any scanline are undefined.
229 *
230 * The XOR mask follows the AND mask on the next 4 bytes aligned offset:
231 * uint8_t *pXor = pAnd + (cbAnd + 3) & ~3
232 * Bytes in the gap between the AND and the XOR mask are undefined.
233 * XOR mask scanlines have no gap between them and size of XOR mask is:
234 * cXor = width * 4 * height.
235 ****
236 *
237 * Preallocate 4 bytes for accessing actual data as p->pointerData
238 */
239 char pointerData[4];
240} VMMDevReqMousePointer;
241
242/** string log request structure */
243typedef struct
244{
245 /** header */
246 VMMDevRequestHeader header;
247 /** variable length string data */
248 char szString[1];
249} VMMDevReqLogString;
250
251/** host version request structure */
252typedef struct
253{
254 /** header */
255 VMMDevRequestHeader header;
256 /** major version */
257 uint32_t major;
258 /** minor version */
259 uint32_t minor;
260 /** build number */
261 uint32_t build;
262} VMMDevReqHostVersion;
263
264/** guest capabilites structure */
265typedef struct
266{
267 /** header */
268 VMMDevRequestHeader header;
269 /** capabilities (VMMDEV_GUEST_*) */
270 uint32_t caps;
271} VMMDevReqGuestCapabilities;
272
273/** idle request structure */
274typedef struct
275{
276 /** header */
277 VMMDevRequestHeader header;
278} VMMDevReqIdle;
279
280/** host time request structure */
281typedef struct
282{
283 /** header */
284 VMMDevRequestHeader header;
285 /** time in milliseconds since unix epoch. Filled by VMMDev. */
286 uint64_t time;
287} VMMDevReqHostTime;
288
289/** hypervisor info structure */
290typedef struct
291{
292 /** header */
293 VMMDevRequestHeader header;
294 /** guest virtual address of proposed hypervisor start */
295 vmmDevHypPtr hypervisorStart;
296 /** hypervisor size in bytes */
297 uint32_t hypervisorSize;
298} VMMDevReqHypervisorInfo;
299
300/** system power requests */
301typedef enum
302{
303 VMMDevPowerState_Invalid = 0,
304 VMMDevPowerState_Pause = 1,
305 VMMDevPowerState_PowerOff = 2,
306 VMMDevPowerState_SaveState = 3,
307 VMMDevPowerState_SizeHack = 0x7fffffff
308} VMMDevPowerState;
309
310/** system power status structure */
311typedef struct
312{
313 /** header */
314 VMMDevRequestHeader header;
315 /** power state request */
316 VMMDevPowerState powerState;
317} VMMDevPowerStateRequest;
318
319/** pending events structure */
320typedef struct
321{
322 /** header */
323 VMMDevRequestHeader header;
324 /** pending event bitmap */
325 uint32_t events;
326} VMMDevEvents;
327
328/** guest filter mask control */
329typedef struct
330{
331 /** header */
332 VMMDevRequestHeader header;
333 /** mask of events to be added to filter */
334 uint32_t u32OrMask;
335 /** mask of events to be removed from filter */
336 uint32_t u32NotMask;
337} VMMDevCtlGuestFilterMask;
338
339/** guest information structure */
340typedef struct VBoxGuestInfo
341{
342 /** The VMMDev interface version expected by additions. */
343 uint32_t additionsVersion;
344 /** guest OS type */
345 OSType osType;
346 /** @todo */
347} VBoxGuestInfo;
348
349/** guest information structure */
350typedef struct
351{
352 /** header */
353 VMMDevRequestHeader header;
354 /** Guest information. */
355 VBoxGuestInfo guestInfo;
356} VMMDevReportGuestInfo;
357
358/** guest statistics values */
359#define VBOX_GUEST_STAT_CPU_LOAD_IDLE BIT(0)
360#define VBOX_GUEST_STAT_CPU_LOAD_KERNEL BIT(1)
361#define VBOX_GUEST_STAT_CPU_LOAD_USER BIT(2)
362#define VBOX_GUEST_STAT_THREADS BIT(3)
363#define VBOX_GUEST_STAT_PROCESSES BIT(4)
364#define VBOX_GUEST_STAT_HANDLES BIT(5)
365#define VBOX_GUEST_STAT_MEMORY_LOAD BIT(6)
366#define VBOX_GUEST_STAT_PHYS_MEM_TOTAL BIT(7)
367#define VBOX_GUEST_STAT_PHYS_MEM_AVAIL BIT(8)
368#define VBOX_GUEST_STAT_PHYS_MEM_BALLOON BIT(9)
369#define VBOX_GUEST_STAT_MEM_COMMIT_TOTAL BIT(10)
370#define VBOX_GUEST_STAT_MEM_KERNEL_TOTAL BIT(11)
371#define VBOX_GUEST_STAT_MEM_KERNEL_PAGED BIT(12)
372#define VBOX_GUEST_STAT_MEM_KERNEL_NONPAGED BIT(13)
373#define VBOX_GUEST_STAT_MEM_SYSTEM_CACHE BIT(14)
374#define VBOX_GUEST_STAT_PAGE_FILE_SIZE BIT(15)
375
376
377/** guest statistics structure */
378typedef struct VBoxGuestStatistics
379{
380 /** Virtual CPU id */
381 uint32_t u32CpuId;
382 /** Reported statistics */
383 uint32_t u32StatCaps;
384 /** Idle CPU load (0-100) for last interval */
385 uint32_t u32CpuLoad_Idle;
386 /** Kernel CPU load (0-100) for last interval */
387 uint32_t u32CpuLoad_Kernel;
388 /** User CPU load (0-100) for last interval */
389 uint32_t u32CpuLoad_User;
390 /** Nr of threads */
391 uint32_t u32Threads;
392 /** Nr of processes */
393 uint32_t u32Processes;
394 /** Nr of handles */
395 uint32_t u32Handles;
396 /** Memory load (0-100) */
397 uint32_t u32MemoryLoad;
398 /** Page size of guest system */
399 uint32_t u32PageSize;
400 /** Total physical memory (in 4kb pages) */
401 uint32_t u32PhysMemTotal;
402 /** Available physical memory (in 4kb pages) */
403 uint32_t u32PhysMemAvail;
404 /** Ballooned physical memory (in 4kb pages) */
405 uint32_t u32PhysMemBalloon;
406 /** Total number of committed memory (which is not necessarily in-use) (in 4kb pages) */
407 uint32_t u32MemCommitTotal;
408 /** Total amount of memory used by the kernel (in 4kb pages) */
409 uint32_t u32MemKernelTotal;
410 /** Total amount of paged memory used by the kernel (in 4kb pages) */
411 uint32_t u32MemKernelPaged;
412 /** Total amount of nonpaged memory used by the kernel (in 4kb pages) */
413 uint32_t u32MemKernelNonPaged;
414 /** Total amount of memory used for the system cache (in 4kb pages) */
415 uint32_t u32MemSystemCache;
416 /** Pagefile size (in 4kb pages) */
417 uint32_t u32PageFileSize;
418} VBoxGuestStatistics;
419
420/** guest statistics command structure */
421typedef struct
422{
423 /** header */
424 VMMDevRequestHeader header;
425 /** Guest information. */
426 VBoxGuestStatistics guestStats;
427} VMMDevReportGuestStats;
428
429/** memory balloon change request structure */
430#define VMMDEV_MAX_MEMORY_BALLOON(PhysMemTotal) ((90*PhysMemTotal)/100)
431
432typedef struct
433{
434 /** header */
435 VMMDevRequestHeader header;
436 uint32_t u32BalloonSize; /* balloon size in megabytes */
437 uint32_t u32PhysMemSize; /* guest ram size in megabytes */
438 uint32_t eventAck;
439} VMMDevGetMemBalloonChangeRequest;
440
441/** inflate/deflate memory balloon structure */
442#define VMMDEV_MEMORY_BALLOON_CHUNK_PAGES (_1M/4096)
443
444typedef struct
445{
446 /** header */
447 VMMDevRequestHeader header;
448 uint32_t cPages;
449 uint32_t fInflate; /* true = inflate, false = defalte */
450 RTGCPHYS aPhysPage[1]; /* variable size */
451} VMMDevChangeMemBalloon;
452
453/** guest statistics interval change request structure */
454typedef struct
455{
456 /** header */
457 VMMDevRequestHeader header;
458 uint32_t u32StatInterval; /* interval in seconds */
459 uint32_t eventAck;
460} VMMDevGetStatisticsChangeRequest;
461
462/** display change request structure */
463typedef struct
464{
465 /** header */
466 VMMDevRequestHeader header;
467 /** horizontal pixel resolution (0 = do not change) */
468 uint32_t xres;
469 /** vertical pixel resolution (0 = do not change) */
470 uint32_t yres;
471 /** bits per pixel (0 = do not change) */
472 uint32_t bpp;
473 /** Flag that the request is an acknowlegement for the VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST.
474 * Values: 0 - just querying, VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST - event acknowledged.
475 */
476 uint32_t eventAck;
477} VMMDevDisplayChangeRequest;
478
479typedef struct
480{
481 /** header */
482 VMMDevRequestHeader header;
483 /** horizontal pixel resolution (0 = do not change) */
484 uint32_t xres;
485 /** vertical pixel resolution (0 = do not change) */
486 uint32_t yres;
487 /** bits per pixel (0 = do not change) */
488 uint32_t bpp;
489 /** Flag that the request is an acknowlegement for the VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST.
490 * Values: 0 - just querying, VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST - event acknowledged.
491 */
492 uint32_t eventAck;
493 /** 0 for primary display, 1 for the first secondary, etc. */
494 uint32_t display;
495} VMMDevDisplayChangeRequest2;
496
497/** video mode supported request structure */
498typedef struct
499{
500 /** header */
501 VMMDevRequestHeader header;
502 /** horizontal pixel resolution (input) */
503 uint32_t width;
504 /** vertical pixel resolution (input) */
505 uint32_t height;
506 /** bits per pixel (input) */
507 uint32_t bpp;
508 /** supported flag (output) */
509 bool fSupported;
510} VMMDevVideoModeSupportedRequest;
511
512/** video modes height reduction request structure */
513typedef struct
514{
515 /** header */
516 VMMDevRequestHeader header;
517 /** height reduction in pixels (output) */
518 uint32_t heightReduction;
519} VMMDevGetHeightReductionRequest;
520
521#define VRDP_EXPERIENCE_LEVEL_ZERO 0 /* Theming disabled. */
522#define VRDP_EXPERIENCE_LEVEL_LOW 1 /* Full window dragging and desktop wallpaper disabled. */
523#define VRDP_EXPERIENCE_LEVEL_MEDIUM 2 /* Font smoothing, gradients. */
524#define VRDP_EXPERIENCE_LEVEL_HIGH 3 /* Animation effects disabled. */
525#define VRDP_EXPERIENCE_LEVEL_FULL 4 /* Everything enabled. */
526
527typedef struct
528{
529 /** header */
530 VMMDevRequestHeader header;
531 /** Whether VRDP is active or not */
532 uint8_t u8VRDPActive;
533 /** The configured experience level for active VRDP. */
534 uint32_t u32VRDPExperienceLevel;
535} VMMDevVRDPChangeRequest;
536
537
538
539#pragma pack()
540
541#ifdef VBOX_HGCM
542
543/** HGCM flags.
544 * @{
545 */
546#define VBOX_HGCM_REQ_DONE (0x1)
547#define VBOX_HGCM_REQ_CANCELLED (0x2)
548/** @} */
549
550#pragma pack(4)
551typedef struct _VMMDevHGCMRequestHeader
552{
553 /** Request header. */
554 VMMDevRequestHeader header;
555
556 /** HGCM flags. */
557 uint32_t fu32Flags;
558
559 /** Result code. */
560 int32_t result;
561} VMMDevHGCMRequestHeader;
562
563/** HGCM service location types. */
564typedef enum
565{
566 VMMDevHGCMLoc_Invalid = 0,
567 VMMDevHGCMLoc_LocalHost = 1,
568 VMMDevHGCMLoc_LocalHost_Existing = 2,
569 VMMDevHGCMLoc_SizeHack = 0x7fffffff
570} HGCMServiceLocationType;
571
572typedef struct
573{
574 char achName[128];
575} HGCMServiceLocationHost;
576
577typedef struct HGCMSERVICELOCATION
578{
579 /** Type of the location. */
580 HGCMServiceLocationType type;
581
582 union
583 {
584 HGCMServiceLocationHost host;
585 } u;
586} HGCMServiceLocation;
587
588typedef struct
589{
590 /* request header */
591 VMMDevHGCMRequestHeader header;
592
593 /** IN: Description of service to connect to. */
594 HGCMServiceLocation loc;
595
596 /** OUT: Client identifier assigned by local instance of HGCM. */
597 uint32_t u32ClientID;
598} VMMDevHGCMConnect;
599
600typedef struct
601{
602 /* request header */
603 VMMDevHGCMRequestHeader header;
604
605 /** IN: Client identifier. */
606 uint32_t u32ClientID;
607} VMMDevHGCMDisconnect;
608
609typedef enum
610{
611 VMMDevHGCMParmType_Invalid = 0,
612 VMMDevHGCMParmType_32bit = 1,
613 VMMDevHGCMParmType_64bit = 2,
614 VMMDevHGCMParmType_PhysAddr = 3,
615 VMMDevHGCMParmType_LinAddr = 4, /**< In and Out */
616 VMMDevHGCMParmType_LinAddr_In = 5, /**< In (read; host<-guest) */
617 VMMDevHGCMParmType_LinAddr_Out = 6, /**< Out (write; host->guest) */
618 VMMDevHGCMParmType_LinAddr_Locked = 7, /**< Locked In and Out */
619 VMMDevHGCMParmType_LinAddr_Locked_In = 8, /**< Locked In (read; host<-guest) */
620 VMMDevHGCMParmType_LinAddr_Locked_Out = 9, /**< Locked Out (write; host->guest) */
621 VMMDevHGCMParmType_SizeHack = 0x7fffffff
622} HGCMFunctionParameterType;
623
624typedef struct _HGCMFUNCTIONPARAMETER
625{
626 HGCMFunctionParameterType type;
627 union
628 {
629 uint32_t value32;
630 uint64_t value64;
631 struct
632 {
633 uint32_t size;
634
635 union
636 {
637 vmmDevHypPhys physAddr;
638 vmmDevHypPtr linearAddr;
639 } u;
640 } Pointer;
641 } u;
642} HGCMFunctionParameter;
643
644typedef struct
645{
646 /* request header */
647 VMMDevHGCMRequestHeader header;
648
649 /** IN: Client identifier. */
650 uint32_t u32ClientID;
651 /** IN: Service function number. */
652 uint32_t u32Function;
653 /** IN: Number of parameters. */
654 uint32_t cParms;
655 /** Parameters follow in form: HGCMFunctionParameter aParms[X]; */
656} VMMDevHGCMCall;
657#pragma pack()
658
659#define VMMDEV_HGCM_CALL_PARMS(a) ((HGCMFunctionParameter *)((char *)a + sizeof (VMMDevHGCMCall)))
660
661#define VBOX_HGCM_MAX_PARMS 32
662
663#endif /* VBOX_HGCM */
664
665
666#define VBVA_F_STATUS_ACCEPTED (0x01)
667#define VBVA_F_STATUS_ENABLED (0x02)
668
669#pragma pack(4)
670
671typedef struct _VMMDevVideoAccelEnable
672{
673 /* request header */
674 VMMDevRequestHeader header;
675
676 /** 0 - disable, !0 - enable. */
677 uint32_t u32Enable;
678
679 /** The size of VBVAMEMORY::au8RingBuffer expected by driver.
680 * The host will refuse to enable VBVA if the size is not equal to
681 * VBVA_RING_BUFFER_SIZE.
682 */
683 uint32_t cbRingBuffer;
684
685 /** Guest initializes the status to 0. Host sets appropriate VBVA_F_STATUS_ flags. */
686 uint32_t fu32Status;
687
688} VMMDevVideoAccelEnable;
689
690typedef struct _VMMDevVideoAccelFlush
691{
692 /* request header */
693 VMMDevRequestHeader header;
694
695} VMMDevVideoAccelFlush;
696
697
698typedef struct _VMMDevVideoSetVisibleRegion
699{
700 /* request header */
701 VMMDevRequestHeader header;
702
703 /** Number of rectangles */
704 uint32_t cRect;
705
706 /** Rectangle array */
707 RTRECT Rect;
708} VMMDevVideoSetVisibleRegion;
709
710
711/** Seamless mode */
712typedef enum
713{
714 VMMDev_Seamless_Disabled = 0, /* normal mode; entire guest desktop displayed */
715 VMMDev_Seamless_Visible_Region = 1, /* visible region mode; only top-level guest windows displayed */
716 VMMDev_Seamless_Host_Window = 2 /* windowed mode; each top-level guest window is represented in a host window */
717} VMMDevSeamlessMode;
718
719typedef struct
720{
721 /** header */
722 VMMDevRequestHeader header;
723
724 /** New seamless mode */
725 VMMDevSeamlessMode mode;
726 /** Flag that the request is an acknowlegement for the VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST.
727 * Values: 0 - just querying, VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST - event acknowledged.
728 */
729 uint32_t eventAck;
730} VMMDevSeamlessChangeRequest;
731
732#pragma pack()
733
734#pragma pack(1)
735
736/** VBVA command header. */
737typedef struct _VBVACMDHDR
738{
739 /** Coordinates of affected rectangle. */
740 int16_t x;
741 int16_t y;
742 uint16_t w;
743 uint16_t h;
744} VBVACMDHDR;
745
746/* VBVA order codes. Must be >= 0, because the VRDP server internally
747 * uses negative values to mark some operations.
748 * Values are important since they are used as an index in the
749 * "supported orders" bit mask.
750 */
751#define VBVA_VRDP_DIRTY_RECT (0)
752#define VBVA_VRDP_SOLIDRECT (1)
753#define VBVA_VRDP_SOLIDBLT (2)
754#define VBVA_VRDP_DSTBLT (3)
755#define VBVA_VRDP_SCREENBLT (4)
756#define VBVA_VRDP_PATBLTBRUSH (5)
757#define VBVA_VRDP_MEMBLT (6)
758#define VBVA_VRDP_CACHED_BITMAP (7)
759#define VBVA_VRDP_DELETED_BITMAP (8)
760#define VBVA_VRDP_LINE (9)
761#define VBVA_VRDP_BOUNDS (10)
762#define VBVA_VRDP_REPEAT (11)
763#define VBVA_VRDP_POLYLINE (12)
764#define VBVA_VRDP_ELLIPSE (13)
765#define VBVA_VRDP_SAVESCREEN (14)
766
767#define VBVA_VRDP_INDEX_TO_BIT(__index) (1 << (__index))
768
769#ifndef VRDP_NO_COM
770/* 128 bit bitmap hash. */
771typedef uint8_t VRDPBITMAPHASH[16];
772
773typedef struct _VRDPORDERPOINT
774{
775 int16_t x;
776 int16_t y;
777} VRDPORDERPOINT;
778
779typedef struct _VRDPORDERPOLYPOINTS
780{
781 uint8_t c;
782 VRDPORDERPOINT a[16];
783} VRDPORDERPOLYPOINTS;
784
785typedef struct _VRDPORDERAREA
786{
787 int16_t x;
788 int16_t y;
789 uint16_t w;
790 uint16_t h;
791} VRDPORDERAREA;
792
793typedef struct _VRDPORDERBOUNDS
794{
795 VRDPORDERPOINT pt1;
796 VRDPORDERPOINT pt2;
797} VRDPORDERBOUNDS;
798
799typedef struct _VRDPORDERREPEAT
800{
801 VRDPORDERBOUNDS bounds;
802} VRDPORDERREPEAT;
803
804
805/* Header for bitmap bits in VBVA VRDP operations. */
806typedef struct _VRDPDATABITS
807{
808 /* Size of bitmap data without the header. */
809 uint32_t cb;
810 int16_t x;
811 int16_t y;
812 uint16_t cWidth;
813 uint16_t cHeight;
814 uint8_t cbPixel;
815} VRDPDATABITS;
816
817typedef struct _VRDPORDERSOLIDRECT
818{
819 int16_t x;
820 int16_t y;
821 uint16_t w;
822 uint16_t h;
823 uint32_t rgb;
824} VRDPORDERSOLIDRECT;
825
826typedef struct _VRDPORDERSOLIDBLT
827{
828 int16_t x;
829 int16_t y;
830 uint16_t w;
831 uint16_t h;
832 uint32_t rgb;
833 uint8_t rop;
834} VRDPORDERSOLIDBLT;
835
836typedef struct _VRDPORDERDSTBLT
837{
838 int16_t x;
839 int16_t y;
840 uint16_t w;
841 uint16_t h;
842 uint8_t rop;
843} VRDPORDERDSTBLT;
844
845typedef struct _VRDPORDERSCREENBLT
846{
847 int16_t x;
848 int16_t y;
849 uint16_t w;
850 uint16_t h;
851 int16_t xSrc;
852 int16_t ySrc;
853 uint8_t rop;
854} VRDPORDERSCREENBLT;
855
856typedef struct _VRDPORDERPATBLTBRUSH
857{
858 int16_t x;
859 int16_t y;
860 uint16_t w;
861 uint16_t h;
862 int8_t xSrc;
863 int8_t ySrc;
864 uint32_t rgbFG;
865 uint32_t rgbBG;
866 uint8_t rop;
867 uint8_t pattern[8];
868} VRDPORDERPATBLTBRUSH;
869
870typedef struct _VRDPORDERMEMBLT
871{
872 int16_t x;
873 int16_t y;
874 uint16_t w;
875 uint16_t h;
876 int16_t xSrc;
877 int16_t ySrc;
878 uint8_t rop;
879 VRDPBITMAPHASH hash;
880} VRDPORDERMEMBLT;
881
882typedef struct _VRDPORDERCACHEDBITMAP
883{
884 VRDPBITMAPHASH hash;
885 /* VRDPDATABITS and the bitmap data follows. */
886} VRDPORDERCACHEDBITMAP;
887
888typedef struct _VRDPORDERDELETEDBITMAP
889{
890 VRDPBITMAPHASH hash;
891} VRDPORDERDELETEDBITMAP;
892
893typedef struct _VRDPORDERLINE
894{
895 int16_t x1;
896 int16_t y1;
897 int16_t x2;
898 int16_t y2;
899 int16_t xBounds1;
900 int16_t yBounds1;
901 int16_t xBounds2;
902 int16_t yBounds2;
903 uint8_t mix;
904 uint32_t rgb;
905} VRDPORDERLINE;
906
907typedef struct _VRDPORDERPOLYLINE
908{
909 VRDPORDERPOINT ptStart;
910 uint8_t mix;
911 uint32_t rgb;
912 VRDPORDERPOLYPOINTS points;
913} VRDPORDERPOLYLINE;
914
915typedef struct _VRDPORDERELLIPSE
916{
917 VRDPORDERPOINT pt1;
918 VRDPORDERPOINT pt2;
919 uint8_t mix;
920 uint8_t fillMode;
921 uint32_t rgb;
922} VRDPORDERELLIPSE;
923
924typedef struct _VRDPORDERSAVESCREEN
925{
926 VRDPORDERPOINT pt1;
927 VRDPORDERPOINT pt2;
928 uint8_t ident;
929 uint8_t restore;
930} VRDPORDERSAVESCREEN;
931#endif /* VRDP_NO_COM */
932#pragma pack()
933
934/* The VBVA ring buffer is suitable for transferring large (< 2gb) amount of data.
935 * For example big bitmaps which do not fit to the buffer.
936 *
937 * Guest starts writing to the buffer by initializing a record entry in the
938 * aRecords queue. VBVA_F_RECORD_PARTIAL indicates that the record is being
939 * written. As data is written to the ring buffer, the guest increases off32End
940 * for the record.
941 *
942 * The host reads the aRecords on flushes and processes all completed records.
943 * When host encounters situation when only a partial record presents and
944 * cbRecord & ~VBVA_F_RECORD_PARTIAL >= VBVA_RING_BUFFER_SIZE - VBVA_RING_BUFFER_THRESHOLD,
945 * the host fetched all record data and updates off32Head. After that on each flush
946 * the host continues fetching the data until the record is completed.
947 *
948 */
949
950#define VBVA_RING_BUFFER_SIZE (_4M - _1K)
951#define VBVA_RING_BUFFER_THRESHOLD (4 * _1K)
952
953#define VBVA_MAX_RECORDS (64)
954
955#define VBVA_F_MODE_ENABLED (0x00000001)
956#define VBVA_F_MODE_VRDP (0x00000002)
957#define VBVA_F_MODE_VRDP_RESET (0x00000004)
958#define VBVA_F_MODE_VRDP_ORDER_MASK (0x00000008)
959
960#define VBVA_F_RECORD_PARTIAL (0x80000000)
961
962#pragma pack(1)
963typedef struct _VBVARECORD
964{
965 /** The length of the record. Changed by guest. */
966 uint32_t cbRecord;
967} VBVARECORD;
968
969typedef struct _VBVAMEMORY
970{
971 /** VBVA_F_MODE_* */
972 uint32_t fu32ModeFlags;
973
974 /** The offset where the data start in the buffer. */
975 uint32_t off32Data;
976 /** The offset where next data must be placed in the buffer. */
977 uint32_t off32Free;
978
979 /** The ring buffer for data. */
980 uint8_t au8RingBuffer[VBVA_RING_BUFFER_SIZE];
981
982 /** The queue of record descriptions. */
983 VBVARECORD aRecords[VBVA_MAX_RECORDS];
984 uint32_t indexRecordFirst;
985 uint32_t indexRecordFree;
986
987 /* RDP orders supported by the client. The guest reports only them
988 * and falls back to DIRTY rects for not supported ones.
989 *
990 * (1 << VBVA_VRDP_*)
991 */
992 uint32_t fu32SupportedOrders;
993
994} VBVAMEMORY;
995#pragma pack()
996
997/** @} */
998
999
1000/**
1001 * VMMDev RAM
1002 * @{
1003 */
1004
1005#pragma pack(1)
1006/** Layout of VMMDEV RAM region that contains information for guest */
1007typedef struct
1008{
1009 /** size */
1010 uint32_t u32Size;
1011 /** version */
1012 uint32_t u32Version;
1013
1014 union {
1015 /** Flag telling that VMMDev set the IRQ and acknowlegment is required */
1016 struct {
1017 bool fHaveEvents;
1018 } V1_04;
1019
1020 struct {
1021 /** Pending events flags, set by host. */
1022 uint32_t u32HostEvents;
1023 /** Mask of events the guest wants to see, set by guest. */
1024 uint32_t u32GuestEventMask;
1025 } V1_03;
1026 } V;
1027
1028 VBVAMEMORY vbvaMemory;
1029
1030} VMMDevMemory;
1031#pragma pack()
1032
1033/** Version of VMMDevMemory structure. */
1034#define VMMDEV_MEMORY_VERSION (1)
1035
1036/** @} */
1037
1038
1039/**
1040 * VMMDev events.
1041 * @{
1042 */
1043
1044/** Host mouse capabilities has been changed. */
1045#define VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED BIT(0)
1046/** HGCM event. */
1047#define VMMDEV_EVENT_HGCM BIT(1)
1048/** A display change request has been issued. */
1049#define VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST BIT(2)
1050/** Credentials are available for judgement. */
1051#define VMMDEV_EVENT_JUDGE_CREDENTIALS BIT(3)
1052/** The guest has been restored. */
1053#define VMMDEV_EVENT_RESTORED BIT(4)
1054/** Seamless mode state changed */
1055#define VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST BIT(5)
1056/** Memory balloon size changed */
1057#define VMMDEV_EVENT_BALLOON_CHANGE_REQUEST BIT(6)
1058/** Statistics interval changed */
1059#define VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST BIT(7)
1060/** VRDP status changed. */
1061#define VMMDEV_EVENT_VRDP BIT(8)
1062
1063
1064/** @} */
1065
1066
1067/**
1068 * VBoxGuest IOCTL codes and structures.
1069 *
1070 * The range 0..15 is for basic driver communication.
1071 * The range 16..31 is for HGCM communcation.
1072 * The range 32..47 is reserved for future use.
1073 * The range 48..63 is for OS specific communcation.
1074 * The 7th bit is reserved for future hacks.
1075 * The 8th bit is reserved for distinguishing between 32-bit and 64-bit
1076 * processes in future 64-bit guest additions.
1077 *
1078 * While windows IOCTL function number has to start at 2048 and stop at 4096 there
1079 * never was any need to do this for everyone. A simple ((Function) | 0x800) would
1080 * have sufficed. On Linux we're now intruding upon the type field. Fortunately
1081 * this hasn't caused any trouble because the FILE_DEVICE_UNKNOWN value was set
1082 * to 0x22 (if it were 0x2C it would not have worked soo smoothly). The situation
1083 * would've been the same for *BSD and Darwin since they seems to share common
1084 * _IOC() heritage.
1085 *
1086 * However, on good old OS/2 we only have 8-bit handy for the function number. The
1087 * result from using the old IOCTL function numbers her would've been overlapping
1088 * between the two ranges.
1089 *
1090 * To fix this problem and get rid of all the unnecessary windowsy crap that I
1091 * bet was copied from my SUPDRVIOC.h once upon a time (although the concept of
1092 * prefixing macros with the purpose of avoid clashes with system stuff and
1093 * to indicate exactly how owns them seems to have been lost somewhere along
1094 * the way), I've introduced a VBOXGUEST_IOCTL_CODE for defining generic IN/OUT
1095 * IOCtls on new ports of the additions.
1096 *
1097 * @remark When creating new IOCtl interfaces keep in mind that not all OSes supports
1098 * reporting back the output size. (This got messed up a little bit in VBoxDrv.)
1099 *
1100 * OS/2 restricts the in/out data size to 64KB, while Linux, BSD and Darwin are
1101 * limited by a 14 bits size field (16KB). So, special considerations need to
1102 * be taken if more input/output needs to be passed around.
1103 *
1104 * When passing variable sized input/output special care need to be taken on
1105 * Unix platforms (if we're going to play by the rules) since the size is
1106 * passed as part of the IOCtl code there. IIRC Darwin will use the size to
1107 * perform locking and in/out copying, I don't quite know about linux and *BSD.
1108 *
1109 * @remark If adding interfaces that only has input or only has output, some new macros
1110 * needs to be created so the most efficient IOCtl data buffering method can be
1111 * used.
1112 *
1113 * @{
1114 */
1115#ifdef RT_ARCH_AMD64
1116# define VBOXGUEST_IOCTL_FLAG 128
1117#elif defined(RT_ARCH_X86)
1118# define VBOXGUEST_IOCTL_FLAG 0
1119#else
1120# error "dunno which arch this is!"
1121#endif
1122
1123#if defined(RT_OS_WINDOWS)
1124# define IOCTL_CODE(DeviceType, Function, Method, Access, DataSize_ignored) \
1125 ( ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method))
1126
1127#elif defined(RT_OS_OS2)
1128# define VBOXGUEST_IOCTL_CATEGORY 0xc2
1129# define VBOXGUEST_IOCTL_CODE(Function, Size) ((unsigned char)(Function))
1130# define VBOXGUEST_IOCTL_CATEGORY_FAST 0xc3 /**< Also defined in VBoxGuestA-os2.asm. */
1131# define VBOXGUEST_IOCTL_CODE_FAST(Function) ((unsigned char)(Function))
1132
1133#elif defined(RT_OS_LINUX)
1134# define IOCTL_CODE(DeviceType, Function, Method_ignored, Access_ignored, DataSize) \
1135 ( (3 << 30) | ((DeviceType) << 8) | (Function) | ((DataSize) << 16) )
1136# define METHOD_BUFFERED 0
1137# define FILE_WRITE_ACCESS 0x0002
1138# define FILE_DEVICE_UNKNOWN 0x00000022
1139
1140#elif 0 /* BSD style - needs some adjusting _IORW takes a type and not a size. */
1141# include <sys/ioccom.h>
1142# define VBOXGUEST_IOCTL_CODE(Function, Size) _IORW('V', (Function) | VBOXGUEST_IOCTL_FLAG, (Size))
1143# define VBOXGUEST_IOCTL_CODE_FAST(Function) _IO( 'V', (Function) | VBOXGUEST_IOCTL_FLAG)
1144
1145#else
1146/* PORTME */
1147#endif
1148
1149/** IOCTL to VBoxGuest to query the VMMDev IO port region start. */
1150#ifdef VBOXGUEST_IOCTL_CODE
1151# define VBOXGUEST_IOCTL_GETVMMDEVPORT VBOXGUEST_IOCTL_CODE(1, sizeof(VBoxGuestPortInfo))
1152# define IOCTL_VBOXGUEST_GETVMMDEVPORT VBOXGUEST_IOCTL_GETVMMDEVPORT
1153#else
1154# define IOCTL_VBOXGUEST_GETVMMDEVPORT IOCTL_CODE(FILE_DEVICE_UNKNOWN, 2048, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof(VBoxGuestPortInfo))
1155#endif
1156
1157#pragma pack(4)
1158typedef struct _VBoxGuestPortInfo
1159{
1160 uint32_t portAddress;
1161 VMMDevMemory *pVMMDevMemory;
1162} VBoxGuestPortInfo;
1163
1164/** IOCTL to VBoxGuest to wait for a VMMDev host notification */
1165#ifdef VBOXGUEST_IOCTL_CODE
1166# define VBOXGUEST_IOCTL_WAITEVENT VBOXGUEST_IOCTL_CODE(2, sizeof(VBoxGuestWaitEventInfo))
1167# define IOCTL_VBOXGUEST_WAITEVENT VBOXGUEST_IOCTL_WAITEVENT
1168#else
1169# define IOCTL_VBOXGUEST_WAITEVENT IOCTL_CODE(FILE_DEVICE_UNKNOWN, 2049, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof(VBoxGuestWaitEventInfo))
1170#endif
1171
1172/**
1173 * Result codes for VBoxGuestWaitEventInfo::u32Result
1174 * @{
1175 */
1176/** Successful completion, an event occured. */
1177#define VBOXGUEST_WAITEVENT_OK (0)
1178/** Successful completion, timed out. */
1179#define VBOXGUEST_WAITEVENT_TIMEOUT (1)
1180/** Wait was interrupted. */
1181#define VBOXGUEST_WAITEVENT_INTERRUPTED (2)
1182/** An error occured while processing the request. */
1183#define VBOXGUEST_WAITEVENT_ERROR (3)
1184/** @} */
1185
1186/** Input and output buffers layout of the IOCTL_VBOXGUEST_WAITEVENT */
1187typedef struct _VBoxGuestWaitEventInfo
1188{
1189 /** timeout in milliseconds */
1190 uint32_t u32TimeoutIn;
1191 /** events to wait for */
1192 uint32_t u32EventMaskIn;
1193 /** result code */
1194 uint32_t u32Result;
1195 /** events occured */
1196 uint32_t u32EventFlagsOut;
1197} VBoxGuestWaitEventInfo;
1198
1199/** IOCTL to VBoxGuest to perform a VMM request
1200 * @remark The data buffer for this IOCtl has an variable size, keep this in mind
1201 * on systems where this matters. */
1202#ifdef VBOXGUEST_IOCTL_CODE
1203# define VBOXGUEST_IOCTL_VMMREQUEST(Size) VBOXGUEST_IOCTL_CODE(3, sizeof(VMMDevRequestHeader))
1204# define IOCTL_VBOXGUEST_VMMREQUEST VBOXGUEST_IOCTL_VMMREQUEST(sizeof(VMMDevRequestHeader))
1205#else
1206# define IOCTL_VBOXGUEST_VMMREQUEST IOCTL_CODE(FILE_DEVICE_UNKNOWN, 2050, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof(VMMDevRequestHeader))
1207#endif
1208
1209/** Input and output buffer layout of the IOCTL_VBOXGUEST_CTL_FILTER_MASK. */
1210typedef struct _VBoxGuestFilterMaskInfo
1211{
1212 uint32_t u32OrMask;
1213 uint32_t u32NotMask;
1214} VBoxGuestFilterMaskInfo;
1215#pragma pack()
1216
1217/** IOCTL to VBoxGuest to control event filter mask */
1218#ifdef VBOXGUEST_IOCTL_CODE
1219# define VBOXGUEST_IOCTL_CTL_FILTER_MASK VBOXGUEST_IOCTL_CODE(4, sizeof(VBoxGuestFilterMaskInfo))
1220# define IOCTL_VBOXGUEST_CTL_FILTER_MASK VBOXGUEST_IOCTL_CTL_FILTER_MASK
1221#else
1222# define IOCTL_VBOXGUEST_CTL_FILTER_MASK IOCTL_CODE(FILE_DEVICE_UNKNOWN, 2051, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof (VBoxGuestFilterMaskInfo))
1223#endif
1224
1225/** IOCTL to VBoxGuest to check memory ballooning */
1226#ifdef VBOXGUEST_IOCTL_CODE
1227# define VBOXGUEST_IOCTL_CTL_CHECK_BALLOON_MASK VBOXGUEST_IOCTL_CODE(4, 100)
1228# define IOCTL_VBOXGUEST_CTL_CHECK_BALLOON VBOXGUEST_IOCTL_CTL_CHECK_BALLOON_MASK
1229#else
1230# define IOCTL_VBOXGUEST_CTL_CHECK_BALLOON IOCTL_CODE(FILE_DEVICE_UNKNOWN, 2052, METHOD_BUFFERED, FILE_WRITE_ACCESS, 0)
1231#endif
1232
1233#ifdef VBOX_HGCM
1234/* These structures are shared between the driver and other binaries,
1235 * therefore packing must be defined explicitely.
1236 */
1237#pragma pack(1)
1238typedef struct _VBoxGuestHGCMConnectInfo
1239{
1240 uint32_t result; /**< OUT */
1241 HGCMServiceLocation Loc; /**< IN */
1242 uint32_t u32ClientID; /**< OUT */
1243} VBoxGuestHGCMConnectInfo;
1244
1245typedef struct _VBoxGuestHGCMDisconnectInfo
1246{
1247 uint32_t result; /**< OUT */
1248 uint32_t u32ClientID; /**< IN */
1249} VBoxGuestHGCMDisconnectInfo;
1250
1251typedef struct _VBoxGuestHGCMCallInfo
1252{
1253 uint32_t result; /**< OUT Host HGCM return code.*/
1254 uint32_t u32ClientID; /**< IN The id of the caller. */
1255 uint32_t u32Function; /**< IN Function number. */
1256 uint32_t cParms; /**< IN How many parms. */
1257 /* Parameters follow in form HGCMFunctionParameter aParms[cParms] */
1258} VBoxGuestHGCMCallInfo;
1259#pragma pack()
1260
1261#ifdef VBOXGUEST_IOCTL_CODE
1262# define VBOXGUEST_IOCTL_HGCM_CONNECT VBOXGUEST_IOCTL_CODE(16, sizeof(VBoxGuestHGCMConnectInfo))
1263# define IOCTL_VBOXGUEST_HGCM_CONNECT VBOXGUEST_IOCTL_HGCM_CONNECT
1264# define VBOXGUEST_IOCTL_HGCM_DISCONNECT VBOXGUEST_IOCTL_CODE(17, sizeof(VBoxGuestHGCMDisconnectInfo))
1265# define IOCTL_VBOXGUEST_HGCM_DISCONNECT VBOXGUEST_IOCTL_HGCM_DISCONNECT
1266# define VBOXGUEST_IOCTL_HGCM_CALL(Size) VBOXGUEST_IOCTL_CODE(18, (Size))
1267# define IOCTL_VBOXGUEST_HGCM_CALL VBOXGUEST_IOCTL_HGCM_CALL(sizeof(VBoxGuestHGCMCallInfo))
1268# define VBOXGUEST_IOCTL_CLIPBOARD_CONNECT VBOXGUEST_IOCTL_CODE(19, sizeof(uint32_t))
1269# define IOCTL_VBOXGUEST_CLIPBOARD_CONNECT VBOXGUEST_IOCTL_CLIPBOARD_CONNECT
1270#else
1271# define IOCTL_VBOXGUEST_HGCM_CONNECT IOCTL_CODE(FILE_DEVICE_UNKNOWN, 3072, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof(VBoxGuestHGCMConnectInfo))
1272# define IOCTL_VBOXGUEST_HGCM_DISCONNECT IOCTL_CODE(FILE_DEVICE_UNKNOWN, 3073, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof(VBoxGuestHGCMDisconnectInfo))
1273# define IOCTL_VBOXGUEST_HGCM_CALL IOCTL_CODE(FILE_DEVICE_UNKNOWN, 3074, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof(VBoxGuestHGCMCallInfo))
1274# define IOCTL_VBOXGUEST_CLIPBOARD_CONNECT IOCTL_CODE(FILE_DEVICE_UNKNOWN, 3075, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof(uint32_t))
1275#endif
1276
1277#define VBOXGUEST_HGCM_CALL_PARMS(a) ((HGCMFunctionParameter *)((uint8_t *)(a) + sizeof (VBoxGuestHGCMCallInfo)))
1278
1279#endif /* VBOX_HGCM */
1280
1281/*
1282 * Credentials request flags and structure
1283 */
1284
1285#define VMMDEV_CREDENTIALS_STRLEN 128
1286
1287/** query from host whether credentials are present */
1288#define VMMDEV_CREDENTIALS_QUERYPRESENCE BIT(1)
1289/** read credentials from host (can be combined with clear) */
1290#define VMMDEV_CREDENTIALS_READ BIT(2)
1291/** clear credentials on host (can be combined with read) */
1292#define VMMDEV_CREDENTIALS_CLEAR BIT(3)
1293/** read credentials for judgement in the guest */
1294#define VMMDEV_CREDENTIALS_READJUDGE BIT(8)
1295/** clear credentials for judegement on the host */
1296#define VMMDEV_CREDENTIALS_CLEARJUDGE BIT(9)
1297/** report credentials acceptance by guest */
1298#define VMMDEV_CREDENTIALS_JUDGE_OK BIT(10)
1299/** report credentials denial by guest */
1300#define VMMDEV_CREDENTIALS_JUDGE_DENY BIT(11)
1301/** report that no judgement could be made by guest */
1302#define VMMDEV_CREDENTIALS_JUDGE_NOJUDGEMENT BIT(12)
1303
1304/** flag telling the guest that credentials are present */
1305#define VMMDEV_CREDENTIALS_PRESENT BIT(16)
1306/** flag telling guest that local logons should be prohibited */
1307#define VMMDEV_CREDENTIALS_NOLOCALLOGON BIT(17)
1308
1309/** credentials request structure */
1310#pragma pack(4)
1311typedef struct _VMMDevCredentials
1312{
1313 /* request header */
1314 VMMDevRequestHeader header;
1315 /* request flags (in/out) */
1316 uint32_t u32Flags;
1317 /* user name (UTF-8) (out) */
1318 char szUserName[VMMDEV_CREDENTIALS_STRLEN];
1319 /* password (UTF-8) (out) */
1320 char szPassword[VMMDEV_CREDENTIALS_STRLEN];
1321 /* domain name (UTF-8) (out) */
1322 char szDomain[VMMDEV_CREDENTIALS_STRLEN];
1323} VMMDevCredentials;
1324#pragma pack()
1325
1326/** inline helper to determine the request size for the given operation */
1327DECLINLINE(size_t) vmmdevGetRequestSize(VMMDevRequestType requestType)
1328{
1329 switch (requestType)
1330 {
1331 case VMMDevReq_GetMouseStatus:
1332 case VMMDevReq_SetMouseStatus:
1333 return sizeof(VMMDevReqMouseStatus);
1334 case VMMDevReq_SetPointerShape:
1335 return sizeof(VMMDevReqMousePointer);
1336 case VMMDevReq_GetHostVersion:
1337 return sizeof(VMMDevReqHostVersion);
1338 case VMMDevReq_Idle:
1339 return sizeof(VMMDevReqIdle);
1340 case VMMDevReq_GetHostTime:
1341 return sizeof(VMMDevReqHostTime);
1342 case VMMDevReq_GetHypervisorInfo:
1343 case VMMDevReq_SetHypervisorInfo:
1344 return sizeof(VMMDevReqHypervisorInfo);
1345 case VMMDevReq_SetPowerStatus:
1346 return sizeof(VMMDevPowerStateRequest);
1347 case VMMDevReq_AcknowledgeEvents:
1348 return sizeof(VMMDevEvents);
1349 case VMMDevReq_ReportGuestInfo:
1350 return sizeof(VMMDevReportGuestInfo);
1351 case VMMDevReq_GetDisplayChangeRequest:
1352 return sizeof(VMMDevDisplayChangeRequest);
1353 case VMMDevReq_GetDisplayChangeRequest2:
1354 return sizeof(VMMDevDisplayChangeRequest2);
1355 case VMMDevReq_VideoModeSupported:
1356 return sizeof(VMMDevVideoModeSupportedRequest);
1357 case VMMDevReq_GetHeightReduction:
1358 return sizeof(VMMDevGetHeightReductionRequest);
1359 case VMMDevReq_ReportGuestCapabilities:
1360 return sizeof(VMMDevReqGuestCapabilities);
1361#ifdef VBOX_HGCM
1362 case VMMDevReq_HGCMConnect:
1363 return sizeof(VMMDevHGCMConnect);
1364 case VMMDevReq_HGCMDisconnect:
1365 return sizeof(VMMDevHGCMDisconnect);
1366 case VMMDevReq_HGCMCall:
1367 return sizeof(VMMDevHGCMCall);
1368#endif
1369 case VMMDevReq_VideoAccelEnable:
1370 return sizeof(VMMDevVideoAccelEnable);
1371 case VMMDevReq_VideoAccelFlush:
1372 return sizeof(VMMDevVideoAccelFlush);
1373 case VMMDevReq_VideoSetVisibleRegion:
1374 return sizeof(VMMDevVideoSetVisibleRegion);
1375 case VMMDevReq_GetSeamlessChangeRequest:
1376 return sizeof(VMMDevSeamlessChangeRequest);
1377 case VMMDevReq_QueryCredentials:
1378 return sizeof(VMMDevCredentials);
1379 case VMMDevReq_ReportGuestStats:
1380 return sizeof(VMMDevReportGuestStats);
1381 case VMMDevReq_GetMemBalloonChangeRequest:
1382 return sizeof(VMMDevGetMemBalloonChangeRequest);
1383 case VMMDevReq_GetStatisticsChangeRequest:
1384 return sizeof(VMMDevGetStatisticsChangeRequest);
1385 case VMMDevReq_ChangeMemBalloon:
1386 return sizeof(VMMDevChangeMemBalloon);
1387 case VMMDevReq_GetVRDPChangeRequest:
1388 return sizeof(VMMDevVRDPChangeRequest);
1389 case VMMDevReq_LogString:
1390 return sizeof(VMMDevReqLogString);
1391 default:
1392 return 0;
1393 }
1394}
1395
1396/**
1397 * Initializes a request structure.
1398 *
1399 */
1400DECLINLINE(int) vmmdevInitRequest(VMMDevRequestHeader *req, VMMDevRequestType type)
1401{
1402 uint32_t requestSize;
1403 if (!req)
1404 return VERR_INVALID_PARAMETER;
1405 requestSize = (uint32_t)vmmdevGetRequestSize(type);
1406 if (!requestSize)
1407 return VERR_INVALID_PARAMETER;
1408 req->size = requestSize;
1409 req->version = VMMDEV_REQUEST_HEADER_VERSION;
1410 req->requestType = type;
1411 req->rc = VERR_GENERAL_FAILURE;
1412 req->reserved1 = 0;
1413 req->reserved2 = 0;
1414 return VINF_SUCCESS;
1415}
1416
1417
1418#ifdef RT_OS_OS2
1419
1420/**
1421 * The data buffer layout for the IDC entry point (AttachDD).
1422 *
1423 * @remark This is defined in multiple 16-bit headers / sources.
1424 * Some places it's called VBGOS2IDC to short things a bit.
1425 */
1426typedef struct VBOXGUESTOS2IDCCONNECT
1427{
1428 /** VMMDEV_VERSION. */
1429 uint32_t u32Version;
1430 /** Opaque session handle. */
1431 uint32_t u32Session;
1432
1433 /**
1434 * The 32-bit service entry point.
1435 *
1436 * @returns VBox status code.
1437 * @param u32Session The above session handle.
1438 * @param iFunction The requested function.
1439 * @param pvData The input/output data buffer. The caller ensures that this
1440 * cannot be swapped out, or that it's acceptable to take a
1441 * page in fault in the current context. If the request doesn't
1442 * take input or produces output, apssing NULL is okay.
1443 * @param cbData The size of the data buffer.
1444 * @param pcbDataReturned Where to store the amount of data that's returned.
1445 * This can be NULL if pvData is NULL.
1446 */
1447 DECLCALLBACKMEMBER(int, pfnServiceEP)(uint32_t u32Session, unsigned iFunction, void *pvData, size_t cbData, size_t *pcbDataReturned);
1448
1449 /** The 16-bit service entry point for C code (cdecl).
1450 *
1451 * It's the same as the 32-bit entry point, but the types has
1452 * changed to 16-bit equivalents.
1453 *
1454 * @code
1455 * int far cdecl
1456 * VBoxGuestOs2IDCService16(uint32_t u32Session, uint16_t iFunction,
1457 * void far *fpvData, uint16_t cbData, uint16_t far *pcbDataReturned);
1458 * @endcode
1459 */
1460 RTFAR16 fpfnServiceEP;
1461
1462 /** The 16-bit service entry point for Assembly code (register).
1463 *
1464 * This is just a wrapper around fpfnServiceEP to simplify calls
1465 * from 16-bit assembly code.
1466 *
1467 * @returns (e)ax: VBox status code; cx: The amount of data returned.
1468 *
1469 * @param u32Session eax - The above session handle.
1470 * @param iFunction dl - The requested function.
1471 * @param pvData es:bx - The input/output data buffer.
1472 * @param cbData cx - The size of the data buffer.
1473 */
1474 RTFAR16 fpfnServiceAsmEP;
1475} VBOXGUESTOS2IDCCONNECT;
1476/** Pointer to VBOXGUESTOS2IDCCONNECT buffer. */
1477typedef VBOXGUESTOS2IDCCONNECT *PVBOXGUESTOS2IDCCONNECT;
1478
1479/** OS/2 specific: IDC client disconnect request.
1480 *
1481 * This takes no input and it doesn't return anything. Obviously this
1482 * is only recognized if it arrives thru the IDC service EP.
1483 */
1484#define VBOXGUEST_IOCTL_OS2_IDC_DISCONNECT VBOXGUEST_IOCTL_CODE(48, sizeof(uint32_t))
1485
1486#endif /* RT_OS_OS2 */
1487
1488/** @} */
1489
1490
1491#ifdef IN_RING3
1492
1493/** @def VBGLR3DECL
1494 * Ring 3 VBGL declaration.
1495 * @param type The return type of the function declaration.
1496 */
1497#define VBGLR3DECL(type) type VBOXCALL
1498
1499/* General-purpose functions */
1500
1501__BEGIN_DECLS
1502VBGLR3DECL(int) VbglR3Init(void);
1503VBGLR3DECL(void) VbglR3Term(void);
1504VBGLR3DECL(int) VbglR3GRPerform(VMMDevRequestHeader *pReq);
1505# ifdef __iprt_time_h__
1506VBGLR3DECL(int) VbglR3GetHostTime(PRTTIMESPEC pTime);
1507# endif
1508VBGLR3DECL(int) VbglR3InterruptEventWaits(void);
1509
1510/* Shared clipboard */
1511
1512VBGLR3DECL(int) VbglR3ClipboardConnect(uint32_t *pu32ClientId);
1513VBGLR3DECL(int) VbglR3ClipboardDisconnect(uint32_t u32ClientId);
1514VBGLR3DECL(int) VbglR3ClipboardGetHostMsg(uint32_t u32ClientId, uint32_t *pMsg, uint32_t *pfFormats);
1515VBGLR3DECL(int) VbglR3ClipboardReadData(uint32_t u32ClientId, uint32_t fFormat, void *pv, uint32_t cb, uint32_t *pcb);
1516VBGLR3DECL(int) VbglR3ClipboardReportFormats(uint32_t u32ClientId, uint32_t fFormats);
1517VBGLR3DECL(int) VbglR3ClipboardWriteData(uint32_t u32ClientId, uint32_t fFormat, void *pv, uint32_t cb);
1518
1519/* Seamless mode */
1520
1521VBGLR3DECL(int) VbglR3SeamlessSetCap(bool bState);
1522VBGLR3DECL(int) VbglR3SeamlessWaitEvent(VMMDevSeamlessMode *pMode);
1523VBGLR3DECL(int) VbglR3SeamlessSendRects(uint32_t cRects, PRTRECT pRects);
1524
1525__END_DECLS
1526
1527#endif /* IN_RING3 */
1528
1529#endif
Note: See TracBrowser for help on using the repository browser.

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