3 * UWP process support for Mono.
5 * Copyright 2016 Microsoft
6 * Licensed under the MIT license. See LICENSE file in the project root for full license information.
10 #include "mono/utils/mono-compiler.h"
12 // FIXME: In order to share function declarations at least, this
13 // file should be merged with its non-uwp counterpart, and fine-grained #if used there.
15 #if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
18 #include <mono/metadata/object-internals.h>
19 #include "mono/metadata/w32process.h"
20 #include "mono/metadata/w32process-internals.h"
21 #include "icall-decl.h"
24 ves_icall_System_Diagnostics_Process_GetProcesses_internal (MonoError
*error
)
26 g_unsupported_api ("EnumProcesses");
27 SetLastError (ERROR_NOT_SUPPORTED
);
28 mono_error_set_not_supported (error
, "This system does not support EnumProcesses");
29 return NULL_HANDLE_ARRAY
;
33 ves_icall_System_Diagnostics_Process_GetProcess_internal (guint32 pid
, MonoError
*error
)
35 g_unsupported_api ("OpenProcess");
36 mono_error_set_not_supported (error
, G_UNSUPPORTED_API
, "OpenProcess");
37 SetLastError (ERROR_NOT_SUPPORTED
);
42 ves_icall_System_Diagnostics_FileVersionInfo_GetVersionInfo_internal (MonoObjectHandle this_obj
,
43 const gunichar2
*filename
, int filename_length
, MonoError
*error
)
45 g_unsupported_api ("GetFileVersionInfoSize, GetFileVersionInfo, VerQueryValue, VerLanguageName");
46 mono_error_set_not_supported (error
, G_UNSUPPORTED_API
, "GetFileVersionInfoSize, GetFileVersionInfo, VerQueryValue, VerLanguageName");
47 SetLastError (ERROR_NOT_SUPPORTED
);
51 ves_icall_System_Diagnostics_Process_GetModules_internal (MonoObjectHandle this_obj
, HANDLE process
, MonoError
*error
)
53 g_unsupported_api ("EnumProcessModules");
54 mono_error_set_not_supported (error
, G_UNSUPPORTED_API
, "EnumProcessModules");
55 SetLastError (ERROR_NOT_SUPPORTED
);
56 return NULL_HANDLE_ARRAY
;
60 ves_icall_System_Diagnostics_Process_ShellExecuteEx_internal (MonoW32ProcessStartInfoHandle proc_start_info
, MonoW32ProcessInfo
*process_info
, MonoError
*error
)
62 g_unsupported_api ("ShellExecuteEx");
63 mono_error_set_not_supported (error
, G_UNSUPPORTED_API
, "ShellExecuteEx");
64 process_info
->pid
= (guint32
)(-ERROR_NOT_SUPPORTED
);
65 SetLastError (ERROR_NOT_SUPPORTED
);
69 // This is the only function in this file that does anything.
70 // Note that process is ignored and it just operates on the current process.
72 ves_icall_System_Diagnostics_Process_ProcessName_internal (HANDLE process
, MonoError
*error
)
74 gunichar2
*name
= NULL
;
76 // FIXME give allocator to mono_get_module_file_name to avoid copies, here and many other
77 if (!mono_get_module_file_name (NULL
, &name
, &len
))
78 return NULL_HANDLE_STRING
;
79 MonoStringHandle res
= mono_string_new_utf16_handle (mono_domain_get (), name
, len
, error
);
85 ves_icall_System_Diagnostics_Process_CreateProcess_internal (MonoW32ProcessStartInfoHandle proc_start_info
,
86 HANDLE stdin_handle
, HANDLE stdout_handle
, HANDLE stderr_handle
, MonoW32ProcessInfo
*process_info
, MonoError
*error
)
88 // FIXME CreateProcess is supported for UWP. Use finer grained #if.
90 const char *api_name
= mono_process_info
->username
? "CreateProcessWithLogonW" : "CreateProcess";
91 memset (process_info
, 0, sizeof (*process_info
));
92 g_unsupported_api (api_name
);
93 mono_error_set_not_supported (error
, G_UNSUPPORTED_API
, api_name
);
94 SetLastError (ERROR_NOT_SUPPORTED
);
99 ves_icall_Microsoft_Win32_NativeMethods_GetProcessWorkingSetSize (gpointer handle
, gsize
*min
, gsize
*max
, MonoError
*error
)
101 g_unsupported_api ("GetProcessWorkingSetSize");
102 mono_error_set_not_supported(error
, G_UNSUPPORTED_API
, "GetProcessWorkingSetSize");
103 SetLastError (ERROR_NOT_SUPPORTED
);
108 ves_icall_Microsoft_Win32_NativeMethods_SetProcessWorkingSetSize (gpointer handle
, gsize min
, gsize max
, MonoError
*error
)
110 g_unsupported_api ("SetProcessWorkingSetSize");
111 mono_error_set_not_supported (error
, G_UNSUPPORTED_API
, "SetProcessWorkingSetSize");
112 SetLastError (ERROR_NOT_SUPPORTED
);
117 ves_icall_Microsoft_Win32_NativeMethods_GetPriorityClass (gpointer handle
, MonoError
*error
)
119 // FIXME GetPriorityClass is supported for UWP. Use finer grained #if.
121 g_unsupported_api ("GetPriorityClass");
122 mono_error_set_not_supported (error
, G_UNSUPPORTED_API
, "GetPriorityClass");
123 SetLastError (ERROR_NOT_SUPPORTED
);
128 ves_icall_Microsoft_Win32_NativeMethods_SetPriorityClass (gpointer handle
, gint32 priorityClass
, MonoError
*error
)
130 // FIXME SetPriorityClass is supported for UWP. Use finer grained #if.
132 g_unsupported_api ("SetPriorityClass");
133 mono_error_set_not_supported(error
, G_UNSUPPORTED_API
, "SetPriorityClass");
134 SetLastError (ERROR_NOT_SUPPORTED
);
138 #else /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
140 MONO_EMPTY_SOURCE_FILE (process_windows_uwp
);
141 #endif /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */