Fix for bug #31730
[mono.git] / mono / os / win32 / util.c
index 3a69258dbc3359472e3d1896b382813217020e7c..009c93dfe8d340e955c427c8bec91b71683d98f5 100644 (file)
@@ -7,25 +7,30 @@
  * (C) 2002 Ximian, Inc. (http://www.ximian.com)
  */
 #include <config.h>
+#include <windows.h>
 #include <mono/metadata/metadata.h>
 #include <mono/os/util.h>
 
 /*
  * mono_set_rootdir:
- * @vm_filename: The pathname of the code invoking us (argv [0])
  *
  * Informs the runtime of the root directory for the Mono installation,
  * the vm_file
  */
 void
-mono_set_rootdir (const char *vm_filename)
+mono_set_rootdir (void)
 {
-       char *dir = g_dirname (vm_filename);
-       char *root = g_strconcat (dir, "/lib");
+       char moddir[MAXPATHLEN], *bindir, *installdir, *root;
+
+       GetModuleFileName (NULL, moddir, sizeof(moddir));
+       bindir = g_path_get_dirname (moddir);
+       installdir = g_path_get_dirname (bindir);
+       root = g_build_path (G_DIR_SEPARATOR_S, installdir, "lib", NULL);
 
        mono_assembly_setrootdir (root);
        g_free (root);
-       g_free (dir);
+       g_free (installdir);
+       g_free (bindir);
 }