summaryrefslogtreecommitdiffstats
path: root/include/VBox/GuestHost
diff options
context:
space:
mode:
Diffstat (limited to 'include/VBox/GuestHost')
-rw-r--r--include/VBox/GuestHost/DragAndDrop.h324
-rw-r--r--include/VBox/GuestHost/DragAndDropDefs.h83
-rw-r--r--include/VBox/GuestHost/GuestControl.h202
-rw-r--r--include/VBox/GuestHost/Makefile.kup0
-rw-r--r--include/VBox/GuestHost/SharedClipboard.h82
-rw-r--r--include/VBox/GuestHost/clipboard-helper.h174
6 files changed, 865 insertions, 0 deletions
diff --git a/include/VBox/GuestHost/DragAndDrop.h b/include/VBox/GuestHost/DragAndDrop.h
new file mode 100644
index 00000000..329c697e
--- /dev/null
+++ b/include/VBox/GuestHost/DragAndDrop.h
@@ -0,0 +1,324 @@
+/* $Id: DragAndDrop.h $ */
+/** @file
+ * DnD - Shared functions between host and guest.
+ */
+
+/*
+ * Copyright (C) 2014-2019 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+#ifndef VBOX_INCLUDED_GuestHost_DragAndDrop_h
+#define VBOX_INCLUDED_GuestHost_DragAndDrop_h
+#ifndef RT_WITHOUT_PRAGMA_ONCE
+# pragma once
+#endif
+
+#include <iprt/assert.h>
+#include <iprt/fs.h>
+
+#include <iprt/cpp/list.h>
+#include <iprt/cpp/ministring.h>
+
+/** DnDURIDroppedFiles flags. */
+typedef uint32_t DNDURIDROPPEDFILEFLAGS;
+
+/** No flags specified. */
+#define DNDURIDROPPEDFILE_FLAGS_NONE 0
+
+/**
+ * Class for maintaining a "dropped files" directory
+ * on the host or guest. This will contain all received files & directories
+ * for a single drag and drop operation.
+ *
+ * In case of a failed drag and drop operation this class can also
+ * perform a gentle rollback if required.
+ */
+class DnDDroppedFiles
+{
+
+public:
+
+ DnDDroppedFiles(void);
+ DnDDroppedFiles(const char *pszPath, DNDURIDROPPEDFILEFLAGS fFlags = DNDURIDROPPEDFILE_FLAGS_NONE);
+ virtual ~DnDDroppedFiles(void);
+
+public:
+
+ int AddFile(const char *pszFile);
+ int AddDir(const char *pszDir);
+ int Close(void);
+ bool IsOpen(void) const;
+ int OpenEx(const char *pszPath, DNDURIDROPPEDFILEFLAGS fFlags = DNDURIDROPPEDFILE_FLAGS_NONE);
+ int OpenTemp(DNDURIDROPPEDFILEFLAGS fFlags = DNDURIDROPPEDFILE_FLAGS_NONE);
+ const char *GetDirAbs(void) const;
+ int Reopen(void);
+ int Reset(bool fDeleteContent);
+ int Rollback(void);
+
+protected:
+
+ int closeInternal(void);
+
+protected:
+
+ /** Open flags. */
+ uint32_t m_fOpen;
+ /** Directory handle for drop directory. */
+ RTDIR m_hDir;
+ /** Absolute path to drop directory. */
+ RTCString m_strPathAbs;
+ /** List for holding created directories in the case of a rollback. */
+ RTCList<RTCString> m_lstDirs;
+ /** List for holding created files in the case of a rollback. */
+ RTCList<RTCString> m_lstFiles;
+};
+
+bool DnDMIMEHasFileURLs(const char *pcszFormat, size_t cchFormatMax);
+bool DnDMIMENeedsDropDir(const char *pcszFormat, size_t cchFormatMax);
+
+int DnDPathSanitizeFilename(char *pszPath, size_t cbPath);
+int DnDPathSanitize(char *pszPath, size_t cbPath);
+
+/** DnDURIObject flags. */
+typedef uint32_t DNDURIOBJECTFLAGS;
+
+/** No flags specified. */
+#define DNDURIOBJECT_FLAGS_NONE 0
+
+/** Mask of all valid DnD URI object flags. */
+#define DNDURIOBJECT_FLAGS_VALID_MASK UINT32_C(0x0)
+
+/**
+ * Class for handling DnD URI objects.
+ * This class abstracts the access and handling objects when performing DnD actions.
+ */
+class DnDURIObject
+{
+public:
+
+ /**
+ * Enumeration for specifying an URI object type.
+ */
+ enum Type
+ {
+ /** Unknown type, do not use. */
+ Type_Unknown = 0,
+ /** Object is a file. */
+ Type_File,
+ /** Object is a directory. */
+ Type_Directory,
+ /** The usual 32-bit hack. */
+ Type_32Bit_Hack = 0x7fffffff
+ };
+
+ /**
+ * Enumeration for specifying an URI object view
+ * for representing its data accordingly.
+ */
+ enum View
+ {
+ /** Unknown view, do not use. */
+ View_Unknown = 0,
+ /** Handle data from the source point of view. */
+ View_Source,
+ /** Handle data from the destination point of view. */
+ View_Target,
+ /** The usual 32-bit hack. */
+ View_Dest_32Bit_Hack = 0x7fffffff
+ };
+
+ DnDURIObject(void);
+ DnDURIObject(Type type,
+ const RTCString &strSrcPathAbs = "",
+ const RTCString &strDstPathAbs = "");
+ virtual ~DnDURIObject(void);
+
+public:
+
+ /**
+ * Returns the given absolute source path of the object.
+ *
+ * @return Absolute source path of the object.
+ */
+ const RTCString &GetSourcePathAbs(void) const { return m_strSrcPathAbs; }
+
+ /**
+ * Returns the given, absolute destination path of the object.
+ *
+ * @return Absolute destination path of the object.
+ */
+ const RTCString &GetDestPathAbs(void) const { return m_strTgtPathAbs; }
+
+ RTFMODE GetMode(void) const;
+
+ uint64_t GetProcessed(void) const;
+
+ uint64_t GetSize(void) const;
+
+ /**
+ * Returns the object's type.
+ *
+ * @return The object's type.
+ */
+ Type GetType(void) const { return m_enmType; }
+
+ /**
+ * Returns the object's view.
+ *
+ * @return The object's view.
+ */
+ View GetView(void) const { return m_enmView; }
+
+public:
+
+ int SetSize(uint64_t cbSize);
+
+public:
+
+ void Close(void);
+ bool IsComplete(void) const;
+ bool IsOpen(void) const;
+ int Open(View enmView, uint64_t fOpen, RTFMODE fMode = 0);
+ int OpenEx(const RTCString &strPath, View enmView, uint64_t fOpen = 0, RTFMODE fMode = 0, DNDURIOBJECTFLAGS = DNDURIOBJECT_FLAGS_NONE);
+ int QueryInfo(View enmView);
+ int Read(void *pvBuf, size_t cbBuf, uint32_t *pcbRead);
+ void Reset(void);
+ int Write(const void *pvBuf, size_t cbBuf, uint32_t *pcbWritten);
+
+public:
+
+ static int RebaseURIPath(RTCString &strPath, const RTCString &strBaseOld = "", const RTCString &strBaseNew = "");
+
+protected:
+
+ void closeInternal(void);
+ int queryInfoInternal(View enmView);
+
+protected:
+
+ /** The object's type. */
+ Type m_enmType;
+ /** The object's view. */
+ View m_enmView;
+ /** Absolute path (base) for the source. */
+ RTCString m_strSrcPathAbs;
+ /** Absolute path (base) for the target. */
+ RTCString m_strTgtPathAbs;
+ /** Whether the object is in "opened" state. */
+ bool m_fIsOpen;
+
+ /** Union containing data depending on the object's type. */
+ union
+ {
+ /** Structure containing members for objects that
+ * are files. */
+ struct
+ {
+ /** File handle. */
+ RTFILE hFile;
+ /** File system object information of this file. */
+ RTFSOBJINFO objInfo;
+ /** Bytes to proces for reading/writing. */
+ uint64_t cbToProcess;
+ /** Bytes processed reading/writing. */
+ uint64_t cbProcessed;
+ } File;
+ struct
+ {
+ /** Directory handle. */
+ RTDIR hDir;
+ /** File system object information of this directory. */
+ RTFSOBJINFO objInfo;
+ } Dir;
+ } u;
+};
+
+/** DnDURIList flags. */
+typedef uint32_t DNDURILISTFLAGS;
+
+/** No flags specified. */
+#define DNDURILIST_FLAGS_NONE 0
+/** Keep the original paths, don't convert paths to relative ones. */
+#define DNDURILIST_FLAGS_ABSOLUTE_PATHS RT_BIT(0)
+/** Resolve all symlinks. */
+#define DNDURILIST_FLAGS_RESOLVE_SYMLINKS RT_BIT(1)
+/** Keep the files + directory entries open while
+ * being in this list. */
+#define DNDURILIST_FLAGS_KEEP_OPEN RT_BIT(2)
+/** Lazy loading: Only enumerate sub directories when needed.
+ ** @todo Implement lazy loading. */
+#define DNDURILIST_FLAGS_LAZY RT_BIT(3)
+
+/** Mask of all valid DnD URI list flags. */
+#define DNDURILIST_FLAGS_VALID_MASK UINT32_C(0xF)
+
+class DnDURIList
+{
+public:
+
+ DnDURIList(void);
+ virtual ~DnDURIList(void);
+
+public:
+
+ int AppendNativePath(const char *pszPath, DNDURILISTFLAGS fFlags);
+ int AppendNativePathsFromList(const char *pszNativePaths, size_t cbNativePaths, DNDURILISTFLAGS fFlags);
+ int AppendNativePathsFromList(const RTCList<RTCString> &lstNativePaths, DNDURILISTFLAGS fFlags);
+ int AppendURIPath(const char *pszURI, DNDURILISTFLAGS fFlags);
+ int AppendURIPathsFromList(const char *pszURIPaths, size_t cbURIPaths, DNDURILISTFLAGS fFlags);
+ int AppendURIPathsFromList(const RTCList<RTCString> &lstURI, DNDURILISTFLAGS fFlags);
+
+ void Clear(void);
+ DnDURIObject *First(void) { return m_lstTree.first(); }
+ bool IsEmpty(void) const { return m_lstTree.isEmpty(); }
+ void RemoveFirst(void);
+ int SetFromURIData(const void *pvData, size_t cbData, DNDURILISTFLAGS fFlags);
+
+ RTCString GetRootEntries(const RTCString &strPathBase = "", const RTCString &strSeparator = "\r\n") const;
+ uint64_t GetRootCount(void) const { return m_lstRoot.size(); }
+ uint64_t GetTotalCount(void) const { return m_cTotal; }
+ uint64_t GetTotalBytes(void) const { return m_cbTotal; }
+
+protected:
+
+ int addEntry(const char *pcszSource, const char *pcszTarget, DNDURILISTFLAGS fFlags);
+ int appendPathRecursive(const char *pcszSrcPath, const char *pcszDstPath, const char *pcszDstBase, size_t cchDstBase, DNDURILISTFLAGS fFlags);
+
+protected:
+
+ /** List of all top-level file/directory entries.
+ * Note: All paths are kept internally as UNIX paths for
+ * easier conversion/handling! */
+ RTCList<RTCString> m_lstRoot;
+ /** List of all URI objects added. The list's content
+ * might vary depending on how the objects are being
+ * added (lazy or not). */
+ RTCList<DnDURIObject *> m_lstTree;
+ /** Total number of all URI objects. */
+ uint64_t m_cTotal;
+ /** Total size of all URI objects, that is, the file
+ * size of all objects (in bytes).
+ * Note: Do *not* size_t here, as we also want to support large files
+ * on 32-bit guests. */
+ uint64_t m_cbTotal;
+};
+
+#endif /* !VBOX_INCLUDED_GuestHost_DragAndDrop_h */
+
diff --git a/include/VBox/GuestHost/DragAndDropDefs.h b/include/VBox/GuestHost/DragAndDropDefs.h
new file mode 100644
index 00000000..6ddf34dd
--- /dev/null
+++ b/include/VBox/GuestHost/DragAndDropDefs.h
@@ -0,0 +1,83 @@
+/** @file
+ * Drag and Drop definitions - Common header for host service and guest clients.
+ */
+
+/*
+ * Copyright (C) 2018-2019 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+#ifndef VBOX_INCLUDED_GuestHost_DragAndDropDefs_h
+#define VBOX_INCLUDED_GuestHost_DragAndDropDefs_h
+#ifndef RT_WITHOUT_PRAGMA_ONCE
+# pragma once
+#endif
+
+#include <iprt/types.h>
+
+/*
+ * The mode of operations.
+ */
+#define VBOX_DRAG_AND_DROP_MODE_OFF 0
+#define VBOX_DRAG_AND_DROP_MODE_HOST_TO_GUEST 1
+#define VBOX_DRAG_AND_DROP_MODE_GUEST_TO_HOST 2
+#define VBOX_DRAG_AND_DROP_MODE_BIDIRECTIONAL 3
+
+#define VBOX_DND_ACTION_IGNORE UINT32_C(0)
+#define VBOX_DND_ACTION_COPY RT_BIT_32(0)
+#define VBOX_DND_ACTION_MOVE RT_BIT_32(1)
+#define VBOX_DND_ACTION_LINK RT_BIT_32(2)
+
+/** A single DnD action. */
+typedef uint32_t VBOXDNDACTION;
+/** A list of (OR'ed) DnD actions. */
+typedef uint32_t VBOXDNDACTIONLIST;
+
+#define hasDnDCopyAction(a) ((a) & VBOX_DND_ACTION_COPY)
+#define hasDnDMoveAction(a) ((a) & VBOX_DND_ACTION_MOVE)
+#define hasDnDLinkAction(a) ((a) & VBOX_DND_ACTION_LINK)
+
+#define isDnDIgnoreAction(a) ((a) == VBOX_DND_ACTION_IGNORE)
+#define isDnDCopyAction(a) ((a) == VBOX_DND_ACTION_COPY)
+#define isDnDMoveAction(a) ((a) == VBOX_DND_ACTION_MOVE)
+#define isDnDLinkAction(a) ((a) == VBOX_DND_ACTION_LINK)
+
+/** @def VBOX_DND_FORMATS_DEFAULT
+ * Default drag'n drop formats.
+ * Note: If you add new entries here, make sure you test those
+ * with all supported guest OSes!
+ */
+#define VBOX_DND_FORMATS_DEFAULT \
+ "text/uri-list", \
+ /* Text. */ \
+ "text/html", \
+ "text/plain;charset=utf-8", \
+ "text/plain;charset=utf-16", \
+ "text/plain", \
+ "text/richtext", \
+ "UTF8_STRING", \
+ "TEXT", \
+ "STRING", \
+ /* OpenOffice formats. */ \
+ /* See: https://wiki.openoffice.org/wiki/Documentation/DevGuide/OfficeDev/Common_Application_Features#OpenOffice.org_Clipboard_Data_Formats */ \
+ "application/x-openoffice-embed-source-xml;windows_formatname=\"Star Embed Source (XML)\"", \
+ "application/x-openoffice;windows_formatname=\"Bitmap\""
+
+#endif /* !VBOX_INCLUDED_GuestHost_DragAndDropDefs_h */
+
diff --git a/include/VBox/GuestHost/GuestControl.h b/include/VBox/GuestHost/GuestControl.h
new file mode 100644
index 00000000..adf53b16
--- /dev/null
+++ b/include/VBox/GuestHost/GuestControl.h
@@ -0,0 +1,202 @@
+/* $Id: GuestControl.h $ */
+/** @file
+ * Guest Control - Common Guest and Host Code.
+ *
+ * @todo r=bird: Just merge this with GuestControlSvc.h!
+ */
+
+/*
+ * Copyright (C) 2016-2019 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+#ifndef VBOX_INCLUDED_GuestHost_GuestControl_h
+#define VBOX_INCLUDED_GuestHost_GuestControl_h
+#ifndef RT_WITHOUT_PRAGMA_ONCE
+# pragma once
+#endif
+
+#include <iprt/types.h>
+
+/* Everything defined in this file lives in this namespace. */
+namespace guestControl {
+
+/**
+ * Process status when executed in the guest.
+ */
+enum eProcessStatus
+{
+ /** Process is in an undefined state. */
+ PROC_STS_UNDEFINED = 0,
+ /** Process has been started. */
+ PROC_STS_STARTED = 1,
+ /** Process terminated normally. */
+ PROC_STS_TEN = 2,
+ /** Process terminated via signal. */
+ PROC_STS_TES = 3,
+ /** Process terminated abnormally. */
+ PROC_STS_TEA = 4,
+ /** Process timed out and was killed. */
+ PROC_STS_TOK = 5,
+ /** Process timed out and was not killed successfully. */
+ PROC_STS_TOA = 6,
+ /** Service/OS is stopping, process was killed. */
+ PROC_STS_DWN = 7,
+ /** Something went wrong (error code in flags). */
+ PROC_STS_ERROR = 8
+};
+
+/** @todo r=bird: Most defines in this file needs to be scoped a little
+ * better! For instance INPUT_FLAG_NONE is very generic. */
+
+/**
+ * Input flags, set by the host. This is needed for
+ * handling flags on the guest side.
+ * Note: Has to match Main's ProcessInputFlag_* flags!
+ */
+#define INPUT_FLAG_NONE 0x0
+#define INPUT_FLAG_EOF RT_BIT(0)
+
+/**
+ * Guest session creation flags.
+ * Only handled internally at the moment.
+ */
+#define SESSIONCREATIONFLAG_NONE 0x0
+
+/** @name DIRREMOVE_FLAG_XXX - Guest directory removement flags.
+ * Essentially using what IPRT's RTDIRRMREC_F_
+ * defines have to offer.
+ * @{
+ */
+#define DIRREMOVE_FLAG_RECURSIVE RT_BIT(0)
+/** Delete the content of the directory and the directory itself. */
+#define DIRREMOVE_FLAG_CONTENT_AND_DIR RT_BIT(1)
+/** Only delete the content of the directory, omit the directory it self. */
+#define DIRREMOVE_FLAG_CONTENT_ONLY RT_BIT(2)
+/** Mask of valid flags. */
+#define DIRREMOVE_FLAG_VALID_MASK UINT32_C(0x00000003)
+/** @} */
+
+/** @name EXECUTEPROCESSFLAG_XXX - Guest process creation flags.
+ * @note Has to match Main's ProcessCreateFlag_* flags!
+ * @{
+ */
+#define EXECUTEPROCESSFLAG_NONE UINT32_C(0x0)
+#define EXECUTEPROCESSFLAG_WAIT_START RT_BIT(0)
+#define EXECUTEPROCESSFLAG_IGNORE_ORPHANED RT_BIT(1)
+#define EXECUTEPROCESSFLAG_HIDDEN RT_BIT(2)
+#define EXECUTEPROCESSFLAG_PROFILE RT_BIT(3)
+#define EXECUTEPROCESSFLAG_WAIT_STDOUT RT_BIT(4)
+#define EXECUTEPROCESSFLAG_WAIT_STDERR RT_BIT(5)
+#define EXECUTEPROCESSFLAG_EXPAND_ARGUMENTS RT_BIT(6)
+#define EXECUTEPROCESSFLAG_UNQUOTED_ARGS RT_BIT(7)
+/** @} */
+
+/** @name OUTPUT_HANDLE_ID_XXX - Pipe handle IDs used internally for referencing
+ * to a certain pipe buffer.
+ * @{
+ */
+#define OUTPUT_HANDLE_ID_STDOUT_DEPRECATED 0 /**< Needed for VBox hosts < 4.1.0. */
+#define OUTPUT_HANDLE_ID_STDOUT 1
+#define OUTPUT_HANDLE_ID_STDERR 2
+/** @} */
+
+/** @name PATHRENAME_FLAG_XXX - Guest path rename flags.
+ * Essentially using what IPRT's RTPATHRENAME_FLAGS_XXX have to offer.
+ * @{
+ */
+/** Do not replace anything. */
+#define PATHRENAME_FLAG_NO_REPLACE UINT32_C(0)
+/** This will replace attempt any target which isn't a directory. */
+#define PATHRENAME_FLAG_REPLACE RT_BIT(0)
+/** Don't allow symbolic links as part of the path. */
+#define PATHRENAME_FLAG_NO_SYMLINKS RT_BIT(1)
+/** Mask of valid flags. */
+#define PATHRENAME_FLAG_VALID_MASK UINT32_C(0x00000003)
+/** @} */
+
+/** @name Defines for guest process array lengths.
+ * @{
+ */
+#define GUESTPROCESS_MAX_CMD_LEN _1K
+#define GUESTPROCESS_MAX_ARGS_LEN _1K
+#define GUESTPROCESS_MAX_ENV_LEN _64K
+#define GUESTPROCESS_MAX_USER_LEN 128
+#define GUESTPROCESS_MAX_PASSWORD_LEN 128
+#define GUESTPROCESS_MAX_DOMAIN_LEN 256
+/** @} */
+
+/** @name Internal tools built into VBoxService which are used in order
+ * to accomplish tasks host<->guest.
+ * @{
+ */
+#define VBOXSERVICE_TOOL_CAT "vbox_cat"
+#define VBOXSERVICE_TOOL_LS "vbox_ls"
+#define VBOXSERVICE_TOOL_RM "vbox_rm"
+#define VBOXSERVICE_TOOL_MKDIR "vbox_mkdir"
+#define VBOXSERVICE_TOOL_MKTEMP "vbox_mktemp"
+#define VBOXSERVICE_TOOL_STAT "vbox_stat"
+/** @} */
+
+/** Special process exit codes for "vbox_cat". */
+typedef enum VBOXSERVICETOOLBOX_CAT_EXITCODE
+{
+ VBOXSERVICETOOLBOX_CAT_EXITCODE_ACCESS_DENIED = RTEXITCODE_END,
+ VBOXSERVICETOOLBOX_CAT_EXITCODE_FILE_NOT_FOUND,
+ VBOXSERVICETOOLBOX_CAT_EXITCODE_PATH_NOT_FOUND,
+ VBOXSERVICETOOLBOX_CAT_EXITCODE_SHARING_VIOLATION,
+ VBOXSERVICETOOLBOX_CAT_EXITCODE_IS_A_DIRECTORY,
+ /** The usual 32-bit type hack. */
+ VBOXSERVICETOOLBOX_CAT_32BIT_HACK = 0x7fffffff
+} VBOXSERVICETOOLBOX_CAT_EXITCODE;
+
+/** Special process exit codes for "vbox_stat". */
+typedef enum VBOXSERVICETOOLBOX_STAT_EXITCODE
+{
+ VBOXSERVICETOOLBOX_STAT_EXITCODE_ACCESS_DENIED = RTEXITCODE_END,
+ VBOXSERVICETOOLBOX_STAT_EXITCODE_FILE_NOT_FOUND,
+ VBOXSERVICETOOLBOX_STAT_EXITCODE_PATH_NOT_FOUND,
+ VBOXSERVICETOOLBOX_STAT_EXITCODE_NET_PATH_NOT_FOUND,
+ /** The usual 32-bit type hack. */
+ VBOXSERVICETOOLBOX_STAT_32BIT_HACK = 0x7fffffff
+} VBOXSERVICETOOLBOX_STAT_EXITCODE;
+
+/**
+ * Input status, reported by the client.
+ */
+enum eInputStatus
+{
+ /** Input is in an undefined state. */
+ INPUT_STS_UNDEFINED = 0,
+ /** Input was written (partially, see cbProcessed). */
+ INPUT_STS_WRITTEN = 1,
+ /** Input failed with an error (see flags for rc). */
+ INPUT_STS_ERROR = 20,
+ /** Process has abandoned / terminated input handling. */
+ INPUT_STS_TERMINATED = 21,
+ /** Too much input data. */
+ INPUT_STS_OVERFLOW = 30
+};
+
+
+
+} /* namespace guestControl */
+
+#endif /* !VBOX_INCLUDED_GuestHost_GuestControl_h */
+
diff --git a/include/VBox/GuestHost/Makefile.kup b/include/VBox/GuestHost/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/include/VBox/GuestHost/Makefile.kup
diff --git a/include/VBox/GuestHost/SharedClipboard.h b/include/VBox/GuestHost/SharedClipboard.h
new file mode 100644
index 00000000..28d44eb3
--- /dev/null
+++ b/include/VBox/GuestHost/SharedClipboard.h
@@ -0,0 +1,82 @@
+/** @file
+ * Shared Clipboard - Common Guest and Host Code.
+ */
+
+/*
+ * Copyright (C) 2006-2019 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+#ifndef VBOX_INCLUDED_GuestHost_SharedClipboard_h
+#define VBOX_INCLUDED_GuestHost_SharedClipboard_h
+#ifndef RT_WITHOUT_PRAGMA_ONCE
+# pragma once
+#endif
+
+#include <iprt/cdefs.h>
+#include <iprt/types.h>
+
+enum
+{
+ /** The number of milliseconds before the clipboard times out. */
+#ifndef TESTCASE
+ CLIPBOARD_TIMEOUT = 5000
+#else
+ CLIPBOARD_TIMEOUT = 1
+#endif
+};
+
+/** Opaque data structure for the X11/VBox frontend/glue code. */
+struct _VBOXCLIPBOARDCONTEXT;
+typedef struct _VBOXCLIPBOARDCONTEXT VBOXCLIPBOARDCONTEXT;
+
+/** Opaque data structure for the X11/VBox backend code. */
+struct _CLIPBACKEND;
+typedef struct _CLIPBACKEND CLIPBACKEND;
+
+/** Opaque request structure for clipboard data.
+ * @todo All use of single and double underscore prefixes is banned! */
+struct _CLIPREADCBREQ;
+typedef struct _CLIPREADCBREQ CLIPREADCBREQ;
+
+/* APIs exported by the X11 backend */
+extern CLIPBACKEND *ClipConstructX11(VBOXCLIPBOARDCONTEXT *pFrontend, bool fHeadless);
+extern void ClipDestructX11(CLIPBACKEND *pBackend);
+#ifdef __cplusplus
+extern int ClipStartX11(CLIPBACKEND *pBackend, bool grab = false);
+#else
+extern int ClipStartX11(CLIPBACKEND *pBackend, bool grab);
+#endif
+extern int ClipStopX11(CLIPBACKEND *pBackend);
+extern void ClipAnnounceFormatToX11(CLIPBACKEND *pBackend,
+ uint32_t u32Formats);
+extern int ClipRequestDataFromX11(CLIPBACKEND *pBackend, uint32_t u32Format,
+ CLIPREADCBREQ *pReq);
+
+/* APIs exported by the X11/VBox frontend */
+extern int ClipRequestDataForX11(VBOXCLIPBOARDCONTEXT *pCtx,
+ uint32_t u32Format, void **ppv,
+ uint32_t *pcb);
+extern void ClipReportX11Formats(VBOXCLIPBOARDCONTEXT *pCtx,
+ uint32_t u32Formats);
+extern void ClipCompleteDataRequestFromX11(VBOXCLIPBOARDCONTEXT *pCtx, int rc,
+ CLIPREADCBREQ *pReq, void *pv,
+ uint32_t cb);
+#endif /* !VBOX_INCLUDED_GuestHost_SharedClipboard_h */
+
diff --git a/include/VBox/GuestHost/clipboard-helper.h b/include/VBox/GuestHost/clipboard-helper.h
new file mode 100644
index 00000000..5ded3ffa
--- /dev/null
+++ b/include/VBox/GuestHost/clipboard-helper.h
@@ -0,0 +1,174 @@
+/* $Id: clipboard-helper.h $ */
+/** @file
+ * Shared Clipboard - Some helper function for converting between the various EOLs.
+ */
+
+/*
+ * Copyright (C) 2006-2019 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+#ifndef VBOX_INCLUDED_GuestHost_clipboard_helper_h
+#define VBOX_INCLUDED_GuestHost_clipboard_helper_h
+#ifndef RT_WITHOUT_PRAGMA_ONCE
+# pragma once
+#endif
+
+#include <iprt/string.h>
+
+/** Constants needed for string conversions done by the Linux/Mac clipboard code. */
+enum {
+ /** In Linux, lines end with a linefeed character. */
+ LINEFEED = 0xa,
+ /** In Windows, lines end with a carriage return and a linefeed character. */
+ CARRIAGERETURN = 0xd,
+ /** Little endian "real" UTF-16 strings start with this marker. */
+ UTF16LEMARKER = 0xfeff,
+ /** Big endian "real" UTF-16 strings start with this marker. */
+ UTF16BEMARKER = 0xfffe
+};
+
+/**
+ * Get the size of the buffer needed to hold a UTF-16-LE zero terminated string
+ * with Windows EOLs converted from a UTF-16 string with Linux EOLs.
+ *
+ * @returns VBox status code.
+ *
+ * @param pwszSrc The source UTF-16 string.
+ * @param cwcSrc The length of the source string in RTUTF16 units.
+ * @param pcwcDst The length of the destination string in RTUTF16 units.
+ */
+int vboxClipboardUtf16GetWinSize(PRTUTF16 pwszSrc, size_t cwcSrc, size_t *pcwcDst);
+
+/**
+ * Convert a UTF-16 text with Linux EOLs to null-terminated UTF-16-LE with
+ * Windows EOLs.
+ *
+ * Does no checking for validity.
+ *
+ * @returns VBox status code
+ *
+ * @param pwszSrc Source UTF-16 text to convert.
+ * @param cwcSrc Size of the source text int RTUTF16 units
+ * @param pwszDst Buffer to store the converted text to.
+ * @param cwcDst Size of the buffer for the converted text in RTUTF16 units.
+ */
+int vboxClipboardUtf16LinToWin(PRTUTF16 pwszSrc, size_t cwcSrc, PRTUTF16 pwszDst, size_t cwcDst);
+
+/**
+ * Get the size of the buffer needed to hold a zero-terminated UTF-16 string
+ * with Linux EOLs converted from a UTF-16 string with Windows EOLs.
+ *
+ * @returns RT status code
+ *
+ * @param pwszSrc The source UTF-16 string
+ * @param cwcSrc The length of the source string in RTUTF16 units.
+ * @retval pcwcDst The length of the destination string in RTUTF16 units.
+ */
+int vboxClipboardUtf16GetLinSize(PRTUTF16 pwszSrc, size_t cwcSrc, size_t *pcwcDst);
+
+/**
+ * Convert UTF-16-LE text with Windows EOLs to zero-terminated UTF-16 with Linux
+ * EOLs. This function does not verify that the UTF-16 is valid.
+ *
+ * @returns VBox status code
+ *
+ * @param pwszSrc Text to convert
+ * @param cwcSrc Size of the source text in RTUTF16 units.
+ * @param pwszDst The buffer to store the converted text to
+ * @param cwcDst The size of the buffer for the destination text in RTUTF16
+ * chars.
+ */
+int vboxClipboardUtf16WinToLin(PRTUTF16 pwszSrc, size_t cwcSrc, PRTUTF16 pwszDst, size_t cwcDst);
+
+#pragma pack(1)
+/** @todo r=bird: Why duplicate these structures here, we've got them in
+ * DevVGA.cpp already! */
+/**
+ * Bitmap File Header. Official win32 name is BITMAPFILEHEADER
+ * Always Little Endian.
+ */
+typedef struct BMFILEHEADER
+{
+/** @todo r=bird: this type centric prefixing is what give hungarian notation a bad name... */
+ uint16_t u16Type;
+ uint32_t u32Size;
+ uint16_t u16Reserved1;
+ uint16_t u16Reserved2;
+ uint32_t u32OffBits;
+} BMFILEHEADER;
+/** Pointer to a BMFILEHEADER structure. */
+typedef BMFILEHEADER *PBMFILEHEADER;
+/** BMP file magic number */
+#define BITMAPHEADERMAGIC (RT_H2LE_U16_C(0x4d42))
+
+/**
+ * Bitmap Info Header. Official win32 name is BITMAPINFOHEADER
+ * Always Little Endian.
+ */
+typedef struct BMINFOHEADER
+{
+/** @todo r=bird: this type centric prefixing is what give hungarian notation a bad name... */
+ uint32_t u32Size;
+ uint32_t u32Width;
+ uint32_t u32Height;
+ uint16_t u16Planes;
+ uint16_t u16BitCount;
+ uint32_t u32Compression;
+ uint32_t u32SizeImage;
+ uint32_t u32XBitsPerMeter;
+ uint32_t u32YBitsPerMeter;
+ uint32_t u32ClrUsed;
+ uint32_t u32ClrImportant;
+} BMINFOHEADER;
+/** Pointer to a BMINFOHEADER structure. */
+typedef BMINFOHEADER *PBMINFOHEADER;
+#pragma pack() /** @todo r=bird: Only BMFILEHEADER needs packing. The BMINFOHEADER is perfectly aligned. */
+
+/**
+ * Convert CF_DIB data to full BMP data by prepending the BM header.
+ * Allocates with RTMemAlloc.
+ *
+ * @returns VBox status code
+ *
+ * @param pvSrc DIB data to convert
+ * @param cbSrc Size of the DIB data to convert in bytes
+ * @param ppvDst Where to store the pointer to the buffer for the
+ * destination data
+ * @param pcbDst Pointer to the size of the buffer for the destination
+ * data in bytes.
+ */
+int vboxClipboardDibToBmp(const void *pvSrc, size_t cbSrc, void **ppvDst, size_t *pcbDst);
+
+/**
+ * Get the address and size of CF_DIB data in a full BMP data in the input buffer.
+ * Does not do any allocation.
+ *
+ * @returns VBox status code
+ *
+ * @param pvSrc BMP data to convert
+ * @param cbSrc Size of the BMP data to convert in bytes
+ * @param ppvDst Where to store the pointer to the destination data
+ * @param pcbDst Pointer to the size of the destination data in bytes
+ */
+int vboxClipboardBmpGetDib(const void *pvSrc, size_t cbSrc, const void **ppvDst, size_t *pcbDst);
+
+
+#endif /* !VBOX_INCLUDED_GuestHost_clipboard_helper_h */
+