Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / metadata / w32process-win32-uwp.c
index 9fc329ad7a22ea3d48860e6669a44c5b8e6d92eb..be769f4b320d1231e88856fa3854be81a33df5f7 100644 (file)
@@ -1,14 +1,19 @@
-/*
- * process-windows-uwp.c: UWP process support for Mono.
+/**
+ * \file
+ * UWP process support for Mono.
  *
  * Copyright 2016 Microsoft
  * Licensed under the MIT license. See LICENSE file in the project root for full license information.
 */
 #include <config.h>
 #include <glib.h>
+#include "mono/utils/mono-compiler.h"
 
 #if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
-#include <Windows.h>
+#include <windows.h>
+#include <mono/metadata/object-internals.h>
+#include "mono/metadata/w32process.h"
+#include "mono/metadata/w32process-internals.h"
 #include "mono/metadata/w32process-win32-internals.h"
 
 gboolean
@@ -24,16 +29,17 @@ mono_process_win_enum_processes (DWORD *pids, DWORD count, DWORD *needed)
 HANDLE
 ves_icall_System_Diagnostics_Process_GetProcess_internal (guint32 pid)
 {
-       HANDLE handle;
-
-       /* GetCurrentProcess returns a pseudo-handle, so use
-        * OpenProcess instead
-        */
-       handle = OpenProcess (PROCESS_ALL_ACCESS, TRUE, pid);
-       if (handle == NULL)
-               /* FIXME: Throw an exception */
-               return NULL;
-       return handle;
+       MonoError mono_error;
+       error_init (&mono_error);
+
+       g_unsupported_api ("OpenProcess");
+
+       mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, "OpenProcess");
+       mono_error_set_pending_exception (&mono_error);
+
+       SetLastError (ERROR_NOT_SUPPORTED);
+
+       return NULL;
 }
 
 void
@@ -41,7 +47,7 @@ mono_w32process_get_fileversion (MonoObject *filever, gunichar2 *filename, MonoE
 {
        g_unsupported_api ("GetFileVersionInfoSize, GetFileVersionInfo, VerQueryValue, VerLanguageName");
 
-       mono_error_init (error);
+       error_init (error);
        mono_error_set_not_supported (error, G_UNSUPPORTED_API, "GetFileVersionInfoSize, GetFileVersionInfo, VerQueryValue, VerLanguageName");
 
        SetLastError (ERROR_NOT_SUPPORTED);
@@ -52,7 +58,7 @@ process_add_module (HANDLE process, HMODULE mod, gunichar2 *filename, gunichar2
 {
        g_unsupported_api ("GetModuleInformation");
 
-       mono_error_init (error);
+       error_init (error);
        mono_error_set_not_supported (error, G_UNSUPPORTED_API, "GetModuleInformation");
 
        SetLastError (ERROR_NOT_SUPPORTED);
@@ -64,7 +70,7 @@ MonoArray *
 ves_icall_System_Diagnostics_Process_GetModules_internal (MonoObject *this_obj, HANDLE process)
 {
        MonoError mono_error;
-       mono_error_init (&mono_error);
+       error_init (&mono_error);
 
        g_unsupported_api ("EnumProcessModules, GetModuleBaseName, GetModuleFileNameEx");
 
@@ -77,10 +83,10 @@ ves_icall_System_Diagnostics_Process_GetModules_internal (MonoObject *this_obj,
 }
 
 MonoBoolean
-ves_icall_System_Diagnostics_Process_ShellExecuteEx_internal (MonoProcessStartInfo *proc_start_info, MonoProcInfo *process_info)
+ves_icall_System_Diagnostics_Process_ShellExecuteEx_internal (MonoW32ProcessStartInfo *proc_start_info, MonoW32ProcessInfo *process_info)
 {
        MonoError mono_error;
-       mono_error_init (&mono_error);
+       error_init (&mono_error);
 
        g_unsupported_api ("ShellExecuteEx");
 
@@ -124,8 +130,8 @@ mono_process_init_startup_info (HANDLE stdin_handle, HANDLE stdout_handle, HANDL
 }
 
 gboolean
-mono_process_create_process (MonoProcInfo *mono_process_info, gunichar2 *shell_path, MonoString *cmd, guint32 creation_flags,
-                            gchar *env_vars, gunichar2 *dir, STARTUPINFO *start_info, PROCESS_INFORMATION *process_info)
+mono_process_create_process (MonoW32ProcessInfo *mono_process_info, MonoString *cmd, guint32 creation_flags,
+       gunichar2 *env_vars, gunichar2 *dir, STARTUPINFO *start_info, PROCESS_INFORMATION *process_info)
 {
        MonoError       mono_error;
        gchar           *api_name = "";
@@ -139,7 +145,7 @@ mono_process_create_process (MonoProcInfo *mono_process_info, gunichar2 *shell_p
        memset (&process_info, 0, sizeof (PROCESS_INFORMATION));
        g_unsupported_api (api_name);
 
-       mono_error_init (&mono_error);
+       error_init (&mono_error);
        mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, api_name);
        mono_error_set_pending_exception (&mono_error);
 
@@ -152,7 +158,7 @@ MonoBoolean
 mono_icall_get_process_working_set_size (gpointer handle, gsize *min, gsize *max)
 {
        MonoError mono_error;
-       mono_error_init (&mono_error);
+       error_init (&mono_error);
 
        g_unsupported_api ("GetProcessWorkingSetSize");
 
@@ -168,7 +174,7 @@ MonoBoolean
 mono_icall_set_process_working_set_size (gpointer handle, gsize min, gsize max)
 {
        MonoError mono_error;
-       mono_error_init (&mono_error);
+       error_init (&mono_error);
 
        g_unsupported_api ("SetProcessWorkingSetSize");
 
@@ -184,7 +190,7 @@ gint32
 mono_icall_get_priority_class (gpointer handle)
 {
        MonoError mono_error;
-       mono_error_init (&mono_error);
+       error_init (&mono_error);
 
        g_unsupported_api ("GetPriorityClass");
 
@@ -200,7 +206,7 @@ MonoBoolean
 mono_icall_set_priority_class (gpointer handle, gint32 priorityClass)
 {
        MonoError mono_error;
-       mono_error_init (&mono_error);
+       error_init (&mono_error);
 
        g_unsupported_api ("SetPriorityClass");
 
@@ -214,8 +220,5 @@ mono_icall_set_priority_class (gpointer handle, gint32 priorityClass)
 
 #else /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
 
-#ifdef _MSC_VER
-// Quiet Visual Studio linker warning, LNK4221, in cases when this source file intentional ends up empty.
-void __mono_win32_process_windows_uwp_quiet_lnk4221(void) {}
-#endif
+MONO_EMPTY_SOURCE_FILE (process_windows_uwp);
 #endif /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */