]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
fileIOPosix.c: Add new function FileIO_CreateRetry().
authorOliver Kurth <okurth@vmware.com>
Fri, 15 Sep 2017 18:22:56 +0000 (11:22 -0700)
committerOliver Kurth <okurth@vmware.com>
Fri, 15 Sep 2017 18:22:56 +0000 (11:22 -0700)
fileIO.h: Add new function FileIO_CreateRetry().
config.h: Add new function Config_TriToBool().
hostinfo.h: Add new function Hostinfo_EnumerateAllProcessPids().
hostname.c: Allow hostname to be UTF8.
posixPosix.c: Using __GLIBC__ define to control use of euidaccess().
vmxnet3_defs.h: Update the coalescing configuration through the guest OS.
                Bump the Tx Data Desc Max Size to 2048.

The drag-n-drop plugin clipboard updated to allow the clipboard size to be adjusted by the consumer via new CPClipboard_InitWithSize() function.

Common source and header file changes that are not applicable to open-vm-tools.

40 files changed:
open-vm-tools/lib/asyncsocket/asyncsocket.c
open-vm-tools/lib/file/fileIOPosix.c
open-vm-tools/lib/foundryMsg/vixTranslateErrOpenSource.c
open-vm-tools/lib/guestApp/guestApp.c
open-vm-tools/lib/include/config.h
open-vm-tools/lib/include/fileIO.h
open-vm-tools/lib/include/hostinfo.h
open-vm-tools/lib/include/posix.h
open-vm-tools/lib/include/sigPosixRegs.h
open-vm-tools/lib/include/timeutil.h
open-vm-tools/lib/include/vm_atomic.h
open-vm-tools/lib/include/vm_basic_asm.h
open-vm-tools/lib/include/vm_basic_defs.h
open-vm-tools/lib/include/vm_basic_types.h
open-vm-tools/lib/include/vm_product_versions.h
open-vm-tools/lib/include/win32util.h [deleted file]
open-vm-tools/lib/include/windowsUtil.h [new file with mode: 0644]
open-vm-tools/lib/lock/ul.c
open-vm-tools/lib/lock/ulSema.c
open-vm-tools/lib/misc/codeset.c
open-vm-tools/lib/misc/codesetOld.c
open-vm-tools/lib/misc/hostname.c
open-vm-tools/lib/misc/posixPosix.c
open-vm-tools/lib/misc/random.c
open-vm-tools/lib/misc/timeutil.c
open-vm-tools/lib/misc/util_misc.c
open-vm-tools/lib/misc/vthreadBase.c
open-vm-tools/lib/panic/panic.c
open-vm-tools/lib/user/util.c
open-vm-tools/lib/vmCheck/vmcheck.c
open-vm-tools/libvmtools/vmtoolsLog.c
open-vm-tools/modules/shared/vmxnet/vmxnet3_defs.h
open-vm-tools/services/plugins/dndcp/dnd/dnd.h
open-vm-tools/services/plugins/dndcp/dnd/dndClipboard.c
open-vm-tools/services/plugins/dndcp/dnd/dndClipboard.h
open-vm-tools/services/plugins/dndcp/dndGuest/copyPasteRpcV3.cc
open-vm-tools/services/plugins/dndcp/dndGuest/copyPasteRpcV4.cc
open-vm-tools/services/plugins/dndcp/dndGuest/dndRpcV4.cc
open-vm-tools/services/plugins/vix/foundryToolsDaemon.c
open-vm-tools/services/plugins/vix/vixTools.c

index 7806e62f293b7129515aea4d39d0cc47c0f617b3..afbaa35bd59cfef1476f9824a24e4676a7c05328 100644 (file)
@@ -1349,7 +1349,7 @@ AsyncSocketGetPort(AsyncSocket *asock)  // IN
 static Bool
 AsyncSocketOSVersionSupportsV4Mapped()
 {
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(VM_WIN_UWP)
    OSVERSIONINFOW osvi = {sizeof(OSVERSIONINFOW)};
 
    /*
index b266a21b21d030bc00ab5b91ff1023eea239032b..3631b55a9cc9ab122fe1c5a47d28ba6a40be554f 100644 (file)
@@ -1028,7 +1028,7 @@ error:
 /*
  *----------------------------------------------------------------------
  *
- * FileIO_Create --
+ * FileIO_CreateRetry --
  *
  *      Open/create a file; specify creation mode
  *
@@ -1045,22 +1045,24 @@ error:
  */
 
 FileIOResult
-FileIO_Create(FileIODescriptor *file,   // OUT:
-              const char *pathName,     // IN:
-              int access,               // IN:
-              FileIOOpenAction action,  // IN:
-              int mode)                 // IN: mode_t for creation
+FileIO_CreateRetry(FileIODescriptor *file,   // OUT:
+                   const char *pathName,     // IN:
+                   int access,               // IN:
+                   FileIOOpenAction action,  // IN:
+                   int mode,                 // IN: mode_t for creation
+                   uint32 msecMaxWaitTime)   // IN:
 {
-   return FileIOCreateRetry(file, pathName, access, action, mode, 0);
+   return FileIOCreateRetry(file, pathName, access, action, mode,
+                            msecMaxWaitTime);
 }
 
 
 /*
  *----------------------------------------------------------------------
  *
- * FileIO_Open --
+ * FileIO_Create --
  *
- *      Open/create a file.
+ *      Open/create a file; specify creation mode
  *
  * Results:
  *      FILEIO_SUCCESS on success: 'file' is set
@@ -1075,12 +1077,13 @@ FileIO_Create(FileIODescriptor *file,   // OUT:
  */
 
 FileIOResult
-FileIO_Open(FileIODescriptor *file,   // OUT:
-            const char *pathName,     // IN:
-            int access,               // IN:
-            FileIOOpenAction action)  // IN:
+FileIO_Create(FileIODescriptor *file,   // OUT:
+              const char *pathName,     // IN:
+              int access,               // IN:
+              FileIOOpenAction action,  // IN:
+              int mode)                 // IN: mode_t for creation
 {
-   return FileIO_OpenRetry(file, pathName, access, action, 0);
+   return FileIOCreateRetry(file, pathName, access, action, mode, 0);
 }
 
 
@@ -1146,6 +1149,35 @@ FileIO_OpenRetry(FileIODescriptor *file,   // OUT:
 }
 
 
+/*
+ *----------------------------------------------------------------------
+ *
+ * FileIO_Open --
+ *
+ *      Open/create a file.
+ *
+ * Results:
+ *      FILEIO_SUCCESS on success: 'file' is set
+ *      FILEIO_OPEN_ERROR_EXIST if the file already exists
+ *      FILEIO_FILE_NOT_FOUND if the file is not present
+ *      FILEIO_ERROR for other errors
+ *
+ * Side effects:
+ *      None
+ *
+ *----------------------------------------------------------------------
+ */
+
+FileIOResult
+FileIO_Open(FileIODescriptor *file,   // OUT:
+            const char *pathName,     // IN:
+            int access,               // IN:
+            FileIOOpenAction action)  // IN:
+{
+   return FileIO_OpenRetry(file, pathName, access, action, 0);
+}
+
+
 /*
  *----------------------------------------------------------------------
  *
index 1b2cc2b3832850a163bea2ff6590cbd149912b64..a582688112b45516b8d3142120b0abd90531552e 100644 (file)
@@ -36,7 +36,7 @@
 #include <string.h>
 
 #ifdef _WIN32
-#include "win32u.h"
+#include "windowsu.h"
 #endif
 
 
index 557274ce728908d63b252a49d8831985ecb34288..de15ec23842aedb0071407ba1e119696d13463fc 100644 (file)
@@ -48,7 +48,7 @@
 #include <shlobj.h>
 #include "productState.h"
 #include "winregistry.h"
-#include "win32util.h"
+#include "windowsUtil.h"
 #endif
 
 /*
index 41ca4a11121e5457f19bbdae7348e5586f2c9a1f..4d3900489870d4d8749d7309fafcde0fbbfeb300 100644 (file)
@@ -120,4 +120,7 @@ Bool Config_GetDataFileKey(struct CryptoKey **key,
 Bool Config_GetDataFileKeys(struct KeySafeUserRing **parentKeys,
                             struct KeySafeUserRing **allKeys);
 
+Bool Config_TriToBool(Bool boolDefaultValue,
+                      int32 triValue);
+
 #endif // _CONFIG_H_
index 04bff6ea8875819961a1eb8a3630f6ab45efaa42..0dcda432b1127120f8cede8b3feb933da39deb08 100644 (file)
@@ -301,6 +301,13 @@ FileIOResult FileIO_Create(FileIODescriptor *file,
                            FileIOOpenAction action,
                            int mode);
 
+FileIOResult FileIO_CreateRetry(FileIODescriptor *file,
+                               const char *pathName,
+                               int access,
+                               FileIOOpenAction action,
+                               int mode,
+                               uint32 msecMaxWaitTime);
+
 FileIOResult FileIO_Open(FileIODescriptor *file,
                          const char *pathName,
                          int access,
index feb6d75120a41dfb356896e6bd8870ab257963cd..199f108318fb3eee6c2af64fe4a88dcacc1d3920 100644 (file)
@@ -90,6 +90,7 @@ Bool Hostinfo_OSIsWow64(void);
 Bool Hostinfo_TSCInvariant(void);
 DWORD Hostinfo_OpenProcessBits(void);
 DWORD Hostinfo_OpenThreadBits(void);
+int Hostinfo_EnumerateAllProcessPids(uint32 **processIds);
 #else
 void Hostinfo_ResetProcessState(const int *keepFds,
                                 size_t numKeepFds);
index df463ae7f5f2f3952265f34925bc9dbb0870bfd1..090f08b93e5f6f82a573c739bfcd1b41f1d2c16f 100644 (file)
@@ -297,7 +297,10 @@ Posix_FreeHostent(struct hostent *he)
 #if defined(_WINSOCKAPI_) || defined(_WINSOCK2API_)
 #include <winbase.h>
 #include "vm_atomic.h"
-
+#if defined(VM_WIN_UWP)
+/* UWP use the network definition in winsock2.h */
+#include <winsock2.h>
+#endif
 
 /*
  *----------------------------------------------------------------------
index 81df2aabab38c52e7e57138e351bd8b671ca1539..a2d43bbbb4f657c0140159f38fb829d7b20cb1fe 100644 (file)
 #endif
 
 #include <signal.h>
-#ifndef __ANDROID__
 #include <sys/ucontext.h>
-#endif
 
-#if __linux__
+#if __linux__ && !defined __ANDROID__
 #  if defined(__x86_64__)
 #    undef REG_RAX
 #    undef REG_RBX
 #define SC_EIP(uc) ((unsigned long) (uc)->uc_mcontext.gregs[EIP])
 #endif
 #elif defined(ANDROID_X86)
-#define SC_EAX(uc) ((unsigned long) (uc)->uc_mcontext.eax)
-#define SC_EBX(uc) ((unsigned long) (uc)->uc_mcontext.ebx)
-#define SC_ECX(uc) ((unsigned long) (uc)->uc_mcontext.ecx)
-#define SC_EDX(uc) ((unsigned long) (uc)->uc_mcontext.edx)
-#define SC_EDI(uc) ((unsigned long) (uc)->uc_mcontext.edi)
-#define SC_ESI(uc) ((unsigned long) (uc)->uc_mcontext.esi)
-#define SC_EBP(uc) ((unsigned long) (uc)->uc_mcontext.ebp)
-#define SC_ESP(uc) ((unsigned long) (uc)->uc_mcontext.esp)
-#define SC_EIP(uc) ((unsigned long) (uc)->uc_mcontext.eip)
+#define SC_EAX(uc) ((unsigned long) (uc)->uc_mcontext.gregs[REG_EAX])
+#define SC_EBX(uc) ((unsigned long) (uc)->uc_mcontext.gregs[REG_EBX])
+#define SC_ECX(uc) ((unsigned long) (uc)->uc_mcontext.gregs[REG_ECX])
+#define SC_EDX(uc) ((unsigned long) (uc)->uc_mcontext.gregs[REG_EDX])
+#define SC_EDI(uc) ((unsigned long) (uc)->uc_mcontext.gregs[REG_EDI])
+#define SC_ESI(uc) ((unsigned long) (uc)->uc_mcontext.gregs[REG_ESI])
+#define SC_EBP(uc) ((unsigned long) (uc)->uc_mcontext.gregs[REG_EBP])
+#define SC_ESP(uc) ((unsigned long) (uc)->uc_mcontext.gregs[REG_ESP])
+#define SC_EIP(uc) ((unsigned long) (uc)->uc_mcontext.gregs[REG_EIP])
 #else
 #ifdef __x86_64__
 #define SC_EAX(uc) ((unsigned long) (uc)->uc_mcontext.gregs[GNU_REG_RAX])
index 15c5124ce9b4377275a30aba234dbacc55accb5f..05ef2f7e5d188f59f5034235061eecdb357b4089 100644 (file)
@@ -40,7 +40,8 @@
 
 struct timeval;
 
-#ifdef _WIN32
+/*struct timespec is not supported on UWP*/
+#if defined(_WIN32) && !defined(VM_WIN_UWP)
 struct timespec {
    time_t tv_sec;
    long   tv_nsec;
index 66be7b800e34769ea5e25cd589f494182020178a..91a97ad3f2f56164fc6f7218e80a144cb30f525c 100644 (file)
@@ -1289,7 +1289,7 @@ Atomic_And(Atomic_uint32 *var, // IN/OUT
    AtomicEpilogue();
 #endif /* VM_X86_ANY */
 #elif defined _MSC_VER
-#if defined(__x86_64__)
+#if defined(__x86_64__) || defined(VM_ARM_32)
    _InterlockedAnd((long *)&var->value, (long)val);
 #else
    __asm mov eax, val
@@ -1355,7 +1355,7 @@ Atomic_Or(Atomic_uint32 *var, // IN/OUT
    AtomicEpilogue();
 #endif /* VM_X86_ANY */
 #elif defined _MSC_VER
-#if defined(__x86_64__)
+#if defined(__x86_64__) || defined(VM_ARM_32)
    _InterlockedOr((long *)&var->value, (long)val);
 #else
    __asm mov eax, val
@@ -1421,7 +1421,7 @@ Atomic_Xor(Atomic_uint32 *var, // IN/OUT
    AtomicEpilogue();
 #endif /* VM_X86_ANY */
 #elif defined _MSC_VER
-#if defined(__x86_64__)
+#if defined(__x86_64__) || defined(VM_ARM_32)
    _InterlockedXor((long *)&var->value, (long)val);
 #else
    __asm mov eax, val
@@ -2109,7 +2109,7 @@ Atomic_CMPXCHG64(Atomic_uint64 *var,   // IN/OUT
    return equal;
 #endif //VM_ARM_V7
 #elif defined _MSC_VER
-#if defined(__x86_64__)
+#if defined(__x86_64__) || defined(VM_ARM_32)
    return (__int64)*oldVal == _InterlockedCompareExchange64((__int64 *)&var->value,
                                                             (__int64)*newVal,
                                                             (__int64)*oldVal);
index 097568d8aa2e44dfbf4c47089214558acb48e684..193e1b612f61b8a04a0c263173a1de1206c50f31 100644 (file)
@@ -641,6 +641,11 @@ uint16set(void *dst, uint16 val, size_t count)
 {
 #ifdef VM_X86_64
    __stosw((uint16*)dst, val, count);
+#elif defined(VM_ARM_32)
+   size_t i;
+   for (i = 0; i < count; i++) {
+      ((uint16 *)dst)[i] = val;
+   }
 #else
    __asm { pushf;
            mov ax, val;
@@ -659,6 +664,11 @@ uint32set(void *dst, uint32 val, size_t count)
 {
 #ifdef VM_X86_64
    __stosd((unsigned long*)dst, (unsigned long)val, count);
+#elif defined(VM_ARM_32)
+   size_t i;
+   for (i = 0; i < count; i++) {
+      ((uint32 *)dst)[i] = val;
+   }
 #else
    __asm { pushf;
            mov eax, val;
@@ -720,12 +730,12 @@ Bswap32(uint32 v) // IN
       : "0" (v)
    );
    return v;
-#elif defined(VM_ARM_32) && !defined(__ANDROID__)
+#elif defined(VM_ARM_32) && !defined(__ANDROID__) && !defined(_MSC_VER)
     __asm__("rev %0, %0" : "+r"(v));
     return v;
 #elif defined(VM_ARM_64)
    __asm__("rev32 %x0, %x0" : "+r"(v));
-    return v;
+   return v;
 #else
    return    (v >> 24)
           | ((v >>  8) & 0xFF00)
@@ -822,7 +832,7 @@ Bswap64(uint64 v) // IN
  */
 static INLINE void
 PAUSE(void)
-#ifdef __GNUC__
+#if defined(__GNUC__) || defined(VM_ARM_32)
 {
 #ifdef VM_ARM_ANY
    /*
@@ -896,6 +906,15 @@ RDTSC(void)
 {
    return __rdtsc();
 }
+#elif defined(VM_ARM_32)
+{
+   /*
+    * We need to do more inverstagetion here to find
+    * a microsoft equivalent of that code
+    */
+   NOT_IMPLEMENTED();
+   return 0;
+}
 #else
 #pragma warning( disable : 4035)
 {
index fb48b533ac2ca29c190b367ec50aceee5248595a..e852e796e9224f926f5253a8e3b8cc22a6851bb5 100644 (file)
@@ -475,7 +475,11 @@ void *_ReturnAddress(void);
 
 #ifdef _WIN32 // {
 
+/* Conflict with definition of Visual Studio 2015 */
+#if (_MSC_VER < 1900)
 #define snprintf  _snprintf
+#endif
+
 #define strtok_r  strtok_s
 
 #if (_MSC_VER < 1500)
index c25eadc0d6e5477350921783e942d6d3548c5533..df344b466c046294202e765728078b8f715cedf6 100644 (file)
@@ -720,10 +720,17 @@ typedef void * UserVA;
 #endif
 #define CONST         const
 
-
 #ifndef INLINE
 #   ifdef _MSC_VER
-#      define INLINE        __inline
+       /*
+        * On UWP(Universal Windows Platform),
+        * Only X86 32bit support '__inline'
+        */
+#      if defined(VM_WIN_UWP) && !defined(VM_X86_32)
+#            define INLINE
+#      else
+#            define INLINE        __inline
+#      endif
 #   else
 #      define INLINE        inline
 #   endif
index b70b582b7d1c69790f6e739cdad326cdcc9d3da7..62cefa22bcf3a037f1d7708fb62e377a21bf4bf8 100644 (file)
@@ -37,7 +37,7 @@
  * versioning is correct.
  */
 #if defined(VMX86_VIEWCLIENT)
-   #define PRODUCT_VERSION    4,0,0,PRODUCT_BUILD_NUMBER_NUMERIC
+   #define PRODUCT_VERSION    4,1,0,PRODUCT_BUILD_NUMBER_NUMERIC
 #elif defined(VMX86_VMRC) /* check VMX86_VMRC before VMX86_DESKTOP */
    #define PRODUCT_VERSION    8,0,0,PRODUCT_BUILD_NUMBER_NUMERIC   /* VMRC_VERSION_NUMBER below has to match this */
 #elif defined(VMX86_FLEX) /* check VMX86_FLEX before VMX86_DESKTOP */
 #define PRECHECK_VERSION "e.x.p"
 #define VIEW_FEATUREPACK_VERSION "5.2.0"
 #define VIEW_CLIENT_VERSION_NUMBER "4.0.0"
-#define VIEW_CLIENT_VERSION "4.0.0"
+#define VIEW_CLIENT_VERSION "4.1.0"
 #define VHSESDK_VERSION "1.0.0"
 #define RDE_RFT_ALL_VERSION "4.0.0"
 #define RDESDK_VERSION "2.0.0"
diff --git a/open-vm-tools/lib/include/win32util.h b/open-vm-tools/lib/include/win32util.h
deleted file mode 100644 (file)
index dc2b9b9..0000000
+++ /dev/null
@@ -1,240 +0,0 @@
-/*********************************************************
- * Copyright (C) 1998-2016 VMware, Inc. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation version 2.1 and no later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE.  See the Lesser GNU General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA.
- *
- *********************************************************/
-
-/*
- * Win32Util.h --
- *
- *    misc Windows utilities
- */
-
-#ifndef WIN32UTIL_H_
-#define WIN32UTIL_H_
-
-#define INCLUDE_ALLOW_USERLEVEL
-#include "includeCheck.h"
-
-#include "vm_basic_types.h"
-#include "vm_atomic.h"
-#include "unicodeTypes.h"
-
-#ifdef _WIN32
-
-#include <windows.h>
-
-/* Type definitions */
-
-typedef enum AutorunState {
-   AUTORUN_UNDEFINED,
-   AUTORUN_ON,
-   AUTORUN_OFF
-} AutorunState;
-
-/* Defines */
-#define VMX_SHUTDOWN_ORDER    0x100    // Application reserved last shutdown range.
-#define UI_SHUTDOWN_ORDER     0x300    // Application reserved first shutdown range.
-#define TOOLS_SHUTDOWN_ORDER  0x100    // Application reserved last shutdown range
-
-/* Function declarations */
-
-char * W32Util_GetInstallPath(void);
-char * W32Util_GetInstallPath64(void);
-
-/*
- * The string returned is allocated on the heap and must be freed by the
- * calling routine.
- */
-
-
-char *W32Util_GetAppDataFilePath(const char *fileName);
-char *W32Util_GetLocalAppDataFilePath(const char *fileName);
-
-char *W32Util_GetCommonAppDataFilePath(const char *fileName);
-char *W32Util_GetVmwareCommonAppDataFilePath(const char *fileName);
-
-char *W32Util_GetMyDocumentPath(void);
-char *W32Util_GetMyVideoPath(BOOL myDocumentsOnFail);
-
-char *W32Util_GetDefaultVMPath(const char *pref);
-char *W32Util_GetInstalledFilePath(const char *fileName);
-char *W32Util_GetInstalledFilePath64(const char *fileName);
-
-HKEY W32Util_OpenProductRegKey(REGSAM access);
-HKEY W32Util_OpenUserRegKey(REGSAM access);
-
-LPTOP_LEVEL_EXCEPTION_FILTER W32Util_SetUnhandledExceptionFilter(void);
-
-
-Bool W32Util_CreateProcessArgv(const char *lpApplicationName,
-                               const char **argv,
-                               LPSECURITY_ATTRIBUTES lpProcessAttributes,
-                               LPSECURITY_ATTRIBUTES lpThreadAttributes,
-                               BOOL bInheritHandles,
-                               DWORD dwCreationFlags,
-                               LPVOID lpEnvironment,
-                               const char *lpCurrentDirectory,
-                               LPSTARTUPINFOA lpStartupInfo,
-                               LPPROCESS_INFORMATION lpProcessInformation);
-
-void W32Util_SplitCommandLine(char *commandLine,
-                              int maxArgs,
-                              char *progName,
-                              int *argc,
-                              char **argv);
-
-BOOL W32Util_ReadFileTimeout(HANDLE hFile,                // handle of file to read
-                             LPVOID lpBuffer,             // pointer to buffer that receives data
-                             DWORD nNumberOfBytesToRead,  // number of bytes to read
-                             LPDWORD lpNumberOfBytesRead, // pointer to number of bytes read
-                             DWORD msTimeout);            // timeout in milliseconds
-
-BOOL W32Util_WriteFileTimeout(HANDLE hFile,                    // handle to file to write to
-                              LPCVOID lpBuffer,                // pointer to data to write to file
-                              DWORD nNumberOfBytesToWrite,     // number of bytes to write
-                              LPDWORD lpNumberOfBytesWritten,  // pointer to number of bytes written
-                              DWORD msTimeout);                // timeout in milliseconds
-
-char *W32Util_RealPath(const char *path);
-
-BOOL W32Util_CheckForPrivilegeHeld(HANDLE token, LPCTSTR priv);
-
-typedef BOOL (*SidFilterFunction)(PSID psid, void *cbData);
-BOOL W32Util_GetEffectiveRightsForName(const char *user,
-                                       const char *path,
-                                       DWORD *rights);
-BOOL W32Util_GetEffectiveRightsForSid(PSID psid,
-                                      const char *path,
-                                      DWORD *rights);
-
-BOOL W32Util_ModifyRights(PSID psid,
-                          const char *path,
-                          DWORD rights,
-                          BOOL isAllow);
-void W32Util_FreeSids(PSID *sidList);
-BOOL W32Util_GetMatchingSids(const char *path,
-                             PSID **psidList,
-                             SidFilterFunction matchCb,
-                             void *cbData);
-
-LPSTR W32Util_WideStrToAsciiStr(LPCWSTR wideStr);
-LPWSTR W32Util_AsciiStrToWideStr(LPCSTR multiStr);
-LPSTR W32Util_WideStrToMultiByteStr(LPCWSTR wideStr, UINT codePage);
-LPWSTR W32Util_MultiByteStrToWideStr(LPCSTR multiStr, UINT codePage);
-
-BOOL W32Util_WinSockAddReference(void);
-BOOL W32Util_WinSockDereference(void);
-
-Bool W32Util_RegisterService(Bool bRegister,
-                             const char *name,
-                             const char *displayName,
-                             const char *description,
-                             const char *binaryPath,
-                             char **errString);
-
-Bool W32Util_DebugService(const char *dbgFile);
-
-Bool W32Util_RegisterEventLog(const char *serviceName,
-                              Bool registryVolatile,
-                              DWORD typesSupported,
-                              const char *eventMsgFile,
-                              const char *categoryMsgFile,
-                              DWORD categoryCount,
-                              const char *paramMsgFile);
-
-Bool W32Util_UnregisterEventLog(const char *serviceName);
-
-typedef enum SetSDPrivsAccounts {
-   SDPRIV_GROUP_ADMIN = 0x1,
-   SDPRIV_GROUP_VMWARE = 0x2,
-   SDPRIV_USER_CURRENT = 0x4,
-} SetSDPrivsAccounts;
-
-Bool W32Util_SetSDPrivs(PSECURITY_DESCRIPTOR pSecurityDescriptor,
-                        DWORD accessType, SetSDPrivsAccounts accounts,
-                        PACL *pAcl, char **errString);
-
-BOOL W32Util_SetSecurityDescriptorW(PSECURITY_DESCRIPTOR pSecurityDescriptor,
-                                    const char *Owner, PACL *pAcl);
-BOOL W32Util_SetSecurityDescriptorSid(PSECURITY_DESCRIPTOR sd, PSID sid,
-                                      PACL *pAcl);
-BOOL W32Util_GetThreadHandle(HANDLE *handle);
-
-Bool W32Util_AccessCheck(HANDLE token,
-                         PSECURITY_DESCRIPTOR pSecurityDescriptor,
-                         int desiredAccess);
-
-Bool W32Util_HasAccessToFile(const char *filename, ACCESS_MASK desiredAccess,
-                             HANDLE token);
-
-Bool W32Util_GetSecurityDescriptor(const char *path,
-                                   PSECURITY_DESCRIPTOR *ppSecurityDescriptor);
-
-void W32Util_InitStdioConsole(void);
-void W32Util_ExitStdioConsole(void);
-
-Bool W32Util_CreateWellKnownSid(WELL_KNOWN_SID_TYPE wsdType,
-                                PSID domainSid,
-                                PSID *pSid);
-
-Bool W32Util_GetCurrentUserSid(PSID *pSid);
-Bool W32Util_GetLocalAdminGroupSid(PSID *pSid);
-Bool W32Util_GetVMwareGroupSid(PSID *pSid);
-Bool W32Util_MakeSafeDirectory(const char *path);
-Bool W32Util_IsDirectorySafe(const char *path);
-Bool W32Util_DoesVolumeSupportAcls(const char *path);
-
-Bool W32Util_GetRegistryAutorun(AutorunState* state);
-Bool W32Util_SetRegistryAutorun(const AutorunState state);
-
-Bool W32Util_AllowAdminCOM(void);
-
-char * W32Util_GetAppDataPath(void);
-char * W32Util_RobustGetLongPath(const char *path);
-
-typedef enum SecureObjectType {
-   SecureObject_Process,
-   SecureObject_Thread
-} SecureObjectType;
-
-PSECURITY_DESCRIPTOR W32Util_ConstructSecureObjectSD(HANDLE hToken,
-                                                     SecureObjectType type);
-Bool W32Util_ReplaceObjectSD(HANDLE hObject,
-                             const PSECURITY_DESCRIPTOR pSD);
-
-HMODULE W32Util_GetModuleByAddress(const void *addr);
-
-Bool W32Util_VerifyXPModeHostLicense(void);
-
-char * W32Util_GetPipeNameFromFilePath(const char *fileName);
-
-Bool W32Util_CheckGroupMembership(HANDLE hToken,
-                                  BOOL respectUAC,
-                                  char * *errString,
-                                  BOOL *bMember);
-
-Bool W32Util_DismountVolumes(uint16 drive,
-                             uint64 offset,
-                             uint64 size,
-                             void **handle);
-Bool W32Util_CloseDismountHandle(void *handle);
-
-Bool W32Util_EnableSafePathSearching(void);
-
-CRITICAL_SECTION *W32Util_GetSingletonCriticalSection(Atomic_Ptr *csMemory);
-
-#endif // _WIN32
-#endif // WIN32UTIL_H_
diff --git a/open-vm-tools/lib/include/windowsUtil.h b/open-vm-tools/lib/include/windowsUtil.h
new file mode 100644 (file)
index 0000000..bb57bd8
--- /dev/null
@@ -0,0 +1,75 @@
+/*********************************************************
+ * Copyright (C) 1998-2016 VMware, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation version 2.1 and no later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the Lesser GNU General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA.
+ *
+ *********************************************************/
+
+/*
+ * WindowsUtil.h --
+ *
+ *    misc Windows utilities
+ */
+
+#ifndef WINDOWSUTIL_H_
+#define WINDOWSUTIL_H_
+
+#define INCLUDE_ALLOW_USERLEVEL
+#include "includeCheck.h"
+
+#include "vm_basic_types.h"
+#include "vm_atomic.h"
+#include "unicodeTypes.h"
+
+#ifdef _WIN32
+
+/* Defines */
+#define VMX_SHUTDOWN_ORDER    0x100    // Application reserved last shutdown range.
+#define UI_SHUTDOWN_ORDER     0x300    // Application reserved first shutdown range.
+#define TOOLS_SHUTDOWN_ORDER  0x100    // Application reserved last shutdown range
+
+#include <windows.h>
+
+#if !defined(VM_WIN_UWP)
+#include "win32Util.h"
+#endif
+
+
+/* Function declarations */
+
+char * W32Util_GetInstallPath(void);
+char * W32Util_GetInstallPath64(void);
+
+/*
+ * The string returned is allocated on the heap and must be freed by the
+ * calling routine.
+ */
+
+char *W32Util_GetAppDataFilePath(const char *fileName);
+char *W32Util_GetLocalAppDataFilePath(const char *fileName);
+
+char *W32Util_GetCommonAppDataFilePath(const char *fileName);
+char *W32Util_GetVmwareCommonAppDataFilePath(const char *fileName);
+
+char *W32Util_GetMyDocumentPath(void);
+char *W32Util_GetMyVideoPath(BOOL myDocumentsOnFail);
+
+char *W32Util_GetDefaultVMPath(const char *pref);
+char *W32Util_GetInstalledFilePath(const char *fileName);
+char *W32Util_GetInstalledFilePath64(const char *fileName);
+
+CRITICAL_SECTION *W32Util_GetSingletonCriticalSection(Atomic_Ptr *csMemory);
+
+#endif // _WIN32
+#endif // WIN32UTIL_H_
index 66a809d3c280401bdd7afcde6413365467f8b18f..3a41684b3683249c6df221e9b60424c3ed7de844 100644 (file)
@@ -174,7 +174,7 @@ MXUserSyndrome(void)
 
    if (syndrome == 0) {
 #if defined(_WIN32)
-      syndrome = GetTickCount();
+      syndrome = (uint32)GetTickCount64();
 #else
       syndrome = time(NULL) & 0xFFFFFFFF;
 #endif
index a68df631725868a0b8b61df0f5abeb00b9ceeeae..d4d852eea04135e8c27bd40f8d61a721d86108b7 100644 (file)
@@ -38,7 +38,7 @@
 #include "ulInt.h"
 #include "hostinfo.h"
 #if defined(_WIN32)
-#include "win32u.h"
+#include "windowsu.h"
 #endif
 
 #define MXUSER_A_BILLION (1000 * 1000 * 1000)
index 17fc97f795a17c445e8f42c62936f86c4b8fa49c..5b1f714e509b5738f1c34763a97e37e74c9bc50c 100644 (file)
@@ -84,7 +84,7 @@
 #include "codeset.h"
 #include "codesetOld.h"
 #include "str.h"
-#include "win32util.h"
+#include "windowsUtil.h"
 #if defined __APPLE__
 #   define LOCATION_WEAK
 #   include "location.h"
@@ -312,7 +312,7 @@ char *
 CodeSet_GetAltPathName(const utf16_t *pathW) // IN
 {
    char *path = NULL;
-#if defined(_WIN32)
+#if defined(_WIN32) && !defined(VM_WIN_UWP)
    DWORD res;
    utf16_t shortPathW[_MAX_PATH];
 
index dc980b890b6303b5a443332f8c6e073032864f5d..e4da7b2bb19ec196e70f03ac263d7060705bb103 100644 (file)
@@ -721,7 +721,7 @@ CodeSetOldGetCodeSetFromLocale(void)
 const char *
 CodeSetOld_GetCurrentCodeSet(void)
 {
-#if defined(CURRENT_IS_UTF8)
+#if defined(CURRENT_IS_UTF8) || defined(VM_WIN_UWP)
    return "UTF-8";
 #elif defined(_WIN32)
    static char ret[20];  // max is "windows-4294967296"
@@ -2140,6 +2140,9 @@ CodeSetOldIso88591ToUtf8Db(char const *bufIn,   // IN:
 static DWORD
 GetInvalidCharsFlag(void)
 {
+#if defined(VM_WIN_UWP)
+   return MB_ERR_INVALID_CHARS;
+#else
    static volatile Bool bFirstCall = TRUE;
    static DWORD retval;
 
@@ -2164,7 +2167,7 @@ GetInvalidCharsFlag(void)
 
 #pragma warning(push)
 #pragma warning(disable : 4996) // 'function': was declared deprecated
-   if(!(bOsVersionInfoEx = GetVersionEx((OSVERSIONINFO *) &osvi))) {
+   if (!(bOsVersionInfoEx = GetVersionEx((OSVERSIONINFO *) &osvi))) {
       /*
        * If GetVersionEx failed, we are running something earlier than NT4+SP6,
        * thus we cannot use MB_ERR_INVALID_CHARS
@@ -2192,6 +2195,7 @@ GetInvalidCharsFlag(void)
    bFirstCall = FALSE;
 
    return retval;
+#endif //VM_WIN_UWP
 }
 #endif
 
index 5a4d6ea033a0688ad29e3a3a0133e597e6abb5f0..3fc34380bbaef16047de005cd66d43fa0cc66b37 100644 (file)
@@ -38,7 +38,7 @@
 #include "log.h"
 #include "hostinfo.h"
 #if defined(_WIN32)    // Windows
-#include "win32u.h"
+#include "windowsu.h"
 #endif
 #include "unicode.h"
 
@@ -165,7 +165,9 @@ Hostinfo_HostName(void)
 
    if ((uname(&un) == 0) && (*un.nodename != '\0')) {
       /* 'un.nodename' is already fully qualified. */
-      result = Unicode_Alloc(un.nodename, STRING_ENCODING_US_ASCII);
+      if (Unicode_IsStringValidUTF8(un.nodename)) {  // ASCII is OK
+         result = Unicode_Duplicate(un.nodename);
+      }
    }
 
    return result;
@@ -220,7 +222,9 @@ Hostinfo_HostName(void)
          p = phe->h_name;
       }
 
-      result = Unicode_Alloc(p, STRING_ENCODING_US_ASCII);
+      if (Unicode_IsStringValidUTF8(p)) {  // ASCII is OK
+         result = Unicode_Duplicate(p);
+      }
    }
 
    return result;
index 1918431d2e879fb729a1d1370836c56f4a33e189..c4bd4be64f051248aca730a962f0a1df270fc60b 100644 (file)
@@ -494,7 +494,7 @@ int
 Posix_EuidAccess(const char *pathName,  // IN:
                  int mode)              // IN:
 {
-#ifdef __linux__
+#if defined(__GLIBC__)
    char *path;
    int ret;
 
index 01f9a8888b8d9c89aff33b9cbb481da21d7c7775..590292a3726524c6d979fe547fe915e55fcfe934 100644 (file)
@@ -46,6 +46,7 @@
 
 
 #if defined(_WIN32)
+#if !defined(VM_WIN_UWP)
 /*
  *-----------------------------------------------------------------------------
  *
@@ -91,6 +92,7 @@ RandomBytesWin32(size_t size,   // IN:
 
    return TRUE;
 }
+#endif // !VM_WIN_UWP
 #else
 /*
  *-----------------------------------------------------------------------------
index 5e3f9ff3353f9228693197ec8747acd7222bf3eb..9fd01fd4be9fa061d6528c234001e26ff3263a03 100644 (file)
@@ -40,7 +40,7 @@
 #include "str.h"
 #include "util.h"
 #ifdef _WIN32
-#include "win32u.h"
+#include "windowsu.h"
 #endif
 
 
index d7c232e6f94a569eedc7660056471aa320a7742c..8d99b678838394fccc6a7f9ce15d258b6fea65dc 100644 (file)
@@ -71,8 +71,8 @@
 #include "unicode.h"
 
 #if defined(_WIN32)
-#include "win32u.h"
-#include "win32util.h"
+#include "windowsu.h"
+#include "windowsUtil.h"
 #endif
 #if defined(__APPLE__)
 #include "utilMacos.h"
@@ -128,7 +128,12 @@ Util_GetCanonicalPath(const char *path)  // IN:
        strchr(VALID_DIRSEPS, driveSpec[1])) {
       remoteDrive = TRUE;
    } else {
+#if defined( VM_WIN_UWP)
+      /* Don't need remote path for UWP until now*/
+      remoteDrive = FALSE;
+#else
       remoteDrive = (GetDriveTypeA(driveSpec) == DRIVE_REMOTE);
+#endif // !VM_WIN_UWP
    }
 
    /*
index 44df6938016a499320b3ceda1c00301eafb2a733..55802e8fb3dc7f8a263587a45fedd9de125755f8 100644 (file)
@@ -210,7 +210,11 @@ VThreadBaseInitKeyWork(Atomic_Int *key, void (*deletePtr)(void*))
       VThreadBaseKeyType newKey;
 
 #if defined _WIN32
+#if defined VM_WIN_UWP
+      newKey = FlsAlloc(NULL);
+#else
       newKey = TlsAlloc();
+#endif
       VERIFY(newKey != VTHREADBASE_INVALID_KEY);
 #else
       Bool success = pthread_key_create(&newKey, deletePtr) == 0;
@@ -228,7 +232,11 @@ VThreadBaseInitKeyWork(Atomic_Int *key, void (*deletePtr)(void*))
           VTHREADBASE_INVALID_KEY) {
          /* Race: someone else init'd */
 #if defined _WIN32
+#if defined VM_WIN_UWP
+         FlsFree(newKey);
+#else
          TlsFree(newKey);
+#endif
 #else
          pthread_key_delete(newKey);
 #endif
@@ -318,7 +326,11 @@ VThreadBaseSetLocal(VThreadLocal local, void *value)
    }
    ASSERT(key != VTHREADBASE_INVALID_KEY);
 #if defined _WIN32
+#if defined VM_WIN_UWP
+   success = FlsSetValue(key, adjustedValue);
+#else
    success = TlsSetValue(key, adjustedValue);
+#endif
 #else
    success = pthread_setspecific(key, adjustedValue) == 0;
 #endif
@@ -373,7 +385,11 @@ VThreadBaseGetLocal(VThreadLocal local)
    ASSERT(VThreadBaseAreKeysInited());
 
 #if defined _WIN32
+#if defined VM_WIN_UWP
+   result = FlsGetValue(key);
+#else
    result = TlsGetValue(key);
+#endif
 #else
    result = pthread_getspecific(key);
 #endif
@@ -842,6 +858,13 @@ VThreadBaseGetNative(void)
 static Bool
 VThreadBaseNativeIsAlive(void *native)
 {
+#if defined(VM_WIN_UWP)
+   /* OpenThread is not support on UWP */
+   NOT_IMPLEMENTED();
+
+   return FALSE;
+#else
+
    // Different access level due to impersonation see PR#780775
    HANDLE hThread = OpenThread(Hostinfo_OpenThreadBits(), FALSE,
                                (DWORD)(uintptr_t)native);
@@ -864,6 +887,7 @@ VThreadBaseNativeIsAlive(void *native)
 
       return exitCode == STILL_ACTIVE;
    }
+#endif // VM_WIN_UWP
 }
 #endif
 
@@ -914,8 +938,11 @@ VThreadBaseSimpleNoID(void)
        *    would only cause missing a reclaim which isn't a problem.
        * Posix: thread exit is hooked (via TLS destructor) and sets
        *    entries to NULL, so any entry that is NULL is reclaimable.
+       * UWP: There is no permission to check thread status with the
+       *    thread id. There are only few threads in UWP client, ignore
+       *    the reclaimation.
        */
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(VM_WIN_UWP)
       void *oldNative;
       reused = HashTable_Lookup(ht, newKey, &oldNative) &&
                (oldNative == NULL ||
index 7118fa23de02081365c044a5d8428a4fbcef088a..2ec9a7c8a6e2ef0f61706e18040b1c18ffb19e08 100644 (file)
@@ -46,7 +46,7 @@
 #include "coreDump.h"
 #endif
 #ifdef _WIN32
-#include "win32u.h"
+#include "windowsu.h"
 #endif
 
 typedef enum {
index 0f3cb1cf137382f9410715f52b1242d6ba5e6a54..4b728e3b509b8569676a21f34cee7e0e177e7f22 100644 (file)
@@ -695,6 +695,9 @@ int
 Util_HasAdminPriv(void)
 {
 #if defined(_WIN32)
+#if defined(VM_WIN_UWP)
+   return 0;
+#else
    HANDLE token = INVALID_HANDLE_VALUE;
    int ret = -1;
 
@@ -734,6 +737,7 @@ end:
    }
 
    return ret;
+#endif // !VM_WIN_UWP
 #else
    return Id_IsSuperUser() ? 1 : 0;
 #endif
index 503c7b9f4ae28c7f295dc4fd3699fa4357ff560a..d7d43c4c86d1e0c6d2d8f15224fb4e84fc1721e1 100644 (file)
@@ -33,8 +33,8 @@
 #include "vmware.h"
 #include "vm_version.h"
 #include "vm_tools_version.h"
-#if !defined(WINNT_DDK)
-#  include "hostinfo.h"
+#ifndef WINNT_DDK
+#include "hostinfo.h"
 #endif
 
 /*
@@ -192,7 +192,7 @@ VmCheck_GetVersion(uint32 *version, // OUT
    ASSERT(type);
 
    /* Make sure EBX does not contain BDOOR_MAGIC */
-   bp.in.size = ~BDOOR_MAGIC;
+   bp.in.size = (size_t)~BDOOR_MAGIC;
    /* Make sure ECX does not contain any known VMX type */
    bp.in.cx.halfs.high = 0xFFFF;
 
index 7d55fa603c92d008ddc6db9da5a129ac6a6805e8..8aef0bdd3b4817428fd2f98210ddb4ce127f379e 100644 (file)
@@ -49,7 +49,7 @@
 #  include <dbghelp.h>
 #  include "coreDump.h"
 #  include "w32Messages.h"
-#  include "win32u.h"
+#  include "windowsu.h"
 #endif
 #include "str.h"
 #include "system.h"
index 8dcf273b26fd428ed59703394ea8c547eae7eca2..886006271b502dff6a5682950fac0b439cac410c 100644 (file)
@@ -122,7 +122,7 @@ typedef enum {
    VMXNET3_CMD_LOAD_PLUGIN,
    VMXNET3_CMD_ACTIVATE_VF,
    VMXNET3_CMD_SET_POLLING,
-   VMXNET3_CMD_UPDATE_COALESCE,
+   VMXNET3_CMD_SET_COALESCE,
    VMXNET3_CMD_REGISTER_MEMREGS,
 
    VMXNET3_CMD_FIRST_GET = 0xF00D0000,
@@ -136,7 +136,6 @@ typedef enum {
    VMXNET3_CMD_GET_DEV_EXTRA_INFO,
    VMXNET3_CMD_GET_CONF_INTR,
    VMXNET3_CMD_GET_ADAPTIVE_RING_INFO,
-   VMXNET3_CMD_GET_COALESCE,
    VMXNET3_CMD_GET_TXDATA_DESC_SIZE
 } Vmxnet3_Cmd;
 
@@ -462,11 +461,12 @@ typedef union Vmxnet3_GenericDesc {
 #define VMXNET3_RC_RING_MAX_SIZE   8192
 
 /* Large enough to accommodate typical payload + encap + extension header */
-#define VMXNET3_RXDATA_DESC_MAX_SIZE 2048
+#define VMXNET3_RXDATA_DESC_MAX_SIZE   2048
+#define VMXNET3_TXDATA_DESC_MIN_SIZE   128
+#define VMXNET3_TXDATA_DESC_MAX_SIZE   2048
 
-#define VMXNET3_TXDATA_DESC_MAX_SIZE 1024
 /* a list of reasons for queue stop */
-#define VMXNET3_TXDATA_DESC_MIN_SIZE 128
+
 #define VMXNET3_ERR_NOEOP        0x80000000  /* cannot find the EOP desc of a pkt */
 #define VMXNET3_ERR_TXD_REUSE    0x80000001  /* reuse a TxDesc before tx completion */
 #define VMXNET3_ERR_BIG_PKT      0x80000002  /* too many TxDesc for a pkt */
@@ -610,6 +610,48 @@ enum vmxnet3_intr_type {
 /* value of intrCtrl */
 #define VMXNET3_IC_DISABLE_ALL  0x1   /* bit 0 */
 
+#define VMXNET3_COAL_STATIC_MAX_DEPTH        128
+#define VMXNET3_COAL_RBC_MIN_RATE            100
+#define VMXNET3_COAL_RBC_MAX_RATE            100000
+
+enum Vmxnet3_CoalesceMode {
+   VMXNET3_COALESCE_DEFAULT    = 0,
+   VMXNET3_COALESCE_DISABLED   = 1,
+   VMXNET3_COALESCE_ADAPT      = 2,
+   VMXNET3_COALESCE_STATIC     = 3,
+   VMXNET3_COALESCE_RBC        = 4
+};
+
+typedef
+#include "vmware_pack_begin.h"
+struct Vmxnet3_CoalesceRbc {
+   uint32 rbc_rate;
+}
+#include "vmware_pack_end.h"
+Vmxnet3_CoalesceRbc;
+
+typedef
+#include "vmware_pack_begin.h"
+struct Vmxnet3_CoalesceStatic {
+   uint32 tx_depth;
+   uint32 tx_comp_depth;
+   uint32 rx_depth;
+}
+#include "vmware_pack_end.h"
+Vmxnet3_CoalesceStatic;
+
+typedef
+#include "vmware_pack_begin.h"
+struct Vmxnet3_CoalesceScheme {
+   enum Vmxnet3_CoalesceMode coalMode;
+   union {
+      Vmxnet3_CoalesceRbc    coalRbc;
+      Vmxnet3_CoalesceStatic coalStatic;
+   } coalPara;
+}
+#include "vmware_pack_end.h"
+Vmxnet3_CoalesceScheme;
+
 typedef
 #include "vmware_pack_begin.h"
 struct Vmxnet3_IntrConf {
index 0483900b918e25d076d7a6d5d1164f2763efc917..38197a8992629239d06047dbc08fb1d2c925ae5f 100644 (file)
@@ -135,6 +135,8 @@ typedef struct CPClipItem {
  */
 typedef struct {
    Bool changed;
+   Bool isInitialized;
+   uint32 maxSize;
    CPClipItem items[CPFORMAT_MAX - 1];
 } CPClipboard;
 
index b134fc7beb435caa23f642ace541ec439b3f1ce3..1a403712e55d5f93440395ce2b9519749f172517 100644 (file)
@@ -155,9 +155,38 @@ CPClipboard_Init(CPClipboard *clip)     // IN/OUT: the clipboard
    ASSERT(clip);
 
    clip->changed = TRUE;
+   clip->maxSize = CPCLIPITEM_MAX_SIZE_V3;
    for (i = CPFORMAT_MIN; i < CPFORMAT_MAX; ++i) {
       CPClipItemInit(&clip->items[CPFormatToIndex(i)]);
    }
+   clip->isInitialized = TRUE;
+}
+
+
+/*
+ *----------------------------------------------------------------------------
+ *
+ * CPClipboard_InitWithSize --
+ *
+ *      Call CPClipboard_Init and set the clipboard size.
+ *
+ * Results:
+ *      None.
+ *
+ * Side effects:
+ *      None.
+ *
+ *----------------------------------------------------------------------------
+ */
+
+void
+CPClipboard_InitWithSize(CPClipboard *clip,  // IN/OUT: the clipboard
+                         uint32 size)        // IN: clipboard size
+{
+   ASSERT(clip);
+
+   CPClipboard_Init(clip);
+   clip->maxSize = size;
 }
 
 
@@ -264,7 +293,7 @@ CPClipboard_SetItem(CPClipboard *clip,          // IN/OUT: the clipboard
       return FALSE;
    }
 
-   if (size >= CPCLIPITEM_MAX_SIZE_V3) {
+   if (size >= (size_t) clip->maxSize) {
       return FALSE;
    }
 
@@ -294,7 +323,7 @@ CPClipboard_SetItem(CPClipboard *clip,          // IN/OUT: the clipboard
    item->exists = TRUE;
 
    /* Drop some data if total size is more than limit. */
-   while (CPClipboard_GetTotalSize(clip) >= CPCLIPITEM_MAX_SIZE_V3 &&
+   while (CPClipboard_GetTotalSize(clip) >= (size_t) clip->maxSize &&
           filterIndex < ARRAYSIZE(filterList)) {
       if (!CPClipboard_ClearItem(clip, filterList[filterIndex])) {
          return FALSE;
@@ -381,7 +410,7 @@ CPClipboard_GetItem(const CPClipboard *clip,    // IN: the clipboard
       *buf = clip->items[CPFormatToIndex(fmt)].buf;
       *size = clip->items[CPFormatToIndex(fmt)].size;
       ASSERT(*buf);
-      ASSERT((*size > 0) && (*size < CPCLIPITEM_MAX_SIZE_V3));
+      ASSERT((*size > 0) && (*size < clip->maxSize));
       return TRUE;
    } else {
       ASSERT(!clip->items[CPFormatToIndex(fmt)].size);
@@ -569,6 +598,8 @@ CPClipboard_Copy(CPClipboard *dest,             // IN: the desination clipboard
       }
    }
    dest->changed = src->changed;
+   dest->maxSize = src->maxSize;
+   dest->isInitialized = TRUE;
 
    return TRUE;
 }
@@ -600,6 +631,12 @@ CPClipboard_Serialize(const CPClipboard *clip, // IN
 
    ASSERT(clip);
    ASSERT(buf);
+   ASSERT(clip->isInitialized);
+
+   /* Return FALSE if not initialized. */
+   if (!clip->isInitialized) {
+      return FALSE;
+   }
 
    /* First append number of formats in clip. */
    if (!DynBuf_Append(buf, &maxFmt, sizeof maxFmt)) {
@@ -656,8 +693,12 @@ CPClipboard_Unserialize(CPClipboard *clip, // OUT: the clipboard
 
    ASSERT(clip);
    ASSERT(buf);
+   ASSERT(clip->isInitialized);
 
-   CPClipboard_Init(clip);
+   /* Return FALSE if not initialized. */
+   if (!clip->isInitialized) {
+      goto error;
+   }
 
    r.pos = buf;
    r.unreadLen = len;
index 2fb7d2bbe1001ef60ce46ea0593f9d9c3bc91e80..96225125c731ea4ac64c971fe612eeccfabd6e7f 100644 (file)
@@ -115,6 +115,7 @@ typedef enum
 
 /* CPClipboard */
 void CPClipboard_Init(CPClipboard *clip);
+void CPClipboard_InitWithSize(CPClipboard *clip, uint32 size);
 void CPClipboard_Destroy(CPClipboard *clip);
 
 void CPClipboard_Clear(CPClipboard *clip);
index 3bacd4d2eccaa217d9b3f0c06bfb8b8a7b5d7419..242a08625250356c7c6a3f4e708c35ead6a2f059 100644 (file)
@@ -268,6 +268,7 @@ CopyPasteRpcV3::HandleMsg(RpcParams *params,
 
       /* Unserialize clipboard data for the command. */
       buf = DnDMsg_GetArg(&msg, 0);
+      CPClipboard_Init(&clip);
       if (!CPClipboard_Unserialize(&clip, DynBuf_Get(buf), DynBuf_GetSize(buf))) {
          g_debug("%s: CPClipboard_Unserialize failed.\n", __FUNCTION__);
          goto exit;
index 72432903c662020685fd5ad1b6db90ef0c71ee56..4eca93817b6d42958e48503267fede5ab5c0fe11 100644 (file)
@@ -273,6 +273,7 @@ CopyPasteRpcV4::HandleMsg(RpcParams *params,
          LOG(0, ("%s: invalid clipboard data.\n", __FUNCTION__));
          break;
       }
+      CPClipboard_Init(&clip);
       if (!CPClipboard_Unserialize(&clip, (void *)binary, binarySize)) {
          LOG(0, ("%s: CPClipboard_Unserialize failed.\n", __FUNCTION__));
          break;
index 6b9e0d13b4c8f95f22fadbdf30e08faf788372ca..736fc43a2daa26c3bdfa021ed5fa41f63ccd89ac 100644 (file)
@@ -658,6 +658,7 @@ DnDRpcV4::HandleMsg(RpcParams *params,
          LOG(0, ("%s: invalid clipboard data.\n", __FUNCTION__));
          break;
       }
+      CPClipboard_Init(&clip);
       if (!CPClipboard_Unserialize(&clip, (void *)binary, binarySize)) {
          LOG(0, ("%s: CPClipboard_Unserialize failed.\n", __FUNCTION__));
          break;
index 795dd11806c12f54b2f584bb2bbf232503aefd5c..1f5673563c69eba0d2ec6126d1d05c6b74d7a5b3 100644 (file)
@@ -45,7 +45,7 @@
 #   include <Windows.h>
 #   include <WinSock2.h>
 #   include <WinSpool.h>
-#   include "win32u.h"
+#   include "windowsu.h"
 #elif _WIN32
 #   include "win95.h"
 #endif
index 56ee94ffbd91c4a65be53fb1666d1fa9077ce36a..51fa269d33e90ce8b11c2515d7e431c3b44cf2cd 100644 (file)
@@ -57,7 +57,7 @@
 #include <WTypes.h>
 #include <io.h>
 #include "wminic.h"
-#include "win32u.h"
+#include "windowsu.h"
 #include <sys/stat.h>
 #include <time.h>
 #define  SECURITY_WIN32
 
 #ifdef _WIN32
 #include "registryWin32.h"
-#include "win32u.h"
+#include "windowsu.h"
 #endif /* _WIN32 */
 #include "hgfsHelper.h"