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>
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 \
#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
+++ /dev/null
-/*
- * 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) */
*/
#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)
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)
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)
{
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)
+++ /dev/null
-#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__ */
+++ /dev/null
-/*
- * 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) */
#endif
#include <windows.h>
#include <psapi.h>
-#include <gmodule-win32-internals.h>
+#include <gmodule.h>
+#include "../utils/w32subset.h"
#define LIBSUFFIX ".dll"
#define LIBPREFIX ""
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)
{
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)
}
}
+#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,
* 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 = GetModuleHandleExW (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 */
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)
// 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)
{
*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.
// 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)
{
*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.
+++ /dev/null
-/*
- * 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) */
#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;
{
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;
}
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 */
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)
+++ /dev/null
-/**
- * \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__ */
#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"
*((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 ()) {
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
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
}
#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)
#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)
#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)
/* 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)
}
#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)
#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)
/* 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 */
+++ /dev/null
-/**
- * \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__ */
-
+++ /dev/null
-/**
- * \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) */
#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
{
}
-#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)
{
{
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 */
+++ /dev/null
-/**
- * \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) */
#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)
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;
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);
/* 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)
}
/* 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;
return STATUS_SUCCESS;
}
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
/* Called by ntdll.dll. */
STDAPI_(VOID) _CorImageUnloading(PVOID ImageBase)
return CorBindToRuntimeEx (pwszVersion, pwszBuildFlavor, 0, rclsid, riid, ppv);
}
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
HMODULE WINAPI MonoLoadImage(LPCWSTR FileName)
{
HANDLE FileHandle;
CloseHandle(FileHandle);
return NULL;
}
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
typedef struct _EXPORT_FIXUP
{
return S_OK;
}
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
void
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)
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>
#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"
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
{
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 */
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
}
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);
#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
}
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;
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)
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
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);
+++ /dev/null
-/**
- * \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__ */
+++ /dev/null
-/**
- * \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);
#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)
}
#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)
{
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
}
#if HAVE_API_SUPPORT_WIN32_SH_GET_FOLDER_PATH
+#include <shlobj.h>
MonoStringHandle
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
{
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
}
#endif
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
static MonoArrayHandle
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;
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);
return result;
}
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
#ifndef ENABLE_NETCORE
MonoArrayHandle
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)
{
+++ /dev/null
-/**
- * \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__ */
+++ /dev/null
-/**
- * \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) */
#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)
{
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)
+++ /dev/null
-/**
- * \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__ */
+++ /dev/null
-/**
- * \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) */
#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
#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)
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) {
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)
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)
{
}
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)
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)
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)
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;
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 */
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) */
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 */
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) */
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)
#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"
}
#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)
{
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 */
}
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);
// 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)
{
#if defined(HOST_WIN32)
#include <windows.h>
+#include <mono/utils/networking.h>
#else
#include <errno.h>
#include <fcntl.h>
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 ());
#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);
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)
{
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);
#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;
}
#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
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;
}
#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);
}
#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.
+++ /dev/null
-/**
- * \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_ */
+++ /dev/null
-/**
- * \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, ©_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);
#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
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);
*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);
*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, ©_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
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
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;
return res;
}
-HANDLE
+gpointer
mono_w32file_get_console_output (void)
{
HANDLE res;
return res;
}
-HANDLE
+gpointer
mono_w32file_get_console_error (void)
{
HANDLE res;
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)
{
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;
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
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
#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;
#define VS_FF_PRIVATEBUILD 0x0008
#define VS_FF_INFOINFERRED 0x0010
#define VS_FF_SPECIALBUILD 0x0020
+#endif
guint32
mono_w32process_get_pid (gpointer handle);
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);
guint32
mono_w32process_ver_language_name (guint32 lang, gunichar2 *lang_out, guint32 lang_len);
-#endif /* HOST_WIN32 */
-
#endif /* _MONO_METADATA_W32PROCESS_INTERNALS_H_ */
}
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;
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;
}
}
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;
}
+++ /dev/null
-/**
- * \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) */
#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)
{
}
-#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)
{
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);
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) {
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,
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,
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;
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)
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;
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);
return ret;
}
+#if HAVE_API_SUPPORT_WIN32_ENUM_PROCESSES
MonoArrayHandle
ves_icall_System_Diagnostics_Process_GetProcesses_internal (MonoError *error)
{
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)
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)
{
return GetCurrentProcess ();
}
-
-#endif
#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)
{
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"
}
}
+#if HAVE_API_SUPPORT_WIN32_GET_FILE_VERSION_INFO
static void
mono_w32process_get_fileversion (MonoObjectHandle filever, MonoStringHandle str, const gunichar2 *filename, MonoError *error)
{
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);
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);
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
}
#endif
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
-
static GPtrArray*
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,
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)
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;
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;
{
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))
}
#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)
{
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)
{
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)
#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
{
}
-#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)
#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;
gpointer handle1;
gpointer handle2;
} OVERLAPPED;
-
#endif
void
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
#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;
#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);
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)
{
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)
{
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)
#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(...)
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)
{
*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)
{
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)
{
return ret;
}
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT) */
-
void
mono_network_init (void)
{
+++ /dev/null
-/**
- * \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
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);
* 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;
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) {
static void
mono_debugger_agent_cleanup (void)
{
- if (!inited)
+ if (!agent_inited)
return;
stop_debugger_thread ();
static void
stop_debugger_thread (void)
{
- if (!inited)
+ if (!agent_inited)
return;
transport_close1 ();
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;
}
GSList *events;
EventInfo ei;
- if (!inited)
+ if (!agent_inited)
return;
memset (&ei, 0, sizeof (ei));
/* Just-In-Time debugging */
if (!catch_ctx) {
- if (agent_config.onuncaught && !inited) {
+ if (agent_config.onuncaught && !agent_inited) {
finish_agent_init (FALSE);
/*
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;
}
}
- if (!inited)
+ if (!agent_inited)
return;
ji = mini_jit_info_table_find (mono_domain_get (), (char *)MONO_CONTEXT_GET_IP (throw_ctx), NULL);
{
DebuggerTlsData *tls;
- if (!inited)
+ if (!agent_inited)
return;
tls = (DebuggerTlsData *)mono_native_tls_get_value (debugger_tls_id);
{
DebuggerTlsData *tls;
- if (!inited)
+ if (!agent_inited)
return;
tls = (DebuggerTlsData *)mono_native_tls_get_value (debugger_tls_id);
#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"
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 ();
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 *
#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"
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)
{
// _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
* 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;
#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"
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)
{
+++ /dev/null
-/**
- * \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) */
-
#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
handler handler;
} HandlerItem;
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#if HAVE_API_SUPPORT_WIN32_CONSOLE
/**
* atexit_wait_keypress:
*
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 },
" --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
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
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)
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
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)
{
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)
/**
- * 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
#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 {
{
}
-#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
#endif
}
#endif
+
+MONO_EMPTY_SOURCE_FILE (simd_intrinsics_netcore);
}
#endif /* DISABLE_JIT */
+MONO_EMPTY_SOURCE_FILE (simd_intrinsics);
#endif /* MONO_ARCH_SIMD_INTRINSICS */
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 \
+++ /dev/null
-/**
- * \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) */
#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>
#include <windows.h>
#include <psapi.h>
+#include <mono/utils/w32subset.h>
+
const char*
mono_dl_get_so_prefix (void)
{
#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 ();
#if HAVE_API_SUPPORT_WIN32_GET_MODULE_HANDLE
hModule = GetModuleHandleW (NULL);
#else
- g_assert_not_reached ();
+#error unknown Windows variant
#endif
}
return hModule;
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)
{
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)
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)
+++ /dev/null
-/**
- * \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__ */
-
#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;
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)
// 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);
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);
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);
}
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)
#else
#include <mono/utils/mono-os-wait.h>
#endif
+#include <mono/utils/w32subset.h>
#define MONO_HAS_SEMAPHORES 1
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)
+++ /dev/null
-/**
- * \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) */
#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 */
}
#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)
{
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)
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)
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)
{
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)
+++ /dev/null
-/**
- * \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*)¤t_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) */
#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 ()
/*
* 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)
{
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*)¤t_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
#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,
{
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.
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.
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)
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
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)) {
#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>
#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.
#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.
//
// 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.
//
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
#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);
#endif
-#endif // Win32
+#endif /* HOST_WIN32 */
} 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__ */
--- /dev/null
+/**
+ * \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
<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>
<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>
<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" />
<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>
<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>
<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>
<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"/>
#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