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.
9 #include "mono/utils/mono-compiler.h"
11 #if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
13 #include "mono/metadata/w32process-win32-internals.h"
16 mono_process_win_enum_processes (DWORD *pids, DWORD count, DWORD *needed)
18 g_unsupported_api ("EnumProcesses");
20 SetLastError (ERROR_NOT_SUPPORTED);
26 ves_icall_System_Diagnostics_Process_GetProcess_internal (guint32 pid)
30 /* GetCurrentProcess returns a pseudo-handle, so use
33 handle = OpenProcess (PROCESS_ALL_ACCESS, TRUE, pid);
35 /* FIXME: Throw an exception */
41 mono_w32process_get_fileversion (MonoObject *filever, gunichar2 *filename, MonoError *error)
43 g_unsupported_api ("GetFileVersionInfoSize, GetFileVersionInfo, VerQueryValue, VerLanguageName");
45 mono_error_init (error);
46 mono_error_set_not_supported (error, G_UNSUPPORTED_API, "GetFileVersionInfoSize, GetFileVersionInfo, VerQueryValue, VerLanguageName");
48 SetLastError (ERROR_NOT_SUPPORTED);
52 process_add_module (HANDLE process, HMODULE mod, gunichar2 *filename, gunichar2 *modulename, MonoClass *proc_class, MonoError *error)
54 g_unsupported_api ("GetModuleInformation");
56 mono_error_init (error);
57 mono_error_set_not_supported (error, G_UNSUPPORTED_API, "GetModuleInformation");
59 SetLastError (ERROR_NOT_SUPPORTED);
65 ves_icall_System_Diagnostics_Process_GetModules_internal (MonoObject *this_obj, HANDLE process)
68 mono_error_init (&mono_error);
70 g_unsupported_api ("EnumProcessModules, GetModuleBaseName, GetModuleFileNameEx");
72 mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, "EnumProcessModules, GetModuleBaseName, GetModuleFileNameEx");
73 mono_error_set_pending_exception (&mono_error);
75 SetLastError (ERROR_NOT_SUPPORTED);
81 ves_icall_System_Diagnostics_Process_ShellExecuteEx_internal (MonoProcessStartInfo *proc_start_info, MonoProcInfo *process_info)
84 mono_error_init (&mono_error);
86 g_unsupported_api ("ShellExecuteEx");
88 mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, "ShellExecuteEx");
89 mono_error_set_pending_exception (&mono_error);
91 process_info->pid = (guint32)(-ERROR_NOT_SUPPORTED);
92 SetLastError (ERROR_NOT_SUPPORTED);
98 ves_icall_System_Diagnostics_Process_ProcessName_internal (HANDLE process)
102 gunichar2 name[MAX_PATH];
105 len = GetModuleFileName (NULL, name, G_N_ELEMENTS (name));
109 string = mono_string_new_utf16_checked (mono_domain_get (), name, len, &error);
110 if (!mono_error_ok (&error))
111 mono_error_set_pending_exception (&error);
117 mono_process_init_startup_info (HANDLE stdin_handle, HANDLE stdout_handle, HANDLE stderr_handle, STARTUPINFO *startinfo)
119 startinfo->cb = sizeof(STARTUPINFO);
120 startinfo->dwFlags = 0;
121 startinfo->hStdInput = INVALID_HANDLE_VALUE;
122 startinfo->hStdOutput = INVALID_HANDLE_VALUE;
123 startinfo->hStdError = INVALID_HANDLE_VALUE;
128 mono_process_create_process (MonoProcInfo *mono_process_info, gunichar2 *shell_path, MonoString *cmd, guint32 creation_flags,
129 gchar *env_vars, gunichar2 *dir, STARTUPINFO *start_info, PROCESS_INFORMATION *process_info)
131 MonoError mono_error;
132 gchar *api_name = "";
134 if (mono_process_info->username) {
135 api_name = "CreateProcessWithLogonW";
137 api_name = "CreateProcess";
140 memset (&process_info, 0, sizeof (PROCESS_INFORMATION));
141 g_unsupported_api (api_name);
143 mono_error_init (&mono_error);
144 mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, api_name);
145 mono_error_set_pending_exception (&mono_error);
147 SetLastError (ERROR_NOT_SUPPORTED);
153 mono_icall_get_process_working_set_size (gpointer handle, gsize *min, gsize *max)
155 MonoError mono_error;
156 mono_error_init (&mono_error);
158 g_unsupported_api ("GetProcessWorkingSetSize");
160 mono_error_set_not_supported(&mono_error, G_UNSUPPORTED_API, "GetProcessWorkingSetSize");
161 mono_error_set_pending_exception (&mono_error);
163 SetLastError (ERROR_NOT_SUPPORTED);
169 mono_icall_set_process_working_set_size (gpointer handle, gsize min, gsize max)
171 MonoError mono_error;
172 mono_error_init (&mono_error);
174 g_unsupported_api ("SetProcessWorkingSetSize");
176 mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, "SetProcessWorkingSetSize");
177 mono_error_set_pending_exception (&mono_error);
179 SetLastError (ERROR_NOT_SUPPORTED);
185 mono_icall_get_priority_class (gpointer handle)
187 MonoError mono_error;
188 mono_error_init (&mono_error);
190 g_unsupported_api ("GetPriorityClass");
192 mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, "GetPriorityClass");
193 mono_error_set_pending_exception (&mono_error);
195 SetLastError (ERROR_NOT_SUPPORTED);
201 mono_icall_set_priority_class (gpointer handle, gint32 priorityClass)
203 MonoError mono_error;
204 mono_error_init (&mono_error);
206 g_unsupported_api ("SetPriorityClass");
208 mono_error_set_not_supported(&mono_error, G_UNSUPPORTED_API, "SetPriorityClass");
209 mono_error_set_pending_exception (&mono_error);
211 SetLastError (ERROR_NOT_SUPPORTED);
216 #else /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
218 MONO_EMPTY_SOURCE_FILE (process_windows_uwp);
219 #endif /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */