VirtualBox

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

Last change on this file since 6356 was 6356, checked in by vboxsync, 17 years ago

Integrated VbglR3Daemonize in GuestR3Lib. Linux vboxclient now uses it. Renamed LINUX_CLIPBOARD to VBOX_X11_CLIPBOARD. clipboard-new has the clipboard implemetation using R3 lib, currently used only by Solaris. Note: this change affects OS2, linux, solaris so someone should check for build breaks on OS2.

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