3 * System.Diagnostics.Process support
6 * Dick Porter (dick@ximian.com)
8 * Copyright 2002 Ximian, Inc.
9 * Copyright 2002-2006 Novell, Inc.
10 * Licensed under the MIT license. See LICENSE file in the project root for full license information.
21 #include <mono/metadata/w32process.h>
22 #include <mono/metadata/assembly.h>
23 #include <mono/metadata/appdomain.h>
24 #include <mono/metadata/image.h>
25 #include <mono/metadata/cil-coff.h>
26 #include <mono/metadata/exception.h>
27 #include <mono/metadata/threadpool-io.h>
28 #include <mono/utils/strenc.h>
29 #include <mono/utils/mono-proclib.h>
30 #include <mono/metadata/w32handle.h>
31 #include <mono/utils/w32api.h>
32 #include <mono/utils/mono-threads-coop.h>
33 #include <mono/utils/w32subset.h>
36 mono_w32process_init (void)
41 mono_w32process_cleanup (void)
46 mono_w32process_signal_finished (void)
51 mono_w32process_get_pid (gpointer handle
)
53 return GetProcessId (handle
);
56 #if HAVE_API_SUPPORT_WIN32_ENUM_WINDOWS
63 mono_enum_windows_callback(HWND hwnd
, LPARAM lparam
)
65 EnumWindowsArgs
*args
= (EnumWindowsArgs
*)lparam
;
67 GetWindowThreadProcessId(hwnd
, &pid
);
68 if (pid
!= args
->pid
|| GetWindow(hwnd
, GW_OWNER
) != NULL
|| !IsWindowVisible(hwnd
)) return TRUE
;
74 ves_icall_System_Diagnostics_Process_MainWindowHandle_internal (guint32 pid
, MonoError
*error
)
76 EnumWindowsArgs args
= {pid
, NULL
};
77 EnumWindows(mono_enum_windows_callback
, (LPARAM
)&args
);
80 #elif !HAVE_EXTERN_DEFINED_WIN32_ENUM_WINDOWS
82 ves_icall_System_Diagnostics_Process_MainWindowHandle_internal (guint32 pid
, MonoError
*error
)
84 /*TODO: Implement for uwp*/
87 #endif /* HAVE_API_SUPPORT_WIN32_ENUM_WINDOWS */
89 #if HAVE_API_SUPPORT_WIN32_ENUM_PROCESS_MODULES
91 mono_w32process_try_get_modules (gpointer process
, gpointer
*modules
, guint32 size
, guint32
*needed
)
93 return EnumProcessModules (process
, (HMODULE
*)modules
, size
, (PDWORD
)needed
);
95 #elif !HAVE_EXTERN_DEFINED_WIN32_ENUM_PROCESS_MODULES
97 mono_w32process_try_get_modules (gpointer process
, gpointer
*modules
, guint32 size
, guint32
*needed
)
99 g_unsupported_api ("EnumProcessModules");
100 SetLastError (ERROR_NOT_SUPPORTED
);
105 #if HAVE_API_SUPPORT_WIN32_GET_MODULE_BASE_NAME
107 mono_w32process_module_get_name (gpointer process
, gpointer module
, gunichar2
**str
, guint32
*len
)
109 return mono_get_module_basename (process
, module
, str
, len
);
111 #elif !HAVE_EXTERN_DEFINED_WIN32_GET_MODULE_BASE_NAME
113 mono_w32process_module_get_name (gpointer process
, gpointer module
, gunichar2
**str
, guint32
*len
)
115 g_unsupported_api ("GetModuleBaseName");
116 SetLastError (ERROR_NOT_SUPPORTED
);
119 #endif /* HAVE_API_SUPPORT_WIN32_GET_MODULE_BASE_NAME */
121 #if HAVE_API_SUPPORT_WIN32_GET_MODULE_FILE_NAME_EX
123 mono_w32process_module_get_filename (gpointer process
, gpointer module
, gunichar2
**str
, guint32
*len
)
125 return mono_get_module_filename_ex (process
, module
, str
, len
);
127 #elif !HAVE_EXTERN_DEFINED_WIN32_GET_MODULE_FILE_NAME_EX
129 mono_w32process_module_get_filename (gpointer process
, gpointer module
, gunichar2
**str
, guint32
*len
)
131 g_unsupported_api ("GetModuleFileNameEx");
132 SetLastError (ERROR_NOT_SUPPORTED
);
135 #endif /* HAVE_API_SUPPORT_WIN32_GET_MODULE_FILE_NAME_EX */
137 #if HAVE_API_SUPPORT_WIN32_GET_MODULE_INFORMATION
139 mono_w32process_module_get_information (gpointer process
, gpointer module
, gpointer modinfo
, guint32 size
)
141 return GetModuleInformation (process
, (HMODULE
)module
, (MODULEINFO
*)modinfo
, size
);
143 #elif !HAVE_EXTERN_DEFINED_WIN32_GET_MODULE_INFORMATION
145 mono_w32process_module_get_information (gpointer process
, gpointer module
, gpointer modinfo
, guint32 size
)
147 g_unsupported_api ("GetModuleInformation");
148 SetLastError (ERROR_NOT_SUPPORTED
);
151 #endif /* HAVE_API_SUPPORT_WIN32_GET_MODULE_INFORMATION */
153 #if HAVE_API_SUPPORT_WIN32_GET_FILE_VERSION_INFO
155 mono_w32process_get_fileversion_info (const gunichar2
*filename
, gpointer
*data
)
162 DWORD datasize
= GetFileVersionInfoSizeW (filename
, &handle
);
166 *data
= g_malloc0 (datasize
);
167 if (!GetFileVersionInfoW (filename
, handle
, datasize
, *data
)) {
174 #elif !HAVE_EXTERN_DEFINED_WIN32_GET_FILE_VERSION_INFO
176 mono_w32process_get_fileversion_info (const gunichar2
*filename
, gpointer
*data
)
178 g_unsupported_api ("GetFileVersionInfo");
179 SetLastError (ERROR_NOT_SUPPORTED
);
182 #endif /* HAVE_API_SUPPORT_WIN32_GET_FILE_VERSION_INFO */
184 #if HAVE_API_SUPPORT_WIN32_VER_QUERY_VALUE
186 mono_w32process_ver_query_value (gconstpointer datablock
, const gunichar2
*subblock
, gpointer
*buffer
, guint32
*len
)
188 return VerQueryValueW (datablock
, subblock
, buffer
, len
);
190 #elif !HAVE_EXTERN_DEFINED_WIN32_VER_QUERY_VALUE
192 mono_w32process_ver_query_value (gconstpointer datablock
, const gunichar2
*subblock
, gpointer
*buffer
, guint32
*len
)
194 g_unsupported_api ("VerQueryValue");
195 SetLastError (ERROR_NOT_SUPPORTED
);
198 #endif /* HAVE_API_SUPPORT_WIN32_VER_QUERY_VALUE */
200 #if HAVE_API_SUPPORT_WIN32_VER_LANGUAGE_NAME
202 mono_w32process_ver_language_name (guint32 lang
, gunichar2
*lang_out
, guint32 lang_len
)
204 return VerLanguageNameW (lang
, lang_out
, lang_len
);
206 #elif !HAVE_EXTERN_DEFINED_WIN32_VER_LANGUAGE_NAME
208 mono_w32process_ver_language_name (guint32 lang
, gunichar2
*lang_out
, guint32 lang_len
)
210 g_unsupported_api ("VerLanguageName");
211 SetLastError (ERROR_NOT_SUPPORTED
);
214 #endif /* HAVE_API_SUPPORT_WIN32_VER_LANGUAGE_NAME */
216 #if HAVE_API_SUPPORT_WIN32_OPEN_PROCESS
218 ves_icall_System_Diagnostics_Process_GetProcess_internal (guint32 pid
, MonoError
*error
)
222 /* GetCurrentProcess returns a pseudo-handle, so use
223 * OpenProcess instead
225 handle
= OpenProcess (PROCESS_ALL_ACCESS
, TRUE
, pid
);
227 /* FIXME: Throw an exception */
231 #elif !HAVE_EXTERN_DEFINED_WIN32_OPEN_PROCESS
233 ves_icall_System_Diagnostics_Process_GetProcess_internal (guint32 pid
, MonoError
*error
)
235 g_unsupported_api ("OpenProcess");
236 mono_error_set_not_supported (error
, G_UNSUPPORTED_API
, "OpenProcess");
237 SetLastError (ERROR_NOT_SUPPORTED
);
240 #endif /* HAVE_API_SUPPORT_WIN32_OPEN_PROCESS */
242 #if HAVE_API_SUPPORT_WIN32_SHELL_EXECUTE_EX
243 #include <shellapi.h>
245 ves_icall_System_Diagnostics_Process_ShellExecuteEx_internal (MonoW32ProcessStartInfoHandle proc_start_info
, MonoW32ProcessInfo
*process_info
, MonoError
*error
)
247 MonoCreateProcessCoop coop
;
248 mono_createprocess_coop_init (&coop
, proc_start_info
, process_info
);
250 SHELLEXECUTEINFOW shellex
= {0};
253 shellex
.cbSize
= sizeof(SHELLEXECUTEINFO
);
254 shellex
.fMask
= (gulong
)(SEE_MASK_NOASYNC
| SEE_MASK_NOCLOSEPROCESS
| SEE_MASK_UNICODE
);
255 shellex
.nShow
= (gulong
)MONO_HANDLE_GETVAL (proc_start_info
, window_style
);
256 shellex
.nShow
= (gulong
)((shellex
.nShow
== 0) ? 1 : (shellex
.nShow
== 1 ? 0 : shellex
.nShow
));
258 shellex
.lpFile
= coop
.filename
;
259 shellex
.lpParameters
= coop
.arguments
;
261 if (coop
.length
.verb
)
262 shellex
.lpVerb
= coop
.verb
;
264 if (coop
.length
.working_directory
)
265 shellex
.lpDirectory
= coop
.working_directory
;
267 if (MONO_HANDLE_GETVAL (proc_start_info
, error_dialog
))
268 shellex
.hwnd
= (HWND
)MONO_HANDLE_GETVAL (proc_start_info
, error_dialog_parent_handle
);
270 shellex
.fMask
= (gulong
)(shellex
.fMask
| SEE_MASK_FLAG_NO_UI
);
273 ret
= ShellExecuteExW (&shellex
);
277 process_info
->pid
= -GetLastError ();
279 process_info
->process_handle
= shellex
.hProcess
;
280 #if !defined(MONO_CROSS_COMPILE)
281 process_info
->pid
= GetProcessId (shellex
.hProcess
);
283 process_info
->pid
= 0;
287 mono_createprocess_coop_cleanup (&coop
);
291 #elif !HAVE_EXTERN_DEFINED_WIN32_SHELL_EXECUTE_EX
293 ves_icall_System_Diagnostics_Process_ShellExecuteEx_internal (MonoW32ProcessStartInfoHandle proc_start_info
, MonoW32ProcessInfo
*process_info
, MonoError
*error
)
295 g_unsupported_api ("ShellExecuteEx");
296 mono_error_set_not_supported (error
, G_UNSUPPORTED_API
, "ShellExecuteEx");
297 process_info
->pid
= (guint32
)(-ERROR_NOT_SUPPORTED
);
298 SetLastError (ERROR_NOT_SUPPORTED
);
301 #endif /* HAVE_API_SUPPORT_WIN32_SHELL_EXECUTE_EX */
303 #if HAVE_API_SUPPORT_WIN32_CREATE_PROCESS_WITH_LOGON || HAVE_API_SUPPORT_WIN32_CREATE_PROCESS
305 mono_process_create_process (MonoCreateProcessCoop
*coop
, MonoW32ProcessInfo
*mono_process_info
,
306 MonoStringHandle cmd
, guint32 creation_flags
, gunichar2
*env_vars
, gunichar2
*dir
,
307 HANDLE stdin_handle
, HANDLE stdout_handle
, HANDLE stderr_handle
, PROCESS_INFORMATION
*process_info
, MonoError
*error
)
309 gboolean result
= FALSE
;
310 MonoGCHandle cmd_gchandle
= NULL
;
311 gunichar2
*cmd_chars
= MONO_HANDLE_IS_NULL (cmd
) ? NULL
: mono_string_handle_pin_chars (cmd
, &cmd_gchandle
);
313 STARTUPINFOW start_info
={0};
314 #if HAVE_API_SUPPORT_WIN32_CONSOLE
315 start_info
.cb
= sizeof(STARTUPINFOW
);
316 start_info
.dwFlags
= STARTF_USESTDHANDLES
;
317 start_info
.hStdInput
= stdin_handle
;
318 start_info
.hStdOutput
= stdout_handle
;
319 start_info
.hStdError
= stderr_handle
;
321 start_info
.dwFlags
= 0;
322 start_info
.hStdInput
= INVALID_HANDLE_VALUE
;
323 start_info
.hStdOutput
= INVALID_HANDLE_VALUE
;
324 start_info
.hStdError
= INVALID_HANDLE_VALUE
;
325 #endif /* HAVE_API_SUPPORT_WIN32_CONSOLE */
328 if (coop
->username
) {
329 #if HAVE_API_SUPPORT_WIN32_CREATE_PROCESS_WITH_LOGON
330 guint32 logon_flags
= mono_process_info
->load_user_profile
? LOGON_WITH_PROFILE
: 0;
332 result
= CreateProcessWithLogonW (coop
->username
,
334 mono_process_info
->password
,
339 env_vars
, dir
, &start_info
, process_info
);
341 memset (process_info
, 0, sizeof (PROCESS_INFORMATION
));
342 g_unsupported_api ("CreateProcessWithLogon");
343 mono_error_set_not_supported (error
, G_UNSUPPORTED_API
, "CreateProcessWithLogon");
344 SetLastError (ERROR_NOT_SUPPORTED
);
345 #endif /* HAVE_API_SUPPORT_WIN32_CREATE_PROCESS_WITH_LOGON */
347 #if HAVE_API_SUPPORT_WIN32_CREATE_PROCESS
348 result
= CreateProcessW (NULL
,
359 memset (process_info
, 0, sizeof (PROCESS_INFORMATION
));
360 g_unsupported_api ("CreateProcess");
361 mono_error_set_not_supported (error
, G_UNSUPPORTED_API
, "CreateProcess");
362 SetLastError (ERROR_NOT_SUPPORTED
);
367 mono_gchandle_free_internal (cmd_gchandle
);
371 #elif !HAVE_EXTERN_DEFINED_WIN32_CREATE_PROCESS_WITH_LOGON && !HAVE_EXTERN_DEFINED_WIN32_CREATE_PROCESS
373 mono_process_create_process (MonoCreateProcessCoop
*coop
, MonoW32ProcessInfo
*mono_process_info
,
374 MonoStringHandle cmd
, guint32 creation_flags
, gunichar2
*env_vars
, gunichar2
*dir
,
375 HANDLE stdin_handle
, HANDLE stdout_handle
, HANDLE stderr_handle
, PROCESS_INFORMATION
*process_info
, MonoError
*error
)
377 memset (process_info
, 0, sizeof (PROCESS_INFORMATION
));
378 g_unsupported_api ("CreateProcessWithLogon, CreateProcess");
379 mono_error_set_not_supported (error
, G_UNSUPPORTED_API
, "CreateProcessWithLogon, CreateProcess");
380 SetLastError (ERROR_NOT_SUPPORTED
);
383 #endif /* HAVE_API_SUPPORT_WIN32_CREATE_PROCESS_WITH_LOGON || HAVE_API_SUPPORT_WIN32_CREATE_PROCESS */
386 process_unquote_application_name (gchar
*appname
)
388 size_t len
= strlen (appname
);
390 if (appname
[len
-1] == '\"')
391 appname
[len
-1] = '\0';
392 if (appname
[0] == '\"')
400 process_quote_path (const gchar
*path
)
402 gchar
*res
= g_shell_quote (path
);
412 /* Only used when UseShellExecute is false */
414 process_complete_path (const gunichar2
*appname
)
416 // FIXME This function should stick to gunichar2.
419 char *utf8appmemory
= NULL
;
422 utf8appmemory
= g_utf16_to_utf8 (appname
, -1, NULL
, NULL
, NULL
);
423 utf8app
= process_unquote_application_name (utf8appmemory
);
425 result
= process_quote_path (utf8app
);
427 g_free (utf8appmemory
);
433 process_get_shell_arguments (MonoCreateProcessCoop
*proc_start_info
, MonoStringHandle
*cmd
, MonoError
*error
)
436 char *new_cmd
= NULL
;
437 char *cmd_utf8
= NULL
;
439 *cmd
= proc_start_info
->coophandle
.arguments
;
441 // FIXME There are excess utf8 <=> gunichar2 conversions here.
442 // We are either returning spath, or spath + " " + cmd.
443 // Just use gunichar2. Maybe move logic to C#.
445 spath
= process_complete_path (proc_start_info
->filename
);
447 /* Seems like our CreateProcess does not work as the windows one.
448 * This hack is needed to deal with paths containing spaces */
449 if (!MONO_HANDLE_IS_NULL (*cmd
)) {
450 cmd_utf8
= mono_string_handle_to_utf8 (*cmd
, error
);
451 goto_if_nok (error
, error
);
452 new_cmd
= g_strdup_printf ("%s %s", spath
, cmd_utf8
);
453 *cmd
= mono_string_new_utf8_len (mono_domain_get (), new_cmd
, strlen (new_cmd
), error
);
454 goto_if_nok (error
, error
);
457 *cmd
= mono_string_new_utf8_len (mono_domain_get (), spath
, strlen (spath
), error
);
458 goto_if_nok (error
, error
);
465 return !MONO_HANDLE_IS_NULL (*cmd
);
467 *cmd
= NULL_HANDLE_STRING
;
472 ves_icall_System_Diagnostics_Process_CreateProcess_internal (MonoW32ProcessStartInfoHandle proc_start_info
,
473 HANDLE stdin_handle
, HANDLE stdout_handle
, HANDLE stderr_handle
, MonoW32ProcessInfo
*process_info
, MonoError
*error
)
475 MonoCreateProcessCoop coop
;
476 mono_createprocess_coop_init (&coop
, proc_start_info
, process_info
);
479 gunichar2
*dir
= NULL
;
480 PROCESS_INFORMATION procinfo
;
481 gunichar2
*env_vars
= NULL
;
482 MonoStringHandle cmd
= NULL_HANDLE_STRING
;
483 guint32 creation_flags
;
485 creation_flags
= CREATE_UNICODE_ENVIRONMENT
;
486 if (MONO_HANDLE_GETVAL (proc_start_info
, create_no_window
))
487 creation_flags
|= CREATE_NO_WINDOW
;
489 if (process_get_shell_arguments (&coop
, &cmd
, error
) == FALSE
) {
490 // FIXME This should be passed back separately.
491 process_info
->pid
= -ERROR_FILE_NOT_FOUND
;
496 if (process_info
->env_variables
) {
497 MonoArrayHandle array
= MONO_HANDLE_NEW (MonoArray
, process_info
->env_variables
);
498 MonoStringHandle var
= MONO_HANDLE_NEW (MonoString
, NULL
);
499 gsize
const array_length
= mono_array_handle_length (array
);
501 // nul-separated and nul-terminated
502 gsize len
= array_length
+ 1 + !array_length
;
504 for (gsize i
= 0; i
< array_length
; i
++) {
505 MONO_HANDLE_ARRAY_GETREF (var
, array
, i
);
506 len
+= mono_string_handle_length (var
);
509 gunichar2
*ptr
= g_new0 (gunichar2
, len
);
512 for (gsize i
= 0; i
< array_length
; i
++) {
513 MONO_HANDLE_ARRAY_GETREF (var
, array
, i
);
514 MonoGCHandle gchandle
= NULL
;
515 memcpy (ptr
, mono_string_handle_pin_chars (var
, &gchandle
), mono_string_handle_length (var
) * sizeof (gunichar2
));
516 mono_gchandle_free_internal (gchandle
);
517 ptr
+= mono_string_handle_length (var
);
518 ptr
+= 1; // Skip over the null-separator
522 /* The default dir name is "". Turn that into NULL to mean
523 * "current directory"
525 if (coop
.length
.working_directory
)
526 dir
= coop
.working_directory
;
528 ret
= mono_process_create_process (&coop
, process_info
, cmd
, creation_flags
, env_vars
, dir
, stdin_handle
, stdout_handle
, stderr_handle
, &procinfo
, error
);
533 process_info
->process_handle
= procinfo
.hProcess
;
534 /*process_info->thread_handle=procinfo.hThread;*/
535 if (procinfo
.hThread
!= NULL
&& procinfo
.hThread
!= INVALID_HANDLE_VALUE
)
536 CloseHandle (procinfo
.hThread
);
537 process_info
->pid
= procinfo
.dwProcessId
;
539 // FIXME This should be passed back separately.
540 process_info
->pid
= -GetLastError ();
544 mono_createprocess_coop_cleanup (&coop
);
548 #if HAVE_API_SUPPORT_WIN32_ENUM_PROCESSES
550 ves_icall_System_Diagnostics_Process_GetProcesses_internal (MonoError
*error
)
552 MonoArrayHandle procs
= NULL_HANDLE_ARRAY
;
559 pids
= g_new0 (DWORD
, count
);
562 success
= EnumProcesses (pids
, count
* sizeof (DWORD
), &needed
);
567 if (needed
< (count
* sizeof (guint32
)))
571 count
= (count
* 3) / 2;
574 count
= needed
/ sizeof (guint32
);
575 procs
= mono_array_new_handle (mono_domain_get (), mono_get_int32_class (), count
, error
);
576 if (!is_ok (error
)) {
577 procs
= NULL_HANDLE_ARRAY
;
581 MONO_ENTER_NO_SAFEPOINTS
;
583 memcpy (mono_array_addr_internal (MONO_HANDLE_RAW (procs
), guint32
, 0), pids
, needed
);
585 MONO_EXIT_NO_SAFEPOINTS
;
591 #elif !HAVE_EXTERN_DEFINED_WIN32_ENUM_PROCESSES
593 ves_icall_System_Diagnostics_Process_GetProcesses_internal (MonoError
*error
)
595 g_unsupported_api ("EnumProcesses");
596 mono_error_set_not_supported (error
, G_UNSUPPORTED_API
, "EnumProcesses");
597 SetLastError (ERROR_NOT_SUPPORTED
);
598 return NULL_HANDLE_ARRAY
;
600 #endif /* HAVE_API_SUPPORT_WIN32_ENUM_PROCESSES */
603 ves_icall_Microsoft_Win32_NativeMethods_CloseProcess (gpointer handle
)
605 return CloseHandle (handle
);
609 ves_icall_Microsoft_Win32_NativeMethods_TerminateProcess (gpointer handle
, gint32 exitcode
)
611 return TerminateProcess (handle
, exitcode
);
615 ves_icall_Microsoft_Win32_NativeMethods_GetExitCodeProcess (gpointer handle
, gint32
*exitcode
)
617 return GetExitCodeProcess (handle
, (PDWORD
)exitcode
);
620 #if HAVE_API_SUPPORT_WIN32_GET_WORKING_SET_SIZE
622 ves_icall_Microsoft_Win32_NativeMethods_GetProcessWorkingSetSize (gpointer handle
, gsize
*min
, gsize
*max
)
624 return GetProcessWorkingSetSize (handle
, (PSIZE_T
)min
, (PSIZE_T
)max
);
626 #elif !HAVE_EXTERN_DEFINED_WIN32_GET_WORKING_SET_SIZE
628 ves_icall_Microsoft_Win32_NativeMethods_GetProcessWorkingSetSize (gpointer handle
, gsize
*min
, gsize
*max
)
631 g_unsupported_api ("GetProcessWorkingSetSize");
632 mono_error_set_not_supported(error
, G_UNSUPPORTED_API
, "GetProcessWorkingSetSize");
633 mono_error_set_pending_exception (error
);
634 SetLastError (ERROR_NOT_SUPPORTED
);
637 #endif /* HAVE_API_SUPPORT_WIN32_GET_WORKING_SET_SIZE */
639 #if HAVE_API_SUPPORT_WIN32_SET_WORKING_SET_SIZE
641 ves_icall_Microsoft_Win32_NativeMethods_SetProcessWorkingSetSize (gpointer handle
, gsize min
, gsize max
)
643 return SetProcessWorkingSetSize (handle
, min
, max
);
645 #elif !HAVE_EXTERN_DEFINED_WIN32_SET_WORKING_SET_SIZE
647 ves_icall_Microsoft_Win32_NativeMethods_SetProcessWorkingSetSize (gpointer handle
, gsize min
, gsize max
)
650 g_unsupported_api ("SetProcessWorkingSetSize");
651 mono_error_set_not_supported (error
, G_UNSUPPORTED_API
, "SetProcessWorkingSetSize");
652 mono_error_set_pending_exception (error
);
653 SetLastError (ERROR_NOT_SUPPORTED
);
656 #endif /* HAVE_API_SUPPORT_WIN32_SET_WORKING_SET_SIZE */
658 #if HAVE_API_SUPPORT_WIN32_GET_PRIORITY_CLASS
660 ves_icall_Microsoft_Win32_NativeMethods_GetPriorityClass (gpointer handle
)
662 return GetPriorityClass (handle
);
664 #elif !HAVE_EXTERN_DEFINED_WIN32_GET_PRIORITY_CLASS
666 ves_icall_Microsoft_Win32_NativeMethods_GetPriorityClass (gpointer handle
)
669 g_unsupported_api ("GetPriorityClass");
670 mono_error_set_not_supported (error
, G_UNSUPPORTED_API
, "GetPriorityClass");
671 mono_error_set_pending_exception (error
);
672 SetLastError (ERROR_NOT_SUPPORTED
);
675 #endif /* HAVE_API_SUPPORT_WIN32_GET_PRIORITY_CLASS */
677 #if HAVE_API_SUPPORT_WIN32_SET_PRIORITY_CLASS
679 ves_icall_Microsoft_Win32_NativeMethods_SetPriorityClass (gpointer handle
, gint32 priorityClass
)
681 return SetPriorityClass (handle
, (guint32
) priorityClass
);
683 #elif !HAVE_EXTERN_DEFINED_WIN32_SET_PRIORITY_CLASS
685 ves_icall_Microsoft_Win32_NativeMethods_SetPriorityClass (gpointer handle
, gint32 priorityClass
)
688 g_unsupported_api ("SetPriorityClass");
689 mono_error_set_not_supported(error
, G_UNSUPPORTED_API
, "SetPriorityClass");
690 mono_error_set_pending_exception (error
);
691 SetLastError (ERROR_NOT_SUPPORTED
);
694 #endif /* HAVE_API_SUPPORT_WIN32_SET_PRIORITY_CLASS */
697 ves_icall_Microsoft_Win32_NativeMethods_GetProcessTimes (gpointer handle
, gint64
*creationtime
, gint64
*exittime
, gint64
*kerneltime
, gint64
*usertime
)
699 return GetProcessTimes (handle
, (LPFILETIME
) creationtime
, (LPFILETIME
) exittime
, (LPFILETIME
) kerneltime
, (LPFILETIME
) usertime
);
703 ves_icall_Microsoft_Win32_NativeMethods_GetCurrentProcess (void)
705 return GetCurrentProcess ();