Extend use of w32subset API partitioning to cover more Win32 functions. (#42977)
authormonojenkins <jo.shields+jenkins@xamarin.com>
Wed, 7 Oct 2020 12:44:42 +0000 (08:44 -0400)
committerGitHub <noreply@github.com>
Wed, 7 Oct 2020 12:44:42 +0000 (14:44 +0200)
Expand usage of w32subset API partitioning making it possible to include/exclude/use/replace different subset of Win32 API's.

Merge UWP source files into regular Windows specific source files keeping one set of Windows implementation files in upstream repro leverage w32subset.h to support CLASSIC or UWP API subsets.

PR also extend capabilities to replace API usage using HAVE_EXTERN_DEFINED_WIN32* making it possible to exclude and replace API usage in downstream repositories.

Co-authored-by: lateralusX <lateralusX@users.noreply.github.com>
87 files changed:
src/mono/mono/eglib/Makefile.am
src/mono/mono/eglib/glib.h
src/mono/mono/eglib/gmisc-win32-uwp.c [deleted file]
src/mono/mono/eglib/gmisc-win32.c
src/mono/mono/eglib/gmodule-win32-internals.h [deleted file]
src/mono/mono/eglib/gmodule-win32-uwp.c [deleted file]
src/mono/mono/eglib/gmodule-win32.c
src/mono/mono/eglib/gunicode-win32-uwp.c [deleted file]
src/mono/mono/eglib/gunicode-win32.c
src/mono/mono/metadata/Makefile.am
src/mono/mono/metadata/cominterop-win32-internals.h [deleted file]
src/mono/mono/metadata/cominterop.c
src/mono/mono/metadata/console-win32-internals.h [deleted file]
src/mono/mono/metadata/console-win32-uwp.c [deleted file]
src/mono/mono/metadata/console-win32.c
src/mono/mono/metadata/coree-windows-uwp.c [deleted file]
src/mono/mono/metadata/coree.c
src/mono/mono/metadata/domain.c
src/mono/mono/metadata/environment.c
src/mono/mono/metadata/file-mmap-posix.c
src/mono/mono/metadata/file-mmap-windows.c
src/mono/mono/metadata/file-mmap.h
src/mono/mono/metadata/icall-internals.h
src/mono/mono/metadata/icall-windows-internals.h [deleted file]
src/mono/mono/metadata/icall-windows-uwp.c [deleted file]
src/mono/mono/metadata/icall-windows.c
src/mono/mono/metadata/icall.c
src/mono/mono/metadata/marshal-windows-internals.h [deleted file]
src/mono/mono/metadata/marshal-windows-uwp.c [deleted file]
src/mono/mono/metadata/marshal-windows.c
src/mono/mono/metadata/mono-security-windows-internals.h [deleted file]
src/mono/mono/metadata/mono-security-windows-uwp.c [deleted file]
src/mono/mono/metadata/mono-security-windows.c
src/mono/mono/metadata/mono-security.c
src/mono/mono/metadata/object.c
src/mono/mono/metadata/threadpool-io.c
src/mono/mono/metadata/threads.c
src/mono/mono/metadata/w32file-unix.c
src/mono/mono/metadata/w32file-win32-internals.h [deleted file]
src/mono/mono/metadata/w32file-win32-uwp.c [deleted file]
src/mono/mono/metadata/w32file-win32.c
src/mono/mono/metadata/w32file.h
src/mono/mono/metadata/w32process-internals.h
src/mono/mono/metadata/w32process-unix.c
src/mono/mono/metadata/w32process-win32-uwp.c [deleted file]
src/mono/mono/metadata/w32process-win32.c
src/mono/mono/metadata/w32process.c
src/mono/mono/metadata/w32semaphore-win32.c
src/mono/mono/metadata/w32socket-internals.h
src/mono/mono/metadata/w32socket-unix.c
src/mono/mono/metadata/w32socket-win32.c
src/mono/mono/metadata/w32socket.c
src/mono/mono/metadata/w32subset.h [deleted file]
src/mono/mono/mini/aot-compiler.c
src/mono/mono/mini/debugger-agent.c
src/mono/mono/mini/driver.c
src/mono/mono/mini/exceptions-amd64.c
src/mono/mono/mini/interp/transform.c
src/mono/mono/mini/mini-exceptions.c
src/mono/mono/mini/mini-windows-uwp.c [deleted file]
src/mono/mono/mini/mini-windows.c
src/mono/mono/mini/simd-intrinsics-netcore.c
src/mono/mono/mini/simd-intrinsics.c
src/mono/mono/utils/Makefile.am
src/mono/mono/utils/mono-dl-windows-uwp.c [deleted file]
src/mono/mono/utils/mono-dl-windows.c
src/mono/mono/utils/mono-mmap-windows-internals.h [deleted file]
src/mono/mono/utils/mono-mmap-windows.c
src/mono/mono/utils/mono-os-semaphore.h
src/mono/mono/utils/mono-os-wait-win32-uwp.c [deleted file]
src/mono/mono/utils/mono-os-wait-win32.c
src/mono/mono/utils/mono-proclib-windows-uwp.c [deleted file]
src/mono/mono/utils/mono-proclib-windows.c
src/mono/mono/utils/mono-threads-windows.c
src/mono/mono/utils/mono-threads.h
src/mono/mono/utils/mono-tls.h
src/mono/mono/utils/mono-windows-thread-name.c
src/mono/mono/utils/w32api.h
src/mono/mono/utils/w32subset.h [new file with mode: 0644]
src/mono/msvc/eglib-win32.targets
src/mono/msvc/eglib-win32.targets.filters
src/mono/msvc/libmonoruntime-win32.targets
src/mono/msvc/libmonoruntime-win32.targets.filters
src/mono/msvc/libmonoutils-common.targets
src/mono/msvc/libmonoutils-common.targets.filters
src/mono/msvc/monozlib.targets
src/mono/msvc/msvc-win32-support.h

index 642ed45..fac8132 100644 (file)
@@ -11,7 +11,7 @@ AM_CFLAGS = $(SHARED_CFLAGS)
 win_files  = \
        eglib-config.hw \
        gdate-win32.c gdir-win32.c gfile-win32.c gmisc-win32.c \
-       gmodule-win32.c gmodule-win32-internals.h gtimer-win32.c gunicode-win32.c
+       gmodule-win32.c gtimer-win32.c gunicode-win32.c
 
 unix_files = \
        gdate-unix.c  gdir-unix.c  gfile-unix.c  gmisc-unix.c   \
index 698ad61..019c3b4 100644 (file)
@@ -1455,7 +1455,7 @@ glong     g_utf8_pointer_to_offset (const gchar *str, const gchar *pos);
 
 #define G_HAVE_API_SUPPORT(x) (x)
 #define G_UNSUPPORTED_API "%s:%d: '%s' not supported.", __FILE__, __LINE__
-#define g_unsupported_api(name) G_STMT_START { g_warning (G_UNSUPPORTED_API, name); } G_STMT_END
+#define g_unsupported_api(name) G_STMT_START { g_debug (G_UNSUPPORTED_API, name); } G_STMT_END
 
 #if _WIN32
 // g_free the result
diff --git a/src/mono/mono/eglib/gmisc-win32-uwp.c b/src/mono/mono/eglib/gmisc-win32-uwp.c
deleted file mode 100644 (file)
index cdf5896..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * gmisc-win32-uwp.c: UWP misc support.
- *
- * Copyright 2016 Microsoft
- * Licensed under the MIT license. See LICENSE file in the project root for full license information.
-*/
-#include <config.h>
-#include <glib.h>
-
-#if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
-#include <windows.h>
-#include <assert.h>
-
-gchar*
-g_win32_getlocale(void)
-{
-       gunichar2 buf[19];
-       gint ccBuf = GetLocaleInfoEx (LOCALE_NAME_USER_DEFAULT, LOCALE_SISO639LANGNAME, buf, 9);
-       assert (ccBuf <= 9);
-       if (ccBuf != 0) {
-               buf[ccBuf - 1] = L'-';
-               ccBuf = GetLocaleInfoEx (LOCALE_NAME_USER_DEFAULT, LOCALE_SISO3166CTRYNAME, buf + ccBuf, 9);
-               assert (ccBuf <= 9);
-       }
-
-       // Check for GetLocaleInfoEx failure.
-       if (ccBuf == 0)
-               buf[0] = L'\0';
-
-       return u16to8 (buf);
-}
-
-#else /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
-
-#ifdef _MSC_VER
-// Quiet Visual Studio linker warning, LNK4221, in cases when this source file intentional ends up empty.
-void __mono_win32_gmisc_win32_uwp_quiet_lnk4221(void) {}
-#endif
-#endif /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
index 4efa27f..f5589cb 100644 (file)
  */
 
 #include <config.h>
-
 #include <stdlib.h>
 #include <glib.h>
-
 #include <windows.h>
-#if _MSC_VER && G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
-#include <shlobj.h>
-#endif
 #include <direct.h>
 #include <io.h>
 #include <assert.h>
+#include "../utils/w32subset.h"
 
 gboolean
 g_hasenv (const gchar *variable)
@@ -97,18 +93,43 @@ g_unsetenv(const gchar *variable)
        g_free(var);
 }
 
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#if HAVE_API_SUPPORT_WIN32_LOCAL_INFO || HAVE_API_SUPPORT_WIN32_LOCAL_INFO_EX
 gchar*
 g_win32_getlocale(void)
 {
+       gunichar2 buf[19];
+       gint ccBuf = 0;
+#if HAVE_API_SUPPORT_WIN32_LOCAL_INFO_EX
+       ccBuf = GetLocaleInfoEx (LOCALE_NAME_USER_DEFAULT, LOCALE_SISO639LANGNAME, buf, 9);
+#elif HAVE_API_SUPPORT_WIN32_LOCAL_INFO
        LCID lcid = GetThreadLocale();
-       gchar buf[19];
-       gint ccBuf = GetLocaleInfoA(lcid, LOCALE_SISO639LANGNAME, buf, 9);
-       buf[ccBuf - 1] = '-';
-       ccBuf += GetLocaleInfoA(lcid, LOCALE_SISO3166CTRYNAME, buf + ccBuf, 9);
-       return g_strdup (buf);
+       ccBuf = GetLocaleInfoW(lcid, LOCALE_SISO639LANGNAME, buf, 9);
+#endif
+       if (ccBuf != 0) {
+               buf[ccBuf - 1] = L'-';
+#if HAVE_API_SUPPORT_WIN32_LOCAL_INFO_EX
+       ccBuf = GetLocaleInfoEx (LOCALE_NAME_USER_DEFAULT, LOCALE_SISO3166CTRYNAME, buf + ccBuf, 9);
+#elif HAVE_API_SUPPORT_WIN32_LOCAL_INFO
+       ccBuf = GetLocaleInfoW(lcid, LOCALE_SISO3166CTRYNAME, buf + ccBuf, 9);
+#endif
+               assert (ccBuf <= 9);
+       }
+
+       // Check for failure.
+       if (ccBuf == 0)
+               buf[0] = L'\0';
+
+       return u16to8 (buf);
 }
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
+#elif !HAVE_EXTERN_DEFINED_WIN32_LOCAL_INFO && !HAVE_EXTERN_DEFINED_WIN32_LOCAL_INFO_EX
+gchar*
+g_win32_getlocale(void)
+{
+       g_unsupported_api ("GetLocaleInfo, GetLocaleInfoEx");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return NULL;
+}
+#endif /* HAVE_API_SUPPORT_WIN32_LOCAL_INFO || HAVE_API_SUPPORT_WIN32_LOCAL_INFO_EX */
 
 gboolean
 g_path_is_absolute (const char *filename)
@@ -128,7 +149,8 @@ g_path_is_absolute (const char *filename)
        return FALSE;
 }
 
-#if _MSC_VER && G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#if _MSC_VER && HAVE_API_SUPPORT_WIN32_SH_GET_FOLDER_PATH
+#include <shlobj.h>
 static gchar*
 g_get_known_folder_path (void)
 {
@@ -147,15 +169,13 @@ g_get_known_folder_path (void)
 
        return folder_path;
 }
-
-#else
-
-static gchar *
+#elif !HAVE_EXTERN_DEFINED_WIN32_SH_GET_FOLDER_PATH
+static inline gchar *
 g_get_known_folder_path (void)
 {
        return NULL;
 }
-#endif
+#endif /* HAVE_API_SUPPORT_WIN32_SH_GET_FOLDER_PATH */
 
 const gchar *
 g_get_home_dir (void)
diff --git a/src/mono/mono/eglib/gmodule-win32-internals.h b/src/mono/mono/eglib/gmodule-win32-internals.h
deleted file mode 100644 (file)
index d18e27f..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef __G_MODULE_WINDOWS_INTERNALS_H__
-#define __G_MODULE_WINDOWS_INTERNALS_H__
-
-#include <config.h>
-#include <glib.h>
-
-#ifdef G_OS_WIN32
-#include <gmodule.h>
-
-gpointer
-w32_find_symbol (const gchar *symbol_name);
-#endif /* G_OS_WIN32 */
-#endif /* __G_MODULE_WINDOWS_INTERNALS_H__ */
diff --git a/src/mono/mono/eglib/gmodule-win32-uwp.c b/src/mono/mono/eglib/gmodule-win32-uwp.c
deleted file mode 100644 (file)
index 5117e3b..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * gmodule-win32-uwp.c: UWP gmodule support.
- *
- * Copyright 2016 Microsoft
- * Licensed under the MIT license. See LICENSE file in the project root for full license information.
-*/
-#include <config.h>
-#include <glib.h>
-
-#if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
-#include <windows.h>
-#include <gmodule-win32-internals.h>
-
-gpointer
-w32_find_symbol (const gchar *symbol_name)
-{
-       g_unsupported_api ("EnumProcessModules");
-       SetLastError (ERROR_NOT_SUPPORTED);
-       return NULL;
-}
-
-const gchar *
-g_module_error (void)
-{
-       gchar *ret = NULL;
-       TCHAR buf [1024];
-       DWORD code = GetLastError ();
-
-       if (!FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
-               code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buf, G_N_ELEMENTS (buf) - 1, NULL) )
-               buf[0] = TEXT('\0');
-
-       ret = u16to8 (buf);
-       return ret;
-}
-
-#else /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
-
-#ifdef _MSC_VER
-// Quiet Visual Studio linker warning, LNK4221, in cases when this source file intentional ends up empty.
-void __mono_win32_gmodule_win32_uwp_quiet_lnk4221(void) {}
-#endif
-#endif /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
index 15cbed3..9b628b2 100644 (file)
@@ -35,7 +35,8 @@
 #endif
 #include <windows.h>
 #include <psapi.h>
-#include <gmodule-win32-internals.h>
+#include <gmodule.h>
+#include "../utils/w32subset.h"
 
 #define LIBSUFFIX ".dll"
 #define LIBPREFIX ""
@@ -72,7 +73,7 @@ g_module_open (const gchar *file, GModuleFlags flags)
        return module;
 }
 
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#if HAVE_API_SUPPORT_WIN32_ENUM_PROCESS_MODULES
 gpointer
 w32_find_symbol (const gchar *symbol_name)
 {
@@ -119,7 +120,17 @@ w32_find_symbol (const gchar *symbol_name)
        g_free (modules);
        return NULL;
 }
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
+#elif !HAVE_EXTERN_DEFINED_WIN32_ENUM_PROCESS_MODULES
+gpointer
+w32_find_symbol (const gchar *symbol_name)
+{
+       g_unsupported_api ("EnumProcessModules");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return NULL;
+}
+#else
+extern gpointer w32_find_symbol (const gchar *symbol_name);
+#endif /* HAVE_API_SUPPORT_WIN32_ENUM_PROCESS_MODULES */
 
 gboolean
 g_module_symbol (GModule *module, const gchar *symbol_name, gpointer *symbol)
@@ -140,6 +151,7 @@ g_module_symbol (GModule *module, const gchar *symbol_name, gpointer *symbol)
        }
 }
 
+#if HAVE_API_SUPPORT_WIN32_GET_MODULE_HANDLE_EX
 gboolean
 g_module_address (void *addr, char *file_name, size_t file_name_len,
                   void **file_base, char *sym_name, size_t sym_name_len,
@@ -150,14 +162,14 @@ g_module_address (void *addr, char *file_name, size_t file_name_len,
         * We have to cast the address because usually this func works with strings,
         * this being an exception.
         */
-       BOOL ret = GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCWSTR)addr, &module);
+       BOOL ret = GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCWSTR)addr, &module);
        if (ret)
                return FALSE;
 
        if (file_name != NULL && file_name_len >= 1) {
                /* sigh, non-const. AIX for POSIX is the same way. */
-               TCHAR *fname = (TCHAR*)g_alloca(255);
-               DWORD bytes = GetModuleFileName(module, fname, 255);
+               WCHAR fname [MAX_PATH];
+               DWORD bytes = GetModuleFileNameW (module, fname, G_N_ELEMENTS (fname));
                /* XXX: check for ERROR_INSUFFICIENT_BUFFER? */
                if (bytes) {
                        /* Convert back to UTF-8 from wide for runtime */
@@ -178,25 +190,47 @@ g_module_address (void *addr, char *file_name, size_t file_name_len,
        FreeLibrary (module);
        return TRUE;
 }
+#elif !HAVE_EXTERN_DEFINED_WIN32_GET_MODULE_HANDLE_EX
+gboolean
+g_module_address (void *addr, char *file_name, size_t file_name_len,
+       void **file_base, char *sym_name, size_t sym_name_len,
+       void **sym_addr)
+{
+       g_unsupported_api ("GetModuleHandleEx");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return FALSE;
+}
+#endif /* HAVE_API_SUPPORT_WIN32_GET_MODULE_HANDLE_EX */
 
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#if HAVE_API_SUPPORT_WIN32_FORMAT_MESSAGE
 const gchar *
 g_module_error (void)
 {
        gchar* ret = NULL;
-       TCHAR* buf = NULL;
        DWORD code = GetLastError ();
+#if HAVE_API_SUPPORT_WIN32_LOCAL_ALLOC_FREE
+       PWSTR buf = NULL;
+       if (FormatMessageW (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (PWSTR)&buf, 0, NULL)) {
+               ret = u16to8 (buf);
+               LocalFree (buf);
+       }
+#else
+       WCHAR local_buf [1024];
+       if (!FormatMessageW (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
+               code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), local_buf, G_N_ELEMENTS (local_buf) - 1, NULL) )
+               local_buf [0] = TEXT('\0');
 
-       /* FIXME: buf must not be NULL! */
-       FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, 
-               code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buf, 0, NULL);
-
-       ret = u16to8 (buf);
-       LocalFree(buf);
-
+       ret = u16to8 (local_buf);
+#endif
        return ret;
 }
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
+#elif !HAVE_EXTERN_DEFINED_WIN32_FORMAT_MESSAGE
+const gchar *
+g_module_error (void)
+{
+       return g_strdup_printf ("GetLastError=%d. FormatMessage not supported.", GetLastError ());
+}
+#endif /* HAVE_API_SUPPORT_WIN32_FORMAT_MESSAGE */
 
 gboolean
 g_module_close (GModule *module)
@@ -279,6 +313,7 @@ mono_get_module_filename (gpointer mod, gunichar2 **pstr, guint32 *plength)
 // Prefer mono_get_module_filename over mono_get_module_filename_ex and mono_get_module_basename.
 // Prefer not-ex, not-base.
 //
+#if HAVE_API_SUPPORT_WIN32_GET_MODULE_FILE_NAME_EX
 gboolean
 mono_get_module_filename_ex (gpointer process, gpointer mod, gunichar2 **pstr, guint32 *plength)
 {
@@ -309,6 +344,15 @@ mono_get_module_filename_ex (gpointer process, gpointer mod, gunichar2 **pstr, g
        *plength = length;
        return success;
 }
+#elif !HAVE_EXTERN_DEFINED_WIN32_GET_MODULE_FILE_NAME_EX
+gboolean
+mono_get_module_filename_ex (gpointer process, gpointer mod, gunichar2 **pstr, guint32 *plength)
+{
+       g_unsupported_api ("GetModuleFileNameEx");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return FALSE;
+}
+#endif /* HAVE_API_SUPPORT_WIN32_GET_MODULE_FILE_NAME_EX */
 
 // This is not about GModule but is still a close fit.
 // This is not named "g_" but that should be ok.
@@ -318,6 +362,7 @@ mono_get_module_filename_ex (gpointer process, gpointer mod, gunichar2 **pstr, g
 // Prefer mono_get_module_filename over mono_get_module_filename_ex and mono_get_module_basename.
 // Prefer not-ex, not-base.
 //
+#if HAVE_API_SUPPORT_WIN32_GET_MODULE_BASE_NAME
 gboolean
 mono_get_module_basename (gpointer process, gpointer mod, gunichar2 **pstr, guint32 *plength)
 {
@@ -348,6 +393,15 @@ mono_get_module_basename (gpointer process, gpointer mod, gunichar2 **pstr, guin
        *plength = length;
        return success;
 }
+#elif !HAVE_EXTERN_DEFINED_WIN32_GET_MODULE_BASE_NAME
+gboolean
+mono_get_module_basename (gpointer process, gpointer mod, gunichar2 **pstr, guint32 *plength)
+{
+       g_unsupported_api ("GetModuleBaseName");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return FALSE;
+}
+#endif /* HAVE_API_SUPPORT_WIN32_GET_MODULE_BASE_NAME */
 
 // g_free the result
 // No MAX_PATH limit.
diff --git a/src/mono/mono/eglib/gunicode-win32-uwp.c b/src/mono/mono/eglib/gunicode-win32-uwp.c
deleted file mode 100644 (file)
index e64493c..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * gunicode-win32-uwp.c: UWP unicode support.
- *
- * Copyright 2016 Microsoft
- * Licensed under the MIT license. See LICENSE file in the project root for full license information.
-*/
-#include <config.h>
-#include <glib.h>
-
-#if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
-#define CODESET 1
-#include <windows.h>
-
-extern const char *eg_my_charset;
-static gboolean is_utf8;
-
-gboolean
-g_get_charset (G_CONST_RETURN char **charset)
-{
-       if (eg_my_charset == NULL) {
-               static char buf [14];
-               CPINFOEXW cp_info;
-
-               GetCPInfoExW (CP_ACP, 0, &cp_info);
-               sprintf (buf, "CP%u", cp_info.CodePage);
-               eg_my_charset = buf;
-               is_utf8 = FALSE;
-       }
-       
-       if (charset != NULL)
-               *charset = eg_my_charset;
-
-       return is_utf8;
-}
-
-#else /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
-
-#ifdef _MSC_VER
-// Quiet Visual Studio linker warning, LNK4221, in cases when this source file intentional ends up empty.
-void __mono_win32_gunicode_win32_uwp_quiet_lnk4221(void) {}
-#endif
-#endif /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
index c6033ea..bbae597 100644 (file)
@@ -7,10 +7,11 @@
 #include <config.h>
 #include <glib.h>
 
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
 #define CODESET 1
 #include <windows.h>
+#include "../utils/w32subset.h"
 
+#if HAVE_API_SUPPORT_WIN32_GET_ACP || HAVE_API_SUPPORT_WIN32_GET_CP_INFO_EX
 extern const char *eg_my_charset;
 static gboolean is_utf8;
 
@@ -19,7 +20,13 @@ g_get_charset (G_CONST_RETURN char **charset)
 {
        if (eg_my_charset == NULL) {
                static char buf [14];
+#if HAVE_API_SUPPORT_WIN32_GET_CP_INFO_EX
+               CPINFOEXW cp_info;
+               GetCPInfoExW (CP_ACP, 0, &cp_info);
+               sprintf (buf, "CP%u", cp_info.CodePage);
+#elif HAVE_API_SUPPORT_WIN32_GET_ACP
                sprintf (buf, "CP%u", GetACP ());
+#endif
                eg_my_charset = buf;
                is_utf8 = FALSE;
        }
@@ -29,11 +36,17 @@ g_get_charset (G_CONST_RETURN char **charset)
 
        return is_utf8;
 }
-
-#else /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
-
+#elif !HAVE_EXTERN_DEFINED_WIN32_GET_ACP && !HAVE_EXTERN_DEFINED_WIN32_GET_CP_INFO_EX
+gboolean
+g_get_charset (G_CONST_RETURN char **charset)
+{
+       g_unsupported_api ("GetACP, GetCPInfoEx");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return FALSE;
+}
+#else
 #ifdef _MSC_VER
 // Quiet Visual Studio linker warning, LNK4221, in cases when this source file intentional ends up empty.
 void __mono_win32_mono_gunicode_win32_quiet_lnk4221(void) {}
 #endif
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
+#endif /* HAVE_API_SUPPORT_WIN32_GET_ACP || HAVE_API_SUPPORT_WIN32_GET_CP_INFO_EX */
index 85a4f01..5c9e1e8 100644 (file)
@@ -5,23 +5,16 @@ if !ENABLE_MSVC_ONLY
 if HOST_WIN32
 win32_sources = \
        console-win32.c \
-       console-win32-internals.h \
-       cominterop-win32-internals.h \
        w32file-win32.c \
-       w32file-win32-internals.h \
        icall-windows.c \
-       icall-windows-internals.h \
        marshal-windows.c \
-       marshal-windows-internals.h \
        mono-security-windows.c \
-       mono-security-windows-internals.h \
        w32mutex-win32.c \
        w32semaphore-win32.c \
        w32event-win32.c \
        w32process-win32.c \
        w32socket-win32.c \
-       w32error-win32.c \
-       w32subset.h
+       w32error-win32.c
 
 platform_sources = $(win32_sources)
 
diff --git a/src/mono/mono/metadata/cominterop-win32-internals.h b/src/mono/mono/metadata/cominterop-win32-internals.h
deleted file mode 100644 (file)
index 795ee2e..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * \file
- * Copyright 2016 Microsoft
- * Licensed under the MIT license. See LICENSE file in the project root for full license information.
- */
-#ifndef __MONO_METADATA_COMINTEROP_WIN32_INTERNALS_H__
-#define __MONO_METADATA_COMINTEROP_WIN32_INTERNALS_H__
-
-#include <config.h>
-#include <glib.h>
-
-// On some Windows platforms the implementation of below methods are hosted
-// in separate source files like cominterop-win32-*.c. On other platforms,
-// the implementation is kept in cominterop.c and declared as static and in some
-// cases even inline.
-#if defined(HOST_WIN32) && !G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT)
-
-guint32
-mono_marshal_win_safearray_get_dim (gpointer safearray);
-
-int
-mono_marshal_win_safe_array_get_lbound (gpointer psa, guint nDim, glong* plLbound);
-
-int
-mono_marshal_win_safe_array_get_ubound (gpointer psa, guint nDim, glong* plUbound);
-
-int
-mono_marshal_win_safearray_get_value (gpointer safearray, gpointer indices, gpointer *result);
-
-void
-mono_marshal_win_safearray_end (gpointer safearray, gpointer indices);
-
-gboolean
-mono_marshal_win_safearray_create_internal (UINT cDims, SAFEARRAYBOUND *rgsabound, gpointer *newsafearray);
-
-int
-mono_marshal_win_safearray_set_value (gpointer safearray, gpointer indices, gpointer value);
-
-#endif /* HOST_WIN32 && !G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT) */
-
-#endif /* __MONO_METADATA_COMINTEROP_WIN32_INTERNALS_H__ */
index a4341bd..d3219a8 100644 (file)
 #include <errno.h>
 #include <mono/utils/w32api.h>
 #if defined (HOST_WIN32)
+MONO_PRAGMA_WARNING_PUSH()
+MONO_PRAGMA_WARNING_DISABLE (4115) // warning C4115: 'IRpcStubBuffer': named type definition in parentheses
 #include <oleauto.h>
-#include "mono/metadata/cominterop-win32-internals.h"
+MONO_PRAGMA_WARNING_POP()
+#include <mono/utils/w32subset.h>
 #endif
 #include "icall-decl.h"
 #include "icall-signatures.h"
@@ -3182,38 +3185,48 @@ mono_bstr_set_length (gunichar2 *bstr, int slen)
        *((guint32 *)bstr - 1) = slen * sizeof (gunichar2);
 }
 
+static mono_bstr
+default_ptr_to_bstr (const gunichar2* ptr, int slen)
+{
+       // In Mono, historically BSTR was allocated with a guaranteed size prefix of 4 bytes regardless of platform.
+       // Presumably this is due to the BStr documentation page, which indicates that behavior and then directs you to call
+       // SysAllocString on Windows to handle the allocation for you. Unfortunately, this is not actually how it works:
+       // The allocation pre-string is pointer-sized, and then only 4 bytes are used for the length regardless. Additionally,
+       // the total length is also aligned to a 16-byte boundary. This preserves the old behavior on legacy and fixes it for
+       // netcore moving forward.
+#ifdef ENABLE_NETCORE
+       mono_bstr const s = (mono_bstr)mono_bstr_alloc ((slen + 1) * sizeof (gunichar2));
+       if (s == NULL)
+               return NULL;
+#else
+       /* allocate len + 1 utf16 characters plus 4 byte integer for length*/
+       guint32 * const ret = (guint32 *)g_malloc ((slen + 1) * sizeof (gunichar2) + sizeof (guint32));
+       if (ret == NULL)
+               return NULL;
+       mono_bstr const s = (mono_bstr)(ret + 1);
+#endif
+       mono_bstr_set_length (s, slen);
+       if (ptr)
+               memcpy (s, ptr, slen * sizeof (gunichar2));
+       s [slen] = 0;
+       return s;
+}
+
 /* PTR can be NULL */
 mono_bstr
 mono_ptr_to_bstr (const gunichar2* ptr, int slen)
 {
 #ifdef HOST_WIN32
+#if HAVE_API_SUPPORT_WIN32_BSTR
        return SysAllocStringLen (ptr, slen);
 #else
-#ifndef DISABLE_COM
-       if (com_provider == MONO_COM_DEFAULT) {
+       return default_ptr_to_bstr (ptr, slen);
 #endif
-               // In Mono, historically BSTR was allocated with a guaranteed size prefix of 4 bytes regardless of platform.
-               // Presumably this is due to the BStr documentation page, which indicates that behavior and then directs you to call
-               // SysAllocString on Windows to handle the allocation for you. Unfortunately, this is not actually how it works:
-               // The allocation pre-string is pointer-sized, and then only 4 bytes are used for the length regardless. Additionally,
-               // the total length is also aligned to a 16-byte boundary. This preserves the old behavior on legacy and fixes it for
-               // netcore moving forward.
-#ifdef ENABLE_NETCORE
-               mono_bstr const s = (mono_bstr)mono_bstr_alloc ((slen + 1) * sizeof (gunichar2));
-               if (s == NULL)
-                       return NULL;
 #else
-               /* allocate len + 1 utf16 characters plus 4 byte integer for length*/
-               guint32 * const ret = (guint32 *)g_malloc ((slen + 1) * sizeof (gunichar2) + sizeof (guint32));
-               if (ret == NULL)
-                       return NULL;
-               mono_bstr const s = (mono_bstr)(ret + 1);
+#ifndef DISABLE_COM
+       if (com_provider == MONO_COM_DEFAULT) {
 #endif
-               mono_bstr_set_length (s, slen);
-               if (ptr)
-                       memcpy (s, ptr, slen * sizeof (gunichar2));
-               s [slen] = 0;
-               return s;
+               return default_ptr_to_bstr (ptr, slen);
 #ifndef DISABLE_COM
        }
        else if (com_provider == MONO_COM_MS && init_com_provider_ms ()) {
@@ -3250,8 +3263,12 @@ mono_string_from_bstr_checked (mono_bstr_const bstr, MonoError *error)
        if (!bstr)
                return NULL_HANDLE_STRING;
 #ifdef HOST_WIN32
+#if HAVE_API_SUPPORT_WIN32_BSTR
        return mono_string_new_utf16_handle (mono_domain_get (), bstr, SysStringLen ((BSTR)bstr), error);
 #else
+       return mono_string_new_utf16_handle (mono_domain_get (), bstr, *((guint32 *)bstr - 1) / sizeof (gunichar2), error);
+#endif /* HAVE_API_SUPPORT_WIN32_BSTR */
+#else
 #ifndef DISABLE_COM
        if (com_provider == MONO_COM_DEFAULT)
 #endif
@@ -3294,8 +3311,12 @@ mono_free_bstr (/*mono_bstr_const*/gpointer bstr)
        if (!bstr)
                return;
 #ifdef HOST_WIN32
+#if HAVE_API_SUPPORT_WIN32_BSTR
        SysFreeString ((BSTR)bstr);
 #else
+       g_free (((char *)bstr) - 4);
+#endif /* HAVE_API_SUPPORT_WIN32_BSTR */
+#else
 #ifndef DISABLE_COM
        if (com_provider == MONO_COM_DEFAULT) {
 #endif
@@ -3704,13 +3725,21 @@ mono_cominterop_emit_marshal_safearray (EmitMarshalContext *m, int argnum, MonoT
 }
 
 #ifdef HOST_WIN32
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT)
+#if HAVE_API_SUPPORT_WIN32_SAFE_ARRAY
 static guint32
 mono_marshal_win_safearray_get_dim (gpointer safearray)
 {
        return SafeArrayGetDim ((SAFEARRAY*)safearray);
 }
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT) */
+#elif !HAVE_EXTERN_DEFINED_WIN32_SAFE_ARRAY
+static guint32
+mono_marshal_win_safearray_get_dim (gpointer safearray)
+{
+       g_unsupported_api ("SafeArrayGetDim");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return MONO_E_NOTIMPL;
+}
+#endif /* HAVE_API_SUPPORT_WIN32_SAFE_ARRAY */
 
 static guint32
 mono_marshal_safearray_get_dim (gpointer safearray)
@@ -3734,13 +3763,21 @@ mono_marshal_safearray_get_dim (gpointer safearray)
 #endif /* HOST_WIN32 */
 
 #ifdef HOST_WIN32
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT)
+#if HAVE_API_SUPPORT_WIN32_SAFE_ARRAY
 static int
 mono_marshal_win_safe_array_get_lbound (gpointer psa, guint nDim, glong* plLbound)
 {
        return SafeArrayGetLBound ((SAFEARRAY*)psa, nDim, plLbound);
 }
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT) */
+#elif !HAVE_EXTERN_DEFINED_WIN32_SAFE_ARRAY
+static int
+mono_marshal_win_safe_array_get_lbound (gpointer psa, guint nDim, glong* plLbound)
+{
+       g_unsupported_api ("SafeArrayGetLBound");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return MONO_E_NOTIMPL;
+}
+#endif /* HAVE_API_SUPPORT_WIN32_SAFE_ARRAY */
 
 static int
 mono_marshal_safe_array_get_lbound (gpointer psa, guint nDim, glong* plLbound)
@@ -3764,13 +3801,21 @@ mono_marshal_safe_array_get_lbound (gpointer psa, guint nDim, glong* plLbound)
 #endif /* HOST_WIN32 */
 
 #ifdef HOST_WIN32
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT)
+#if HAVE_API_SUPPORT_WIN32_SAFE_ARRAY
 static int
 mono_marshal_win_safe_array_get_ubound (gpointer psa, guint nDim, glong* plUbound)
 {
        return SafeArrayGetUBound ((SAFEARRAY*)psa, nDim, plUbound);
 }
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT) */
+#elif !HAVE_EXTERN_DEFINED_WIN32_SAFE_ARRAY
+static int
+mono_marshal_win_safe_array_get_ubound (gpointer psa, guint nDim, glong* plUbound)
+{
+       g_unsupported_api ("SafeArrayGetUBound");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return MONO_E_NOTIMPL;
+}
+#endif /* HAVE_API_SUPPORT_WIN32_SAFE_ARRAY */
 
 static int
 mono_marshal_safe_array_get_ubound (gpointer psa, guint nDim, glong* plUbound)
@@ -3873,13 +3918,24 @@ mono_marshal_safearray_begin (gpointer safearray, MonoArray **result, gpointer *
 
 /* This is an icall */
 #ifdef HOST_WIN32
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT)
+#if HAVE_API_SUPPORT_WIN32_SAFE_ARRAY
 static int
 mono_marshal_win_safearray_get_value (gpointer safearray, gpointer indices, gpointer *result)
 {
        return SafeArrayPtrOfIndex ((SAFEARRAY*)safearray, (LONG*)indices, result);
 }
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT) */
+#elif !HAVE_EXTERN_DEFINED_WIN32_SAFE_ARRAY
+static int
+mono_marshal_win_safearray_get_value (gpointer safearray, gpointer indices, gpointer *result)
+{
+       ERROR_DECL (error);
+       g_unsupported_api ("SafeArrayPtrOfIndex");
+       mono_error_set_not_supported (error, G_UNSUPPORTED_API, "SafeArrayPtrOfIndex");
+       mono_error_set_pending_exception (error);
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return MONO_E_NOTIMPL;
+}
+#endif /* HAVE_API_SUPPORT_WIN32_SAFE_ARRAY */
 
 static gpointer
 mono_marshal_safearray_get_value (gpointer safearray, gpointer indices)
@@ -3961,14 +4017,22 @@ gboolean mono_marshal_safearray_next (gpointer safearray, gpointer indices)
 }
 
 #ifdef HOST_WIN32
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT)
+#if HAVE_API_SUPPORT_WIN32_SAFE_ARRAY
 static void
 mono_marshal_win_safearray_end (gpointer safearray, gpointer indices)
 {
        g_free(indices);
        SafeArrayDestroy ((SAFEARRAY*)safearray);
 }
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT) */
+#elif !HAVE_EXTERN_DEFINED_WIN32_SAFE_ARRAY
+static void
+mono_marshal_win_safearray_end (gpointer safearray, gpointer indices)
+{
+       g_free(indices);
+       g_unsupported_api ("SafeArrayDestroy");
+       SetLastError (ERROR_NOT_SUPPORTED);
+}
+#endif /* HAVE_API_SUPPORT_WIN32_SAFE_ARRAY */
 
 static void
 mono_marshal_safearray_end (gpointer safearray, gpointer indices)
@@ -3991,14 +4055,23 @@ mono_marshal_safearray_end (gpointer safearray, gpointer indices)
 #endif /* HOST_WIN32 */
 
 #ifdef HOST_WIN32
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT)
+#if HAVE_API_SUPPORT_WIN32_SAFE_ARRAY
 static gboolean
 mono_marshal_win_safearray_create_internal (UINT cDims, SAFEARRAYBOUND *rgsabound, gpointer *newsafearray)
 {
        *newsafearray = SafeArrayCreate (VT_VARIANT, cDims, rgsabound);
        return TRUE;
 }
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT) */
+#elif !HAVE_EXTERN_DEFINED_WIN32_SAFE_ARRAY
+static gboolean
+mono_marshal_win_safearray_create_internal (UINT cDims, SAFEARRAYBOUND *rgsabound, gpointer *newsafearray)
+{
+       g_unsupported_api ("SafeArrayCreate");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       *newsafearray = NULL;
+       return FALSE;
+}
+#endif /* HAVE_API_SUPPORT_WIN32_SAFE_ARRAY */
 
 static gboolean
 mono_marshal_safearray_create_internal (UINT cDims, SAFEARRAYBOUND *rgsabound, gpointer *newsafearray)
@@ -4054,13 +4127,24 @@ mono_marshal_safearray_create (MonoArray *input, gpointer *newsafearray, gpointe
 
 /* This is an icall */
 #ifdef HOST_WIN32
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT)
+#if HAVE_API_SUPPORT_WIN32_SAFE_ARRAY
 static int
 mono_marshal_win_safearray_set_value (gpointer safearray, gpointer indices, gpointer value)
 {
        return SafeArrayPutElement ((SAFEARRAY*)safearray, (LONG*)indices, value);
 }
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT) */
+#elif !HAVE_EXTERN_DEFINED_WIN32_SAFE_ARRAY
+static int
+mono_marshal_win_safearray_set_value (gpointer safearray, gpointer indices, gpointer value)
+{
+       ERROR_DECL (error);
+       g_unsupported_api ("SafeArrayPutElement");
+       mono_error_set_not_supported (error, G_UNSUPPORTED_API, "SafeArrayPutElement");
+       mono_error_set_pending_exception (error);
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return MONO_E_NOTIMPL;
+}
+#endif /* HAVE_API_SUPPORT_WIN32_SAFE_ARRAY */
 
 #endif /* HOST_WIN32 */
 
diff --git a/src/mono/mono/metadata/console-win32-internals.h b/src/mono/mono/metadata/console-win32-internals.h
deleted file mode 100644 (file)
index 0022457..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- * \file
- * Copyright 2016 Microsoft
- * Licensed under the MIT license. See LICENSE file in the project root for full license information.
- */
-#ifndef __MONO_CONSOLE_WIN32_INTERNALS_H__
-#define __MONO_CONSOLE_WIN32_INTERNALS_H__
-
-#include <config.h>
-#include <glib.h>
-
-#include "mono/metadata/object.h"
-#include "mono/metadata/object-internals.h"
-#include "mono/utils/mono-error.h"
-#include "mono/utils/mono-error-internals.h"
-#include <mono/metadata/console-io.h>
-
-#endif /* __MONO_CONSOLE_WIN32_INTERNALS_H__ */
-
diff --git a/src/mono/mono/metadata/console-win32-uwp.c b/src/mono/mono/metadata/console-win32-uwp.c
deleted file mode 100644 (file)
index 6f59a60..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/**
- * \file
- * UWP console support for Mono.
- *
- * Copyright 2016 Microsoft
- * Licensed under the MIT license. See LICENSE file in the project root for full license information.
-*/
-#include <config.h>
-#include <glib.h>
-#include "mono/utils/mono-compiler.h"
-
-#if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
-#include <windows.h>
-#include "mono/metadata/console-win32-internals.h"
-#include "icall-decl.h"
-
-MonoBoolean
-ves_icall_System_ConsoleDriver_Isatty (HANDLE handle, MonoError* error)
-{
-       g_unsupported_api ("Console");
-
-       mono_error_set_not_supported (error, G_UNSUPPORTED_API, "Console");
-
-       SetLastError (ERROR_NOT_SUPPORTED);
-
-       return FALSE;
-}
-
-MonoBoolean
-ves_icall_System_ConsoleDriver_SetEcho (MonoBoolean want_echo, MonoError* error)
-{
-       g_unsupported_api ("Console");
-
-       mono_error_set_not_supported (error, G_UNSUPPORTED_API, "Console");
-
-       SetLastError (ERROR_NOT_SUPPORTED);
-
-       return FALSE;
-}
-
-MonoBoolean
-ves_icall_System_ConsoleDriver_SetBreak (MonoBoolean want_break, MonoError* error)
-{
-       g_unsupported_api ("Console");
-
-       mono_error_set_not_supported (error, G_UNSUPPORTED_API, "Console");
-
-       SetLastError (ERROR_NOT_SUPPORTED);
-
-       return FALSE;
-}
-
-gint32
-ves_icall_System_ConsoleDriver_InternalKeyAvailable (gint32 timeout, MonoError* error)
-{
-       g_unsupported_api ("Console");
-
-       mono_error_set_not_supported (error, G_UNSUPPORTED_API, "Console");
-
-       SetLastError (ERROR_NOT_SUPPORTED);
-
-       return FALSE;
-}
-
-MonoBoolean
-ves_icall_System_ConsoleDriver_TtySetup (MonoStringHandle keypad, MonoStringHandle teardown, MonoArrayHandleOut control_chars, int **size, MonoError* error)
-{
-       g_unsupported_api ("Console");
-
-       mono_error_set_not_supported (error, G_UNSUPPORTED_API, "Console");
-
-       SetLastError (ERROR_NOT_SUPPORTED);
-
-       return FALSE;
-}
-
-#else /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
-
-MONO_EMPTY_SOURCE_FILE (console_win32_uwp);
-#endif /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
index ba885ce..90ed52c 100644 (file)
@@ -28,6 +28,7 @@
 #include <mono/metadata/metadata.h>
 #include <mono/metadata/console-io.h>
 #include <mono/metadata/exception.h>
+#include <mono/utils/w32subset.h>
 #include "icall-decl.h"
 
 void
@@ -40,7 +41,7 @@ mono_console_handle_async_ops (void)
 {
 }
 
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#if HAVE_API_SUPPORT_WIN32_CONSOLE
 MonoBoolean
 ves_icall_System_ConsoleDriver_Isatty (HANDLE handle, MonoError* error)
 {
@@ -71,4 +72,49 @@ ves_icall_System_ConsoleDriver_TtySetup (MonoStringHandle keypad, MonoStringHand
 {
        return FALSE;
 }
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
+#elif !HAVE_EXTERN_DEFINED_WIN32_CONSOLE
+MonoBoolean
+ves_icall_System_ConsoleDriver_Isatty (HANDLE handle, MonoError* error)
+{
+       g_unsupported_api ("Console");
+       mono_error_set_not_supported (error, G_UNSUPPORTED_API, "Console");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return FALSE;
+}
+
+MonoBoolean
+ves_icall_System_ConsoleDriver_SetEcho (MonoBoolean want_echo, MonoError* error)
+{
+       g_unsupported_api ("Console");
+       mono_error_set_not_supported (error, G_UNSUPPORTED_API, "Console");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return FALSE;
+}
+
+MonoBoolean
+ves_icall_System_ConsoleDriver_SetBreak (MonoBoolean want_break, MonoError* error)
+{
+       g_unsupported_api ("Console");
+       mono_error_set_not_supported (error, G_UNSUPPORTED_API, "Console");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return FALSE;
+}
+
+gint32
+ves_icall_System_ConsoleDriver_InternalKeyAvailable (gint32 timeout, MonoError* error)
+{
+       g_unsupported_api ("Console");
+       mono_error_set_not_supported (error, G_UNSUPPORTED_API, "Console");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return FALSE;
+}
+
+MonoBoolean
+ves_icall_System_ConsoleDriver_TtySetup (MonoStringHandle keypad, MonoStringHandle teardown, MonoArrayHandleOut control_chars, int **size, MonoError* error)
+{
+       g_unsupported_api ("Console");
+       mono_error_set_not_supported (error, G_UNSUPPORTED_API, "Console");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return FALSE;
+}
+#endif /* HAVE_API_SUPPORT_WIN32_CONSOLE */
diff --git a/src/mono/mono/metadata/coree-windows-uwp.c b/src/mono/mono/metadata/coree-windows-uwp.c
deleted file mode 100644 (file)
index ef4c2b7..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * \file
- * UWP coree support for Mono.
- *
- * Copyright 2016 Microsoft
- * Licensed under the MIT license. See LICENSE file in the project root for full license information.
-*/
-#include <config.h>
-#include <glib.h>
-#include "mono/utils/mono-compiler.h"
-
-#if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
-#include <windows.h>
-#include "mono/metadata/coree-internals.h"
-
-BOOL STDMETHODCALLTYPE
-_CorDllMain(HINSTANCE hInst, DWORD dwReason, LPVOID lpReserved)
-{
-       g_unsupported_api ("_CorDllMain");
-       return FALSE;
-}
-
-__int32 STDMETHODCALLTYPE
-_CorExeMain(void)
-{
-       g_unsupported_api ("_CorExeMain");
-       ExitProcess (EXIT_FAILURE);
-}
-
-STDAPI
-_CorValidateImage(PVOID *ImageBase, LPCWSTR FileName)
-{
-       g_unsupported_api ("_CorValidateImage");
-       return E_UNEXPECTED;
-}
-
-HMODULE WINAPI
-MonoLoadImage(LPCWSTR FileName)
-{
-       g_unsupported_api ("MonoLoadImage");
-       return NULL;
-}
-
-void
-mono_coree_set_act_ctx (const char *file_name)
-{
-       g_unsupported_api ("CreateActCtx, ActivateActCtx");
-       SetLastError (ERROR_NOT_SUPPORTED);
-
-       return;
-}
-
-#else /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
-
-MONO_EMPTY_SOURCE_FILE (coree_windows_uwp);
-#endif /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
index c936ec3..e140148 100644 (file)
 #include "environment.h"
 #include "coree.h"
 #include "coree-internals.h"
-
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
-#include <shellapi.h>
-#endif
-
-HMODULE coree_module_handle = NULL;
-
-static gboolean init_from_coree = FALSE;
+#include <mono/utils/w32subset.h>
 
 gchar*
 mono_get_module_file_name (HMODULE module_handle)
@@ -72,8 +65,13 @@ mono_get_module_file_name (HMODULE module_handle)
        return file_name_utf8;
 }
 
+HMODULE coree_module_handle = NULL;
+static gboolean init_from_coree = FALSE;
+
+#if HAVE_API_SUPPORT_WIN32_COREE
+#include <shellapi.h>
+
 /* Entry point called by LdrLoadDll of ntdll.dll after _CorValidateImage. */
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
 BOOL STDMETHODCALLTYPE _CorDllMain(HINSTANCE hInst, DWORD dwReason, LPVOID lpReserved)
 {
        MonoAssembly* assembly;
@@ -144,10 +142,8 @@ BOOL STDMETHODCALLTYPE _CorDllMain(HINSTANCE hInst, DWORD dwReason, LPVOID lpRes
 
        return TRUE;
 }
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
 
 /* Called by ntdll.dll reagardless of entry point after _CorValidateImage. */
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
 __int32 STDMETHODCALLTYPE _CorExeMain(void)
 {
        ERROR_DECL (error);
@@ -221,7 +217,6 @@ __int32 STDMETHODCALLTYPE _CorExeMain(void)
        /* return does not terminate the process. */
        ExitProcess (mono_environment_exitcode_get ());
 }
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
 
 /* Called by msvcrt.dll when shutting down. */
 void STDMETHODCALLTYPE CorExitProcess(int exitCode)
@@ -238,7 +233,6 @@ void STDMETHODCALLTYPE CorExitProcess(int exitCode)
 }
 
 /* Called by ntdll.dll before _CorDllMain and _CorExeMain. */
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
 STDAPI _CorValidateImage(PVOID *ImageBase, LPCWSTR FileName)
 {
        IMAGE_DOS_HEADER* DosHeader;
@@ -401,7 +395,6 @@ STDAPI _CorValidateImage(PVOID *ImageBase, LPCWSTR FileName)
 
        return STATUS_SUCCESS;
 }
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
 
 /* Called by ntdll.dll. */
 STDAPI_(VOID) _CorImageUnloading(PVOID ImageBase)
@@ -423,7 +416,6 @@ STDAPI CorBindToRuntime(LPCWSTR pwszVersion, LPCWSTR pwszBuildFlavor, REFCLSID r
        return CorBindToRuntimeEx (pwszVersion, pwszBuildFlavor, 0, rclsid, riid, ppv);
 }
 
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
 HMODULE WINAPI MonoLoadImage(LPCWSTR FileName)
 {
        HANDLE FileHandle;
@@ -500,7 +492,6 @@ CloseFile:
        CloseHandle(FileHandle);
        return NULL;
 }
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
 
 typedef struct _EXPORT_FIXUP
 {
@@ -855,7 +846,6 @@ STDAPI MonoFixupExe(HMODULE ModuleHandle)
        return S_OK;
 }
 
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
 void
 mono_coree_set_act_ctx (const char* file_name)
 {
@@ -916,7 +906,6 @@ mono_coree_set_act_ctx (const char* file_name)
        if (handle != INVALID_HANDLE_VALUE)
                ActivateActCtx_proc (handle, &cookie);
 }
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
 
 void
 mono_load_coree (const char* exe_file_name)
@@ -960,6 +949,62 @@ mono_fixup_exe_image (MonoImage* image)
                MonoFixupExe ((HMODULE) image->raw_data);
 }
 
+#elif !HAVE_EXTERN_DEFINED_WIN32_COREE
+BOOL STDMETHODCALLTYPE
+_CorDllMain(HINSTANCE hInst, DWORD dwReason, LPVOID lpReserved)
+{
+       g_unsupported_api ("_CorDllMain");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return FALSE;
+}
+
+__int32 STDMETHODCALLTYPE
+_CorExeMain(void)
+{
+       g_unsupported_api ("_CorExeMain");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       ExitProcess (EXIT_FAILURE);
+}
+
+STDAPI
+_CorValidateImage(PVOID *ImageBase, LPCWSTR FileName)
+{
+       g_unsupported_api ("_CorValidateImage");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return E_UNEXPECTED;
+}
+
+HMODULE WINAPI
+MonoLoadImage(LPCWSTR FileName)
+{
+       g_unsupported_api ("MonoLoadImage");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return NULL;
+}
+
+void
+mono_coree_set_act_ctx (const char *file_name)
+{
+       g_unsupported_api ("CreateActCtx, ActivateActCtx");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return;
+}
+
+void
+mono_load_coree (const char* exe_file_name)
+{
+       g_unsupported_api ("mono_load_coree");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return;
+}
+
+void
+mono_fixup_exe_image (MonoImage* image)
+{
+       return;
+}
+#endif /* HAVE_API_SUPPORT_WIN32_COREE */
+
 #else
 
 #include <mono/utils/mono-compiler.h>
index 15ac596..185cd5b 100644 (file)
@@ -51,6 +51,7 @@
 #include <mono/metadata/profiler-private.h>
 #include <mono/metadata/coree.h>
 #include <mono/utils/mono-experiments.h>
+#include <mono/utils/w32subset.h>
 #include "external-only.h"
 #include "mono/utils/mono-tls-inline.h"
 
@@ -511,7 +512,7 @@ mono_init_internal (const char *filename, const char *exe_filename, const char *
        if (domain)
                g_assert_not_reached ();
 
-#if defined(HOST_WIN32) && G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#if defined(HOST_WIN32) && HAVE_API_SUPPORT_WIN32_SET_ERROR_MODE
        /* Avoid system error message boxes. */
        SetErrorMode (SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
 #endif
index 3502495..cabd095 100644 (file)
@@ -69,10 +69,10 @@ ves_icall_System_Environment_GetOSVersionString (MonoError *error)
 {
        error_init (error);
 #ifdef HOST_WIN32
-       OSVERSIONINFOEX verinfo;
-
+       MONO_DISABLE_WARNING (4996) // 'GetVersionExW': was declared deprecated
+       OSVERSIONINFOEXW verinfo;
        verinfo.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX);
-       if (GetVersionEx ((OSVERSIONINFO*)&verinfo)) {
+       if (GetVersionExW ((OSVERSIONINFO*)&verinfo)) {
                char version [128];
                /* maximum string length is 45 bytes
                   4 x 10 bytes per number, 1 byte for 0, 3 x 1 byte for dots, 1 for NULL */
@@ -83,6 +83,7 @@ ves_icall_System_Environment_GetOSVersionString (MonoError *error)
                                 verinfo.wServicePackMajor << 16);
                return mono_string_new_handle (mono_domain_get (), version, error);
        }
+       MONO_RESTORE_WARNING
 #elif defined(HAVE_SYS_UTSNAME_H) && defined(_AIX)
        /*
         * AIX puts the major version number in .version and minor in .release; so make a
index 31adaa5..0246848 100644 (file)
@@ -555,10 +555,10 @@ mono_mmap_map (void *handle, gint64 offset, gint64 *size, int access, void **mma
 }
 
 MonoBoolean
-mono_mmap_unmap (void *mmap_handle, MonoError *error)
+mono_mmap_unmap (void *base_address, MonoError *error)
 {
        int res = 0;
-       MmapInstance *h = (MmapInstance *)mmap_handle;
+       MmapInstance *h = (MmapInstance *)base_address;
 
        MONO_ENTER_GC_SAFE;
        res = mono_file_unmap (h->address, h->free_handle);
index 792bbf8..ea4c326 100644 (file)
 #include <config.h>
 #include <glib.h>
 #include <mono/utils/mono-compiler.h>
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) && defined(HOST_WIN32)
-
-#include <glib.h>
-
+#ifdef HOST_WIN32
+#include <mono/utils/mono-error.h>
+#include <mono/utils/mono-error-internals.h>
+#include <mono/metadata/object-internals.h>
 #include <mono/metadata/file-mmap.h>
+#include <mono/utils/w32subset.h>
 
+#if HAVE_API_SUPPORT_WIN32_FILE_MAPPING
 // These control the retry behaviour when lock violation errors occur during Flush:
 #define MAX_FLUSH_WAITS 15  // must be <=30
 #define MAX_FLUSH_RETIRES_PER_WAIT 20
@@ -448,11 +450,11 @@ mono_mmap_map (void *handle, gint64 offset, gint64 *size, int access, void **mma
 }
 
 MonoBoolean
-mono_mmap_unmap (void *mmap_handle, MonoError *error)
+mono_mmap_unmap (void *base_address, MonoError *error)
 {
-       g_assert (mmap_handle);
+       g_assert (base_address);
 
-       MmapInstance *h = (MmapInstance *) mmap_handle;
+       MmapInstance *h = (MmapInstance *) base_address;
 
        gboolean result;
        MONO_ENTER_GC_SAFE;
@@ -462,9 +464,70 @@ mono_mmap_unmap (void *mmap_handle, MonoError *error)
        g_free (h);
        return result;
 }
+#elif !HAVE_EXTERN_DEFINED_WIN32_FILE_MAPPING
+void *
+mono_mmap_open_file (const gunichar2 *path, gint path_length, int mode, const gunichar2 *mapName, gint mapName_length, gint64 *capacity, int access, int options, int *ioerror, MonoError *error)
+{
+       g_unsupported_api ("MapViewOfFile");
+       mono_error_set_not_supported (error, G_UNSUPPORTED_API, "MapViewOfFile");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return NULL;
+}
 
-#else
+void *
+mono_mmap_open_handle (void *handle, const gunichar2 *mapName, gint mapName_length, gint64 *capacity, int access, int options, int *ioerror, MonoError *error)
+{
+       g_unsupported_api ("MapViewOfFile");
+       mono_error_set_not_supported (error, G_UNSUPPORTED_API, "MapViewOfFile");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return NULL;
+}
 
-MONO_EMPTY_SOURCE_FILE (file_mmap_windows);
+void
+mono_mmap_close (void *mmap_handle, MonoError *error)
+{
+       g_unsupported_api ("MapViewOfFile");
+       mono_error_set_not_supported (error, G_UNSUPPORTED_API, "MapViewOfFile");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return;
+}
 
-#endif
+void
+mono_mmap_configure_inheritability (void *mmap_handle, gint32 inheritability, MonoError *error)
+{
+       g_unsupported_api ("MapViewOfFile");
+       mono_error_set_not_supported (error, G_UNSUPPORTED_API, "MapViewOfFile");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return;
+}
+
+void
+mono_mmap_flush (void *mmap_handle, MonoError *error)
+{
+       g_unsupported_api ("FlushViewOfFile");
+       mono_error_set_not_supported (error, G_UNSUPPORTED_API, "FlushViewOfFile");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return;
+}
+
+int
+mono_mmap_map (void *handle, gint64 offset, gint64 *size, int access, void **mmap_handle, void **base_address, MonoError *error)
+{
+       g_unsupported_api ("MapViewOfFile");
+       mono_error_set_not_supported (error, G_UNSUPPORTED_API, "MapViewOfFile");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return 0;
+}
+
+MonoBoolean
+mono_mmap_unmap (void *base_address, MonoError *error)
+{
+       g_unsupported_api ("UnmapViewOfFile");
+       mono_error_set_not_supported (error, G_UNSUPPORTED_API, "UnmapViewOfFile");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return FALSE;
+}
+#endif /* HAVE_API_SUPPORT_WIN32_FILE_MAPPING */
+#endif /* HOST_WIN32 */
+
+MONO_EMPTY_SOURCE_FILE (file_mmap_windows)
index a30f566..68bcd97 100644 (file)
@@ -34,11 +34,11 @@ mono_mmap_flush (void *mmap_handle, MonoError *error);
 
 ICALL_EXPORT
 void*
-mono_mmap_open_file (const gunichar2 *path, gint path_length, int mode, const gunichar2 *mapName, gint mapName_length, gint64 *capacity, int access, int options, int *win32error, MonoError *error);
+mono_mmap_open_file (const gunichar2 *path, gint path_length, int mode, const gunichar2 *mapName, gint mapName_length, gint64 *capacity, int access, int options, int *ioerror, MonoError *error);
 
 ICALL_EXPORT
 void*
-mono_mmap_open_handle (void *handle, const gunichar2 *mapName, gint mapName_length, gint64 *capacity, int access, int options, int *win32error, MonoError *error);
+mono_mmap_open_handle (void *handle, const gunichar2 *mapName, gint mapName_length, gint64 *capacity, int access, int options, int *ioerror, MonoError *error);
 
 ICALL_EXPORT
 int
index 69ecc58..c699aa4 100644 (file)
@@ -51,17 +51,6 @@ gint32
 mono_icall_wait_for_input_idle (gpointer handle, gint32 milliseconds);
 #endif  /* HOST_WIN32 */
 
-// On platforms not using classic WIN API support the  implementation of bellow methods are hosted in separate source file
-// icall-windows-*.c. On platforms using classic WIN API the implementation is still keept in icall.c and still declared
-// static and in some places even inlined.
-#if !G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
-MonoArray *
-mono_icall_get_logical_drives (void);
-
-guint32
-mono_icall_drive_info_get_drive_type (MonoString *root_path_name);
-#endif  /* !G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
-
 gconstpointer
 mono_lookup_internal_call_full (MonoMethod *method, gboolean warn_on_missing, mono_bool *uses_handles, mono_bool *foreign);
 
diff --git a/src/mono/mono/metadata/icall-windows-internals.h b/src/mono/mono/metadata/icall-windows-internals.h
deleted file mode 100644 (file)
index b187621..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- * \file
- * Copyright 2016 Microsoft
- * Licensed under the MIT license. See LICENSE file in the project root for full license information.
- */
-#ifndef __MONO_METADATA_ICALL_WINDOWS_INTERNALS_H__
-#define __MONO_METADATA_ICALL_WINDOWS_INTERNALS_H__
-
-#include <config.h>
-#include <glib.h>
-
-#ifdef HOST_WIN32
-#include "mono/metadata/icall-internals.h"
-#include "mono/metadata/object.h"
-#include "mono/metadata/object-internals.h"
-#include "mono/metadata/class.h"
-#include "mono/metadata/class-internals.h"
-#endif /* HOST_WIN32 */
-#endif /* __MONO_METADATA_ICALL_WINDOWS_INTERNALS_H__ */
diff --git a/src/mono/mono/metadata/icall-windows-uwp.c b/src/mono/mono/metadata/icall-windows-uwp.c
deleted file mode 100644 (file)
index 694335e..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * \file
- * UWP icall support for Mono.
- *
- * Copyright 2016 Microsoft
- * Licensed under the MIT license. See LICENSE file in the project root for full license information.
-*/
-#include <config.h>
-#include <glib.h>
-#include "mono/utils/mono-compiler.h"
-#include <windows.h>
-#include "mono/metadata/icall-windows-internals.h"
-#include "mono/metadata/w32subset.h"
-
-#if !HAVE_API_SUPPORT_WIN32_GET_COMPUTER_NAME
-MonoStringHandle
-mono_icall_get_machine_name (MonoError *error)
-{
-       g_unsupported_api ("GetComputerName");
-       return mono_string_new_handle (mono_domain_get (), "mono", error);
-}
-#endif
-
-#if !HAVE_API_SUPPORT_WIN32_SH_GET_FOLDER_PATH
-MonoStringHandle
-mono_icall_get_windows_folder_path (int folder, MonoError *error)
-{
-       error_init (error);
-       g_unsupported_api ("SHGetFolderPath");
-       return mono_string_new_handle (mono_domain_get (), "", error);
-}
-#endif
-
-#if !HAVE_API_SUPPORT_WIN32_GET_LOGICAL_DRIVE_STRINGS
-MonoArrayHandle
-mono_icall_get_logical_drives (MonoError *error)
-{
-       g_unsupported_api ("GetLogicalDriveStrings");
-
-       mono_error_set_not_supported (error, G_UNSUPPORTED_API, "GetLogicalDriveStrings");
-
-       SetLastError (ERROR_NOT_SUPPORTED);
-
-       return NULL_HANDLE_ARRAY;
-}
-#endif
-
-#if !HAVE_API_SUPPORT_WIN32_SEND_MESSAGE_TIMEOUT
-ICALL_EXPORT void
-ves_icall_System_Environment_BroadcastSettingChange (MonoError *error)
-{
-       g_unsupported_api ("SendMessageTimeout");
-
-       mono_error_set_not_supported (error, G_UNSUPPORTED_API, "SendMessageTimeout");
-
-       SetLastError (ERROR_NOT_SUPPORTED);
-}
-#endif
-
-#if !HAVE_API_SUPPORT_WIN32_WAIT_FOR_INPUT_IDLE
-gint32
-mono_icall_wait_for_input_idle (gpointer handle, gint32 milliseconds)
-{
-       ERROR_DECL (error);
-
-       g_unsupported_api ("WaitForInputIdle");
-
-       mono_error_set_not_supported (error, G_UNSUPPORTED_API, "WaitForInputIdle");
-       mono_error_set_pending_exception (error);
-
-       return WAIT_TIMEOUT;
-}
-#endif
-
-MONO_EMPTY_SOURCE_FILE (icall_windows_uwp);
index 93fed0d..1e94095 100644 (file)
 #if defined(HOST_WIN32)
 #include <winsock2.h>
 #include <windows.h>
-#include "mono/metadata/icall-windows-internals.h"
-#include "mono/metadata/w32subset.h"
-#if HAVE_API_SUPPORT_WIN32_SH_GET_FOLDER_PATH
-#include <shlobj.h>
-#endif
+#include <mono/metadata/icall-internals.h>
+#include <mono/utils/w32subset.h>
 
 void
 mono_icall_make_platform_path (gchar *path)
@@ -45,15 +42,6 @@ mono_icall_module_get_hinstance (MonoImage *image)
 }
 
 #if HAVE_API_SUPPORT_WIN32_GET_COMPUTER_NAME
-// Support older UWP SDK?
-WINBASEAPI
-BOOL
-WINAPI
-GetComputerNameW (
-       PWSTR buffer,
-       PDWORD size
-       );
-
 MonoStringHandle
 mono_icall_get_machine_name (MonoError *error)
 {
@@ -64,6 +52,13 @@ mono_icall_get_machine_name (MonoError *error)
                return mono_string_new_utf16_handle (mono_domain_get (), buf, len, error);
        return MONO_HANDLE_NEW (MonoString, NULL);
 }
+#elif !HAVE_EXTERN_DEFINED_WIN32_GET_COMPUTER_NAME
+MonoStringHandle
+mono_icall_get_machine_name (MonoError *error)
+{
+       g_unsupported_api ("GetComputerName");
+       return mono_string_new_handle (mono_domain_get (), "mono", error);
+}
 #endif
 
 int
@@ -154,6 +149,7 @@ cleanup:
 }
 
 #if HAVE_API_SUPPORT_WIN32_SH_GET_FOLDER_PATH
+#include <shlobj.h>
 MonoStringHandle
 mono_icall_get_windows_folder_path (int folder, MonoError *error)
 {
@@ -172,13 +168,29 @@ mono_icall_get_windows_folder_path (int folder, MonoError *error)
        }
        return mono_string_new_handle (mono_domain_get (), "", error);
 }
+#elif !HAVE_EXTERN_DEFINED_WIN32_SH_GET_FOLDER_PATH
+MonoStringHandle
+mono_icall_get_windows_folder_path (int folder, MonoError *error)
+{
+       error_init (error);
+       g_unsupported_api ("SHGetFolderPath");
+       return mono_string_new_handle (mono_domain_get (), "", error);
+}
 #endif
 
 #if HAVE_API_SUPPORT_WIN32_SEND_MESSAGE_TIMEOUT
 ICALL_EXPORT void
 ves_icall_System_Environment_BroadcastSettingChange (MonoError *error)
 {
-       SendMessageTimeout (HWND_BROADCAST, WM_SETTINGCHANGE, (WPARAM)NULL, (LPARAM)L"Environment", SMTO_ABORTIFHUNG, 2000, 0);
+       SendMessageTimeoutW (HWND_BROADCAST, WM_SETTINGCHANGE, (WPARAM)NULL, (LPARAM)L"Environment", SMTO_ABORTIFHUNG, 2000, 0);
+}
+#elif !HAVE_EXTERN_DEFINED_WIN32_SEND_MESSAGE_TIMEOUT
+ICALL_EXPORT void
+ves_icall_System_Environment_BroadcastSettingChange (MonoError *error)
+{
+       g_unsupported_api ("SendMessageTimeout");
+       mono_error_set_not_supported (error, G_UNSUPPORTED_API, "SendMessageTimeout");
+       SetLastError (ERROR_NOT_SUPPORTED);
 }
 #endif
 
@@ -188,6 +200,16 @@ mono_icall_wait_for_input_idle (gpointer handle, gint32 milliseconds)
 {
        return WaitForInputIdle (handle, milliseconds);
 }
+#elif !HAVE_EXTERN_DEFINED_WIN32_WAIT_FOR_INPUT_IDLE
+gint32
+mono_icall_wait_for_input_idle (gpointer handle, gint32 milliseconds)
+{
+       ERROR_DECL (error);
+       g_unsupported_api ("WaitForInputIdle");
+       mono_error_set_not_supported (error, G_UNSUPPORTED_API, "WaitForInputIdle");
+       mono_error_set_pending_exception (error);
+       return WAIT_TIMEOUT;
+}
 #endif
 
 void
index f2c003a..2d70ba3 100644 (file)
@@ -7866,7 +7866,6 @@ ves_icall_System_Environment_GetWindowsFolderPath (int folder, MonoError *error)
 }
 #endif
 
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
 static MonoArrayHandle
 mono_icall_get_logical_drives (MonoError *error)
 {
@@ -7874,7 +7873,7 @@ mono_icall_get_logical_drives (MonoError *error)
        gunichar2 *u16;
        guint initial_size = 127, size = 128;
        gint ndrives;
-       MonoArrayHandle result;
+       MonoArrayHandle result = NULL_HANDLE_ARRAY;
        MonoStringHandle drivestr;
        MonoDomain *domain = mono_domain_get ();
        gint len;
@@ -7883,7 +7882,9 @@ mono_icall_get_logical_drives (MonoError *error)
        ptr = buf;
 
        while (size > initial_size) {
-               size = (guint) mono_w32file_get_logical_drive (initial_size, ptr);
+               size = (guint) mono_w32file_get_logical_drive (initial_size, ptr, error);
+               if (!is_ok (error))
+                       goto leave;
                if (size > initial_size) {
                        if (ptr != buf)
                                g_free (ptr);
@@ -7928,7 +7929,6 @@ leave:
 
        return result;
 }
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
 
 #ifndef ENABLE_NETCORE
 MonoArrayHandle
@@ -7937,6 +7937,12 @@ ves_icall_System_Environment_GetLogicalDrivesInternal (MonoError *error)
        return mono_icall_get_logical_drives (error);
 }
 
+guint32
+ves_icall_System_IO_DriveInfo_GetDriveType (const gunichar2 *root_path_name, gint32 root_path_name_length, MonoError *error)
+{
+       return mono_w32file_get_drive_type (root_path_name, root_path_name_length, error);
+}
+
 MonoStringHandle
 ves_icall_System_IO_DriveInfo_GetDriveFormat (const gunichar2 *path, gint32 path_length, MonoError *error)
 {
diff --git a/src/mono/mono/metadata/marshal-windows-internals.h b/src/mono/mono/metadata/marshal-windows-internals.h
deleted file mode 100644 (file)
index 9d251cd..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/**
- * \file
- * Copyright 2016 Microsoft
- * Licensed under the MIT license. See LICENSE file in the project root for full license information.
- */
-#ifndef __MONO_METADATA_MARSHAL_WINDOWS_INTERNALS_H__
-#define __MONO_METADATA_MARSHAL_WINDOWS_INTERNALS_H__
-
-#include <config.h>
-#include <glib.h>
-
-#ifdef HOST_WIN32
-#include "mono/metadata/marshal.h"
-#include "mono/metadata/marshal-internals.h"
-#include "mono/metadata/exception.h"
-#endif /* HOST_WIN32 */
-
-#endif /* __MONO_METADATA_MARSHAL_WINDOWS_INTERNALS_H__ */
diff --git a/src/mono/mono/metadata/marshal-windows-uwp.c b/src/mono/mono/metadata/marshal-windows-uwp.c
deleted file mode 100644 (file)
index 4b2ed10..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * \file
- * UWP marshal support for Mono.
- *
- * Copyright 2016 Microsoft
- * Licensed under the MIT license. See LICENSE file in the project root for full license information.
-*/
-#include <config.h>
-#include <glib.h>
-#include "mono/utils/mono-compiler.h"
-
-#if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
-
-#include <windows.h>
-#include "mono/metadata/marshal-windows-internals.h"
-
-void *
-mono_marshal_alloc_hglobal (size_t size)
-{
-       return HeapAlloc (GetProcessHeap (), 0, size);
-}
-
-gpointer
-mono_marshal_realloc_hglobal (gpointer ptr, size_t size)
-{
-       return HeapReAlloc (GetProcessHeap (), 0, ptr, size);
-}
-
-void
-mono_marshal_free_hglobal (gpointer ptr)
-{
-       HeapFree (GetProcessHeap (), 0, ptr);
-}
-
-#else /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
-
-MONO_EMPTY_SOURCE_FILE (marshal_windows_uwp);
-#endif /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
index feb0eb9..1220048 100644 (file)
@@ -9,14 +9,18 @@
 #include <glib.h>
 
 #if defined(HOST_WIN32)
-
+#include <mono/utils/mono-compiler.h>
+MONO_PRAGMA_WARNING_PUSH()
+MONO_PRAGMA_WARNING_DISABLE (4115) // warning C4115: 'IRpcStubBuffer': named type definition in parentheses
 #include <winsock2.h>
 #include <windows.h>
 #include <objbase.h>
-#include "mono/metadata/marshal-windows-internals.h"
+MONO_PRAGMA_WARNING_POP()
+#include "mono/metadata/marshal-internals.h"
+#include <mono/utils/w32subset.h>
 #include "icall-decl.h"
 
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#if HAVE_API_SUPPORT_WIN32_GLOBAL_ALLOC_FREE
 
 void*
 mono_marshal_alloc_hglobal (size_t size)
@@ -35,8 +39,25 @@ mono_marshal_free_hglobal (gpointer ptr)
 {
        GlobalFree (ptr);
 }
+#elif !HAVE_EXTERN_DEFINED_WIN32_GLOBAL_ALLOC_FREE
+void *
+mono_marshal_alloc_hglobal (size_t size)
+{
+       return HeapAlloc (GetProcessHeap (), 0, size);
+}
 
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
+gpointer
+mono_marshal_realloc_hglobal (gpointer ptr, size_t size)
+{
+       return HeapReAlloc (GetProcessHeap (), 0, ptr, size);
+}
+
+void
+mono_marshal_free_hglobal (gpointer ptr)
+{
+       HeapFree (GetProcessHeap (), 0, ptr);
+}
+#endif /* HAVE_API_SUPPORT_WIN32_GLOBAL_ALLOC_FREE */
 
 void*
 mono_marshal_alloc_co_task_mem (size_t size)
diff --git a/src/mono/mono/metadata/mono-security-windows-internals.h b/src/mono/mono/metadata/mono-security-windows-internals.h
deleted file mode 100644 (file)
index 94df8c7..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * \file
- * Copyright 2016 Microsoft
- * Licensed under the MIT license. See LICENSE file in the project root for full license information.
- */
-#ifndef __MONO_METADATA_MONO_SECURITY_WINDOWS_INTERNALS_H__
-#define __MONO_METADATA_MONO_SECURITY_WINDOWS_INTERNALS_H__
-
-#include <config.h>
-#include <glib.h>
-
-#ifdef HOST_WIN32
-#include "mono/metadata/security.h"
-#include "mono/metadata/object.h"
-#include "mono/metadata/object-internals.h"
-#include "mono/metadata/metadata.h"
-#include "mono/metadata/metadata-internals.h"
-
-gint32
-mono_security_win_get_token_name (gpointer token, gunichar2 ** uniname, MonoError *error);
-
-gboolean
-mono_security_win_is_machine_protected (const gunichar2 *path, MonoError *error);
-
-gboolean
-mono_security_win_is_user_protected (const gunichar2 *path, MonoError *error);
-
-gboolean
-mono_security_win_protect_machine (const gunichar2 *path, MonoError *error);
-
-gboolean
-mono_security_win_protect_user (const gunichar2 *path, MonoError *error);
-
-#endif /* HOST_WIN32 */
-
-#endif /* __MONO_METADATA_MONO_SECURITY_WINDOWS_INTERNALS_H__ */
diff --git a/src/mono/mono/metadata/mono-security-windows-uwp.c b/src/mono/mono/metadata/mono-security-windows-uwp.c
deleted file mode 100644 (file)
index 5923fe0..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/**
- * \file
- * UWP security support for Mono.
- *
- * Copyright 2016 Microsoft
- * Licensed under the MIT license. See LICENSE file in the project root for full license information.
-*/
-#include <config.h>
-#include <glib.h>
-#include "mono/utils/mono-compiler.h"
-
-#if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
-
-#include <windows.h>
-#include "mono/metadata/mono-security-windows-internals.h"
-
-static void
-mono_security_win_not_supported (const char *functions, MonoError *error)
-{
-       g_unsupported_api (functions);
-       mono_error_set_not_supported (error, G_UNSUPPORTED_API, functions);
-       SetLastError (ERROR_NOT_SUPPORTED);
-}
-
-gpointer
-mono_security_principal_windows_identity_get_current_token (MonoError *error)
-{
-       // FIXME This is now supported by UWP.
-       mono_security_win_not_supported ("OpenThreadToken, OpenProcessToken", error);
-       return NULL;
-}
-
-gpointer
-ves_icall_System_Security_Principal_WindowsIdentity_GetCurrentToken (MonoError *error)
-{
-       return mono_security_principal_windows_identity_get_current_token (error);
-}
-
-MonoArrayHandle
-ves_icall_System_Security_Principal_WindowsIdentity_GetRoles (gpointer token, MonoError *error)
-{
-       mono_security_win_not_supported ("GetTokenInformation", error);
-       return NULL_HANDLE_ARRAY;
-}
-
-gpointer
-ves_icall_System_Security_Principal_WindowsImpersonationContext_DuplicateToken (gpointer token, MonoError *error)
-{
-       // FIXME This is now supported by UWP.
-       mono_security_win_not_supported ("DuplicateToken", error);
-       return NULL;
-}
-
-MonoBoolean
-ves_icall_System_Security_Principal_WindowsImpersonationContext_SetCurrentToken (gpointer token, MonoError *error)
-{
-       mono_security_win_not_supported ("ImpersonateLoggedOnUser", error);
-       return FALSE;
-}
-
-MonoBoolean
-ves_icall_System_Security_Principal_WindowsImpersonationContext_RevertToSelf (MonoError *error)
-{
-       mono_security_win_not_supported ("RevertToSelf", error);
-       return FALSE;
-}
-
-gint32
-mono_security_win_get_token_name (gpointer token, gunichar2 **uniname, MonoError *error)
-{
-       // FIXME This is now supported by UWP.
-       mono_security_win_not_supported ("GetTokenInformation", error);
-       return 0;
-}
-
-gboolean
-mono_security_win_is_machine_protected (const gunichar2 *path, MonoError *error)
-{
-       // FIXME This is now supported by UWP.
-       mono_security_win_not_supported ("GetNamedSecurityInfo, LocalFree", error);
-       return FALSE;
-}
-
-gboolean
-mono_security_win_is_user_protected (const gunichar2 *path, MonoError *error)
-{
-       // FIXME This is now supported by UWP.
-       mono_security_win_not_supported ("GetNamedSecurityInfo, LocalFree", error);
-       return FALSE;
-}
-
-gboolean
-mono_security_win_protect_machine (const gunichar2 *path, MonoError *error)
-{
-       // FIXME This is now supported by UWP. Except BuildTrusteeWithSid?
-       mono_security_win_not_supported ("BuildTrusteeWithSid, SetEntriesInAcl, SetNamedSecurityInfo, LocalFree, FreeSid", error);
-       return FALSE;
-}
-
-gboolean
-mono_security_win_protect_user (const gunichar2 *path, MonoError *error)
-{
-       // FIXME This is now supported by UWP. Except BuildTrusteeWithSid?
-       mono_security_win_not_supported ("BuildTrusteeWithSid, SetEntriesInAcl, SetNamedSecurityInfo, LocalFree", error);
-       return FALSE;
-}
-
-#else /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
-
-MONO_EMPTY_SOURCE_FILE (mono_security_windows_uwp);
-
-#endif /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
index 553ef60..534d26d 100644 (file)
 #if defined(HOST_WIN32)
 #include <winsock2.h>
 #include <windows.h>
-#include "mono/metadata/mono-security-windows-internals.h"
 #include <mono/metadata/handle.h>
+#include <mono/utils/mono-error.h>
+#include <mono/utils/mono-error-internals.h>
+#include <mono/metadata/object-internals.h>
+#include <mono/utils/w32subset.h>
 
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#if HAVE_API_SUPPORT_WIN32_SECURITY
 #include <aclapi.h>
 #include <accctrl.h>
 #endif
@@ -23,7 +26,7 @@
 #define PROTECTED_DACL_SECURITY_INFORMATION    0x80000000L
 #endif
 
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#if HAVE_API_SUPPORT_WIN32_SECURITY
 
 static gunichar2*
 GetSidName (gunichar2 *server, PSID sid, gint32 *size)
@@ -33,14 +36,14 @@ GetSidName (gunichar2 *server, PSID sid, gint32 *size)
        DWORD cchDomain = 0;
        SID_NAME_USE peUse; /* out */
 
-       LookupAccountSid (server, sid, NULL, &cchName, NULL,
+       LookupAccountSidW (server, sid, NULL, &cchName, NULL,
                &cchDomain, &peUse);
 
        if ((cchName > 0) && (cchDomain > 0)) {
                gunichar2 *user = g_malloc0 ((cchName + 1) * 2);
                gunichar2 *domain = g_malloc0 ((cchDomain + 1) * 2);
 
-               LookupAccountSid (server, sid, user, &cchName, domain,
+               LookupAccountSidW (server, sid, user, &cchName, domain,
                        &cchDomain, &peUse);
 
                if (cchName > 0) {
@@ -110,7 +113,35 @@ mono_security_win_get_token_name (gpointer token, gunichar2 ** uniname, MonoErro
 
        return size;
 }
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
+#elif !HAVE_EXTERN_DEFINED_WIN32_SECURITY
+static void
+mono_security_win_not_supported (const char *functions, MonoError *error)
+{
+       g_unsupported_api (functions);
+       mono_error_set_not_supported (error, G_UNSUPPORTED_API, functions);
+       SetLastError (ERROR_NOT_SUPPORTED);
+}
+
+gpointer
+mono_security_principal_windows_identity_get_current_token (MonoError *error)
+{
+       mono_security_win_not_supported ("OpenThreadToken, OpenProcessToken", error);
+       return NULL;
+}
+
+gpointer
+ves_icall_System_Security_Principal_WindowsIdentity_GetCurrentToken (MonoError *error)
+{
+       return mono_security_principal_windows_identity_get_current_token (error);
+}
+
+gint32
+mono_security_win_get_token_name (gpointer token, gunichar2 **uniname, MonoError *error)
+{
+       mono_security_win_not_supported ("GetTokenInformation", error);
+       return 0;
+}
+#endif /* HAVE_API_SUPPORT_WIN32_SECURITY */
 
 MonoStringHandle
 ves_icall_System_Security_Principal_WindowsIdentity_GetTokenName (gpointer token, MonoError *error)
@@ -151,7 +182,7 @@ ves_icall_System_Security_Principal_WindowsIdentity_GetUserToken (MonoStringHand
        return token;
 }
 
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#if HAVE_API_SUPPORT_WIN32_SECURITY
 MonoArrayHandle
 ves_icall_System_Security_Principal_WindowsIdentity_GetRoles (gpointer token, MonoError *error)
 {
@@ -203,7 +234,15 @@ ves_icall_System_Security_Principal_WindowsIdentity_GetRoles (gpointer token, Mo
        }
        return array;
 }
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
+#elif !HAVE_EXTERN_DEFINED_WIN32_SECURITY
+MonoArray*
+ves_icall_System_Security_Principal_WindowsIdentity_GetRoles (gpointer token, MonoError *error)
+{
+       mono_security_win_not_supported ("GetTokenInformation", error);
+       mono_error_set_pending_exception (error);
+       return NULL;
+}
+#endif /* HAVE_API_SUPPORT_WIN32_SECURITY */
 
 MonoBoolean
 ves_icall_System_Security_Principal_WindowsImpersonationContext_CloseToken (gpointer token, MonoError *error)
@@ -211,14 +250,21 @@ ves_icall_System_Security_Principal_WindowsImpersonationContext_CloseToken (gpoi
        return !!CloseHandle (token);
 }
 
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#if HAVE_API_SUPPORT_WIN32_SECURITY
 gpointer
 ves_icall_System_Security_Principal_WindowsImpersonationContext_DuplicateToken (gpointer token, MonoError *error)
 {
        gpointer dupe = NULL;
        return DuplicateToken (token, SecurityImpersonation, &dupe) ? dupe : NULL;
 }
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
+#elif !HAVE_EXTERN_DEFINED_WIN32_SECURITY
+gpointer
+ves_icall_System_Security_Principal_WindowsImpersonationContext_DuplicateToken (gpointer token, MonoError *error)
+{
+       mono_security_win_not_supported ("DuplicateToken", error);
+       return NULL;
+}
+#endif /* HAVE_API_SUPPORT_WIN32_SECURITY */
 
 MonoBoolean
 ves_icall_System_Security_Principal_WindowsPrincipal_IsMemberOfGroupId (gpointer user, gpointer group, MonoError *error)
@@ -236,7 +282,7 @@ ves_icall_System_Security_Principal_WindowsPrincipal_IsMemberOfGroupName (gpoint
        return FALSE;
 }
 
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#if HAVE_API_SUPPORT_WIN32_SECURITY
 
 static PSID
 GetSidHelper (const SID_IDENTIFIER_AUTHORITY *authority, BYTE subAuthorityCount, DWORD subAuthority0, DWORD subAuthority1)
@@ -291,10 +337,10 @@ static ACCESS_MASK
 GetRightsFromSid (PSID sid, PACL acl)
 {
        ACCESS_MASK rights = 0;
-       TRUSTEE trustee;
+       TRUSTEEW trustee;
 
        BuildTrusteeWithSidW (&trustee, sid);
-       if (GetEffectiveRightsFromAcl (acl, &trustee, &rights) != ERROR_SUCCESS)
+       if (GetEffectiveRightsFromAclW (acl, &trustee, &rights) != ERROR_SUCCESS)
                return 0;
 
        return rights;
@@ -368,7 +414,7 @@ mono_security_win_protect_machine (const gunichar2 *path, MonoError *error)
 
        if (pEveryoneSid && pAdminsSid) {
                PACL pDACL = NULL;
-               EXPLICIT_ACCESS ea [2];
+               EXPLICIT_ACCESSW ea [2];
                ZeroMemory (&ea, sizeof (ea));
 
                /* grant all access to the BUILTIN\Administrators group */
@@ -387,7 +433,7 @@ mono_security_win_protect_machine (const gunichar2 *path, MonoError *error)
                ea [1].Trustee.TrusteeForm = TRUSTEE_IS_SID;
                ea [1].Trustee.TrusteeType = TRUSTEE_IS_WELL_KNOWN_GROUP;
 
-               retval = SetEntriesInAcl (2, ea, NULL, &pDACL);
+               retval = SetEntriesInAclW (2, ea, NULL, &pDACL);
                if (retval == ERROR_SUCCESS) {
                        /* with PROTECTED_DACL_SECURITY_INFORMATION we */
                        /* remove any existing ACL (like inherited ones) */
@@ -413,7 +459,7 @@ mono_security_win_protect_user (const gunichar2 *path, MonoError *error)
        PSID const pCurrentSid = GetCurrentUserSid (error);
        if (pCurrentSid) {
                PACL pDACL = NULL;
-               EXPLICIT_ACCESS ea;
+               EXPLICIT_ACCESSW ea;
                ZeroMemory (&ea, sizeof (EXPLICIT_ACCESS));
 
                /* grant exclusive access to the current user */
@@ -424,7 +470,7 @@ mono_security_win_protect_user (const gunichar2 *path, MonoError *error)
                ea.Trustee.TrusteeForm = TRUSTEE_IS_SID;
                ea.Trustee.TrusteeType = TRUSTEE_IS_USER;
 
-               retval = SetEntriesInAcl (1, &ea, NULL, &pDACL);
+               retval = SetEntriesInAclW (1, &ea, NULL, &pDACL);
                if (retval == ERROR_SUCCESS) {
                        /* with PROTECTED_DACL_SECURITY_INFORMATION we
                           remove any existing ACL (like inherited ones) */
@@ -439,8 +485,35 @@ mono_security_win_protect_user (const gunichar2 *path, MonoError *error)
 
        return retval == ERROR_SUCCESS;
 }
+#elif !HAVE_EXTERN_DEFINED_WIN32_SECURITY
+gboolean
+mono_security_win_is_machine_protected (const gunichar2 *path, MonoError *error)
+{
+       mono_security_win_not_supported ("GetNamedSecurityInfo, LocalFree", error);
+       return FALSE;
+}
+
+gboolean
+mono_security_win_is_user_protected (const gunichar2 *path, MonoError *error)
+{
+       mono_security_win_not_supported ("GetNamedSecurityInfo, LocalFree", error);
+       return FALSE;
+}
 
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
+gboolean
+mono_security_win_protect_machine (const gunichar2 *path, MonoError *error)
+{
+       mono_security_win_not_supported ("BuildTrusteeWithSid, SetEntriesInAcl, SetNamedSecurityInfo, LocalFree, FreeSid", error);
+       return FALSE;
+}
+
+gboolean
+mono_security_win_protect_user (const gunichar2 *path, MonoError *error)
+{
+       mono_security_win_not_supported ("BuildTrusteeWithSid, SetEntriesInAcl, SetNamedSecurityInfo, LocalFree", error);
+       return FALSE;
+}
+#endif /* HAVE_API_SUPPORT_WIN32_SECURITY */
 
 MonoBoolean
 ves_icall_Mono_Security_Cryptography_KeyPairPersistence_CanSecure (const gunichar2 *root)
index f25e94d..b360d82 100644 (file)
@@ -20,6 +20,7 @@
 #include <mono/metadata/metadata-internals.h>
 #include <mono/metadata/security.h>
 #include <mono/utils/strenc.h>
+#include <mono/utils/w32subset.h>
 #include "reflection-internals.h"
 #include "icall-decl.h"
 
@@ -366,7 +367,7 @@ ves_icall_System_Security_Principal_WindowsImpersonationContext_DuplicateToken (
 }
 #endif /* !HOST_WIN32 */
 
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#if HAVE_API_SUPPORT_WIN32_SECURITY
 MonoBoolean
 ves_icall_System_Security_Principal_WindowsImpersonationContext_SetCurrentToken (gpointer token, MonoError *error)
 {
@@ -406,7 +407,25 @@ ves_icall_System_Security_Principal_WindowsImpersonationContext_RevertToSelf (Mo
        return geteuid () == suid;
 #endif
 }
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
+#elif !HAVE_EXTERN_DEFINED_WIN32_SECURITY
+MonoBoolean
+ves_icall_System_Security_Principal_WindowsImpersonationContext_SetCurrentToken (gpointer token, MonoError *error)
+{
+       g_unsupported_api ("ImpersonateLoggedOnUser");
+       mono_error_set_not_supported (error, G_UNSUPPORTED_API, "ImpersonateLoggedOnUser");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return FALSE;
+}
+
+MonoBoolean
+ves_icall_System_Security_Principal_WindowsImpersonationContext_RevertToSelf (MonoError *error)
+{
+       g_unsupported_api ("RevertToSelf");
+       mono_error_set_not_supported (error, G_UNSUPPORTED_API, "RevertToSelf");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return FALSE;
+}
+#endif /* HAVE_API_SUPPORT_WIN32_SECURITY */
 
 /* System.Security.Principal.WindowsPrincipal */
 
index 5f640a2..6ae6a2a 100644 (file)
@@ -8454,7 +8454,7 @@ mono_async_result_new (MonoDomain *domain, HANDLE handle, MonoObject *state, gpo
 }
 
 static MonoObject*
-mono_message_invoke (MonoThreadInfo* mono_thread_info_current_var,
+mono_message_invoke (MonoThreadInfo* thread_info_current_var,
                     MonoObject* target, MonoMethodMessage* msg,
                     MonoObject** exc, MonoArray** out_args, MonoError* error);
 
@@ -8614,7 +8614,7 @@ mono_remoting_invoke (MonoObject *real_proxy, MonoMethodMessage *msg, MonoObject
 
 // FIXME inline in the only caller
 static MonoObject*
-mono_message_invoke (MonoThreadInfo *mono_thread_info_current_var,
+mono_message_invoke (MonoThreadInfo *thread_info_current_var,
                     MonoObject *target, MonoMethodMessage *msg,
                     MonoObject **exc, MonoArray **out_args, MonoError *error) 
 {
index a8a947e..fdfef2d 100644 (file)
@@ -21,6 +21,7 @@
 
 #if defined(HOST_WIN32)
 #include <windows.h>
+#include <mono/utils/networking.h>
 #else
 #include <errno.h>
 #include <fcntl.h>
@@ -518,8 +519,8 @@ wakeup_pipes_init (void)
        g_assert (threadpool_io->wakeup_pipes [1] != INVALID_SOCKET);
 
        server.sin_family = AF_INET;
-       server.sin_addr.s_addr = inet_addr ("127.0.0.1");
        server.sin_port = 0;
+       inet_pton (server.sin_family, "127.0.0.1", &server.sin_addr);
        if (bind (server_sock, (SOCKADDR*) &server, sizeof (server)) == SOCKET_ERROR) {
                closesocket (server_sock);
                g_error ("wakeup_pipes_init: bind () failed, error (%d)\n", WSAGetLastError ());
index 4d7b221..e37dd79 100644 (file)
 #include <mono/utils/mono-os-wait.h>
 #include <mono/metadata/exception-internals.h>
 #include <mono/utils/mono-state.h>
-#include <mono/metadata/w32subset.h>
 #include <mono/metadata/mono-config.h>
 #include <mono/utils/mono-tls-inline.h>
 #include <mono/utils/lifo-semaphore.h>
+#include <mono/utils/w32subset.h>
 
 #ifdef HAVE_SYS_WAIT_H
 #include <sys/wait.h>
 #endif
 
 #if defined(HOST_WIN32)
+#include <mono/utils/mono-compiler.h>
+MONO_PRAGMA_WARNING_PUSH()
+MONO_PRAGMA_WARNING_DISABLE (4115) // warning C4115: 'IRpcStubBuffer': named type definition in parentheses
 #include <objbase.h>
+MONO_PRAGMA_WARNING_POP()
 #include <sys/timeb.h>
 extern gboolean
 mono_native_thread_join_handle (HANDLE thread_handle, gboolean close_handle);
@@ -2376,7 +2380,6 @@ ves_icall_System_Threading_WaitHandle_Wait_internal (gpointer *handles, gint32 n
        return map_native_wait_result_to_managed (ret, numhandles);
 }
 
-#if HAVE_API_SUPPORT_WIN32_SIGNAL_OBJECT_AND_WAIT
 gint32
 ves_icall_System_Threading_WaitHandle_SignalAndWait_Internal (gpointer toSignal, gpointer toWait, gint32 ms, MonoError *error)
 {
@@ -2398,8 +2401,6 @@ ves_icall_System_Threading_WaitHandle_SignalAndWait_Internal (gpointer toSignal,
        return map_native_wait_result_to_managed (ret, 1);
 }
 
-#endif
-
 gint32 ves_icall_System_Threading_Interlocked_Increment_Int (gint32 *location)
 {
        return mono_atomic_inc_i32 (location);
index 5ec7f54..2105d20 100644 (file)
@@ -3834,7 +3834,7 @@ mono_w32file_create_pipe (gpointer *readpipe, gpointer *writepipe, guint32 size)
 #ifdef HAVE_GETFSSTAT
 /* Darwin has getfsstat */
 gint32
-mono_w32file_get_logical_drive (guint32 len, gunichar2 *buf)
+mono_w32file_get_logical_drive (guint32 len, gunichar2 *buf, MonoError *error)
 {
        struct statfs *stats;
        gint size, n, i;
@@ -3875,7 +3875,7 @@ mono_w32file_get_logical_drive (guint32 len, gunichar2 *buf)
 }
 #elif _AIX
 gint32
-mono_w32file_get_logical_drive (guint32 len, gunichar2 *buf)
+mono_w32file_get_logical_drive (guint32 len, gunichar2 *buf, MonoError *error)
 {
        struct vmount *mounts;
        // ret will first be the errno cond, then no of structs
@@ -3976,7 +3976,7 @@ static void append_to_mountpoint (LinuxMountInfoParseState *state);
 static gboolean add_drive_string (guint32 len, gunichar2 *buf, LinuxMountInfoParseState *state);
 
 gint32
-mono_w32file_get_logical_drive (guint32 len, gunichar2 *buf)
+mono_w32file_get_logical_drive (guint32 len, gunichar2 *buf, MonoError *error)
 {
        gint fd;
        gint32 ret = 0;
@@ -4248,7 +4248,7 @@ add_drive_string (guint32 len, gunichar2 *buf, LinuxMountInfoParseState *state)
 }
 #else
 gint32
-mono_w32file_get_logical_drive (guint32 len, gunichar2 *buf)
+mono_w32file_get_logical_drive (guint32 len, gunichar2 *buf, MonoError *error)
 {
        return GetLogicalDriveStrings_Mtab (len, buf);
 }
@@ -4728,7 +4728,7 @@ GetDriveTypeFromPath (const gchar *utf8_root_path_name)
 
 #ifndef ENABLE_NETCORE
 guint32
-ves_icall_System_IO_DriveInfo_GetDriveType (const gunichar2 *root_path_name, gint32 root_path_name_length, MonoError *error)
+mono_w32file_get_drive_type (const gunichar2 *root_path_name, gint32 root_path_name_length, MonoError *error)
 {
        // FIXME Check for embedded nuls here or in managed.
 
diff --git a/src/mono/mono/metadata/w32file-win32-internals.h b/src/mono/mono/metadata/w32file-win32-internals.h
deleted file mode 100644 (file)
index a60b4fa..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-/**
- * \file
- * Copyright 2016 Microsoft
- * Licensed under the MIT license. See LICENSE file in the project root for full license information.
- */
-#ifndef _MONO_METADATA_W32FILE_WIN32_INTERNALS_H_
-#define _MONO_METADATA_W32FILE_WIN32_INTERNALS_H_
-
-#include <config.h>
-#include <glib.h>
-
-#ifdef HOST_WIN32
-#include "mono/metadata/w32file.h"
-#include "mono/metadata/w32file-internals.h"
-#endif /* HOST_WIN32 */
-#endif /* _MONO_METADATA_W32FILE_WIN32_INTERNALS_H_ */
diff --git a/src/mono/mono/metadata/w32file-win32-uwp.c b/src/mono/mono/metadata/w32file-win32-uwp.c
deleted file mode 100644 (file)
index 0538b74..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-/**
- * \file
- * UWP w32file support for Mono.
- *
- * Copyright 2016 Microsoft
- * Licensed under the MIT license. See LICENSE file in the project root for full license information.
-*/
-#include <config.h>
-#include <glib.h>
-#include "mono/utils/mono-compiler.h"
-#include <windows.h>
-#include "mono/metadata/w32file-win32-internals.h"
-#include "mono/metadata/w32subset.h"
-#include "icall-decl.h"
-
-#if !HAVE_API_SUPPORT_WIN32_MOVE_FILE && HAVE_API_SUPPORT_WIN32_MOVE_FILE_EX
-gboolean
-mono_w32file_move (const gunichar2 *path, const gunichar2 *dest, gint32 *error)
-{
-       gboolean result = FALSE;
-       MONO_ENTER_GC_SAFE;
-
-       result = MoveFileExW (path, dest, MOVEFILE_COPY_ALLOWED);
-       if (result == FALSE) {
-               *error=GetLastError ();
-       }
-
-       MONO_EXIT_GC_SAFE;
-       return result;
-}
-#endif
-
-#if !HAVE_API_SUPPORT_WIN32_COPY_FILE && HAVE_API_SUPPORT_WIN32_COPY_FILE2
-gboolean
-mono_w32file_copy (const gunichar2 *path, const gunichar2 *dest, gboolean overwrite, gint32 *error)
-{
-       gboolean                                                result = FALSE;
-       COPYFILE2_EXTENDED_PARAMETERS   copy_param = {0};
-
-       copy_param.dwSize = sizeof (COPYFILE2_EXTENDED_PARAMETERS);
-       copy_param.dwCopyFlags = (!overwrite) ? COPY_FILE_FAIL_IF_EXISTS : 0;
-
-       MONO_ENTER_GC_SAFE;
-
-       result = SUCCEEDED (CopyFile2 (path, dest, &copy_param));
-       if (result == FALSE) {
-               *error=GetLastError ();
-       }
-
-       MONO_EXIT_GC_SAFE;
-       return result;
-}
-#endif
-
-#if !HAVE_API_SUPPORT_WIN32_GET_STD_HANDLE
-HANDLE
-mono_w32file_get_console_output (void)
-{
-       ERROR_DECL (error);
-
-       g_unsupported_api ("GetStdHandle (STD_OUTPUT_HANDLE)");
-
-       mono_error_set_not_supported (error, G_UNSUPPORTED_API, "GetStdHandle (STD_OUTPUT_HANDLE)");
-       mono_error_set_pending_exception (error);
-
-       SetLastError (ERROR_NOT_SUPPORTED);
-
-       return INVALID_HANDLE_VALUE;
-}
-
-HANDLE
-mono_w32file_get_console_input (void)
-{
-       ERROR_DECL (error);
-
-       g_unsupported_api ("GetStdHandle (STD_INPUT_HANDLE)");
-
-       mono_error_set_not_supported (error, G_UNSUPPORTED_API, "GetStdHandle (STD_INPUT_HANDLE)");
-       mono_error_set_pending_exception (error);
-
-       SetLastError (ERROR_NOT_SUPPORTED);
-
-       return INVALID_HANDLE_VALUE;
-}
-
-HANDLE
-mono_w32file_get_console_error (void)
-{
-       ERROR_DECL (error);
-
-       g_unsupported_api ("GetStdHandle (STD_ERROR_HANDLE)");
-
-       mono_error_set_not_supported (error, G_UNSUPPORTED_API, "GetStdHandle (STD_ERROR_HANDLE)");
-       mono_error_set_pending_exception (error);
-
-       SetLastError (ERROR_NOT_SUPPORTED);
-
-       return INVALID_HANDLE_VALUE;
-}
-#endif // HAVE_API_SUPPORT_WIN32_GET_STD_HANDLE
-
-MONO_EMPTY_SOURCE_FILE (file_io_windows_uwp);
index 112f546..ab6efc5 100644 (file)
@@ -10,8 +10,7 @@
 
 #include <winsock2.h>
 #include <windows.h>
-#include "mono/metadata/w32file-win32-internals.h"
-#include "mono/metadata/w32subset.h"
+#include <mono/utils/w32subset.h>
 #include "icall-decl.h"
 
 void
@@ -430,8 +429,7 @@ mono_w32file_get_file_system_type (const gunichar2 *path, gunichar2 *fsbuffer, g
 gboolean
 mono_w32file_move (const gunichar2 *path, const gunichar2 *dest, gint32 *error)
 {
-       gboolean result;
-
+       gboolean result = FALSE;
        MONO_ENTER_GC_SAFE;
 
        result = MoveFileW (path, dest);
@@ -439,45 +437,65 @@ mono_w32file_move (const gunichar2 *path, const gunichar2 *dest, gint32 *error)
                *error = GetLastError ();
 
        MONO_EXIT_GC_SAFE;
+       return result;
+}
+#elif HAVE_API_SUPPORT_WIN32_MOVE_FILE_EX
+gboolean
+mono_w32file_move (const gunichar2 *path, const gunichar2 *dest, gint32 *error)
+{
+       gboolean result = FALSE;
+       MONO_ENTER_GC_SAFE;
+
+       result = MoveFileExW (path, dest, MOVEFILE_COPY_ALLOWED);
+       if (!result) {
+               *error = GetLastError ();
+       }
 
+       MONO_EXIT_GC_SAFE;
        return result;
 }
+#elif !HAVE_EXTERN_DEFINED_WIN32_MOVE_FILE && !HAVE_EXTERN_DEFINED_WIN32_MOVE_FILE_EX
+gboolean
+mono_w32file_move (const gunichar2 *path, const gunichar2 *dest, gint32 *error)
+{
+       g_unsupported_api ("MoveFile, MoveFileEx");
+       *error = ERROR_NOT_SUPPORTED;
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return FALSE;
+}
 #endif
 
 #if HAVE_API_SUPPORT_WIN32_REPLACE_FILE
 gboolean
-mono_w32file_replace (const gunichar2 *destinationFileName, const gunichar2 *sourceFileName, const gunichar2 *destinationBackupFileName, guint32 flags, gint32 *error)
+mono_w32file_replace (const gunichar2 *destination_file_name, const gunichar2 *source_file_name, const gunichar2 *destination_backup_file_name, guint32 flags, gint32 *error)
 {
-       gboolean result;
-
+       gboolean result = FALSE;
        MONO_ENTER_GC_SAFE;
 
-       result = ReplaceFileW (destinationFileName, sourceFileName, destinationBackupFileName, flags, NULL, NULL);
+       result = ReplaceFileW (destination_file_name, source_file_name, destination_backup_file_name, flags, NULL, NULL);
        if (!result)
                *error = GetLastError ();
 
        MONO_EXIT_GC_SAFE;
-
        return result;
 }
+#elif !HAVE_EXTERN_DEFINED_WIN32_REPLACE_FILE
+gboolean
+mono_w32file_replace (const gunichar2 *destination_file_name, const gunichar2 *source_file_name, const gunichar2 *destination_backup_file_name, guint32 flags, gint32 *error)
+{
+       g_unsupported_api ("ReplaceFile");
+       *error = ERROR_NOT_SUPPORTED;
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return FALSE;
+}
 #endif
 
 #if HAVE_API_SUPPORT_WIN32_COPY_FILE
-// Support older UWP SDK?
-WINBASEAPI
-BOOL
-WINAPI
-CopyFileW (
-       PCWSTR ExistingFileName,
-       PCWSTR NewFileName,
-       BOOL FailIfExists
-       );
 
 gboolean
 mono_w32file_copy (const gunichar2 *path, const gunichar2 *dest, gboolean overwrite, gint32 *error)
 {
-       gboolean result;
-
+       gboolean result = FALSE;
        MONO_ENTER_GC_SAFE;
 
        result = CopyFileW (path, dest, !overwrite);
@@ -485,9 +503,37 @@ mono_w32file_copy (const gunichar2 *path, const gunichar2 *dest, gboolean overwr
                *error = GetLastError ();
 
        MONO_EXIT_GC_SAFE;
+       return result;
+}
+#elif HAVE_API_SUPPORT_WIN32_COPY_FILE2
+gboolean
+mono_w32file_copy (const gunichar2 *path, const gunichar2 *dest, gboolean overwrite, gint32 *error)
+{
+       gboolean result = FALSE;
+       COPYFILE2_EXTENDED_PARAMETERS copy_param = {0};
+
+       copy_param.dwSize = sizeof (COPYFILE2_EXTENDED_PARAMETERS);
+       copy_param.dwCopyFlags = (!overwrite) ? COPY_FILE_FAIL_IF_EXISTS : 0;
+
+       MONO_ENTER_GC_SAFE;
 
+       result = SUCCEEDED (CopyFile2 (path, dest, &copy_param));
+       if (result == FALSE) {
+               *error=GetLastError ();
+       }
+
+       MONO_EXIT_GC_SAFE;
        return result;
 }
+#elif !HAVE_EXTERN_DEFINED_WIN32_COPY_FILE && !HAVE_EXTERN_DEFINED_WIN32_COPY_FILE2
+gboolean
+mono_w32file_copy (const gunichar2 *path, const gunichar2 *dest, gboolean overwrite, gint32 *error)
+{
+       g_unsupported_api ("CopyFile, CopyFile2");
+       *error = ERROR_NOT_SUPPORTED;
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return FALSE;
+}
 #endif
 
 #if HAVE_API_SUPPORT_WIN32_LOCK_FILE
@@ -506,6 +552,15 @@ mono_w32file_lock (gpointer handle, gint64 position, gint64 length, gint32 *erro
 
        return result;
 }
+#elif !HAVE_EXTERN_DEFINED_WIN32_LOCK_FILE
+gboolean
+mono_w32file_lock (gpointer handle, gint64 position, gint64 length, gint32 *error)
+{
+       g_unsupported_api ("LockFile");
+       *error = ERROR_NOT_SUPPORTED;
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return FALSE;
+}
 #endif
 
 #if HAVE_API_SUPPORT_WIN32_UNLOCK_FILE
@@ -524,10 +579,19 @@ mono_w32file_unlock (gpointer handle, gint64 position, gint64 length, gint32 *er
 
        return result;
 }
+#elif !HAVE_EXTERN_DEFINED_WIN32_UNLOCK_FILE
+gboolean
+mono_w32file_unlock (gpointer handle, gint64 position, gint64 length, gint32 *error)
+{
+       g_unsupported_api ("UnlockFile");
+       *error = ERROR_NOT_SUPPORTED;
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return FALSE;
+}
 #endif
 
 #if HAVE_API_SUPPORT_WIN32_GET_STD_HANDLE
-HANDLE
+gpointer
 mono_w32file_get_console_input (void)
 {
        HANDLE res;
@@ -537,7 +601,7 @@ mono_w32file_get_console_input (void)
        return res;
 }
 
-HANDLE
+gpointer
 mono_w32file_get_console_output (void)
 {
        HANDLE res;
@@ -547,7 +611,7 @@ mono_w32file_get_console_output (void)
        return res;
 }
 
-HANDLE
+gpointer
 mono_w32file_get_console_error (void)
 {
        HANDLE res;
@@ -556,10 +620,33 @@ mono_w32file_get_console_error (void)
        MONO_EXIT_GC_SAFE;
        return res;
 }
-#endif // HAVE_API_SUPPORT_WIN32_GET_STD_HANDLE
+#elif !HAVE_EXTERN_DEFINED_WIN32_GET_STD_HANDLE
+gpointer
+mono_w32file_get_console_input (void)
+{
+       g_unsupported_api ("GetStdHandle (STD_INPUT_HANDLE)");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return INVALID_HANDLE_VALUE;
+}
 
-#if HAVE_API_SUPPORT_WIN32_GET_FILE_SIZE_EX
+gpointer
+mono_w32file_get_console_output (void)
+{
+       g_unsupported_api ("GetStdHandle (STD_OUTPUT_HANDLE)");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return INVALID_HANDLE_VALUE;
+}
+
+gpointer
+mono_w32file_get_console_error (void)
+{
+       g_unsupported_api ("GetStdHandle (STD_ERROR_HANDLE)");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return INVALID_HANDLE_VALUE;
+}
+#endif
 
+#if HAVE_API_SUPPORT_WIN32_GET_FILE_SIZE_EX
 gint64
 mono_w32file_get_file_size (HANDLE handle, gint32 *error)
 {
@@ -575,37 +662,41 @@ mono_w32file_get_file_size (HANDLE handle, gint32 *error)
        MONO_EXIT_GC_SAFE;
        return length.QuadPart;
 }
+#elif !HAVE_EXTERN_DEFINED_WIN32_GET_FILE_SIZE_EX
+gint64
+mono_w32file_get_file_size (HANDLE handle, gint32 *error)
+{
+       g_unsupported_api ("GetFileSizeEx");
+       *error = ERROR_NOT_SUPPORTED;
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return 0;
+}
+#endif
 
-#endif // HAVE_API_SUPPORT_WIN32_GET_FILE_SIZE_EX
-
-// Support older UWP SDK.
-WINBASEAPI
-UINT
-WINAPI
-GetDriveTypeW (
-       PCWSTR RootPathName
-       );
-
+#if HAVE_API_SUPPORT_WIN32_GET_DRIVE_TYPE
 guint32
-ves_icall_System_IO_DriveInfo_GetDriveType (const gunichar2 *root_path_name, gint32 root_path_name_length, MonoError *error)
+mono_w32file_get_drive_type (const gunichar2 *root_path_name, gint32 root_path_name_length, MonoError *error)
 {
-       // FIXME Check for embedded nuls here or in native.
-#if HAVE_API_SUPPORT_WIN32_GET_DRIVE_TYPE
        guint32 res;
        MONO_ENTER_GC_SAFE;
        res = GetDriveTypeW (root_path_name);
        MONO_EXIT_GC_SAFE;
        return res;
-#else
+}
+#elif !HAVE_EXTERN_DEFINED_WIN32_GET_DRIVE_TYPE
+guint32
+mono_w32file_get_drive_type (const gunichar2 *root_path_name, gint32 root_path_name_length, MonoError *error)
+{
        g_unsupported_api ("GetDriveType");
        mono_error_set_not_supported (error, G_UNSUPPORTED_API, "GetDriveType");
+       SetLastError (ERROR_NOT_SUPPORTED);
        return DRIVE_UNKNOWN;
-#endif
 }
+#endif
 
 #if HAVE_API_SUPPORT_WIN32_GET_LOGICAL_DRIVE_STRINGS
 gint32
-mono_w32file_get_logical_drive (guint32 len, gunichar2 *buf)
+mono_w32file_get_logical_drive (guint32 len, gunichar2 *buf, MonoError *error)
 {
        gint32 res;
        MONO_ENTER_GC_SAFE;
@@ -613,4 +704,13 @@ mono_w32file_get_logical_drive (guint32 len, gunichar2 *buf)
        MONO_EXIT_GC_SAFE;
        return res;
 }
+#elif !HAVE_EXTERN_DEFINED_WIN32_GET_LOGICAL_DRIVE_STRINGS
+gint32
+mono_w32file_get_logical_drive (guint32 len, gunichar2 *buf, MonoError *error)
+{
+       g_unsupported_api ("GetLogicalDriveStrings");
+       mono_error_set_not_supported (error, G_UNSUPPORTED_API, "GetLogicalDriveStrings");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return 0;
+}
 #endif
index 7729925..e40eac1 100644 (file)
@@ -467,8 +467,11 @@ mono_w32file_set_cwd (const gunichar2 *path);
 gboolean
 mono_w32file_create_pipe (gpointer *readpipe, gpointer *writepipe, guint32 size);
 
+guint32
+mono_w32file_get_drive_type (const gunichar2 *root_path_name, gint32 root_path_name_length, MonoError *error);
+
 gint32
-mono_w32file_get_logical_drive (guint32 len, gunichar2 *buf);
+mono_w32file_get_logical_drive (guint32 len, gunichar2 *buf, MonoError *error);
 
 #ifndef PLATFORM_NO_DRIVEINFO
 gboolean
index 96fd556..21de0d3 100644 (file)
@@ -7,9 +7,11 @@
 
 #include <config.h>
 #include <glib.h>
+#include <mono/utils/w32subset.h>
 
-#ifndef HOST_WIN32
-
+#ifdef HOST_WIN32
+#include <windows.h>
+#else
 typedef struct {
        guint32 dwSignature; /* Should contain 0xFEEF04BD on le machines */
        guint32 dwStrucVersion;
@@ -38,6 +40,7 @@ typedef struct {
 #define VS_FF_PRIVATEBUILD     0x0008
 #define VS_FF_INFOINFERRED     0x0010
 #define VS_FF_SPECIALBUILD     0x0020
+#endif
 
 guint32
 mono_w32process_get_pid (gpointer handle);
@@ -52,7 +55,7 @@ gboolean
 mono_w32process_module_get_filename (gpointer process, gpointer module, gunichar2 **str, guint32 *len);
 
 gboolean
-mono_w32process_module_get_information (gpointer process, gpointer module, MODULEINFO *modinfo, guint32 size);
+mono_w32process_module_get_information (gpointer process, gpointer module, gpointer modinfo, guint32 size);
 
 gboolean
 mono_w32process_get_fileversion_info (const gunichar2 *filename, gpointer *data);
@@ -63,6 +66,4 @@ mono_w32process_ver_query_value (gconstpointer datablock, const gunichar2 *subbl
 guint32
 mono_w32process_ver_language_name (guint32 lang, gunichar2 *lang_out, guint32 lang_len);
 
-#endif /* HOST_WIN32 */
-
 #endif /* _MONO_METADATA_W32PROCESS_INTERNALS_H_ */
index c1ccbca..8f9fb8c 100644 (file)
@@ -1057,7 +1057,7 @@ mono_w32process_module_get_name (gpointer handle, gpointer module, gunichar2 **s
 }
 
 gboolean
-mono_w32process_module_get_information (gpointer handle, gpointer module, MODULEINFO *modinfo, guint32 size)
+mono_w32process_module_get_information (gpointer handle, gpointer module, gpointer modinfo, guint32 size)
 {
        MonoW32Handle *handle_data;
        MonoW32HandleProcess *process_handle;
@@ -1107,9 +1107,9 @@ mono_w32process_module_get_information (gpointer handle, gpointer module, MODULE
                        if (ret == FALSE &&
                                ((module == NULL && match_procname_to_modulename (pname, found_module->filename)) ||
                                 (module != NULL && found_module->address_start == module))) {
-                               modinfo->lpBaseOfDll = found_module->address_start;
-                               modinfo->SizeOfImage = (gsize)(found_module->address_end) - (gsize)(found_module->address_start);
-                               modinfo->EntryPoint = found_module->address_offset;
+                               ((MODULEINFO *)modinfo)->lpBaseOfDll = found_module->address_start;
+                               ((MODULEINFO *)modinfo)->SizeOfImage = (gsize)(found_module->address_end) - (gsize)(found_module->address_start);
+                               ((MODULEINFO *)modinfo)->EntryPoint = found_module->address_offset;
                                ret = TRUE;
                        }
 
@@ -3525,7 +3525,7 @@ mono_w32process_get_fileversion_info (const gunichar2 *filename, gpointer *data)
 }
 
 gboolean
-mono_w32process_module_get_information (gpointer handle, gpointer module, MODULEINFO *modinfo, guint32 size)
+mono_w32process_module_get_information (gpointer handle, gpointer module, gpointer modinfo, guint32 size)
 {
        return FALSE;
 }
diff --git a/src/mono/mono/metadata/w32process-win32-uwp.c b/src/mono/mono/metadata/w32process-win32-uwp.c
deleted file mode 100644 (file)
index 406a015..0000000
+++ /dev/null
@@ -1,149 +0,0 @@
-/**
- * \file
- * UWP process support for Mono.
- *
- * Copyright 2016 Microsoft
- * Licensed under the MIT license. See LICENSE file in the project root for full license information.
-*/
-#include <config.h>
-#include <glib.h>
-#include "mono/utils/mono-compiler.h"
-
-// FIXME: In order to share function declarations at least, this
-// file should be merged with its non-uwp counterpart, and fine-grained #if used there.
-
-#if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
-
-#include <windows.h>
-#include <mono/metadata/object-internals.h>
-#include "mono/metadata/w32process.h"
-#include "mono/metadata/w32process-internals.h"
-#include "icall-decl.h"
-
-MonoArrayHandle
-ves_icall_System_Diagnostics_Process_GetProcesses_internal (MonoError *error)
-{
-       g_unsupported_api ("EnumProcesses");
-       mono_error_set_not_supported (error, "This system does not support EnumProcesses");
-       SetLastError (ERROR_NOT_SUPPORTED);
-       return NULL_HANDLE_ARRAY;
-}
-
-HANDLE
-ves_icall_System_Diagnostics_Process_GetProcess_internal (guint32 pid, MonoError *error)
-{
-       g_unsupported_api ("OpenProcess");
-       mono_error_set_not_supported (error, G_UNSUPPORTED_API, "OpenProcess");
-       SetLastError (ERROR_NOT_SUPPORTED);
-       return NULL;
-}
-
-void
-ves_icall_System_Diagnostics_FileVersionInfo_GetVersionInfo_internal (MonoObjectHandle this_obj,
-               const gunichar2 *filename, int filename_length, MonoError *error)
-{
-       g_unsupported_api ("GetFileVersionInfoSize, GetFileVersionInfo, VerQueryValue, VerLanguageName");
-       mono_error_set_not_supported (error, G_UNSUPPORTED_API, "GetFileVersionInfoSize, GetFileVersionInfo, VerQueryValue, VerLanguageName");
-       SetLastError (ERROR_NOT_SUPPORTED);
-}
-
-MonoArrayHandle
-ves_icall_System_Diagnostics_Process_GetModules_internal (MonoObjectHandle this_obj, HANDLE process, MonoError *error)
-{
-       g_unsupported_api ("EnumProcessModules");
-       mono_error_set_not_supported (error, G_UNSUPPORTED_API, "EnumProcessModules");
-       SetLastError (ERROR_NOT_SUPPORTED);
-       return NULL_HANDLE_ARRAY;
-}
-
-MonoBoolean
-ves_icall_System_Diagnostics_Process_ShellExecuteEx_internal (MonoW32ProcessStartInfoHandle proc_start_info, MonoW32ProcessInfo *process_info, MonoError *error)
-{
-       g_unsupported_api ("ShellExecuteEx");
-       mono_error_set_not_supported (error, G_UNSUPPORTED_API, "ShellExecuteEx");
-       process_info->pid = (guint32)(-ERROR_NOT_SUPPORTED);
-       SetLastError (ERROR_NOT_SUPPORTED);
-       return FALSE;
-}
-
-// This is the only function in this file that does anything.
-// Note that process is ignored and it just operates on the current process.
-MonoStringHandle
-ves_icall_System_Diagnostics_Process_ProcessName_internal (HANDLE process, MonoError *error)
-{
-       gunichar2 *name = NULL;
-       guint32 len = 0;
-       // FIXME give allocator to mono_get_module_file_name to avoid copies, here and many other
-       if (!mono_get_module_file_name (NULL, &name, &len))
-               return NULL_HANDLE_STRING;
-       MonoStringHandle res = mono_string_new_utf16_handle (mono_domain_get (), name, len, error);
-       g_free (name);
-       return res;
-}
-
-MonoBoolean
-ves_icall_System_Diagnostics_Process_CreateProcess_internal (MonoW32ProcessStartInfoHandle proc_start_info,
-       HANDLE stdin_handle, HANDLE stdout_handle, HANDLE stderr_handle, MonoW32ProcessInfo *process_info, MonoError *error)
-{
-       // FIXME CreateProcess is supported for UWP. Use finer grained #if.
-
-       const char *api_name = mono_process_info->username ? "CreateProcessWithLogonW" : "CreateProcess";
-       memset (process_info, 0, sizeof (*process_info));
-       g_unsupported_api (api_name);
-       mono_error_set_not_supported (error, G_UNSUPPORTED_API, api_name);
-       SetLastError (ERROR_NOT_SUPPORTED);
-       return FALSE;
-}
-
-MonoBoolean
-ves_icall_Microsoft_Win32_NativeMethods_GetProcessWorkingSetSize (gpointer handle, gsize *min, gsize *max)
-{
-       ERROR_DECL (error);
-       g_unsupported_api ("GetProcessWorkingSetSize");
-       mono_error_set_not_supported(error, G_UNSUPPORTED_API, "GetProcessWorkingSetSize");
-       mono_error_set_pending_exception (error);
-       SetLastError (ERROR_NOT_SUPPORTED);
-       return FALSE;
-}
-
-MonoBoolean
-ves_icall_Microsoft_Win32_NativeMethods_SetProcessWorkingSetSize (gpointer handle, gsize min, gsize max)
-{
-       ERROR_DECL (error);
-       g_unsupported_api ("SetProcessWorkingSetSize");
-       mono_error_set_not_supported (error, G_UNSUPPORTED_API, "SetProcessWorkingSetSize");
-       mono_error_set_pending_exception (error);
-       SetLastError (ERROR_NOT_SUPPORTED);
-       return FALSE;
-}
-
-gint32
-ves_icall_Microsoft_Win32_NativeMethods_GetPriorityClass (gpointer handle)
-{
-       // FIXME GetPriorityClass is supported for UWP. Use finer grained #if.
-
-       ERROR_DECL (error);
-       g_unsupported_api ("GetPriorityClass");
-       mono_error_set_not_supported (error, G_UNSUPPORTED_API, "GetPriorityClass");
-       mono_error_set_pending_exception (error);
-       SetLastError (ERROR_NOT_SUPPORTED);
-       return FALSE;
-}
-
-MonoBoolean
-ves_icall_Microsoft_Win32_NativeMethods_SetPriorityClass (gpointer handle, gint32 priorityClass)
-{
-       // FIXME SetPriorityClass is supported for UWP. Use finer grained #if.
-
-       ERROR_DECL (error);
-       g_unsupported_api ("SetPriorityClass");
-       mono_error_set_not_supported(error, G_UNSUPPORTED_API, "SetPriorityClass");
-       mono_error_set_pending_exception (error);
-       SetLastError (ERROR_NOT_SUPPORTED);
-       return FALSE;
-}
-
-#else /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
-
-MONO_EMPTY_SOURCE_FILE (process_windows_uwp);
-#endif /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
index e03bf66..ebd5a68 100644 (file)
@@ -18,7 +18,6 @@
 #include <winsock2.h>
 #include <windows.h>
 
-#include <mono/metadata/object-internals.h>
 #include <mono/metadata/w32process.h>
 #include <mono/metadata/assembly.h>
 #include <mono/metadata/appdomain.h>
 #include <mono/metadata/threadpool-io.h>
 #include <mono/utils/strenc.h>
 #include <mono/utils/mono-proclib.h>
-/* FIXME: fix this code to not depend so much on the internals */
-#include <mono/metadata/class-internals.h>
 #include <mono/metadata/w32handle.h>
 #include <mono/utils/w32api.h>
 #include <mono/utils/mono-threads-coop.h>
-
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
-#include <shellapi.h>
-#endif
-
-#include "icall-decl.h"
+#include <mono/utils/w32subset.h>
 
 void
 mono_w32process_init (void)
@@ -55,8 +47,140 @@ mono_w32process_signal_finished (void)
 {
 }
 
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+guint32
+mono_w32process_get_pid (gpointer handle)
+{
+       return GetProcessId (handle);
+}
+
+#if HAVE_API_SUPPORT_WIN32_ENUM_PROCESS_MODULES
+gboolean
+mono_w32process_try_get_modules (gpointer process, gpointer *modules, guint32 size, guint32 *needed)
+{
+       return EnumProcessModules (process, (HMODULE *)modules, size, (PDWORD)needed);
+}
+#elif !HAVE_EXTERN_DEFINED_WIN32_ENUM_PROCESS_MODULES
+gboolean
+mono_w32process_try_get_modules (gpointer process, gpointer *modules, guint32 size, guint32 *needed)
+{
+       g_unsupported_api ("EnumProcessModules");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return FALSE;
+}
+#endif
+
+#if HAVE_API_SUPPORT_WIN32_GET_MODULE_BASE_NAME
+gboolean
+mono_w32process_module_get_name (gpointer process, gpointer module, gunichar2 **str, guint32 *len)
+{
+       return mono_get_module_basename (process, module, str, len);
+}
+#elif !HAVE_EXTERN_DEFINED_WIN32_GET_MODULE_BASE_NAME
+gboolean
+mono_w32process_module_get_name (gpointer process, gpointer module, gunichar2 **str, guint32 *len)
+{
+       g_unsupported_api ("GetModuleBaseName");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return FALSE;
+ }
+#endif /* HAVE_API_SUPPORT_WIN32_GET_MODULE_BASE_NAME */
+
+#if HAVE_API_SUPPORT_WIN32_GET_MODULE_FILE_NAME_EX
+gboolean
+mono_w32process_module_get_filename (gpointer process, gpointer module, gunichar2 **str, guint32 *len)
+{
+       return mono_get_module_filename_ex (process, module, str, len);
+}
+#elif !HAVE_EXTERN_DEFINED_WIN32_GET_MODULE_FILE_NAME_EX
+gboolean
+mono_w32process_module_get_filename (gpointer process, gpointer module, gunichar2 **str, guint32 *len)
+{
+       g_unsupported_api ("GetModuleFileNameEx");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return FALSE;
+ }
+#endif /* HAVE_API_SUPPORT_WIN32_GET_MODULE_FILE_NAME_EX */
+
+#if HAVE_API_SUPPORT_WIN32_GET_MODULE_INFORMATION
+gboolean
+mono_w32process_module_get_information (gpointer process, gpointer module, gpointer modinfo, guint32 size)
+{
+       return GetModuleInformation (process, (HMODULE)module, (MODULEINFO *)modinfo, size);
+}
+#elif !HAVE_EXTERN_DEFINED_WIN32_GET_MODULE_INFORMATION
+gboolean
+mono_w32process_module_get_information (gpointer process, gpointer module, gpointer modinfo, guint32 size)
+{
+       g_unsupported_api ("GetModuleInformation");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return FALSE;
+}
+#endif /* HAVE_API_SUPPORT_WIN32_GET_MODULE_INFORMATION */
+
+#if HAVE_API_SUPPORT_WIN32_GET_FILE_VERSION_INFO
+gboolean
+mono_w32process_get_fileversion_info (const gunichar2 *filename, gpointer *data)
+{
+       DWORD handle;
+
+       g_assert (data);
+       *data = NULL;
+
+       DWORD datasize = GetFileVersionInfoSizeW (filename, &handle);
+       if (datasize <= 0)
+               return FALSE;
 
+       *data = g_malloc0 (datasize);
+       if (!GetFileVersionInfoW (filename, handle, datasize, *data)) {
+               g_free (*data);
+               return FALSE;
+       }
+
+       return TRUE;
+}
+#elif !HAVE_EXTERN_DEFINED_WIN32_GET_FILE_VERSION_INFO
+gboolean
+mono_w32process_get_fileversion_info (const gunichar2 *filename, gpointer *data)
+{
+       g_unsupported_api ("GetFileVersionInfo");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return FALSE;
+}
+#endif /* HAVE_API_SUPPORT_WIN32_GET_FILE_VERSION_INFO */
+
+#if HAVE_API_SUPPORT_WIN32_VER_QUERY_VALUE
+gboolean
+mono_w32process_ver_query_value (gconstpointer datablock, const gunichar2 *subblock, gpointer *buffer, guint32 *len)
+{
+       return VerQueryValueW (datablock, subblock, buffer, len);
+}
+#elif !HAVE_EXTERN_DEFINED_WIN32_VER_QUERY_VALUE
+gboolean
+mono_w32process_ver_query_value (gconstpointer datablock, const gunichar2 *subblock, gpointer *buffer, guint32 *len)
+{
+       g_unsupported_api ("VerQueryValue");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return FALSE;
+}
+#endif /* HAVE_API_SUPPORT_WIN32_VER_QUERY_VALUE */
+
+#if HAVE_API_SUPPORT_WIN32_VER_LANGUAGE_NAME
+guint32
+mono_w32process_ver_language_name (guint32 lang, gunichar2 *lang_out, guint32 lang_len)
+{
+       return VerLanguageNameW (lang, lang_out, lang_len);
+}
+#elif !HAVE_EXTERN_DEFINED_WIN32_VER_LANGUAGE_NAME
+guint32
+mono_w32process_ver_language_name (guint32 lang, gunichar2 *lang_out, guint32 lang_len)
+{
+       g_unsupported_api ("VerLanguageName");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return 0;
+}
+#endif /* HAVE_API_SUPPORT_WIN32_VER_LANGUAGE_NAME */
+
+#if HAVE_API_SUPPORT_WIN32_OPEN_PROCESS
 HANDLE
 ves_icall_System_Diagnostics_Process_GetProcess_internal (guint32 pid, MonoError *error)
 {
@@ -71,14 +195,26 @@ ves_icall_System_Diagnostics_Process_GetProcess_internal (guint32 pid, MonoError
                return NULL;
        return handle;
 }
+#elif !HAVE_EXTERN_DEFINED_WIN32_OPEN_PROCESS
+HANDLE
+ves_icall_System_Diagnostics_Process_GetProcess_internal (guint32 pid, MonoError *error)
+{
+       g_unsupported_api ("OpenProcess");
+       mono_error_set_not_supported (error, G_UNSUPPORTED_API, "OpenProcess");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return NULL;
+}
+#endif /* HAVE_API_SUPPORT_WIN32_OPEN_PROCESS */
 
+#if HAVE_API_SUPPORT_WIN32_SHELL_EXECUTE_EX
+#include <shellapi.h>
 MonoBoolean
 ves_icall_System_Diagnostics_Process_ShellExecuteEx_internal (MonoW32ProcessStartInfoHandle proc_start_info, MonoW32ProcessInfo *process_info, MonoError *error)
 {
        MonoCreateProcessCoop coop;
        mono_createprocess_coop_init (&coop, proc_start_info, process_info);
 
-       SHELLEXECUTEINFO shellex = {0};
+       SHELLEXECUTEINFOW shellex = {0};
        gboolean ret;
 
        shellex.cbSize = sizeof(SHELLEXECUTEINFO);
@@ -101,7 +237,7 @@ ves_icall_System_Diagnostics_Process_ShellExecuteEx_internal (MonoW32ProcessStar
                shellex.fMask = (gulong)(shellex.fMask | SEE_MASK_FLAG_NO_UI);
 
        MONO_ENTER_GC_SAFE;
-       ret = ShellExecuteEx (&shellex);
+       ret = ShellExecuteExW (&shellex);
        MONO_EXIT_GC_SAFE;
        
        if (ret == FALSE) {
@@ -119,28 +255,45 @@ ves_icall_System_Diagnostics_Process_ShellExecuteEx_internal (MonoW32ProcessStar
 
        return ret;
 }
-
-static void
-mono_process_init_startup_info (HANDLE stdin_handle, HANDLE stdout_handle, HANDLE stderr_handle, STARTUPINFO *startinfo)
+#elif !HAVE_EXTERN_DEFINED_WIN32_SHELL_EXECUTE_EX
+MonoBoolean
+ves_icall_System_Diagnostics_Process_ShellExecuteEx_internal (MonoW32ProcessStartInfoHandle proc_start_info, MonoW32ProcessInfo *process_info, MonoError *error)
 {
-       startinfo->cb = sizeof(STARTUPINFO);
-       startinfo->dwFlags = STARTF_USESTDHANDLES;
-       startinfo->hStdInput = stdin_handle;
-       startinfo->hStdOutput = stdout_handle;
-       startinfo->hStdError = stderr_handle;
+       g_unsupported_api ("ShellExecuteEx");
+       mono_error_set_not_supported (error, G_UNSUPPORTED_API, "ShellExecuteEx");
+       process_info->pid = (guint32)(-ERROR_NOT_SUPPORTED);
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return FALSE;
 }
+#endif /* HAVE_API_SUPPORT_WIN32_SHELL_EXECUTE_EX */
 
+#if HAVE_API_SUPPORT_WIN32_CREATE_PROCESS_WITH_LOGON || HAVE_API_SUPPORT_WIN32_CREATE_PROCESS
 static gboolean
 mono_process_create_process (MonoCreateProcessCoop *coop, MonoW32ProcessInfo *mono_process_info,
-       MonoStringHandle cmd, guint32 creation_flags, gunichar2 *env_vars, gunichar2 *dir, STARTUPINFO *start_info,
-       PROCESS_INFORMATION *process_info)
+       MonoStringHandle cmd, guint32 creation_flags, gunichar2 *env_vars, gunichar2 *dir,
+       HANDLE stdin_handle, HANDLE stdout_handle, HANDLE stderr_handle, PROCESS_INFORMATION *process_info, MonoError *error)
 {
        gboolean result = FALSE;
        MonoGCHandle cmd_gchandle = NULL;
        gunichar2 *cmd_chars = MONO_HANDLE_IS_NULL (cmd) ? NULL : mono_string_handle_pin_chars (cmd, &cmd_gchandle);
 
+       STARTUPINFOW start_info={0};
+#if HAVE_API_SUPPORT_WIN32_CONSOLE
+       start_info.cb = sizeof(STARTUPINFOW);
+       start_info.dwFlags = STARTF_USESTDHANDLES;
+       start_info.hStdInput = stdin_handle;
+       start_info.hStdOutput = stdout_handle;
+       start_info.hStdError = stderr_handle;
+#else
+       start_info.dwFlags = 0;
+       start_info.hStdInput = INVALID_HANDLE_VALUE;
+       start_info.hStdOutput = INVALID_HANDLE_VALUE;
+       start_info.hStdError = INVALID_HANDLE_VALUE;
+#endif /* HAVE_API_SUPPORT_WIN32_CONSOLE */
+
        MONO_ENTER_GC_SAFE;
        if (coop->username) {
+#if HAVE_API_SUPPORT_WIN32_CREATE_PROCESS_WITH_LOGON
                guint32 logon_flags = mono_process_info->load_user_profile ? LOGON_WITH_PROFILE : 0;
 
                result = CreateProcessWithLogonW (coop->username,
@@ -150,8 +303,15 @@ mono_process_create_process (MonoCreateProcessCoop *coop, MonoW32ProcessInfo *mo
                                                  NULL,
                                                  cmd_chars,
                                                  creation_flags,
-                                                 env_vars, dir, start_info, process_info);
+                                                 env_vars, dir, &start_info, process_info);
+#else
+               memset (process_info, 0, sizeof (PROCESS_INFORMATION));
+               g_unsupported_api ("CreateProcessWithLogon");
+               mono_error_set_not_supported (error, G_UNSUPPORTED_API, "CreateProcessWithLogon");
+               SetLastError (ERROR_NOT_SUPPORTED);
+#endif /* HAVE_API_SUPPORT_WIN32_CREATE_PROCESS_WITH_LOGON */
        } else {
+#if HAVE_API_SUPPORT_WIN32_CREATE_PROCESS
                result = CreateProcessW (NULL,
                                        cmd_chars,
                                        NULL,
@@ -160,8 +320,14 @@ mono_process_create_process (MonoCreateProcessCoop *coop, MonoW32ProcessInfo *mo
                                        creation_flags,
                                        env_vars,
                                        dir,
-                                       start_info,
+                                       &start_info,
                                        process_info);
+#else
+               memset (process_info, 0, sizeof (PROCESS_INFORMATION));
+               g_unsupported_api ("CreateProcess");
+               mono_error_set_not_supported (error, G_UNSUPPORTED_API, "CreateProcess");
+               SetLastError (ERROR_NOT_SUPPORTED);
+#endif
        }
        MONO_EXIT_GC_SAFE;
 
@@ -169,6 +335,19 @@ mono_process_create_process (MonoCreateProcessCoop *coop, MonoW32ProcessInfo *mo
 
        return result;
 }
+#elif !HAVE_EXTERN_DEFINED_WIN32_CREATE_PROCESS_WITH_LOGON && !HAVE_EXTERN_DEFINED_WIN32_CREATE_PROCESS
+static gboolean
+mono_process_create_process (MonoCreateProcessCoop *coop, MonoW32ProcessInfo *mono_process_info,
+       MonoStringHandle cmd, guint32 creation_flags, gunichar2 *env_vars, gunichar2 *dir,
+       HANDLE stdin_handle, HANDLE stdout_handle, HANDLE stderr_handle, PROCESS_INFORMATION *process_info, MonoError *error)
+{
+       memset (process_info, 0, sizeof (PROCESS_INFORMATION));
+       g_unsupported_api ("CreateProcessWithLogon, CreateProcess");
+       mono_error_set_not_supported (error, G_UNSUPPORTED_API, "CreateProcessWithLogon, CreateProcess");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return FALSE;
+}
+#endif /* HAVE_API_SUPPORT_WIN32_CREATE_PROCESS_WITH_LOGON || HAVE_API_SUPPORT_WIN32_CREATE_PROCESS */
 
 static gchar*
 process_unquote_application_name (gchar *appname)
@@ -265,14 +444,11 @@ ves_icall_System_Diagnostics_Process_CreateProcess_internal (MonoW32ProcessStart
 
        gboolean ret;
        gunichar2 *dir = NULL;
-       STARTUPINFOW startinfo={0};
        PROCESS_INFORMATION procinfo;
        gunichar2 *env_vars = NULL;
        MonoStringHandle cmd = NULL_HANDLE_STRING;
        guint32 creation_flags;
 
-       mono_process_init_startup_info (stdin_handle, stdout_handle, stderr_handle, &startinfo);
-
        creation_flags = CREATE_UNICODE_ENVIRONMENT;
        if (MONO_HANDLE_GETVAL (proc_start_info, create_no_window))
                creation_flags |= CREATE_NO_WINDOW;
@@ -316,7 +492,7 @@ ves_icall_System_Diagnostics_Process_CreateProcess_internal (MonoW32ProcessStart
        if (coop.length.working_directory)
                dir = coop.working_directory;
 
-       ret = mono_process_create_process (&coop, process_info, cmd, creation_flags, env_vars, dir, &startinfo, &procinfo);
+       ret = mono_process_create_process (&coop, process_info, cmd, creation_flags, env_vars, dir, stdin_handle, stdout_handle, stderr_handle, &procinfo, error);
 
        g_free (env_vars);
 
@@ -336,6 +512,7 @@ exit:
        return ret;
 }
 
+#if HAVE_API_SUPPORT_WIN32_ENUM_PROCESSES
 MonoArrayHandle
 ves_icall_System_Diagnostics_Process_GetProcesses_internal (MonoError *error)
 {
@@ -378,6 +555,16 @@ exit:
        g_free (pids);
        return procs;
 }
+#elif !HAVE_EXTERN_DEFINED_WIN32_ENUM_PROCESSES
+MonoArrayHandle
+ves_icall_System_Diagnostics_Process_GetProcesses_internal (MonoError *error)
+{
+       g_unsupported_api ("EnumProcesses");
+       mono_error_set_not_supported (error, G_UNSUPPORTED_API, "EnumProcesses");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return NULL_HANDLE_ARRAY;
+}
+#endif /* HAVE_API_SUPPORT_WIN32_ENUM_PROCESSES */
 
 MonoBoolean
 ves_icall_Microsoft_Win32_NativeMethods_CloseProcess (gpointer handle)
@@ -397,29 +584,81 @@ ves_icall_Microsoft_Win32_NativeMethods_GetExitCodeProcess (gpointer handle, gin
        return GetExitCodeProcess (handle, (PDWORD)exitcode);
 }
 
+#if HAVE_API_SUPPORT_WIN32_GET_WORKING_SET_SIZE
 MonoBoolean
 ves_icall_Microsoft_Win32_NativeMethods_GetProcessWorkingSetSize (gpointer handle, gsize *min, gsize *max)
 {
        return GetProcessWorkingSetSize (handle, (PSIZE_T)min, (PSIZE_T)max);
 }
+#elif !HAVE_EXTERN_DEFINED_WIN32_GET_WORKING_SET_SIZE
+MonoBoolean
+ves_icall_Microsoft_Win32_NativeMethods_GetProcessWorkingSetSize (gpointer handle, gsize *min, gsize *max)
+{
+       ERROR_DECL (error);
+       g_unsupported_api ("GetProcessWorkingSetSize");
+       mono_error_set_not_supported(error, G_UNSUPPORTED_API, "GetProcessWorkingSetSize");
+       mono_error_set_pending_exception (error);
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return FALSE;
+}
+#endif /* HAVE_API_SUPPORT_WIN32_GET_WORKING_SET_SIZE */
 
+#if HAVE_API_SUPPORT_WIN32_SET_WORKING_SET_SIZE
 MonoBoolean
 ves_icall_Microsoft_Win32_NativeMethods_SetProcessWorkingSetSize (gpointer handle, gsize min, gsize max)
 {
        return SetProcessWorkingSetSize (handle, min, max);
 }
+#elif !HAVE_EXTERN_DEFINED_WIN32_SET_WORKING_SET_SIZE
+MonoBoolean
+ves_icall_Microsoft_Win32_NativeMethods_SetProcessWorkingSetSize (gpointer handle, gsize min, gsize max)
+{
+       ERROR_DECL (error);
+       g_unsupported_api ("SetProcessWorkingSetSize");
+       mono_error_set_not_supported (error, G_UNSUPPORTED_API, "SetProcessWorkingSetSize");
+       mono_error_set_pending_exception (error);
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return FALSE;
+}
+#endif /* HAVE_API_SUPPORT_WIN32_SET_WORKING_SET_SIZE */
 
+#if HAVE_API_SUPPORT_WIN32_GET_PRIORITY_CLASS
 gint32
 ves_icall_Microsoft_Win32_NativeMethods_GetPriorityClass (gpointer handle)
 {
        return GetPriorityClass (handle);
 }
+#elif !HAVE_EXTERN_DEFINED_WIN32_GET_PRIORITY_CLASS
+gint32
+ves_icall_Microsoft_Win32_NativeMethods_GetPriorityClass (gpointer handle)
+{
+       ERROR_DECL (error);
+       g_unsupported_api ("GetPriorityClass");
+       mono_error_set_not_supported (error, G_UNSUPPORTED_API, "GetPriorityClass");
+       mono_error_set_pending_exception (error);
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return FALSE;
+}
+#endif /* HAVE_API_SUPPORT_WIN32_GET_PRIORITY_CLASS */
 
+#if HAVE_API_SUPPORT_WIN32_SET_PRIORITY_CLASS
 MonoBoolean
 ves_icall_Microsoft_Win32_NativeMethods_SetPriorityClass (gpointer handle, gint32 priorityClass)
 {
        return SetPriorityClass (handle, (guint32) priorityClass);
 }
+#elif !HAVE_EXTERN_DEFINED_WIN32_SET_PRIORITY_CLASS
+MonoBoolean
+ves_icall_Microsoft_Win32_NativeMethods_SetPriorityClass (gpointer handle, gint32 priorityClass)
+{
+       ERROR_DECL (error);
+       g_unsupported_api ("SetPriorityClass");
+       mono_error_set_not_supported(error, G_UNSUPPORTED_API, "SetPriorityClass");
+       mono_error_set_pending_exception (error);
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return FALSE;
+}
+#endif /* HAVE_API_SUPPORT_WIN32_SET_PRIORITY_CLASS */
 
 MonoBoolean
 ves_icall_Microsoft_Win32_NativeMethods_GetProcessTimes (gpointer handle, gint64 *creationtime, gint64 *exittime, gint64 *kerneltime, gint64 *usertime)
@@ -432,5 +671,3 @@ ves_icall_Microsoft_Win32_NativeMethods_GetCurrentProcess (void)
 {
        return GetCurrentProcess ();
 }
-
-#endif
index 215fede..08f9386 100644 (file)
 #define LOGDEBUG(...)
 /* define LOGDEBUG(...) g_message(__VA_ARGS__)  */
 
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) && defined(HOST_WIN32)
-
-static guint32
-mono_w32process_get_pid (gpointer handle)
-{
-       return GetProcessId (handle);
-}
-
-static gboolean
-mono_w32process_try_get_modules (gpointer process, HMODULE *modules, guint32 size, PDWORD needed)
-{
-       return EnumProcessModules (process, modules, size, needed);
-}
-
-static gboolean
-mono_w32process_module_get_name (gpointer process, gpointer module, gunichar2 **str, guint32 *len)
-{
-       return mono_get_module_basename (process, module, str, len);
-}
-
-static gboolean
-mono_w32process_module_get_filename (gpointer process, gpointer module, gunichar2 **str, guint32 *len)
-{
-       return mono_get_module_filename_ex (process, module, str, len);
-}
-
-static gboolean
-mono_w32process_module_get_information (gpointer process, gpointer module, MODULEINFO *modinfo, guint32 size)
-{
-       return GetModuleInformation (process, (HMODULE)module, modinfo, size);
-}
-
-static gboolean
-mono_w32process_get_fileversion_info (const gunichar2 *filename, gpointer *data)
-{
-       DWORD handle;
-
-       g_assert (data);
-       *data = NULL;
-
-       DWORD datasize = GetFileVersionInfoSizeW (filename, &handle);
-       if (datasize <= 0)
-               return FALSE;
-
-       *data = g_malloc0 (datasize);
-       if (!GetFileVersionInfoW (filename, handle, datasize, *data)) {
-               g_free (*data);
-               return FALSE;
-       }
-
-       return TRUE;
-}
-
-static gboolean
-mono_w32process_ver_query_value (gconstpointer datablock, const gunichar2 *subblock, gpointer *buffer, guint32 *len)
-{
-       return VerQueryValueW (datablock, subblock, buffer, len);
-}
-
-static guint32
-mono_w32process_ver_language_name (guint32 lang, gunichar2 *lang_out, guint32 lang_len)
-{
-       return VerLanguageNameW (lang, lang_out, lang_len);
-}
-
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) && defined(HOST_WIN32) */
-
 static MonoClass*
 get_file_version_info_class (MonoImage *system_image)
 {
@@ -205,8 +138,6 @@ process_set_field_bool (MonoObjectHandle obj, const char *fieldname, guint8 val)
        MONO_HANDLE_SET_FIELD_VAL (obj, guint8, process_resolve_field (obj, fieldname), val);
 }
 
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
-
 #define SFI_COMMENTS           "\\StringFileInfo\\%02X%02X%02X%02X\\Comments"
 #define SFI_COMPANYNAME                "\\StringFileInfo\\%02X%02X%02X%02X\\CompanyName"
 #define SFI_FILEDESCRIPTION    "\\StringFileInfo\\%02X%02X%02X%02X\\FileDescription"
@@ -284,6 +215,7 @@ process_module_stringtable (MonoObjectHandle filever, MonoStringHandle str, gpoi
        }
 }
 
+#if HAVE_API_SUPPORT_WIN32_GET_FILE_VERSION_INFO
 static void
 mono_w32process_get_fileversion (MonoObjectHandle filever, MonoStringHandle str, const gunichar2 *filename, MonoError *error)
 {
@@ -303,22 +235,22 @@ mono_w32process_get_fileversion (MonoObjectHandle filever, MonoStringHandle str,
                goto cleanup;
 
        if (mono_w32process_ver_query_value (data, query, (gpointer *)&ffi, &ffi_size)) {
-               #define LOWORD(i32) ((guint16)((i32) & 0xFFFF))
-               #define HIWORD(i32) ((guint16)(((guint32)(i32) >> 16) & 0xFFFF))
+               #define MONO_LOWORD(i32) ((guint16)((i32) & 0xFFFF))
+               #define MONO_HIWORD(i32) ((guint16)(((guint32)(i32) >> 16) & 0xFFFF))
 
                LOGDEBUG (g_message ("%s: recording assembly: FileName [%s] FileVersionInfo [%d.%d.%d.%d]",
-                       __func__, g_utf16_to_utf8 (filename, -1, NULL, NULL, NULL), HIWORD (ffi->dwFileVersionMS),
-                               LOWORD (ffi->dwFileVersionMS), HIWORD (ffi->dwFileVersionLS), LOWORD (ffi->dwFileVersionLS)));
+                       _func__, g_utf16_to_utf8 (filename, -1, NULL, NULL, NULL), MONO_HIWORD (ffi->dwFileVersionMS),
+                       MONO_LOWORD (ffi->dwFileVersionMS), MONO_HIWORD (ffi->dwFileVersionLS), MONO_LOWORD (ffi->dwFileVersionLS)));
 
-               process_set_field_int (filever, "filemajorpart", HIWORD (ffi->dwFileVersionMS));
-               process_set_field_int (filever, "fileminorpart", LOWORD (ffi->dwFileVersionMS));
-               process_set_field_int (filever, "filebuildpart", HIWORD (ffi->dwFileVersionLS));
-               process_set_field_int (filever, "fileprivatepart", LOWORD (ffi->dwFileVersionLS));
+               process_set_field_int (filever, "filemajorpart", MONO_HIWORD (ffi->dwFileVersionMS));
+               process_set_field_int (filever, "fileminorpart", MONO_LOWORD (ffi->dwFileVersionMS));
+               process_set_field_int (filever, "filebuildpart", MONO_HIWORD (ffi->dwFileVersionLS));
+               process_set_field_int (filever, "fileprivatepart", MONO_LOWORD (ffi->dwFileVersionLS));
 
-               process_set_field_int (filever, "productmajorpart", HIWORD (ffi->dwProductVersionMS));
-               process_set_field_int (filever, "productminorpart", LOWORD (ffi->dwProductVersionMS));
-               process_set_field_int (filever, "productbuildpart", HIWORD (ffi->dwProductVersionLS));
-               process_set_field_int (filever, "productprivatepart", LOWORD (ffi->dwProductVersionLS));
+               process_set_field_int (filever, "productmajorpart", MONO_HIWORD (ffi->dwProductVersionMS));
+               process_set_field_int (filever, "productminorpart", MONO_LOWORD (ffi->dwProductVersionMS));
+               process_set_field_int (filever, "productbuildpart", MONO_HIWORD (ffi->dwProductVersionLS));
+               process_set_field_int (filever, "productprivatepart", MONO_LOWORD (ffi->dwProductVersionLS));
 
                process_set_field_bool (filever, "isdebug", ((ffi->dwFileFlags & ffi->dwFileFlagsMask) & VS_FF_DEBUG) != 0);
                process_set_field_bool (filever, "isprerelease", ((ffi->dwFileFlags & ffi->dwFileFlagsMask) & VS_FF_PRERELEASE) != 0);
@@ -326,8 +258,8 @@ mono_w32process_get_fileversion (MonoObjectHandle filever, MonoStringHandle str,
                process_set_field_bool (filever, "isprivatebuild", ((ffi->dwFileFlags & ffi->dwFileFlagsMask) & VS_FF_PRIVATEBUILD) != 0);
                process_set_field_bool (filever, "isspecialbuild", ((ffi->dwFileFlags & ffi->dwFileFlagsMask) & VS_FF_SPECIALBUILD) != 0);
 
-               #undef LOWORD
-               #undef HIWORD
+               #undef MONO_LOWORD
+               #undef MONO_HIWORD
        }
        g_free (query);
 
@@ -370,8 +302,15 @@ cleanup:
        g_free (query);
        g_free (data);
 }
-
-#endif // G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#elif !HAVE_EXTERN_DEFINED_WIN32_GET_FILE_VERSION_INFO
+static void
+mono_w32process_get_fileversion (MonoObjectHandle filever, MonoStringHandle str, const gunichar2 *filename, MonoError *error)
+{
+       g_unsupported_api ("GetFileVersionInfo");
+       mono_error_set_not_supported (error, G_UNSUPPORTED_API, "GetFileVersionInfo");
+       SetLastError (ERROR_NOT_SUPPORTED);
+}
+#endif
 
 #ifndef ENABLE_NETCORE
 void
@@ -387,8 +326,6 @@ ves_icall_System_Diagnostics_FileVersionInfo_GetVersionInfo_internal (MonoObject
 }
 #endif
 
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
-
 static GPtrArray*
 get_domain_assemblies (MonoDomain *domain)
 {
@@ -417,6 +354,7 @@ get_domain_assemblies (MonoDomain *domain)
        return assemblies;
 }
 
+#if HAVE_API_SUPPORT_WIN32_GET_MODULE_INFORMATION
 static void
 process_add_module (MonoObjectHandle item, MonoObjectHandle filever, MonoStringHandle str,
        HANDLE process, HMODULE mod, const gunichar2 *filename, const gunichar2 *modulename,
@@ -459,6 +397,18 @@ process_add_module (MonoObjectHandle item, MonoObjectHandle filever, MonoStringH
 exit:
        HANDLE_FUNCTION_RETURN ();
 }
+#elif !HAVE_EXTERN_DEFINED_WIN32_GET_MODULE_INFORMATION
+void
+process_add_module (MonoObjectHandle item, MonoObjectHandle filever, MonoStringHandle str,
+       HANDLE process, HMODULE mod, const gunichar2 *filename, const gunichar2 *modulename,
+       MonoClass *proc_class, MonoError *error)
+{
+       g_unsupported_api ("GetModuleInformation");
+       mono_error_set_not_supported (error, G_UNSUPPORTED_API, "GetModuleInformation");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return NULL;
+}
+#endif
 
 static void
 process_get_assembly_fileversion (MonoObjectHandle filever, MonoAssembly *assembly)
@@ -513,7 +463,7 @@ ves_icall_System_Diagnostics_Process_GetModules_internal (MonoObjectHandle this_
        gunichar2 *modname = NULL;
        guint32 filename_len = 0;
        guint32 modname_len = 0;
-       DWORD needed = 0;
+       guint32 needed = 0;
        guint32 count = 0;
        guint32 module_count = 0;
        guint32 assembly_count = 0;
@@ -536,7 +486,7 @@ ves_icall_System_Diagnostics_Process_GetModules_internal (MonoObjectHandle this_
                assembly_count = assemblies->len;
        }
 
-       if (mono_w32process_try_get_modules (process, mods, sizeof (mods), &needed))
+       if (mono_w32process_try_get_modules (process, (gpointer *)mods, sizeof (mods), &needed))
                module_count += needed / sizeof (HMODULE);
 
        count = module_count + assembly_count;
@@ -585,10 +535,10 @@ ves_icall_System_Diagnostics_Process_ProcessName_internal (HANDLE process, MonoE
 {
        gunichar2 *name = NULL;
        HMODULE mod = 0;
-       DWORD needed = 0;
+       guint32 needed = 0;
        guint32 len = 0;
 
-       if (!mono_w32process_try_get_modules (process, &mod, sizeof (mod), &needed))
+       if (!mono_w32process_try_get_modules (process, (gpointer *)&mod, sizeof (mod), &needed))
                return NULL_HANDLE_STRING;
 
        if (!mono_w32process_module_get_name (process, mod, &name, &len))
@@ -600,9 +550,6 @@ ves_icall_System_Diagnostics_Process_ProcessName_internal (HANDLE process, MonoE
 }
 #endif /* ENABLE_NETCORE */
 
-#endif // G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) && defined(HOST_WIN32)
-
-// This is the only part of this file common to classic and UWP.
 gint64
 ves_icall_System_Diagnostics_Process_GetProcessData (int pid, gint32 data_type, MonoProcessError *error)
 {
@@ -612,8 +559,6 @@ ves_icall_System_Diagnostics_Process_GetProcessData (int pid, gint32 data_type,
        return mono_process_get_data_with_error (GINT_TO_POINTER (pid), (MonoProcessData)data_type, error);
 }
 
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
-
 static void
 mono_pin_string (MonoStringHandle in_coophandle, MonoStringHandle *out_coophandle, gunichar2 **chars, gsize *length, MonoGCHandle *gchandle)
 {
@@ -658,5 +603,3 @@ mono_createprocess_coop_cleanup (MonoCreateProcessCoop *coop)
        mono_unpin_array ((MonoGCHandle*)&coop->gchandle, sizeof (coop->gchandle) / sizeof (MonoGCHandle));
        memset (coop, 0, sizeof (*coop));
 }
-
-#endif // G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
index 4e26b38..3856be4 100644 (file)
@@ -12,7 +12,8 @@
 
 #include <windows.h>
 #include <winbase.h>
-#include "object-internals.h"
+#include <mono/metadata/object-internals.h>
+#include <mono/utils/w32subset.h>
 #include "icall-decl.h"
 
 void
@@ -20,19 +21,32 @@ mono_w32semaphore_init (void)
 {
 }
 
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT)
+#if HAVE_API_SUPPORT_WIN32_CREATE_SEMAPHORE || HAVE_API_SUPPORT_WIN32_CREATE_SEMAPHORE_EX
 gpointer
 ves_icall_System_Threading_Semaphore_CreateSemaphore_icall (gint32 initialCount, gint32 maximumCount,
        const gunichar2 *name, gint32 name_length, gint32 *win32error)
-{ 
+{
        HANDLE sem;
        MONO_ENTER_GC_SAFE;
+#if HAVE_API_SUPPORT_WIN32_CREATE_SEMAPHORE
        sem = CreateSemaphoreW (NULL, initialCount, maximumCount, name);
+#elif HAVE_API_SUPPORT_WIN32_CREATE_SEMAPHORE_EX
+       sem = CreateSemaphoreExW (NULL, initialCount, maximumCount, name, 0, SEMAPHORE_ALL_ACCESS);
+#endif
        MONO_EXIT_GC_SAFE;
        *win32error = GetLastError ();
        return sem;
 }
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT) */
+#elif !HAVE_EXTERN_DEFINED_WIN32_CREATE_SEMAPHORE && !HAVE_EXTERN_DEFINED_WIN32_CREATE_SEMAPHORE_EX
+gpointer
+ves_icall_System_Threading_Semaphore_CreateSemaphore_icall (gint32 initialCount, gint32 maximumCount,
+       const gunichar2 *name, gint32 name_length, gint32 *win32error)
+{
+       g_unsupported_api ("CreateSemaphore, CreateSemaphoreEx");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return NULL;
+}
+#endif /* HAVE_API_SUPPORT_WIN32_CREATE_SEMAPHORE || HAVE_API_SUPPORT_WIN32_CREATE_SEMAPHORE_EX) */
 
 MonoBoolean
 ves_icall_System_Threading_Semaphore_ReleaseSemaphore_internal (gpointer handle, gint32 releaseCount, gint32 *prevcount)
index 0fe5209..6e4785d 100644 (file)
 #define socklen_t int
 #endif
 
-#ifndef HOST_WIN32
-
-#define TF_DISCONNECT 0x01
-#define TF_REUSE_SOCKET 0x02
+#include <mono/utils/w32subset.h>
 
+#if defined(HOST_WIN32) && (HAVE_API_SUPPORT_WIN32_TRANSMIT_FILE || HAVE_API_SUPPORT_WIN32_DISCONNECT_EX)
+#include <mswsock.h>
+#else
 typedef struct {
        gpointer Head;
        guint32 HeadLength;
        gpointer Tail;
        guint32 TailLength;
 } TRANSMIT_FILE_BUFFERS, *LPTRANSMIT_FILE_BUFFERS;
+#endif
+
+#ifndef HOST_WIN32
+#define TF_DISCONNECT 0x01
+#define TF_REUSE_SOCKET 0x02
 
 typedef struct {
        guint32 Data1;
@@ -51,7 +56,6 @@ typedef struct {
        gpointer handle1;
        gpointer handle2;
 } OVERLAPPED;
-
 #endif
 
 void
@@ -84,12 +88,9 @@ mono_w32socket_sendto (SOCKET s, const char *buf, int len, int flags, const stru
 int
 mono_w32socket_sendbuffers (SOCKET s, LPWSABUF lpBuffers, guint32 dwBufferCount, guint32 *lpNumberOfBytesRecvd, guint32 lpFlags, gpointer lpOverlapped, gpointer lpCompletionRoutine, gboolean blocking);
 
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT)
-
 BOOL
-mono_w32socket_transmit_file (SOCKET hSocket, gpointer hFile, LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers, guint32 dwReserved, gboolean blocking);
+mono_w32socket_transmit_file (SOCKET hSocket, gpointer hFile, gpointer lpTransmitBuffers, guint32 dwReserved, gboolean blocking);
 
-#endif
 
 #ifndef HOST_WIN32
 
index f5803a4..276aabe 100644 (file)
@@ -575,7 +575,7 @@ mono_w32socket_sendbuffers (SOCKET sock, WSABUF *buffers, guint32 count, guint32
 #define SF_BUFFER_SIZE 16384
 
 BOOL
-mono_w32socket_transmit_file (SOCKET sock, gpointer file_handle, TRANSMIT_FILE_BUFFERS *buffers, guint32 flags, gboolean blocking)
+mono_w32socket_transmit_file (SOCKET sock, gpointer file_handle, gpointer lpTransmitBuffers, guint32 flags, gboolean blocking)
 {
        MonoThreadInfo *info;
        SocketHandle *sockethandle;
@@ -586,6 +586,7 @@ mono_w32socket_transmit_file (SOCKET sock, gpointer file_handle, TRANSMIT_FILE_B
 #else
        gpointer buffer;
 #endif
+       TRANSMIT_FILE_BUFFERS *buffers = (TRANSMIT_FILE_BUFFERS *)lpTransmitBuffers;
 
        if (!mono_fdhandle_lookup_and_ref(sock, (MonoFDHandle**) &sockethandle)) {
                mono_w32error_set_last (WSAENOTSOCK);
index 513e5bb..5f0238d 100644 (file)
@@ -125,7 +125,7 @@ int mono_w32socket_sendbuffers (SOCKET s, WSABUF *lpBuffers, guint32 dwBufferCou
        return ret;
 }
 
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT)
+#if HAVE_API_SUPPORT_WIN32_TRANSMIT_FILE
 static gint
 internal_w32socket_transmit_file (SOCKET sock, gpointer file, TRANSMIT_FILE_BUFFERS *lpTransmitBuffers, guint32 dwReserved, gboolean blocking)
 {
@@ -169,7 +169,9 @@ internal_w32socket_transmit_file (SOCKET sock, gpointer file, TRANSMIT_FILE_BUFF
 
        return ret;
 }
+#endif /* HAVE_API_SUPPORT_WIN32_TRANSMIT_FILE */
 
+#if HAVE_API_SUPPORT_WIN32_DISCONNECT_EX
 static gint
 internal_w32socket_disconnect (SOCKET sock, gboolean reuse, gboolean blocking)
 {
@@ -213,24 +215,45 @@ internal_w32socket_disconnect (SOCKET sock, gboolean reuse, gboolean blocking)
 
        return ret;
 }
+#endif /* HAVE_API_SUPPORT_WIN32_DISCONNECT_EX */
 
-BOOL mono_w32socket_transmit_file (SOCKET hSocket, gpointer hFile, TRANSMIT_FILE_BUFFERS *lpTransmitBuffers, guint32 dwReserved, gboolean blocking)
+#if HAVE_API_SUPPORT_WIN32_TRANSMIT_FILE
+BOOL mono_w32socket_transmit_file (SOCKET hSocket, gpointer hFile, gpointer lpTransmitBuffers, guint32 dwReserved, gboolean blocking)
 {
-       return internal_w32socket_transmit_file (hSocket, hFile, lpTransmitBuffers, dwReserved, blocking) == 0 ? TRUE : FALSE;
+       return internal_w32socket_transmit_file (hSocket, hFile, (LPTRANSMIT_FILE_BUFFERS)lpTransmitBuffers, dwReserved, blocking) == 0 ? TRUE : FALSE;
 }
+#elif !HAVE_EXTERN_DEFINED_WIN32_TRANSMIT_FILE
+BOOL mono_w32socket_transmit_file (SOCKET hSocket, gpointer hFile, gpointer lpTransmitBuffers, guint32 dwReserved, gboolean blocking)
+{
+       g_unsupported_api ("TransmitFile");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return FALSE;
+}
+#endif /* HAVE_API_SUPPORT_WIN32_TRANSMIT_FILE */
 
+#if HAVE_API_SUPPORT_WIN32_DISCONNECT_EX
 gint
 mono_w32socket_disconnect (SOCKET sock, gboolean reuse)
 {
        gint ret = SOCKET_ERROR;
 
        ret = internal_w32socket_disconnect (sock, reuse, TRUE);
+#if HAVE_API_SUPPORT_WIN32_TRANSMIT_FILE
        if (ret == 0)
                ret = internal_w32socket_transmit_file (sock, NULL, NULL, TF_DISCONNECT | (reuse ? TF_REUSE_SOCKET : 0), TRUE);
+#endif /* HAVE_API_SUPPORT_WIN32_TRANSMIT_FILE */
 
        return ret;
 }
-#endif /* #if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT) */
+#elif !HAVE_EXTERN_DEFINED_WIN32_DISCONNECT_EX
+gint
+mono_w32socket_disconnect (SOCKET sock, gboolean reuse)
+{
+       g_unsupported_api ("DisconnectEx");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return ERROR_NOT_SUPPORTED;
+}
+#endif /* HAVE_API_SUPPORT_WIN32_DISCONNECT_EX */
 
 gint
 mono_w32socket_set_blocking (SOCKET sock, gboolean blocking)
index 6b93083..db3edc8 100644 (file)
 #define getifaddrs Qp2getifaddrs
 #endif
 
-#if defined(_MSC_VER) && G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT)
-#include <MSWSock.h>
-#endif
 #include "icall-decl.h"
 
 #define LOGDEBUG(...)  
@@ -1341,8 +1338,6 @@ ves_icall_System_Net_Sockets_Socket_Connect_icall (gsize sock, MonoObjectHandle
        g_free (sa);
 }
 
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT)
-
 void
 ves_icall_System_Net_Sockets_Socket_Disconnect_icall (gsize sock, MonoBoolean reuse, gint32 *werror)
 {
@@ -1351,8 +1346,6 @@ ves_icall_System_Net_Sockets_Socket_Disconnect_icall (gsize sock, MonoBoolean re
        *werror = mono_w32socket_disconnect (sock, reuse);
 }
 
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT) */
-
 MonoBoolean
 ves_icall_System_Net_Sockets_Socket_Duplicate_icall (gpointer handle, gint32 targetProcessId, gpointer *duplicate_handle, gint32 *werror)
 {
@@ -2559,8 +2552,6 @@ ves_icall_System_Net_Dns_GetHostName (MonoStringHandleOut h_name, MonoError *err
        return TRUE;
 }
 
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT)
-
 MonoBoolean
 ves_icall_System_Net_Sockets_Socket_SendFile_icall (gsize sock, MonoStringHandle filename, MonoArrayHandle pre_buffer, MonoArrayHandle post_buffer, gint flags, gint32 *werror, MonoBoolean blocking, MonoError *error)
 {
@@ -2615,8 +2606,6 @@ ves_icall_System_Net_Sockets_Socket_SendFile_icall (gsize sock, MonoStringHandle
        return ret;
 }
 
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT) */
-
 void
 mono_network_init (void)
 {
diff --git a/src/mono/mono/metadata/w32subset.h b/src/mono/mono/metadata/w32subset.h
deleted file mode 100644 (file)
index 7cfdcab..0000000
+++ /dev/null
@@ -1,225 +0,0 @@
-/**
- * \file
- * Define Win32 API subset defaults.
- * Other subsetters can fork this file, or
- * define symbols ahead of it, or after it (with undef).
- *
- * Note that #if of an undefined symbols is defined as if 0,
- * so that an implicit default here.
- *
- * Copyright 2018 Microsoft
- * Licensed under the MIT license. See LICENSE file in the project root for full license information.
- */
-
-#ifndef HAVE_API_SUPPORT_WIN32_GET_COMPUTER_NAME
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
-#define HAVE_API_SUPPORT_WIN32_GET_COMPUTER_NAME 1
-#else
-#define HAVE_API_SUPPORT_WIN32_GET_COMPUTER_NAME 0
-#endif
-#endif
-
-#ifndef HAVE_API_SUPPORT_WIN32_GET_DRIVE_TYPE
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
-#define HAVE_API_SUPPORT_WIN32_GET_DRIVE_TYPE 1
-#else
-#define HAVE_API_SUPPORT_WIN32_GET_DRIVE_TYPE 0
-#endif
-#endif
-
-#ifndef HAVE_API_SUPPORT_WIN32_REPLACE_FILE
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
-#define HAVE_API_SUPPORT_WIN32_REPLACE_FILE 1
-#else
-#define HAVE_API_SUPPORT_WIN32_REPLACE_FILE 0
-#endif
-#endif
-
-#ifndef HAVE_API_SUPPORT_WIN32_COPY_FILE
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
-#define HAVE_API_SUPPORT_WIN32_COPY_FILE 1
-#else
-#define HAVE_API_SUPPORT_WIN32_COPY_FILE 0
-#endif
-#endif
-
-#ifndef HAVE_API_SUPPORT_WIN32_COPY_FILE2 // not on Windows7
-#if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
-#define HAVE_API_SUPPORT_WIN32_COPY_FILE2 1
-#else
-#define HAVE_API_SUPPORT_WIN32_COPY_FILE2 0
-#endif
-#endif
-
-#ifndef HAVE_API_SUPPORT_WIN32_LOCK_FILE
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
-#define HAVE_API_SUPPORT_WIN32_LOCK_FILE 1
-#else
-#define HAVE_API_SUPPORT_WIN32_LOCK_FILE 0
-#endif
-#endif
-
-#ifndef HAVE_API_SUPPORT_WIN32_UNLOCK_FILE
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
-#define HAVE_API_SUPPORT_WIN32_UNLOCK_FILE 1
-#else
-#define HAVE_API_SUPPORT_WIN32_UNLOCK_FILE 0
-#endif
-#endif
-
-#ifndef HAVE_API_SUPPORT_WIN32_MOVE_FILE
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
-#define HAVE_API_SUPPORT_WIN32_MOVE_FILE 1
-#else
-#define HAVE_API_SUPPORT_WIN32_MOVE_FILE 0
-#endif
-#endif
-
-#ifndef HAVE_API_SUPPORT_WIN32_MOVE_FILE_EX
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
-#define HAVE_API_SUPPORT_WIN32_MOVE_FILE_EX 1
-#else
-#define HAVE_API_SUPPORT_WIN32_MOVE_FILE_EX 0
-#endif
-#endif
-
-#ifndef HAVE_API_SUPPORT_WIN32_GET_STD_HANDLE
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
-#define HAVE_API_SUPPORT_WIN32_GET_STD_HANDLE 1
-#else
-#define HAVE_API_SUPPORT_WIN32_GET_STD_HANDLE 0
-#endif
-#endif
-
-#ifndef HAVE_API_SUPPORT_WIN32_GET_FILE_SIZE_EX
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
-#define HAVE_API_SUPPORT_WIN32_GET_FILE_SIZE_EX 1
-#else
-#define HAVE_API_SUPPORT_WIN32_GET_FILE_SIZE_EX 0
-#endif
-#endif
-
-#ifndef HAVE_API_SUPPORT_WIN32_GET_LOGICAL_DRIVE_STRINGS
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
-#define HAVE_API_SUPPORT_WIN32_GET_LOGICAL_DRIVE_STRINGS 1
-#else
-#define HAVE_API_SUPPORT_WIN32_GET_LOGICAL_DRIVE_STRINGS 0
-#endif
-#endif
-
-#ifndef HAVE_API_SUPPORT_WIN32_SH_GET_FOLDER_PATH
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
-#define HAVE_API_SUPPORT_WIN32_SH_GET_FOLDER_PATH 1
-#else
-#define HAVE_API_SUPPORT_WIN32_SH_GET_FOLDER_PATH 0
-#endif
-#endif
-
-#ifndef HAVE_API_SUPPORT_WIN32_SEND_MESSAGE_TIMEOUT
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
-#define HAVE_API_SUPPORT_WIN32_SEND_MESSAGE_TIMEOUT 1
-#else
-#define HAVE_API_SUPPORT_WIN32_SEND_MESSAGE_TIMEOUT 0
-#endif
-#endif
-
-#ifndef HAVE_API_SUPPORT_WIN32_WAIT_FOR_INPUT_IDLE
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
-#define HAVE_API_SUPPORT_WIN32_WAIT_FOR_INPUT_IDLE 1
-#else
-#define HAVE_API_SUPPORT_WIN32_WAIT_FOR_INPUT_IDLE 0
-#endif
-#endif
-
-#ifndef HAVE_API_SUPPORT_WIN32_SIGNAL_OBJECT_AND_WAIT
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
-#define HAVE_API_SUPPORT_WIN32_SIGNAL_OBJECT_AND_WAIT 1
-#else
-#define HAVE_API_SUPPORT_WIN32_SIGNAL_OBJECT_AND_WAIT 0
-#endif
-#endif
-
-#ifndef HAVE_API_SUPPORT_WIN32_MSG_WAIT_FOR_MULTIPLE_OBJECTS
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
-#define HAVE_API_SUPPORT_WIN32_MSG_WAIT_FOR_MULTIPLE_OBJECTS 1
-#else
-#define HAVE_API_SUPPORT_WIN32_MSG_WAIT_FOR_MULTIPLE_OBJECTS 0
-#endif
-#endif
-
-#ifndef HAVE_API_SUPPORT_WIN32_SET_ERROR_MODE
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
-#define HAVE_API_SUPPORT_WIN32_SET_ERROR_MODE 1
-#else
-#define HAVE_API_SUPPORT_WIN32_SET_ERROR_MODE 0
-#endif
-#endif
-
-#ifndef HAVE_API_SUPPORT_WIN32_LOAD_LIBRARY
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
-#define HAVE_API_SUPPORT_WIN32_LOAD_LIBRARY 1
-#else
-#define HAVE_API_SUPPORT_WIN32_LOAD_LIBRARY 0
-#endif
-#endif
-
-#ifndef HAVE_API_SUPPORT_WIN32_LOAD_PACKAGED_LIBRARY
-#if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
-#define HAVE_API_SUPPORT_WIN32_LOAD_PACKAGED_LIBRARY 1
-#else
-#define HAVE_API_SUPPORT_WIN32_LOAD_PACKAGED_LIBRARY 0
-#endif
-#endif
-
-#ifndef HAVE_API_SUPPORT_WIN32_GET_MODULE_HANDLE
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
-#define HAVE_API_SUPPORT_WIN32_GET_MODULE_HANDLE 1
-#else
-#define HAVE_API_SUPPORT_WIN32_GET_MODULE_HANDLE 0
-#endif
-#endif
-
-#ifndef HAVE_API_SUPPORT_WIN32_SET_THREAD_CONTEXT
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
-#define HAVE_API_SUPPORT_WIN32_SET_THREAD_CONTEXT 1
-#else
-#define HAVE_API_SUPPORT_WIN32_SET_THREAD_CONTEXT 0
-#endif
-#endif
-
-#ifndef HAVE_API_SUPPORT_WIN32_CANCEL_SYNCHRONOUS_IO
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
-#define HAVE_API_SUPPORT_WIN32_CANCEL_SYNCHRONOUS_IO 1
-#else
-#define HAVE_API_SUPPORT_WIN32_CANCEL_SYNCHRONOUS_IO 0
-#endif
-#endif
-
-#ifndef HAVE_API_SUPPORT_WIN32_OPEN_THREAD
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
-#define HAVE_API_SUPPORT_WIN32_OPEN_THREAD 1
-#else
-#define HAVE_API_SUPPORT_WIN32_OPEN_THREAD 0
-#endif
-#endif
-
-#ifndef HAVE_API_SUPPORT_WIN32_IS_WOW64_PROCESS
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
-#define HAVE_API_SUPPORT_WIN32_IS_WOW64_PROCESS 1
-#else
-#define HAVE_API_SUPPORT_WIN32_IS_WOW64_PROCESS 0
-#endif
-#endif
-
-#ifndef HAVE_SET_THREAD_DESCRIPTION
-#define HAVE_SET_THREAD_DESCRIPTION 0
-#endif
-
-#ifndef HAVE_SET_THREAD_NAME
-// https://github.com/microsoft/xbox-live-api/blob/90b38b434d9c13ce4916c116cd28a98b239e38e2/InProgressSamples/Kits/ATGTK/ThreadHelpers.h#L21
-#if defined(_XBOX_ONE) && defined(_TITLE)
-#define HAVE_SET_THREAD_NAME 1
-#else
-#define HAVE_SET_THREAD_NAME 0
-#endif
-#endif
index 5879c06..6778143 100644 (file)
@@ -9937,12 +9937,16 @@ mono_aot_patch_info_dup (MonoJumpInfo* ji)
        return res;
 }
 
+#ifdef HOST_WIN32
+#include <mono/utils/w32subset.h>
+#endif
+
 static int
 execute_system (const char * command)
 {
        int status = 0;
 
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) && defined(HOST_WIN32)
+#if defined (HOST_WIN32) && defined (HAVE_SYSTEM)
        // We need an extra set of quotes around the whole command to properly handle commands 
        // with spaces since internally the command is called through "cmd /c.
        char * quoted_command = g_strdup_printf ("\"%s\"", command);
index a7d2dc4..2fab2d7 100644 (file)
@@ -549,7 +549,7 @@ static AgentConfig agent_config;
  * establishment and the startup of the agent thread is only done in response to
  * an event.
  */
-static gint32 inited;
+static gint32 agent_inited;
 
 #ifndef DISABLE_SOCKET_TRANSPORT
 static int conn_fd;
@@ -1046,7 +1046,7 @@ debugger_agent_init (void)
 static void
 finish_agent_init (gboolean on_startup)
 {
-       if (mono_atomic_cas_i32 (&inited, 1, 0) == 1)
+       if (mono_atomic_cas_i32 (&agent_inited, 1, 0) == 1)
                return;
 
        if (agent_config.launch) {
@@ -1088,7 +1088,7 @@ finish_agent_init (gboolean on_startup)
 static void
 mono_debugger_agent_cleanup (void)
 {
-       if (!inited)
+       if (!agent_inited)
                return;
 
        stop_debugger_thread ();
@@ -1621,7 +1621,7 @@ transport_handshake (void)
 static void
 stop_debugger_thread (void)
 {
-       if (!inited)
+       if (!agent_inited)
                return;
 
        transport_close1 ();
@@ -3858,7 +3858,7 @@ process_event (EventKind event, gpointer arg, gint32 il_offset, MonoContext *ctx
        static int ecount;
        int nevents;
 
-       if (!inited) {
+       if (!agent_inited) {
                DEBUG_PRINTF (2, "Debugger agent not initialized yet: dropping %s\n", event_to_string (event));
                return;
        }
@@ -5117,7 +5117,7 @@ debugger_agent_unhandled_exception (MonoException *exc)
        GSList *events;
        EventInfo ei;
 
-       if (!inited)
+       if (!agent_inited)
                return;
 
        memset (&ei, 0, sizeof (ei));
@@ -5163,7 +5163,7 @@ debugger_agent_handle_exception (MonoException *exc, MonoContext *throw_ctx,
 
        /* Just-In-Time debugging */
        if (!catch_ctx) {
-               if (agent_config.onuncaught && !inited) {
+               if (agent_config.onuncaught && !agent_inited) {
                        finish_agent_init (FALSE);
 
                        /*
@@ -5174,7 +5174,7 @@ debugger_agent_handle_exception (MonoException *exc, MonoContext *throw_ctx,
                        process_event (EVENT_KIND_EXCEPTION, &ei, 0, throw_ctx, events, SUSPEND_POLICY_ALL);
                        return;
                }
-       } else if (agent_config.onthrow && !inited) {
+       } else if (agent_config.onthrow && !agent_inited) {
                GSList *l;
                gboolean found = FALSE;
 
@@ -5201,7 +5201,7 @@ debugger_agent_handle_exception (MonoException *exc, MonoContext *throw_ctx,
                }
        }
 
-       if (!inited)
+       if (!agent_inited)
                return;
 
        ji = mini_jit_info_table_find (mono_domain_get (), (char *)MONO_CONTEXT_GET_IP (throw_ctx), NULL);
@@ -5263,7 +5263,7 @@ debugger_agent_begin_exception_filter (MonoException *exc, MonoContext *ctx, Mon
 {
        DebuggerTlsData *tls;
 
-       if (!inited)
+       if (!agent_inited)
                return;
 
        tls = (DebuggerTlsData *)mono_native_tls_get_value (debugger_tls_id);
@@ -5302,7 +5302,7 @@ debugger_agent_end_exception_filter (MonoException *exc, MonoContext *ctx, MonoC
 {
        DebuggerTlsData *tls;
 
-       if (!inited)
+       if (!agent_inited)
                return;
 
        tls = (DebuggerTlsData *)mono_native_tls_get_value (debugger_tls_id);
index 2f3cfcb..1b5c8f6 100644 (file)
@@ -55,6 +55,7 @@
 #include "mono/metadata/w32handle.h"
 #include "mono/metadata/callspec.h"
 #include "mono/metadata/custom-attrs-internals.h"
+#include <mono/utils/w32subset.h>
 
 #include "mini.h"
 #include "jit.h"
@@ -2739,7 +2740,7 @@ mono_main (int argc, char* argv[])
                        exit (1);
                }
 
-#if defined(HOST_WIN32) && G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#if defined(HOST_WIN32) && HAVE_API_SUPPORT_WIN32_CONSOLE
                /* Detach console when executing IMAGE_SUBSYSTEM_WINDOWS_GUI on win32 */
                if (!enable_debugging && !mono_compile_aot && mono_assembly_get_image_internal (assembly)->image_info->cli_header.nt.pe_subsys_required == IMAGE_SUBSYSTEM_WINDOWS_GUI)
                        FreeConsole ();
@@ -3222,7 +3223,7 @@ mono_parse_options (const char *options, int *ref_argc, char **ref_argv [], gboo
        return NULL;
 }
 
-#if defined(HOST_WIN32) && G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#if defined(HOST_WIN32) && HAVE_API_SUPPORT_WIN32_COMMAND_LINE_TO_ARGV
 #include <shellapi.h>
 
 static char *
index e23329d..82f25f8 100644 (file)
@@ -37,6 +37,7 @@
 #include <mono/metadata/mono-debug.h>
 #include <mono/utils/mono-mmap.h>
 #include <mono/utils/mono-state.h>
+#include <mono/utils/w32subset.h>
 
 #include "mini.h"
 #include "mini-amd64.h"
@@ -71,7 +72,7 @@ static LONG CALLBACK seh_unhandled_exception_filter(EXCEPTION_POINTERS* ep)
        return EXCEPTION_CONTINUE_SEARCH;
 }
 
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#if HAVE_API_SUPPORT_WIN32_RESET_STKOFLW
 static gpointer
 get_win32_restore_stack (void)
 {
@@ -124,7 +125,7 @@ get_win32_restore_stack (void)
        // _resetstkoflw unsupported on none desktop Windows platforms.
        return NULL;
 }
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
+#endif /* HAVE_API_SUPPORT_WIN32_RESET_STKOFLW */
 
 /*
  * Unhandled Exception Filter
index bc75fac..456698e 100644 (file)
@@ -3393,14 +3393,14 @@ interp_emit_load_const (TransformData *td, gpointer field_addr, int mt)
  *   Emit some implicit conversions which are not part of the .net spec, but are allowed by MS.NET.
  */
 static void
-emit_convert (TransformData *td, int stack_type, MonoType *ftype)
+emit_convert (TransformData *td, int stype, MonoType *ftype)
 {
        ftype = mini_get_underlying_type (ftype);
 
        // FIXME: Add more
        switch (ftype->type) {
        case MONO_TYPE_I8: {
-               switch (stack_type) {
+               switch (stype) {
                case STACK_TYPE_I4:
                        interp_add_ins (td, MINT_CONV_I8_I4);
                        break;
index 0a5ce18..19d8b2b 100644 (file)
@@ -69,6 +69,7 @@
 #include <mono/utils/mono-error-internals.h>
 #include <mono/utils/mono-state.h>
 #include <mono/utils/mono-threads-debug.h>
+#include <mono/utils/w32subset.h>
 
 #include "mini.h"
 #include "trace.h"
@@ -3216,7 +3217,7 @@ mono_free_altstack (MonoJitTlsData *tls)
                mono_mprotect (tls->stack_ovf_guard_base, tls->stack_ovf_guard_size, MONO_MMAP_READ|MONO_MMAP_WRITE);
 }
 
-#elif G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) && defined(HOST_WIN32)
+#elif HAVE_API_SUPPORT_WIN32_SET_THREAD_STACK_GUARANTEE && defined(HOST_WIN32)
 void
 mono_setup_altstack (MonoJitTlsData *tls)
 {
diff --git a/src/mono/mono/mini/mini-windows-uwp.c b/src/mono/mono/mini/mini-windows-uwp.c
deleted file mode 100644 (file)
index 97bea43..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * \file
- * UWP profiler stat support for Mono.
- *
- * Copyright 2016 Microsoft
- * Licensed under the MIT license. See LICENSE file in the project root for full license information.
- */
-#include <config.h>
-#include <glib.h>
-#include "mono/utils/mono-compiler.h"
-
-#if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
-#include <windows.h>
-
-void
-mono_runtime_setup_stat_profiler (void)
-{
-       g_unsupported_api ("OpenThread, GetThreadContext");
-       SetLastError (ERROR_NOT_SUPPORTED);
-       return;
-}
-
-void
-mono_runtime_shutdown_stat_profiler (void)
-{
-       g_unsupported_api ("OpenThread, GetThreadContext");
-       SetLastError (ERROR_NOT_SUPPORTED);
-       return;
-}
-
-static gboolean
-mono_setup_thread_context(DWORD thread_id, MonoContext *mono_context)
-{
-       memset (mono_context, 0, sizeof (MonoContext));
-       return FALSE;
-}
-
-#else /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
-
-MONO_EMPTY_SOURCE_FILE (mini_windows_uwp);
-#endif /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
-
index eca6011..12bc4c7 100644 (file)
@@ -44,6 +44,7 @@
 #include <mono/utils/mono-logger-internals.h>
 #include <mono/utils/mono-mmap.h>
 #include <mono/utils/dtrace.h>
+#include <mono/utils/w32subset.h>
 
 #include "mini.h"
 #include "mini-runtime.h"
 
 #include "jit-icalls.h"
 
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
-#include <mmsystem.h>
-#endif
-
 #define MONO_HANDLER_DELIMITER ','
 #define MONO_HANDLER_DELIMITER_LEN G_N_ELEMENTS(MONO_HANDLER_DELIMITER)-1
 
@@ -74,7 +71,7 @@ typedef struct {
        handler handler;
 } HandlerItem;
 
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#if HAVE_API_SUPPORT_WIN32_CONSOLE
 /**
 * atexit_wait_keypress:
 *
@@ -121,7 +118,7 @@ install_atexit_wait_keypress (void)
        return;
 }
 
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
+#endif /* HAVE_API_SUPPORT_WIN32_CONSOLE */
 
 // Table describing handlers that can be installed at process startup. Adding a new handler can be done by adding a new item to the table together with an install handler function.
 const HandlerItem g_handler_items[] = { { MONO_HANDLER_ATEXIT_WAIT_KEYPRESS, MONO_HANDLER_ATEXIT_WAIT_KEYPRESS_LEN, install_atexit_wait_keypress },
@@ -229,13 +226,13 @@ mono_runtime_install_custom_handlers_usage (void)
                 "   --handlers=HANDLERS            Enable handler support, HANDLERS is a comma\n"
                 "                                  separated list of available handlers to install.\n"
                 "\n"
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#if HAVE_API_SUPPORT_WIN32_CONSOLE
                 "HANDLERS is composed of:\n"
                 "    atexit-waitkeypress           Install an atexit handler waiting for a keypress\n"
                 "                                  before exiting process.\n");
 #else
                 "No handlers supported on current platform.\n");
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
+#endif /* HAVE_API_SUPPORT_WIN32_CONSOLE */
 }
 
 void
@@ -258,7 +255,6 @@ mono_cleanup_native_crash_info (void)
        return;
 }
 
-#if G_HAVE_API_SUPPORT (HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT)
 /* mono_chain_signal:
  *
  *   Call the original signal handler for the signal given by the arguments, which
@@ -273,6 +269,7 @@ MONO_SIG_HANDLER_SIGNATURE (mono_chain_signal)
        return TRUE;
 }
 
+#if !HAVE_EXTERN_DEFINED_NATIVE_CRASH_HANDLER
 #ifndef MONO_CROSS_COMPILE
 void
 mono_dump_native_crash_info (const char *signal, MonoContext *mctx, MONO_SIG_HANDLER_INFO_TYPE *info)
@@ -287,10 +284,11 @@ mono_post_native_crash_handler (const char *signal, MonoContext *mctx, MONO_SIG_
                abort ();
 }
 #endif /* !MONO_CROSS_COMPILE */
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT) */
+#endif /* !HAVE_EXTERN_DEFINED_NATIVE_CRASH_HANDLER */
 
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
-static MMRESULT        g_timer_event = 0;
+#if HAVE_API_SUPPORT_WIN32_TIMERS
+#include <mmsystem.h>
+static MMRESULT g_timer_event = 0;
 static HANDLE g_timer_main_thread = INVALID_HANDLE_VALUE;
 
 static VOID
@@ -371,7 +369,25 @@ mono_runtime_shutdown_stat_profiler (void)
        stop_profiler_timer_event ();
        return;
 }
+#elif !HAVE_EXTERN_DEFINED_WIN32_TIMERS
+void
+mono_runtime_setup_stat_profiler (void)
+{
+       g_unsupported_api ("timeGetDevCaps, timeBeginPeriod, timeEndPeriod, timeSetEvent, timeKillEvent");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return;
+}
 
+void
+mono_runtime_shutdown_stat_profiler (void)
+{
+       g_unsupported_api ("timeGetDevCaps, timeBeginPeriod, timeEndPeriod, timeSetEvent, timeKillEvent");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return;
+}
+#endif /* HAVE_API_SUPPORT_WIN32_TIMERS */
+
+#if HAVE_API_SUPPORT_WIN32_OPEN_THREAD
 gboolean
 mono_setup_thread_context(DWORD thread_id, MonoContext *mono_context)
 {
@@ -396,7 +412,15 @@ mono_setup_thread_context(DWORD thread_id, MonoContext *mono_context)
        CloseHandle (handle);
        return TRUE;
 }
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
+#elif !HAVE_EXTERN_DEFINED_WIN32_OPEN_THREAD
+gboolean
+mono_setup_thread_context (DWORD thread_id, MonoContext *mono_context)
+{
+       g_unsupported_api ("OpenThread");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return FALSE;
+}
+#endif /* HAVE_API_SUPPORT_WIN32_OPEN_THREAD */
 
 gboolean
 mono_thread_state_init_from_handle (MonoThreadUnwindState *tctx, MonoThreadInfo *info, void *sigctx)
index 5d13fda..41dffe4 100644 (file)
@@ -1,25 +1,12 @@
 /**
- * SIMD Intrinsics support for netcore
+ * SIMD Intrinsics support for netcore.
+ * Only LLVM is supported as a backend.
  */
 
 #include <config.h>
 #include <mono/utils/mono-compiler.h>
 #include <mono/metadata/icall-decl.h>
 #include "mini.h"
-
-#if defined(DISABLE_JIT)
-
-void
-mono_simd_intrinsics_init (void)
-{
-}
-
-#else
-
-/*
- * Only LLVM is supported as a backend.
- */
-
 #include "mini-runtime.h"
 #include "ir-emit.h"
 #ifdef ENABLE_LLVM
@@ -32,6 +19,15 @@ mono_simd_intrinsics_init (void)
 
 #if defined (MONO_ARCH_SIMD_INTRINSICS) && defined(ENABLE_NETCORE)
 
+#if defined(DISABLE_JIT)
+
+void
+mono_simd_intrinsics_init (void)
+{
+}
+
+#else
+
 #define MSGSTRFIELD(line) MSGSTRFIELD1(line)
 #define MSGSTRFIELD1(line) str##line
 static const struct msgstr_t {
@@ -2168,14 +2164,8 @@ mono_simd_simplify_indirection (MonoCompile *cfg)
 {
 }
 
-#else
-
-MONO_EMPTY_SOURCE_FILE (simd_intrinsics_netcore);
-
-#endif
-
 #endif /* DISABLE_JIT */
-
+#endif /* MONO_ARCH_SIMD_INTRINSICS */
 
 #if defined(ENABLE_NETCORE) && defined(TARGET_AMD64)
 void
@@ -2187,3 +2177,5 @@ ves_icall_System_Runtime_Intrinsics_X86_X86Base___cpuidex (int abcd[4], int func
 #endif
 }
 #endif
+
+MONO_EMPTY_SOURCE_FILE (simd_intrinsics_netcore);
index cd1aa96..8d58689 100644 (file)
@@ -2658,4 +2658,5 @@ on_exit:
 }
 
 #endif /* DISABLE_JIT */
+MONO_EMPTY_SOURCE_FILE (simd_intrinsics);
 #endif /* MONO_ARCH_SIMD_INTRINSICS */
index fa3b539..ca9c86e 100644 (file)
@@ -98,7 +98,6 @@ monoutils_sources = \
        mono-mmap-wasm.c                \
        mono-mmap.h             \
        mono-mmap-internals.h   \
-       mono-mmap-windows-internals.h   \
        mono-os-mutex.h         \
        mono-os-mutex.c         \
        mono-flight-recorder.h          \
diff --git a/src/mono/mono/utils/mono-dl-windows-uwp.c b/src/mono/mono/utils/mono-dl-windows-uwp.c
deleted file mode 100644 (file)
index e3e5ddf..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * \file
- * UWP dl support for Mono.
- *
- * Copyright 2016 Microsoft
- * Licensed under the MIT license. See LICENSE file in the project root for full license information.
-*/
-#include <config.h>
-#include <glib.h>
-#include "mono/utils/mono-compiler.h"
-
-#if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
-#include <windows.h>
-#include "mono/utils/mono-dl-windows-internals.h"
-
-void*
-mono_dl_lookup_symbol_in_process (const char *symbol_name)
-{
-       g_unsupported_api ("EnumProcessModules");
-       SetLastError (ERROR_NOT_SUPPORTED);
-
-       return NULL;
-}
-
-char*
-mono_dl_current_error_string (void)
-{
-       char *ret = NULL;
-       TCHAR buf [1024];
-       DWORD code = GetLastError ();
-
-       if (!FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
-               code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buf, G_N_ELEMENTS(buf) - 1, NULL))
-               buf[0] = TEXT('\0');
-
-       ret = u16to8 (buf);
-       return ret;
-}
-
-#else /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
-
-MONO_EMPTY_SOURCE_FILE (mono_dl_windows_uwp);
-#endif /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
index 966d71a..05ba1cc 100644 (file)
 
 #if defined(HOST_WIN32)
 
-#include "mono/utils/mono-dl.h"
-#include "mono/utils/mono-dl-windows-internals.h"
-#include "mono/utils/mono-embed.h"
-#include "mono/utils/mono-path.h"
-#include "mono/metadata/w32subset.h"
+#include <mono/utils/mono-dl.h>
+#include <mono/utils/mono-dl-windows-internals.h>
+#include <mono/utils/mono-embed.h>
+#include <mono/utils/mono-path.h>
 
 #include <stdlib.h>
 #include <stdio.h>
@@ -28,6 +27,8 @@
 #include <windows.h>
 #include <psapi.h>
 
+#include <mono/utils/w32subset.h>
+
 const char*
 mono_dl_get_so_prefix (void)
 {
@@ -61,7 +62,7 @@ mono_dl_open_file (const char *file, int flags)
 #elif HAVE_API_SUPPORT_WIN32_LOAD_PACKAGED_LIBRARY
                hModule = LoadPackagedLibrary (file_utf16, NULL);
 #else
-               g_assert_not_reached ();
+#error unknown Windows variant
 #endif
                if (!hModule)
                        last_error = GetLastError ();
@@ -78,7 +79,7 @@ mono_dl_open_file (const char *file, int flags)
 #if HAVE_API_SUPPORT_WIN32_GET_MODULE_HANDLE
                hModule = GetModuleHandleW (NULL);
 #else
-               g_assert_not_reached ();
+#error unknown Windows variant
 #endif
        }
        return hModule;
@@ -91,7 +92,7 @@ mono_dl_close_handle (MonoDl *module)
                FreeLibrary ((HMODULE)module->handle);
 }
 
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#if HAVE_API_SUPPORT_WIN32_ENUM_PROCESS_MODULES
 void*
 mono_dl_lookup_symbol_in_process (const char *symbol_name)
 {
@@ -139,7 +140,15 @@ mono_dl_lookup_symbol_in_process (const char *symbol_name)
        g_free (modules);
        return NULL;
 }
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
+#elif !HAVE_EXTERN_DEFINED_WIN32_ENUM_PROCESS_MODULES
+void*
+mono_dl_lookup_symbol_in_process (const char *symbol_name)
+{
+       g_unsupported_api ("EnumProcessModules");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return NULL;
+}
+#endif /* HAVE_API_SUPPORT_WIN32_ENUM_PROCESS_MODULES */
 
 void*
 mono_dl_lookup_symbol (MonoDl *module, const char *symbol_name)
@@ -166,25 +175,36 @@ mono_dl_convert_flags (int mono_flags, int native_flags)
        return native_flags;
 }
 
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#if HAVE_API_SUPPORT_WIN32_FORMAT_MESSAGE
 char*
 mono_dl_current_error_string (void)
 {
        char* ret = NULL;
-       wchar_t* buf = NULL;
        DWORD code = GetLastError ();
-
-       if (FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
-               code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&buf, 0, NULL))
-       {
-               ret = g_utf16_to_utf8 (buf, wcslen(buf), NULL, NULL, NULL);
+#if HAVE_API_SUPPORT_WIN32_LOCAL_ALLOC_FREE
+       PWSTR buf = NULL;
+       if (FormatMessageW (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
+               code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (PWSTR)&buf, 0, NULL)) {
+               ret = u16to8 (buf);
                LocalFree (buf);
-       } else {
-               g_assert_not_reached ();
        }
+#else
+       WCHAR local_buf [1024];
+       if (!FormatMessageW (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
+               code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), local_buf, G_N_ELEMENTS (local_buf) - 1, NULL) )
+               local_buf [0] = TEXT('\0');
+
+       ret = u16to8 (local_buf)
+#endif
        return ret;
 }
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
+#elif !HAVE_EXTERN_DEFINED_WIN32_FORMAT_MESSAGE
+char *
+mono_dl_current_error_string (void)
+{
+       return g_strdup_printf ("GetLastError=%d. FormatMessage not supported.", GetLastError ());
+}
+#endif /* HAVE_API_SUPPORT_WIN32_FORMAT_MESSAGE */
 
 int
 mono_dl_get_executable_path (char *buf, int buflen)
diff --git a/src/mono/mono/utils/mono-mmap-windows-internals.h b/src/mono/mono/utils/mono-mmap-windows-internals.h
deleted file mode 100644 (file)
index 3076a51..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- * \file
- */
-
-#ifndef __MONO_UTILS_MMAP_WINDOWS_H__
-#define __MONO_UTILS_MMAP_WINDOWS_H__
-
-#include <config.h>
-#include <glib.h>
-
-#ifdef HOST_WIN32
-#include "mono/utils/mono-mmap.h"
-#include "mono/utils/mono-mmap-internals.h"
-
-int
-mono_mmap_win_prot_from_flags (int flags);
-#endif /* HOST_WIN32 */
-#endif /* __MONO_UTILS_MMAP_WINDOWS_H__ */
-
index 3d10a1f..a7612ad 100644 (file)
 #include <glib.h>
 
 #if defined(HOST_WIN32)
+#include <io.h>
 #include <windows.h>
-#include "mono/utils/mono-mmap-windows-internals.h"
 #include <mono/utils/mono-counters.h>
-#include <io.h>
+#include "mono/utils/mono-mmap.h"
+#include "mono/utils/mono-mmap-internals.h"
+#include <mono/utils/w32subset.h>
 
 static void *malloced_shared_area;
 
@@ -136,19 +138,50 @@ mono_vfree (void *addr, size_t length, MonoMemAccountType type)
        return 0;
 }
 
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
-
+#if HAVE_API_SUPPORT_WIN32_FILE_MAPPING || HAVE_API_SUPPORT_WIN32_FILE_MAPPING_FROM_APP
 static void
-remove_trailing_whitespace_utf16 (wchar_t *s)
+remove_trailing_whitespace_utf8 (gchar *s)
 {
-       gsize length = wcslen (s);
-       gsize const original_length = length;
-       while (length > 0 && iswspace (s [length - 1]))
+       glong length = g_utf8_strlen (s, -1);
+       glong const original_length = length;
+       while (length > 0 && g_ascii_isspace (s [length - 1]))
                --length;
        if (length != original_length)
                s [length] = 0;
 }
 
+#if HAVE_API_SUPPORT_WIN32_FORMAT_MESSAGE
+gchar *
+format_win32_error_string (gint32 win32_error)
+{
+       gchar *ret = NULL;
+#if HAVE_API_SUPPORT_WIN32_LOCAL_ALLOC_FREE
+       PWSTR buf = NULL;
+       if (FormatMessageW (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
+               win32_error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (PWSTR)&buf, 0, NULL)) {
+               ret = u16to8 (buf);
+               LocalFree (buf);
+       }
+#else
+       WCHAR local_buf [1024];
+       if (!FormatMessageW (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
+               win32_error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), local_buf, G_N_ELEMENTS (local_buf) - 1, NULL) )
+               local_buf [0] = TEXT('\0');
+
+       ret = u16to8 (local_buf)
+#endif
+       if (ret)
+               remove_trailing_whitespace_utf8 (ret);
+       return ret;
+}
+#elif !HAVE_EXTERN_DEFINED_WIN32_FORMAT_MESSAGE
+gchar *
+format_win32_error_string (gint32 error_code)
+{
+       return g_strdup_printf ("GetLastError=%d. FormatMessage not supported.", GetLastError ());
+}
+#endif /* HAVE_API_SUPPORT_WIN32_FORMAT_MESSAGE */
+
 void*
 mono_file_map_error (size_t length, int flags, int fd, guint64 offset, void **ret_handle,
        const char *filepath, char **error_message)
@@ -182,7 +215,7 @@ mono_file_map_error (size_t length, int flags, int fd, guint64 offset, void **re
        // See https://docs.microsoft.com/en-us/windows/desktop/Memory/creating-a-file-mapping-object.
        const guint64 mapping_length = offset + length;
 
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#if HAVE_API_SUPPORT_WIN32_FILE_MAPPING
 
        failed_function = "CreateFileMapping";
        mapping = CreateFileMappingW (file, NULL, prot, (DWORD)(mapping_length >> 32), (DWORD)mapping_length, NULL);
@@ -194,7 +227,7 @@ mono_file_map_error (size_t length, int flags, int fd, guint64 offset, void **re
        if (ptr == NULL)
                goto exit;
 
-#elif G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
+#elif HAVE_API_SUPPORT_WIN32_FILE_MAPPING_FROM_APP
 
        failed_function = "CreateFileMappingFromApp";
        mapping = CreateFileMappingFromApp (file, NULL, prot, mapping_length, NULL);
@@ -216,13 +249,10 @@ exit:
                if (mapping)
                        CloseHandle (mapping);
                if (error_message) {
-                       WCHAR win32_error_string [100] = { 0 }; // FIXME LocalFree not initially in UWP but it is now.
-                       FormatMessageW (FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM,
-                               0, win32_error, 0, win32_error_string, 99, NULL);
-                       // Win32 error messages end with an unsightly newline.
-                       remove_trailing_whitespace_utf16 (win32_error_string);
-                       *error_message = g_strdup_printf ("%s failed file:%s length:0x%IX offset:0x%" PRIX64 " function:%s error:%ls(0x%X)\n",
+                       gchar *win32_error_string = format_win32_error_string (win32_error);
+                       *error_message = g_strdup_printf ("%s failed file:%s length:0x%IX offset:0x%I64X function:%s error:%s(0x%X)\n",
                                __func__, filepath ? filepath : "", length, offset, failed_function, win32_error_string, win32_error);
+                       g_free (win32_error_string);
                }
                SetLastError (win32_error);
        }
@@ -230,21 +260,39 @@ exit:
        return ptr;
 }
 
+int
+mono_file_unmap (void *addr, void *handle)
+{
+       UnmapViewOfFile (addr);
+       CloseHandle (handle);
+       return 0;
+}
+#elif !HAVE_EXTERN_DEFINED_WIN32_FILE_MAPPING && !HAVE_EXTERN_DEFINED_WIN32_FILE_MAPPING_FROM_APP
 void*
-mono_file_map (size_t length, int flags, int fd, guint64 offset, void **ret_handle)
+mono_file_map_error (size_t length, int flags, int fd, guint64 offset, void **ret_handle,
+       const char *filepath, char **error_message)
 {
-       return mono_file_map_error (length, flags, fd, offset, ret_handle, NULL, NULL);
+       g_unsupported_api ("CreateFileMapping");
+       *ret_handle = NULL;
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return NULL;
 }
 
 int
 mono_file_unmap (void *addr, void *handle)
 {
-       UnmapViewOfFile (addr);
-       CloseHandle (handle);
+       g_unsupported_api ("UnmapViewOfFile");
+       SetLastError (ERROR_NOT_SUPPORTED);
+
        return 0;
 }
+#endif /* HAVE_API_SUPPORT_WIN32_FILE_MAPPING || HAVE_API_SUPPORT_WIN32_FILE_MAPPING_FROM_APP */
 
-#endif // G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
+void*
+mono_file_map (size_t length, int flags, int fd, guint64 offset, void **ret_handle)
+{
+       return mono_file_map_error (length, flags, fd, offset, ret_handle, NULL, NULL);
+}
 
 int
 mono_mprotect (void *addr, size_t length, int flags)
index a2962c1..bf06c79 100644 (file)
@@ -33,6 +33,7 @@
 #else
 #include <mono/utils/mono-os-wait.h>
 #endif
+#include <mono/utils/w32subset.h>
 
 #define MONO_HAS_SEMAPHORES 1
 
@@ -284,18 +285,27 @@ mono_os_sem_post (MonoSemType *sem)
 
 typedef HANDLE MonoSemType;
 
+#if HAVE_API_SUPPORT_WIN32_CREATE_SEMAPHORE || HAVE_API_SUPPORT_WIN32_CREATE_SEMAPHORE_EX
 static inline void
 mono_os_sem_init (MonoSemType *sem, int value)
 {
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
-       *sem = CreateSemaphore (NULL, value, 0x7FFFFFFF, NULL);
-#else
-       *sem = CreateSemaphoreEx (NULL, value, 0x7FFFFFFF, NULL, 0, SEMAPHORE_ALL_ACCESS);
+#if HAVE_API_SUPPORT_WIN32_CREATE_SEMAPHORE
+       *sem = CreateSemaphoreW (NULL, value, 0x7FFFFFFF, NULL);
+#elif HAVE_API_SUPPORT_WIN32_CREATE_SEMAPHORE_EX
+       *sem = CreateSemaphoreExW (NULL, value, 0x7FFFFFFF, NULL, 0, SEMAPHORE_ALL_ACCESS);
 #endif
-
        if (G_UNLIKELY (*sem == NULL))
                g_error ("%s: CreateSemaphore failed with error %d", __func__, GetLastError ());
 }
+#elif !HAVE_EXTERN_DEFINED_WIN32_CREATE_SEMAPHORE && !HAVE_EXTERN_DEFINED_WIN32_CREATE_SEMAPHORE_EX
+static inline void
+mono_os_sem_init (MonoSemType *sem, int value)
+{
+       *sem = NULL;
+       g_unsupported_api ("CreateSemaphore, CreateSemaphoreEx");
+       SetLastError (ERROR_NOT_SUPPORTED);
+}
+#endif /* HAVE_API_SUPPORT_WIN32_CREATE_SEMAPHORE || HAVE_API_SUPPORT_WIN32_CREATE_SEMAPHORE_EX */
 
 static inline void
 mono_os_sem_destroy (MonoSemType *sem)
diff --git a/src/mono/mono/utils/mono-os-wait-win32-uwp.c b/src/mono/mono/utils/mono-os-wait-win32-uwp.c
deleted file mode 100644 (file)
index 79ecfd5..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * \file
- * UWP OS wait support for Mono.
- *
- * Copyright 2017 Microsoft
- * Licensed under the MIT license. See LICENSE file in the project root for full license information.
-*/
-#include <config.h>
-#include <glib.h>
-#include "mono/utils/mono-compiler.h"
-
-#if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
-#include <windows.h>
-
-DWORD
-mono_win32_msg_wait_for_multiple_objects_ex (DWORD count, CONST HANDLE *handles, DWORD timeout, DWORD wakeMask, DWORD flags)
-{
-       g_unsupported_api ("MsgWaitForMultipleObjectsEx");
-       SetLastError (ERROR_NOT_SUPPORTED);
-
-       return WAIT_FAILED;
-}
-
-DWORD
-mono_coop_win32_msg_wait_for_multiple_objects_ex (DWORD count, CONST HANDLE *handles, DWORD timeout, DWORD wakeMask, DWORD flags)
-{
-       g_unsupported_api ("MsgWaitForMultipleObjectsEx");
-       SetLastError (ERROR_NOT_SUPPORTED);
-
-       return WAIT_FAILED;
-}
-
-#else /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
-
-MONO_EMPTY_SOURCE_FILE (mono_os_wait_win32_uwp);
-#endif /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
index 4bd9035..b006196 100644 (file)
@@ -13,8 +13,8 @@
 #include "mono-threads-debug.h"
 #include "mono-logger-internals.h"
 #include "mono-error-internals.h"
-#include <mono/metadata/w32subset.h>
 #include <mono/utils/checked-build.h>
+#include <mono/utils/w32subset.h>
 
 /* Empty handler only used to detect interrupt state of current thread. */
 /* Needed in order to correctly avoid entering wait methods under */
@@ -222,7 +222,6 @@ mono_coop_win32_wait_for_multiple_objects_ex (DWORD count, CONST HANDLE *handles
 }
 
 #if HAVE_API_SUPPORT_WIN32_SIGNAL_OBJECT_AND_WAIT
-
 static DWORD
 win32_signal_object_and_wait_interrupt_checked (MonoThreadInfo *info, HANDLE toSignal, HANDLE toWait, DWORD timeout, BOOL alertable)
 {
@@ -250,6 +249,15 @@ win32_signal_object_and_wait (HANDLE toSignal, HANDLE toWait, DWORD timeout, BOO
 
        return result;
 }
+#elif !HAVE_EXTERN_DEFINED_WIN32_SIGNAL_OBJECT_AND_WAIT
+static DWORD
+win32_signal_object_and_wait (HANDLE toSignal, HANDLE toWait, DWORD timeout, BOOL alertable, BOOL cooperative)
+{
+       g_unsupported_api ("SignalObjectAndWait");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return WAIT_FAILED;
+}
+#endif /* HAVE_API_SUPPORT_WIN32_SIGNAL_OBJECT_AND_WAIT */
 
 DWORD
 mono_win32_signal_object_and_wait (HANDLE toSignal, HANDLE toWait, DWORD timeout, BOOL alertable)
@@ -263,8 +271,6 @@ mono_coop_win32_signal_object_and_wait (HANDLE toSignal, HANDLE toWait, DWORD ti
        return win32_signal_object_and_wait (toSignal, toWait, timeout, alertable, TRUE);
 }
 
-#endif /* HAVE_API_SUPPORT_WIN32_SIGNAL_OBJECT_AND_WAIT */
-
 #if HAVE_API_SUPPORT_WIN32_MSG_WAIT_FOR_MULTIPLE_OBJECTS
 static DWORD
 win32_msg_wait_for_multiple_objects_ex_interrupt_checked (MonoThreadInfo *info, DWORD count, CONST HANDLE *handles, DWORD timeout, DWORD wakeMask, DWORD flags, BOOL alertable)
@@ -294,6 +300,15 @@ win32_msg_wait_for_multiple_objects_ex (DWORD count, CONST HANDLE *handles, DWOR
 
        return result;
 }
+#elif !HAVE_EXTERN_DEFINED_WIN32_MSG_WAIT_FOR_MULTIPLE_OBJECTS
+static DWORD
+win32_msg_wait_for_multiple_objects_ex (DWORD count, CONST HANDLE *handles, DWORD timeout, DWORD wakeMask, DWORD flags, BOOL cooperative)
+{
+       g_unsupported_api ("MsgWaitForMultipleObjectsEx");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return WAIT_FAILED;
+}
+#endif /* HAVE_API_SUPPORT_WIN32_MSG_WAIT_FOR_MULTIPLE_OBJECTS */
 
 DWORD
 mono_win32_msg_wait_for_multiple_objects_ex (DWORD count, CONST HANDLE *handles, DWORD timeout, DWORD wakeMask, DWORD flags)
@@ -306,7 +321,6 @@ mono_coop_win32_msg_wait_for_multiple_objects_ex (DWORD count, CONST HANDLE *han
 {
        return win32_msg_wait_for_multiple_objects_ex (count, handles, timeout, wakeMask, flags, TRUE);
 }
-#endif /* HAVE_API_SUPPORT_WIN32_MSG_WAIT_FOR_MULTIPLE_OBJECTS */
 
 static DWORD
 win32_wsa_wait_for_multiple_events_interrupt_checked (MonoThreadInfo *info, DWORD count, const WSAEVENT FAR *handles, BOOL waitAll, DWORD timeout, BOOL alertable)
diff --git a/src/mono/mono/utils/mono-proclib-windows-uwp.c b/src/mono/mono/utils/mono-proclib-windows-uwp.c
deleted file mode 100644 (file)
index 15a7cb2..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- * \file
- * UWP proclib support for Mono.
- *
- * Copyright 2016 Microsoft
- * Licensed under the MIT license. See LICENSE file in the project root for full license information.
-*/
-#include <config.h>
-#include <glib.h>
-#include "mono/utils/mono-compiler.h"
-
-#if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
-#include <windows.h>
-#include <mono/utils/mono-proclib.h>
-
-gint32
-mono_cpu_usage (MonoCpuUsageState *prev)
-{
-       gint32 cpu_usage = 0;
-       gint64 cpu_total_time;
-       gint64 cpu_busy_time;
-       guint64 idle_time;
-       guint64 kernel_time;
-       guint64 user_time;
-       guint64 current_time;
-       guint64 creation_time;
-       guint64 exit_time;
-
-       GetSystemTimeAsFileTime ((FILETIME*)&current_time);
-       if (!GetProcessTimes (GetCurrentProcess (), (FILETIME*)&creation_time, (FILETIME*)&exit_time, (FILETIME*)&kernel_time, (FILETIME*)&user_time)) {
-               g_error ("GetProcessTimes() failed, error code is %d\n", GetLastError ());
-               return -1;
-       }
-
-       // GetProcessTimes user_time is a sum of user time spend by all threads in the process.
-       // This means that the total user time can be more than real time. In order to adjust for this
-       // the total available time that we can be scheduled depends on the number of available cores.
-       // For example, having 2 threads running 100% on a 2 core system for 100 ms will return a user_time of 200ms
-       // but the current_time - creation_time will only be 100ms but by adjusting the available time based on number of
-       // of availalbe cores will gives use the total load of the process.
-       guint64 total_available_time = (current_time - creation_time) * mono_cpu_count ();
-
-       idle_time = total_available_time - (kernel_time + user_time);
-
-       cpu_total_time = (gint64)((idle_time - (prev ? prev->idle_time : 0)) + (user_time - (prev ? prev->user_time : 0)) + (kernel_time - (prev ? prev->kernel_time : 0)));
-       cpu_busy_time = (gint64)(cpu_total_time - (idle_time - (prev ? prev->idle_time : 0)));
-
-       if (prev) {
-               prev->idle_time = idle_time;
-               prev->kernel_time = kernel_time;
-               prev->user_time = user_time;
-       }
-
-       if (cpu_total_time > 0 && cpu_busy_time > 0)
-               cpu_usage = (gint32)(cpu_busy_time * 100 / cpu_total_time);
-
-       return cpu_usage;
-}
-
-#else /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
-
-MONO_EMPTY_SOURCE_FILE (mono_proclib_windows_uwp);
-#endif /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
index df108ae..cc56ecb 100644 (file)
@@ -11,7 +11,8 @@
 
 #ifdef HOST_WIN32
 #include <windows.h>
-#include "mono/utils/mono-proclib.h"
+#include <mono/utils/mono-proclib.h>
+#include <mono/utils/w32subset.h>
 
 int
 mono_process_current_pid ()
@@ -34,13 +35,8 @@ mono_cpu_count (void)
 /*
  * This function returns the cpu usage in percentage,
  * normalized on the number of cores.
- *
- * Warning : the percentage returned can be > 100%. This
- * might happens on systems like Android which, for
- * battery and performance reasons, shut down cores and
- * lie about the number of active cores.
  */
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#if HAVE_API_SUPPORT_WIN32_GET_SYSTEM_TIMES
 gint32
 mono_cpu_usage (MonoCpuUsageState *prev)
 {
@@ -70,7 +66,59 @@ mono_cpu_usage (MonoCpuUsageState *prev)
 
        return cpu_usage;
 }
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
+#elif HAVE_API_SUPPORT_WIN32_GET_SYSTEM_TIME_AS_FILE_TIME && HAVE_API_SUPPORT_WIN32_GET_PROCESS_TIMES
+gint32
+mono_cpu_usage (MonoCpuUsageState *prev)
+{
+       gint32 cpu_usage = 0;
+       gint64 cpu_total_time;
+       gint64 cpu_busy_time;
+       guint64 idle_time;
+       guint64 kernel_time;
+       guint64 user_time;
+       guint64 current_time;
+       guint64 creation_time;
+       guint64 exit_time;
+
+       GetSystemTimeAsFileTime ((FILETIME*)&current_time);
+       if (!GetProcessTimes (GetCurrentProcess (), (FILETIME*)&creation_time, (FILETIME*)&exit_time, (FILETIME*)&kernel_time, (FILETIME*)&user_time)) {
+               g_error ("GetProcessTimes() failed, error code is %d\n", GetLastError ());
+               return -1;
+       }
+
+       // GetProcessTimes user_time is a sum of user time spend by all threads in the process.
+       // This means that the total user time can be more than real time. In order to adjust for this
+       // the total available time that we can be scheduled depends on the number of available cores.
+       // For example, having 2 threads running 100% on a 2 core system for 100 ms will return a user_time of 200ms
+       // but the current_time - creation_time will only be 100ms but by adjusting the available time based on number of
+       // of availalbe cores will gives use the total load of the process.
+       guint64 total_available_time = (current_time - creation_time) * mono_cpu_count ();
+
+       idle_time = total_available_time - (kernel_time + user_time);
+
+       cpu_total_time = (gint64)((idle_time - (prev ? prev->idle_time : 0)) + (user_time - (prev ? prev->user_time : 0)) + (kernel_time - (prev ? prev->kernel_time : 0)));
+       cpu_busy_time = (gint64)(cpu_total_time - (idle_time - (prev ? prev->idle_time : 0)));
+
+       if (prev) {
+               prev->idle_time = idle_time;
+               prev->kernel_time = kernel_time;
+               prev->user_time = user_time;
+       }
+
+       if (cpu_total_time > 0 && cpu_busy_time > 0)
+               cpu_usage = (gint32)(cpu_busy_time * 100 / cpu_total_time);
+
+       return cpu_usage;
+}
+#elif !HAVE_EXTERN_DEFINED_WIN32_GET_SYSTEM_TIMES && !HAVE_EXTERN_DEFINED_WIN32_GET_SYSTEM_TIME_AS_FILE_TIME && !HAVE_EXTERN_DEFINED_WIN32_GET_PROCESS_TIMES
+gint32
+mono_cpu_usage (MonoCpuUsageState *prev)
+{
+       g_unsupported_api ("GetSystemTimes, GetSystemTimeAsFileTime, GetProcessTimes");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return -1;
+}
+#endif /* HAVE_API_SUPPORT_WIN32_GET_SYSTEM_TIMES */
 
 #else
 
index 0ec8017..6523674 100644 (file)
@@ -17,8 +17,8 @@
 #include <mono/utils/mono-threads-coop.h>
 #include <mono/utils/mono-threads-debug.h>
 #include <mono/utils/mono-os-wait.h>
-#include <mono/metadata/w32subset.h>
 #include <limits.h>
+#include <mono/utils/w32subset.h>
 
 enum Win32APCInfo {
        WIN32_APC_INFO_CLEARED = 0,
@@ -76,6 +76,7 @@ abort_apc (ULONG_PTR param)
 {
        THREADS_INTERRUPT_DEBUG ("%06d - abort_apc () called", GetCurrentThreadId ());
 
+#if HAVE_API_SUPPORT_WIN32_CANCEL_IO || HAVE_API_SUPPORT_WIN32_CANCEL_IO_EX
        MonoThreadInfo *info = mono_thread_info_current_unchecked ();
        if (info) {
                // Check if pending interrupt is still relevant and current thread has not left alertable wait region.
@@ -88,12 +89,17 @@ abort_apc (ULONG_PTR param)
                        HANDLE io_handle = (HANDLE)info->win32_apc_info_io_handle;
                        if (io_handle != INVALID_HANDLE_VALUE) {
                                // In order to break IO waits, cancel all outstanding IO requests.
-                               // Start to cancel IO requests for the registered IO handle issued by current thread.
                                // NOTE, this is NOT a blocking call.
+#if HAVE_API_SUPPORT_WIN32_CANCEL_IO
+                               // Start to cancel IO requests for the registered IO handle issued by current thread.
                                CancelIo (io_handle);
+#elif HAVE_API_SUPPORT_WIN32_CANCEL_IO_EX
+                               CancelIoEx (io_handle, NULL);
+#endif
                        }
                }
        }
+#endif /* HAVE_API_SUPPORT_WIN32_CANCEL_IO || HAVE_API_SUPPORT_WIN32_CANCEL_IO_EX */
 }
 
 // Attempt to cancel sync blocking IO on abort syscall requests.
@@ -443,10 +449,6 @@ mono_native_thread_join_handle (HANDLE thread_handle, gboolean close_handle)
        return res != WAIT_FAILED;
 }
 
-/*
- * Can't OpenThread on UWP until SDK 15063 (our minspec today is 10240),
- * but this function doesn't seem to be used on Windows anyway
- */
 #if HAVE_API_SUPPORT_WIN32_OPEN_THREAD
 gboolean
 mono_native_thread_join (MonoNativeThreadId tid)
@@ -458,6 +460,14 @@ mono_native_thread_join (MonoNativeThreadId tid)
 
        return mono_native_thread_join_handle (handle, TRUE);
 }
+#elif !HAVE_EXTERN_DEFINED_WIN32_OPEN_THREAD
+gboolean
+mono_native_thread_join (MonoNativeThreadId tid)
+{
+       g_unsupported_api ("OpenThread");
+       SetLastError (ERROR_NOT_SUPPORTED);
+       return FALSE;
+}
 #endif
 
 void
@@ -517,7 +527,7 @@ gboolean
 mono_threads_platform_in_critical_region (THREAD_INFO_TYPE *info)
 {
        gboolean ret = FALSE;
-#if SIZEOF_VOID_P == 4 && HAVE_API_SUPPORT_WIN32_OPEN_THREAD
+#if SIZEOF_VOID_P == 4 && HAVE_API_SUPPORT_WIN32_IS_WOW64_PROCESS && HAVE_API_SUPPORT_WIN32_OPEN_THREAD
 /* FIXME On cygwin these are not defined */
 #if defined(CONTEXT_EXCEPTION_REQUEST) && defined(CONTEXT_EXCEPTION_REPORTING) && defined(CONTEXT_EXCEPTION_ACTIVE)
        if (is_wow64 && thread_is_cooperative_suspend_aware (info)) {
index c47a33d..8a5b0ef 100644 (file)
@@ -22,6 +22,7 @@
 #include <mono/utils/os-event.h>
 #include <mono/utils/refcount.h>
 #include <mono/utils/mono-error-internals.h>
+#include <mono/utils/w32subset.h>
 
 #include <glib.h>
 #include <config.h>
@@ -73,10 +74,10 @@ typedef gsize (*MonoThreadStart)(gpointer);
 
 #endif /* #ifdef HOST_WIN32 */
 
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) && defined(HOST_WIN32) && defined(_DEBUG)
+#if HAVE_API_SUPPORT_WIN32_SET_THREAD_STACK_GUARANTEE && defined(HOST_WIN32) && defined(_DEBUG)
 // Need more memory on Windows debug build (due to less optimization) to handle stack overflows.
 #define MONO_STACK_OVERFLOW_GUARD_SIZE (64 * 1024)
-#elif G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) && defined(HOST_WIN32)
+#elif HAVE_API_SUPPORT_WIN32_SET_THREAD_STACK_GUARANTEE && defined(HOST_WIN32)
 #define MONO_STACK_OVERFLOW_GUARD_SIZE (32 * 1024)
 #elif defined(HOST_WIN32)
 // Not supported.
index 0491e03..671cd3a 100644 (file)
@@ -63,7 +63,22 @@ g_static_assert (TLS_KEY_DOMAIN == 0);
 #define mono_native_tls_free TlsFree
 #define mono_native_tls_set_value TlsSetValue
 
+#ifdef HAVE_WINTERNL_H
 #include <winternl.h>
+#else
+typedef struct _TEB {
+       PVOID Reserved1[12];
+       PVOID ProcessEnvironmentBlock;
+       PVOID Reserved2[399];
+       BYTE Reserved3[1952];
+       PVOID TlsSlots[64];
+       BYTE Reserved4[8];
+       PVOID Reserved5[26];
+       PVOID ReservedForOle;
+       PVOID Reserved6[4];
+       PVOID TlsExpansionSlots;
+} TEB, *PTEB;
+#endif
 
 // TlsGetValue always writes 0 to LastError. Which can cause problems. This never changes LastError.
 //
index ce9675d..2ae7a96 100644 (file)
@@ -7,14 +7,9 @@
 //  is running when the exception is raised. There is
 //  no way to get the thread name and they do not appear in ETW traces.
 //
-// XboxOne: SetThreadName(thread handle, unicode)
-//   This works with or without a debugger and can be retrieved with GetThreadName.
-//   Sometimes an inline function SetThreadDescription for source compat with next.
-//   https://github.com/microsoft/xbox-live-api/blob/90b38b434d9c13ce4916c116cd28a98b239e38e2/InProgressSamples/Kits/ATGTK/ThreadHelpers.h#L21
-//
 // Windows 10 1607 or newer (according to documentation, or Creators Update says https://randomascii.wordpress.com/2015/10/26/thread-naming-in-windows-time-for-something-better).
 //  SetThreadDescription(thread handle, unicode)
-//  This is like XboxOne -- works with or without debugger, can be retrieved
+//  Works with or without debugger, can be retrieved
 //  with GetThreadDescription, and appears in ETW traces.
 //  See https://randomascii.wordpress.com/2015/10/26/thread-naming-in-windows-time-for-something-better.
 //
@@ -36,7 +31,7 @@
 WINBASEAPI HMODULE WINAPI LoadLibraryExW (PCWSTR, HANDLE, DWORD);
 #define LOAD_LIBRARY_SEARCH_SYSTEM32        0x00000800
 
-#include "mono/metadata/w32subset.h"
+#include <mono/utils/w32subset.h>
 
 // This is compiler specific because of the use of __try / __except.
 #if _MSC_VER
@@ -75,24 +70,13 @@ mono_native_thread_set_name (MonoNativeThreadId tid, const char *name)
 #endif
 }
 
-#if HAVE_SET_THREAD_NAME
-
-void
-mono_thread_set_name_windows (HANDLE thread_handle, PCWSTR thread_name)
-{
-       SetThreadName (thread_handle, thread_name);
-}
-
-#elif HAVE_SET_THREAD_DESCRIPTION
-
+#if HAVE_API_SUPPORT_WIN32_SET_THREAD_DESCRIPTION
 void
 mono_thread_set_name_windows (HANDLE thread_handle, PCWSTR thread_name)
 {
        SetThreadDescription (thread_handle, thread_name);
 }
-
-#else // LoadLibrary / GetProcAddress
-
+#elif !HAVE_EXTERN_DEFINED_WIN32_SET_THREAD_DESCRIPTION
 typedef
 HRESULT
 (__stdcall * MonoSetThreadDescription_t) (HANDLE thread_handle, PCWSTR thread_name);
@@ -140,4 +124,4 @@ mono_thread_set_name_windows (HANDLE thread_handle, PCWSTR thread_name)
 
 #endif
 
-#endif // Win32
+#endif /* HOST_WIN32 */
index 25fb3ac..d9f41aa 100644 (file)
@@ -52,10 +52,6 @@ typedef struct pollfd {
 } WSAPOLLFD, *PWSAPOLLFD, *LPWSAPOLLFD;
 #endif
 
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT)
-#include <mswsock.h>
-#endif
-
 #endif /* HOST_WIN32 */
 
 #endif /* __MONO_UTILS_W32API_H__ */
diff --git a/src/mono/mono/utils/w32subset.h b/src/mono/mono/utils/w32subset.h
new file mode 100644 (file)
index 0000000..1c41538
--- /dev/null
@@ -0,0 +1,616 @@
+/**
+ * \file
+ * Define Win32 API subset defaults.
+ * Other subsetters can fork this file, or
+ * define symbols ahead of it, or after it (with undef).
+ *
+ * Note that #if of an undefined symbols is defined as if 0,
+ * so that an implicit default here.
+ *
+ * Copyright 2019 Microsoft
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
+ */
+
+#ifndef HAVE_API_SUPPORT_WIN32_BSTR
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_BSTR 1
+#else
+#define HAVE_API_SUPPORT_WIN32_BSTR 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_CANCEL_IO
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || \
+       G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_CANCEL_IO 1
+#else
+#define HAVE_API_SUPPORT_WIN32_CANCEL_IO 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_CANCEL_IO_EX
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || \
+       G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_CANCEL_IO_EX 1
+#else
+#define HAVE_API_SUPPORT_WIN32_CANCEL_IO_EX 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_CANCEL_SYNCHRONOUS_IO
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_CANCEL_SYNCHRONOUS_IO 1
+#else
+#define HAVE_API_SUPPORT_WIN32_CANCEL_SYNCHRONOUS_IO 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_COMMAND_LINE_TO_ARGV
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_COMMAND_LINE_TO_ARGV 1
+#else
+#define HAVE_API_SUPPORT_WIN32_COMMAND_LINE_TO_ARGV 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_CONSOLE
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_CONSOLE 1
+#else
+#define HAVE_API_SUPPORT_WIN32_CONSOLE 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_COPY_FILE
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || \
+       G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_COPY_FILE 1
+#else
+#define HAVE_API_SUPPORT_WIN32_COPY_FILE 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_COPY_FILE2
+#if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_COPY_FILE2 1
+#else
+#define HAVE_API_SUPPORT_WIN32_COPY_FILE2 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_COREE
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_COREE 1
+#else
+#define HAVE_API_SUPPORT_WIN32_COREE 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_CREATE_PROCESS
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || \
+       G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_CREATE_PROCESS 1
+#else
+#define HAVE_API_SUPPORT_WIN32_CREATE_PROCESS 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_CREATE_PROCESS_WITH_LOGON
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_CREATE_PROCESS_WITH_LOGON 1
+#else
+#define HAVE_API_SUPPORT_WIN32_CREATE_PROCESS_WITH_LOGON 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_CREATE_SEMAPHORE
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || \
+       G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_CREATE_SEMAPHORE 1
+#else
+#define HAVE_API_SUPPORT_WIN32_CREATE_SEMAPHORE 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_CREATE_SEMAPHORE_EX
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || \
+       G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_CREATE_SEMAPHORE_EX 1
+#else
+#define HAVE_API_SUPPORT_WIN32_CREATE_SEMAPHORE_EX 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_DISCONNECT_EX
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || \
+       G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_DISCONNECT_EX 1
+#else
+#define HAVE_API_SUPPORT_WIN32_DISCONNECT_EX 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_ENUM_PROCESSES
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || \
+       G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_ENUM_PROCESSES 1
+#else
+#define HAVE_API_SUPPORT_WIN32_ENUM_PROCESSES 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_ENUM_PROCESS_MODULES
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_ENUM_PROCESS_MODULES 1
+#else
+#define HAVE_API_SUPPORT_WIN32_ENUM_PROCESS_MODULES 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_FILE_MAPPING
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_FILE_MAPPING 1
+#else
+#define HAVE_API_SUPPORT_WIN32_FILE_MAPPING 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_FILE_MAPPING_FROM_APP
+#if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_FILE_MAPPING_FROM_APP 1
+#else
+#define HAVE_API_SUPPORT_WIN32_FILE_MAPPING_FROM_APP 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_FORMAT_MESSAGE
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || \
+       G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_FORMAT_MESSAGE 1
+#else
+#define HAVE_API_SUPPORT_WIN32_FORMAT_MESSAGE 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_GET_ACP
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || \
+       G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_GET_ACP 1
+#else
+#define HAVE_API_SUPPORT_WIN32_GET_ACP 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_GET_COMPUTER_NAME
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || \
+       G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_GET_COMPUTER_NAME 1
+#else
+#define HAVE_API_SUPPORT_WIN32_GET_COMPUTER_NAME 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_GET_CP_INFO_EX
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || \
+       G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_GET_CP_INFO_EX 1
+#else
+#define HAVE_API_SUPPORT_WIN32_GET_CP_INFO_EX 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_GET_DRIVE_TYPE
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || \
+       G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_GET_DRIVE_TYPE 1
+#else
+#define HAVE_API_SUPPORT_WIN32_GET_DRIVE_TYPE 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_GET_FILE_SIZE_EX
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || \
+       G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_GET_FILE_SIZE_EX 1
+#else
+#define HAVE_API_SUPPORT_WIN32_GET_FILE_SIZE_EX 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_GET_FILE_VERSION_INFO
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_GET_FILE_VERSION_INFO 1
+#else
+#define HAVE_API_SUPPORT_WIN32_GET_FILE_VERSION_INFO 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_GET_LOGICAL_DRIVE_STRINGS
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_GET_LOGICAL_DRIVE_STRINGS 1
+#else
+#define HAVE_API_SUPPORT_WIN32_GET_LOGICAL_DRIVE_STRINGS 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_GET_MODULE_BASE_NAME
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || \
+       G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_GET_MODULE_BASE_NAME 1
+#else
+#define HAVE_API_SUPPORT_WIN32_GET_MODULE_BASE_NAME 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_GET_MODULE_FILE_NAME_EX
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || \
+       G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_GET_MODULE_FILE_NAME_EX 1
+#else
+#define HAVE_API_SUPPORT_WIN32_GET_MODULE_FILE_NAME_EX 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_GET_MODULE_HANDLE
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_GET_MODULE_HANDLE 1
+#else
+#define HAVE_API_SUPPORT_WIN32_GET_MODULE_HANDLE 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_GET_MODULE_HANDLE_EX
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_GET_MODULE_HANDLE_EX 1
+#else
+#define HAVE_API_SUPPORT_WIN32_GET_MODULE_HANDLE_EX 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_GET_MODULE_INFORMATION
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || \
+       G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_GET_MODULE_INFORMATION 1
+#else
+#define HAVE_API_SUPPORT_WIN32_GET_MODULE_INFORMATION 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_GET_PRIORITY_CLASS
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_GET_PRIORITY_CLASS 1
+#else
+#define HAVE_API_SUPPORT_WIN32_GET_PRIORITY_CLASS 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_GET_PROCESS_TIMES
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || \
+       G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_GET_PROCESS_TIMES 1
+#else
+#define HAVE_API_SUPPORT_WIN32_GET_PROCESS_TIMES 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_GET_STD_HANDLE
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_GET_STD_HANDLE 1
+#else
+#define HAVE_API_SUPPORT_WIN32_GET_STD_HANDLE 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_GET_SYSTEM_TIME_AS_FILE_TIME
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || \
+       G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_GET_SYSTEM_TIME_AS_FILE_TIME 1
+#else
+#define HAVE_API_SUPPORT_WIN32_GET_SYSTEM_TIME_AS_FILE_TIME 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_GET_SYSTEM_TIMES
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_GET_SYSTEM_TIMES 1
+#else
+#define HAVE_API_SUPPORT_WIN32_GET_SYSTEM_TIMES 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_GET_WORKING_SET_SIZE
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_GET_WORKING_SET_SIZE 1
+#else
+#define HAVE_API_SUPPORT_WIN32_GET_WORKING_SET_SIZE 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_GLOBAL_ALLOC_FREE
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || \
+       G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_GLOBAL_ALLOC_FREE 1
+#else
+#define HAVE_API_SUPPORT_WIN32_GLOBAL_ALLOC_FREE 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_IS_WOW64_PROCESS
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_IS_WOW64_PROCESS 1
+#else
+#define HAVE_API_SUPPORT_WIN32_IS_WOW64_PROCESS 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_LOAD_LIBRARY
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_LOAD_LIBRARY 1
+#else
+#define HAVE_API_SUPPORT_WIN32_LOAD_LIBRARY 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_LOAD_PACKAGED_LIBRARY
+#if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_LOAD_PACKAGED_LIBRARY 1
+#else
+#define HAVE_API_SUPPORT_WIN32_LOAD_PACKAGED_LIBRARY 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_LOCAL_ALLOC_FREE
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || \
+       G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_LOCAL_ALLOC_FREE 1
+#else
+#define HAVE_API_SUPPORT_WIN32_LOCAL_ALLOC_FREE 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_LOCAL_INFO
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || \
+       G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_LOCAL_INFO 1
+#else
+#define HAVE_API_SUPPORT_WIN32_LOCAL_INFO 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_LOCAL_INFO_EX
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || \
+       G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_LOCAL_INFO_EX 1
+#else
+#define HAVE_API_SUPPORT_WIN32_LOCAL_INFO_EX 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_LOCK_FILE
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || \
+       G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_LOCK_FILE 1
+#else
+#define HAVE_API_SUPPORT_WIN32_LOCK_FILE 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_MOVE_FILE
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_MOVE_FILE 1
+#else
+#define HAVE_API_SUPPORT_WIN32_MOVE_FILE 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_MOVE_FILE_EX
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || \
+       G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_MOVE_FILE_EX 1
+#else
+#define HAVE_API_SUPPORT_WIN32_MOVE_FILE_EX 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_MSG_WAIT_FOR_MULTIPLE_OBJECTS
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_MSG_WAIT_FOR_MULTIPLE_OBJECTS 1
+#else
+#define HAVE_API_SUPPORT_WIN32_MSG_WAIT_FOR_MULTIPLE_OBJECTS 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_OPEN_PROCESS
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || \
+       G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_OPEN_PROCESS 1
+#else
+#define HAVE_API_SUPPORT_WIN32_OPEN_PROCESS 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_OPEN_THREAD
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || \
+       G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_OPEN_THREAD 1
+#else
+#define HAVE_API_SUPPORT_WIN32_OPEN_THREAD 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_REPLACE_FILE
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || \
+       G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_REPLACE_FILE 1
+#else
+#define HAVE_API_SUPPORT_WIN32_REPLACE_FILE 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_RESET_STKOFLW
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_RESET_STKOFLW 1
+#else
+#define HAVE_API_SUPPORT_WIN32_RESET_STKOFLW 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_SAFE_ARRAY
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_SAFE_ARRAY 1
+#else
+#define HAVE_API_SUPPORT_WIN32_SAFE_ARRAY 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_SECURITY
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_SECURITY 1
+#else
+#define HAVE_API_SUPPORT_WIN32_SECURITY 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_SEND_MESSAGE_TIMEOUT
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_SEND_MESSAGE_TIMEOUT 1
+#else
+#define HAVE_API_SUPPORT_WIN32_SEND_MESSAGE_TIMEOUT 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_SET_ERROR_MODE
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || \
+       G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_SET_ERROR_MODE 1
+#else
+#define HAVE_API_SUPPORT_WIN32_SET_ERROR_MODE 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_SET_PRIORITY_CLASS
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_SET_PRIORITY_CLASS 1
+#else
+#define HAVE_API_SUPPORT_WIN32_SET_PRIORITY_CLASS 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_SET_THREAD_CONTEXT
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_SET_THREAD_CONTEXT 1
+#else
+#define HAVE_API_SUPPORT_WIN32_SET_THREAD_CONTEXT 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_SET_THREAD_DESCRIPTION
+#if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_SET_THREAD_DESCRIPTION 1
+#else
+#define HAVE_API_SUPPORT_WIN32_SET_THREAD_DESCRIPTION 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_SET_THREAD_STACK_GUARANTEE
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_SET_THREAD_STACK_GUARANTEE 1
+#else
+#define HAVE_API_SUPPORT_WIN32_SET_THREAD_STACK_GUARANTEE 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_SET_WORKING_SET_SIZE
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_SET_WORKING_SET_SIZE 1
+#else
+#define HAVE_API_SUPPORT_WIN32_SET_WORKING_SET_SIZE 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_SH_GET_FOLDER_PATH
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_SH_GET_FOLDER_PATH 1
+#else
+#define HAVE_API_SUPPORT_WIN32_SH_GET_FOLDER_PATH 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_SHELL_EXECUTE_EX
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_SHELL_EXECUTE_EX 1
+#else
+#define HAVE_API_SUPPORT_WIN32_SHELL_EXECUTE_EX 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_SIGNAL_OBJECT_AND_WAIT
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || \
+       G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_SIGNAL_OBJECT_AND_WAIT 1
+#else
+#define HAVE_API_SUPPORT_WIN32_SIGNAL_OBJECT_AND_WAIT 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_TIMERS
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_TIMERS 1
+#else
+#define HAVE_API_SUPPORT_WIN32_TIMERS 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_TRANSMIT_FILE
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || \
+       G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_TRANSMIT_FILE 1
+#else
+#define HAVE_API_SUPPORT_WIN32_TRANSMIT_FILE 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_UNLOCK_FILE
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || \
+       G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_UNLOCK_FILE 1
+#else
+#define HAVE_API_SUPPORT_WIN32_UNLOCK_FILE 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_VER_LANGUAGE_NAME
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_VER_LANGUAGE_NAME 1
+#else
+#define HAVE_API_SUPPORT_WIN32_VER_LANGUAGE_NAME 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_VER_QUERY_VALUE
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_VER_QUERY_VALUE 1
+#else
+#define HAVE_API_SUPPORT_WIN32_VER_QUERY_VALUE 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_WAIT_FOR_INPUT_IDLE
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_WAIT_FOR_INPUT_IDLE 1
+#else
+#define HAVE_API_SUPPORT_WIN32_WAIT_FOR_INPUT_IDLE 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_PIPE_OPEN_CLOSE
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#define HAVE_API_SUPPORT_WIN32_PIPE_OPEN_CLOSE 1
+#else
+#define HAVE_API_SUPPORT_WIN32_PIPE_OPEN_CLOSE 0
+#endif
+#endif
+
+#ifndef HAVE_API_SUPPORT_WIN32_CONTEXT_XSTATE
+#define HAVE_API_SUPPORT_WIN32_CONTEXT_XSTATE 0
+#endif
index fbe78bc..49d5a7d 100644 (file)
@@ -6,7 +6,6 @@
     <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gfile-win32.c" />
     <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gmisc-win32.c" />
     <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gmodule-win32.c" />
-    <ClInclude Include="$(MonoSourceLocation)\mono\eglib\gmodule-win32-internals.h" />
     <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gtimer-win32.c" />
     <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gunicode-win32.c" />
   </ItemGroup>
index c848331..b677ba8 100644 (file)
@@ -16,9 +16,6 @@
     <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gmodule-win32.c">
       <Filter>Source Files$(EGLibFilterSubFolder)\win32</Filter>
     </ClCompile>
-    <ClInclude Include="$(MonoSourceLocation)\mono\eglib\gmodule-win32-internals.h">
-      <Filter>Header Files$(EGLibFilterSubFolder)\win32</Filter>
-    </ClInclude>
     <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gtimer-win32.c">
       <Filter>Source Files$(EGLibFilterSubFolder)\win32</Filter>
     </ClCompile>
index bf15d05..316f22c 100644 (file)
@@ -2,16 +2,10 @@
 <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <ItemGroup Label="win32_sources">
     <ClCompile Include="$(MonoSourceLocation)\mono\metadata\console-win32.c" />
-    <ClInclude Include="$(MonoSourceLocation)\mono\metadata\console-win32-internals.h" />
-    <ClInclude Include="$(MonoSourceLocation)\mono\metadata\cominterop-win32-internals.h" />
     <ClCompile Include="$(MonoSourceLocation)\mono\metadata\w32file-win32.c" />
-    <ClInclude Include="$(MonoSourceLocation)\mono\metadata\w32file-win32-internals.h" />
     <ClCompile Include="$(MonoSourceLocation)\mono\metadata\icall-windows.c" />
-    <ClInclude Include="$(MonoSourceLocation)\mono\metadata\icall-windows-internals.h" />
     <ClCompile Include="$(MonoSourceLocation)\mono\metadata\marshal-windows.c" />
-    <ClInclude Include="$(MonoSourceLocation)\mono\metadata\marshal-windows-internals.h" />
     <ClCompile Include="$(MonoSourceLocation)\mono\metadata\mono-security-windows.c" />
-    <ClInclude Include="$(MonoSourceLocation)\mono\metadata\mono-security-windows-internals.h" />
     <ClCompile Include="$(MonoSourceLocation)\mono\metadata\w32mutex-win32.c" />
     <ClCompile Include="$(MonoSourceLocation)\mono\metadata\w32semaphore-win32.c" />
     <ClCompile Include="$(MonoSourceLocation)\mono\metadata\w32event-win32.c" />
index d120579..52d34a6 100644 (file)
@@ -4,36 +4,18 @@
     <ClCompile Include="$(MonoSourceLocation)\mono\metadata\console-win32.c">
       <Filter>Source Files$(MonoRuntimeFilterSubFolder)\win32</Filter>
     </ClCompile>
-    <ClInclude Include="$(MonoSourceLocation)\mono\metadata\console-win32-internals.h">
-      <Filter>Header Files$(MonoRuntimeFilterSubFolder)\win32</Filter>
-    </ClInclude>
-    <ClInclude Include="$(MonoSourceLocation)\mono\metadata\cominterop-win32-internals.h">
-      <Filter>Header Files$(MonoRuntimeFilterSubFolder)\win32</Filter>
-    </ClInclude>
     <ClCompile Include="$(MonoSourceLocation)\mono\metadata\w32file-win32.c">
       <Filter>Source Files$(MonoRuntimeFilterSubFolder)\win32</Filter>
     </ClCompile>
-    <ClInclude Include="$(MonoSourceLocation)\mono\metadata\w32file-win32-internals.h">
-      <Filter>Header Files$(MonoRuntimeFilterSubFolder)\win32</Filter>
-    </ClInclude>
     <ClCompile Include="$(MonoSourceLocation)\mono\metadata\icall-windows.c">
       <Filter>Source Files$(MonoRuntimeFilterSubFolder)\win32</Filter>
     </ClCompile>
-    <ClInclude Include="$(MonoSourceLocation)\mono\metadata\icall-windows-internals.h">
-      <Filter>Header Files$(MonoRuntimeFilterSubFolder)\win32</Filter>
-    </ClInclude>
     <ClCompile Include="$(MonoSourceLocation)\mono\metadata\marshal-windows.c">
       <Filter>Source Files$(MonoRuntimeFilterSubFolder)\win32</Filter>
     </ClCompile>
-    <ClInclude Include="$(MonoSourceLocation)\mono\metadata\marshal-windows-internals.h">
-      <Filter>Header Files$(MonoRuntimeFilterSubFolder)\win32</Filter>
-    </ClInclude>
     <ClCompile Include="$(MonoSourceLocation)\mono\metadata\mono-security-windows.c">
       <Filter>Source Files$(MonoRuntimeFilterSubFolder)\win32</Filter>
     </ClCompile>
-    <ClInclude Include="$(MonoSourceLocation)\mono\metadata\mono-security-windows-internals.h">
-      <Filter>Header Files$(MonoRuntimeFilterSubFolder)\win32</Filter>
-    </ClInclude>
     <ClCompile Include="$(MonoSourceLocation)\mono\metadata\w32mutex-win32.c">
       <Filter>Source Files$(MonoRuntimeFilterSubFolder)\win32</Filter>
     </ClCompile>
index 88cc2c3..28e3d1c 100644 (file)
@@ -47,7 +47,6 @@
     <ClCompile Include="$(MonoSourceLocation)\mono\utils\mono-mmap-windows.c" />
     <ClInclude Include="$(MonoSourceLocation)\mono\utils\mono-mmap.h" />
     <ClInclude Include="$(MonoSourceLocation)\mono\utils\mono-mmap-internals.h" />
-    <ClInclude Include="$(MonoSourceLocation)\mono\utils\mono-mmap-windows-internals.h" />
     <ClInclude Include="$(MonoSourceLocation)\mono\utils\mono-os-mutex.h" />
     <ClCompile Include="$(MonoSourceLocation)\mono\utils\mono-os-mutex.c">
       <ExcludedFromBuild>$(ExcludeFromWindowsBuild)</ExcludedFromBuild>
index 88f842f..c60ab51 100644 (file)
@@ -94,9 +94,6 @@
     <ClInclude Include="$(MonoSourceLocation)\mono\utils\mono-mmap-internals.h">
       <Filter>Header Files$(MonoUtilsFilterSubFolder)\common</Filter>
     </ClInclude>
-    <ClInclude Include="$(MonoSourceLocation)\mono\utils\mono-mmap-windows-internals.h">
-      <Filter>Header Files$(MonoUtilsFilterSubFolder)\common</Filter>
-    </ClInclude>
     <ClInclude Include="$(MonoSourceLocation)\mono\utils\mono-os-mutex.h">
       <Filter>Header Files$(MonoUtilsFilterSubFolder)\common</Filter>
     </ClInclude>
index 6d62dd4..b30e5b4 100644 (file)
@@ -3,27 +3,35 @@
   <ItemGroup Label="monozlib">
     <ClCompile Include="$(MonoSourceLocation)\mono\zlib\adler32.c">
       <CompileAs>CompileAsC</CompileAs>
+      <DisableSpecificWarnings>4005;4131</DisableSpecificWarnings>
     </ClCompile>
     <ClCompile Include="$(MonoSourceLocation)\mono\zlib\crc32.c">
       <CompileAs>CompileAsC</CompileAs>
+      <DisableSpecificWarnings>4005;4131</DisableSpecificWarnings>
     </ClCompile>
     <ClCompile Include="$(MonoSourceLocation)\mono\zlib\deflate.c">
       <CompileAs>CompileAsC</CompileAs>
+      <DisableSpecificWarnings>4005;4131</DisableSpecificWarnings>
     </ClCompile>
     <ClCompile Include="$(MonoSourceLocation)\mono\zlib\inffast.c">
       <CompileAs>CompileAsC</CompileAs>
+      <DisableSpecificWarnings>4005;4131</DisableSpecificWarnings>
     </ClCompile>
     <ClCompile Include="$(MonoSourceLocation)\mono\zlib\inflate.c">
       <CompileAs>CompileAsC</CompileAs>
+      <DisableSpecificWarnings>4005;4131</DisableSpecificWarnings>
     </ClCompile>
     <ClCompile Include="$(MonoSourceLocation)\mono\zlib\inftrees.c">
       <CompileAs>CompileAsC</CompileAs>
+      <DisableSpecificWarnings>4005;4131</DisableSpecificWarnings>
     </ClCompile>
     <ClCompile Include="$(MonoSourceLocation)\mono\zlib\trees.c">
       <CompileAs>CompileAsC</CompileAs>
+      <DisableSpecificWarnings>4005;4131</DisableSpecificWarnings>
     </ClCompile>
     <ClCompile Include="$(MonoSourceLocation)\mono\zlib\zutil.c">
       <CompileAs>CompileAsC</CompileAs>
+      <DisableSpecificWarnings>4005;4131</DisableSpecificWarnings>
     </ClCompile>
     <ClInclude Include="$(MonoSourceLocation)\mono\zlib\crc32.h"/>
     <ClInclude Include="$(MonoSourceLocation)\mono\zlib\deflate.h"/>
index 926de0c..763933c 100644 (file)
@@ -25,9 +25,6 @@
 #elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
        #define HAVE_CLASSIC_WINAPI_SUPPORT 0
        #define HAVE_UWP_WINAPI_SUPPORT 1
-#ifndef HAVE_EXTERN_DEFINED_WINAPI_SUPPORT
-       #error Unsupported WINAPI family
-#endif
 #else
        #define HAVE_CLASSIC_WINAPI_SUPPORT 0
        #define HAVE_UWP_WINAPI_SUPPORT 0