2 * process-windows-uwp.c: UWP process support for Mono.
4 * Copyright 2016 Microsoft
5 * Licensed under the MIT license. See LICENSE file in the project root for full license information.
10 #if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
12 #include "mono/metadata/w32process-win32-internals.h"
15 mono_process_win_enum_processes (DWORD *pids, DWORD count, DWORD *needed)
17 g_unsupported_api ("EnumProcesses");
19 SetLastError (ERROR_NOT_SUPPORTED);
25 ves_icall_System_Diagnostics_Process_GetProcess_internal (guint32 pid)
29 /* GetCurrentProcess returns a pseudo-handle, so use
32 handle = OpenProcess (PROCESS_ALL_ACCESS, TRUE, pid);
34 /* FIXME: Throw an exception */
40 mono_w32process_get_fileversion (MonoObject *filever, gunichar2 *filename, MonoError *error)
42 g_unsupported_api ("GetFileVersionInfoSize, GetFileVersionInfo, VerQueryValue, VerLanguageName");
44 mono_error_init (error);
45 mono_error_set_not_supported (error, G_UNSUPPORTED_API, "GetFileVersionInfoSize, GetFileVersionInfo, VerQueryValue, VerLanguageName");
47 SetLastError (ERROR_NOT_SUPPORTED);
51 process_add_module (HANDLE process, HMODULE mod, gunichar2 *filename, gunichar2 *modulename, MonoClass *proc_class, MonoError *error)
53 g_unsupported_api ("GetModuleInformation");
55 mono_error_init (error);
56 mono_error_set_not_supported (error, G_UNSUPPORTED_API, "GetModuleInformation");
58 SetLastError (ERROR_NOT_SUPPORTED);
64 ves_icall_System_Diagnostics_Process_GetModules_internal (MonoObject *this_obj, HANDLE process)
67 mono_error_init (&mono_error);
69 g_unsupported_api ("EnumProcessModules, GetModuleBaseName, GetModuleFileNameEx");
71 mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, "EnumProcessModules, GetModuleBaseName, GetModuleFileNameEx");
72 mono_error_set_pending_exception (&mono_error);
74 SetLastError (ERROR_NOT_SUPPORTED);
80 ves_icall_System_Diagnostics_Process_ShellExecuteEx_internal (MonoProcessStartInfo *proc_start_info, MonoProcInfo *process_info)
83 mono_error_init (&mono_error);
85 g_unsupported_api ("ShellExecuteEx");
87 mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, "ShellExecuteEx");
88 mono_error_set_pending_exception (&mono_error);
90 process_info->pid = (guint32)(-ERROR_NOT_SUPPORTED);
91 SetLastError (ERROR_NOT_SUPPORTED);
97 ves_icall_System_Diagnostics_Process_ProcessName_internal (HANDLE process)
101 gunichar2 name[MAX_PATH];
104 len = GetModuleFileName (NULL, name, G_N_ELEMENTS (name));
108 string = mono_string_new_utf16_checked (mono_domain_get (), name, len, &error);
109 if (!mono_error_ok (&error))
110 mono_error_set_pending_exception (&error);
116 mono_process_init_startup_info (HANDLE stdin_handle, HANDLE stdout_handle, HANDLE stderr_handle, STARTUPINFO *startinfo)
118 startinfo->cb = sizeof(STARTUPINFO);
119 startinfo->dwFlags = 0;
120 startinfo->hStdInput = INVALID_HANDLE_VALUE;
121 startinfo->hStdOutput = INVALID_HANDLE_VALUE;
122 startinfo->hStdError = INVALID_HANDLE_VALUE;
127 mono_process_create_process (MonoProcInfo *mono_process_info, gunichar2 *shell_path, MonoString *cmd, guint32 creation_flags,
128 gchar *env_vars, gunichar2 *dir, STARTUPINFO *start_info, PROCESS_INFORMATION *process_info)
130 MonoError mono_error;
131 gchar *api_name = "";
133 if (mono_process_info->username) {
134 api_name = "CreateProcessWithLogonW";
136 api_name = "CreateProcess";
139 memset (&process_info, 0, sizeof (PROCESS_INFORMATION));
140 g_unsupported_api (api_name);
142 mono_error_init (&mono_error);
143 mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, api_name);
144 mono_error_set_pending_exception (&mono_error);
146 SetLastError (ERROR_NOT_SUPPORTED);
152 mono_icall_get_process_working_set_size (gpointer handle, gsize *min, gsize *max)
154 MonoError mono_error;
155 mono_error_init (&mono_error);
157 g_unsupported_api ("GetProcessWorkingSetSize");
159 mono_error_set_not_supported(&mono_error, G_UNSUPPORTED_API, "GetProcessWorkingSetSize");
160 mono_error_set_pending_exception (&mono_error);
162 SetLastError (ERROR_NOT_SUPPORTED);
168 mono_icall_set_process_working_set_size (gpointer handle, gsize min, gsize max)
170 MonoError mono_error;
171 mono_error_init (&mono_error);
173 g_unsupported_api ("SetProcessWorkingSetSize");
175 mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, "SetProcessWorkingSetSize");
176 mono_error_set_pending_exception (&mono_error);
178 SetLastError (ERROR_NOT_SUPPORTED);
184 mono_icall_get_priority_class (gpointer handle)
186 MonoError mono_error;
187 mono_error_init (&mono_error);
189 g_unsupported_api ("GetPriorityClass");
191 mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, "GetPriorityClass");
192 mono_error_set_pending_exception (&mono_error);
194 SetLastError (ERROR_NOT_SUPPORTED);
200 mono_icall_set_priority_class (gpointer handle, gint32 priorityClass)
202 MonoError mono_error;
203 mono_error_init (&mono_error);
205 g_unsupported_api ("SetPriorityClass");
207 mono_error_set_not_supported(&mono_error, G_UNSUPPORTED_API, "SetPriorityClass");
208 mono_error_set_pending_exception (&mono_error);
210 SetLastError (ERROR_NOT_SUPPORTED);
215 #else /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
218 // Quiet Visual Studio linker warning, LNK4221, in cases when this source file intentional ends up empty.
219 void __mono_win32_process_windows_uwp_quiet_lnk4221(void) {}
221 #endif /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */