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/object-internals.h>
14 #include "mono/metadata/w32process.h"
15 #include "mono/metadata/w32process-internals.h"
16 #include "mono/metadata/w32process-win32-internals.h"
19 mono_process_win_enum_processes (DWORD *pids, DWORD count, DWORD *needed)
21 g_unsupported_api ("EnumProcesses");
23 SetLastError (ERROR_NOT_SUPPORTED);
29 ves_icall_System_Diagnostics_Process_GetProcess_internal (guint32 pid)
32 mono_error_init (&mono_error);
34 g_unsupported_api ("OpenProcess");
36 mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, "OpenProcess");
37 mono_error_set_pending_exception (&mono_error);
39 SetLastError (ERROR_NOT_SUPPORTED);
45 mono_w32process_get_fileversion (MonoObject *filever, gunichar2 *filename, MonoError *error)
47 g_unsupported_api ("GetFileVersionInfoSize, GetFileVersionInfo, VerQueryValue, VerLanguageName");
49 mono_error_init (error);
50 mono_error_set_not_supported (error, G_UNSUPPORTED_API, "GetFileVersionInfoSize, GetFileVersionInfo, VerQueryValue, VerLanguageName");
52 SetLastError (ERROR_NOT_SUPPORTED);
56 process_add_module (HANDLE process, HMODULE mod, gunichar2 *filename, gunichar2 *modulename, MonoClass *proc_class, MonoError *error)
58 g_unsupported_api ("GetModuleInformation");
60 mono_error_init (error);
61 mono_error_set_not_supported (error, G_UNSUPPORTED_API, "GetModuleInformation");
63 SetLastError (ERROR_NOT_SUPPORTED);
69 ves_icall_System_Diagnostics_Process_GetModules_internal (MonoObject *this_obj, HANDLE process)
72 mono_error_init (&mono_error);
74 g_unsupported_api ("EnumProcessModules, GetModuleBaseName, GetModuleFileNameEx");
76 mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, "EnumProcessModules, GetModuleBaseName, GetModuleFileNameEx");
77 mono_error_set_pending_exception (&mono_error);
79 SetLastError (ERROR_NOT_SUPPORTED);
85 ves_icall_System_Diagnostics_Process_ShellExecuteEx_internal (MonoW32ProcessStartInfo *proc_start_info, MonoW32ProcessInfo *process_info)
88 mono_error_init (&mono_error);
90 g_unsupported_api ("ShellExecuteEx");
92 mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, "ShellExecuteEx");
93 mono_error_set_pending_exception (&mono_error);
95 process_info->pid = (guint32)(-ERROR_NOT_SUPPORTED);
96 SetLastError (ERROR_NOT_SUPPORTED);
102 ves_icall_System_Diagnostics_Process_ProcessName_internal (HANDLE process)
106 gunichar2 name[MAX_PATH];
109 len = GetModuleFileName (NULL, name, G_N_ELEMENTS (name));
113 string = mono_string_new_utf16_checked (mono_domain_get (), name, len, &error);
114 if (!mono_error_ok (&error))
115 mono_error_set_pending_exception (&error);
121 mono_process_init_startup_info (HANDLE stdin_handle, HANDLE stdout_handle, HANDLE stderr_handle, STARTUPINFO *startinfo)
123 startinfo->cb = sizeof(STARTUPINFO);
124 startinfo->dwFlags = 0;
125 startinfo->hStdInput = INVALID_HANDLE_VALUE;
126 startinfo->hStdOutput = INVALID_HANDLE_VALUE;
127 startinfo->hStdError = INVALID_HANDLE_VALUE;
132 mono_process_create_process (MonoW32ProcessInfo *mono_process_info, MonoString *cmd, guint32 creation_flags,
133 gunichar2 *env_vars, gunichar2 *dir, STARTUPINFO *start_info, PROCESS_INFORMATION *process_info)
135 MonoError mono_error;
136 gchar *api_name = "";
138 if (mono_process_info->username) {
139 api_name = "CreateProcessWithLogonW";
141 api_name = "CreateProcess";
144 memset (&process_info, 0, sizeof (PROCESS_INFORMATION));
145 g_unsupported_api (api_name);
147 mono_error_init (&mono_error);
148 mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, api_name);
149 mono_error_set_pending_exception (&mono_error);
151 SetLastError (ERROR_NOT_SUPPORTED);
157 mono_icall_get_process_working_set_size (gpointer handle, gsize *min, gsize *max)
159 MonoError mono_error;
160 mono_error_init (&mono_error);
162 g_unsupported_api ("GetProcessWorkingSetSize");
164 mono_error_set_not_supported(&mono_error, G_UNSUPPORTED_API, "GetProcessWorkingSetSize");
165 mono_error_set_pending_exception (&mono_error);
167 SetLastError (ERROR_NOT_SUPPORTED);
173 mono_icall_set_process_working_set_size (gpointer handle, gsize min, gsize max)
175 MonoError mono_error;
176 mono_error_init (&mono_error);
178 g_unsupported_api ("SetProcessWorkingSetSize");
180 mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, "SetProcessWorkingSetSize");
181 mono_error_set_pending_exception (&mono_error);
183 SetLastError (ERROR_NOT_SUPPORTED);
189 mono_icall_get_priority_class (gpointer handle)
191 MonoError mono_error;
192 mono_error_init (&mono_error);
194 g_unsupported_api ("GetPriorityClass");
196 mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, "GetPriorityClass");
197 mono_error_set_pending_exception (&mono_error);
199 SetLastError (ERROR_NOT_SUPPORTED);
205 mono_icall_set_priority_class (gpointer handle, gint32 priorityClass)
207 MonoError mono_error;
208 mono_error_init (&mono_error);
210 g_unsupported_api ("SetPriorityClass");
212 mono_error_set_not_supported(&mono_error, G_UNSUPPORTED_API, "SetPriorityClass");
213 mono_error_set_pending_exception (&mono_error);
215 SetLastError (ERROR_NOT_SUPPORTED);
220 #else /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
222 MONO_EMPTY_SOURCE_FILE (process_windows_uwp);
223 #endif /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */