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 #if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
14 #include <mono/metadata/object-internals.h>
15 #include "mono/metadata/w32process.h"
16 #include "mono/metadata/w32process-internals.h"
17 #include "mono/metadata/w32process-win32-internals.h"
20 mono_process_win_enum_processes (DWORD *pids, DWORD count, DWORD *needed)
22 g_unsupported_api ("EnumProcesses");
24 SetLastError (ERROR_NOT_SUPPORTED);
30 ves_icall_System_Diagnostics_Process_GetProcess_internal (guint32 pid)
33 error_init (&mono_error);
35 g_unsupported_api ("OpenProcess");
37 mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, "OpenProcess");
38 mono_error_set_pending_exception (&mono_error);
40 SetLastError (ERROR_NOT_SUPPORTED);
46 mono_w32process_get_fileversion (MonoObject *filever, gunichar2 *filename, MonoError *error)
48 g_unsupported_api ("GetFileVersionInfoSize, GetFileVersionInfo, VerQueryValue, VerLanguageName");
51 mono_error_set_not_supported (error, G_UNSUPPORTED_API, "GetFileVersionInfoSize, GetFileVersionInfo, VerQueryValue, VerLanguageName");
53 SetLastError (ERROR_NOT_SUPPORTED);
57 process_add_module (HANDLE process, HMODULE mod, gunichar2 *filename, gunichar2 *modulename, MonoClass *proc_class, MonoError *error)
59 g_unsupported_api ("GetModuleInformation");
62 mono_error_set_not_supported (error, G_UNSUPPORTED_API, "GetModuleInformation");
64 SetLastError (ERROR_NOT_SUPPORTED);
70 ves_icall_System_Diagnostics_Process_GetModules_internal (MonoObject *this_obj, HANDLE process)
73 error_init (&mono_error);
75 g_unsupported_api ("EnumProcessModules, GetModuleBaseName, GetModuleFileNameEx");
77 mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, "EnumProcessModules, GetModuleBaseName, GetModuleFileNameEx");
78 mono_error_set_pending_exception (&mono_error);
80 SetLastError (ERROR_NOT_SUPPORTED);
86 ves_icall_System_Diagnostics_Process_ShellExecuteEx_internal (MonoW32ProcessStartInfo *proc_start_info, MonoW32ProcessInfo *process_info)
89 error_init (&mono_error);
91 g_unsupported_api ("ShellExecuteEx");
93 mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, "ShellExecuteEx");
94 mono_error_set_pending_exception (&mono_error);
96 process_info->pid = (guint32)(-ERROR_NOT_SUPPORTED);
97 SetLastError (ERROR_NOT_SUPPORTED);
103 ves_icall_System_Diagnostics_Process_ProcessName_internal (HANDLE process)
107 gunichar2 name[MAX_PATH];
110 len = GetModuleFileName (NULL, name, G_N_ELEMENTS (name));
114 string = mono_string_new_utf16_checked (mono_domain_get (), name, len, &error);
115 if (!mono_error_ok (&error))
116 mono_error_set_pending_exception (&error);
122 mono_process_init_startup_info (HANDLE stdin_handle, HANDLE stdout_handle, HANDLE stderr_handle, STARTUPINFO *startinfo)
124 startinfo->cb = sizeof(STARTUPINFO);
125 startinfo->dwFlags = 0;
126 startinfo->hStdInput = INVALID_HANDLE_VALUE;
127 startinfo->hStdOutput = INVALID_HANDLE_VALUE;
128 startinfo->hStdError = INVALID_HANDLE_VALUE;
133 mono_process_create_process (MonoW32ProcessInfo *mono_process_info, MonoString *cmd, guint32 creation_flags,
134 gunichar2 *env_vars, gunichar2 *dir, STARTUPINFO *start_info, PROCESS_INFORMATION *process_info)
136 MonoError mono_error;
137 gchar *api_name = "";
139 if (mono_process_info->username) {
140 api_name = "CreateProcessWithLogonW";
142 api_name = "CreateProcess";
145 memset (&process_info, 0, sizeof (PROCESS_INFORMATION));
146 g_unsupported_api (api_name);
148 error_init (&mono_error);
149 mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, api_name);
150 mono_error_set_pending_exception (&mono_error);
152 SetLastError (ERROR_NOT_SUPPORTED);
158 mono_icall_get_process_working_set_size (gpointer handle, gsize *min, gsize *max)
160 MonoError mono_error;
161 error_init (&mono_error);
163 g_unsupported_api ("GetProcessWorkingSetSize");
165 mono_error_set_not_supported(&mono_error, G_UNSUPPORTED_API, "GetProcessWorkingSetSize");
166 mono_error_set_pending_exception (&mono_error);
168 SetLastError (ERROR_NOT_SUPPORTED);
174 mono_icall_set_process_working_set_size (gpointer handle, gsize min, gsize max)
176 MonoError mono_error;
177 error_init (&mono_error);
179 g_unsupported_api ("SetProcessWorkingSetSize");
181 mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, "SetProcessWorkingSetSize");
182 mono_error_set_pending_exception (&mono_error);
184 SetLastError (ERROR_NOT_SUPPORTED);
190 mono_icall_get_priority_class (gpointer handle)
192 MonoError mono_error;
193 error_init (&mono_error);
195 g_unsupported_api ("GetPriorityClass");
197 mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, "GetPriorityClass");
198 mono_error_set_pending_exception (&mono_error);
200 SetLastError (ERROR_NOT_SUPPORTED);
206 mono_icall_set_priority_class (gpointer handle, gint32 priorityClass)
208 MonoError mono_error;
209 error_init (&mono_error);
211 g_unsupported_api ("SetPriorityClass");
213 mono_error_set_not_supported(&mono_error, G_UNSUPPORTED_API, "SetPriorityClass");
214 mono_error_set_pending_exception (&mono_error);
216 SetLastError (ERROR_NOT_SUPPORTED);
221 #else /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
223 MONO_EMPTY_SOURCE_FILE (process_windows_uwp);
224 #endif /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */