data=((gunichar2 *)data)+(unicode_chars (block->key)+1);
/* align on a 32-bit boundary */
- data=(gpointer)(((unsigned)data+3) & (~3));
+ data=(gpointer)((char *)data + 3);
+ data=(gpointer)((char *)data - (GPOINTER_TO_INT(data) & 3));
return(data);
}
gunichar2 *value;
/* align on a 32-bit boundary */
- data_ptr=(gpointer)(((unsigned)data_ptr+3) & (~3));
+ data_ptr=(gpointer)((char *)data_ptr + 3);
+ data_ptr=(gpointer)((char *)data_ptr -
+ (GPOINTER_TO_INT(data_ptr) & 3));
data_ptr=process_get_versioninfo_block (data_ptr, &block);
if(block.data_len==0) {
while(string_len<data_len) {
/* align on a 32-bit boundary */
- data_ptr=(gpointer)(((unsigned)data_ptr+3) & (~3));
+ data_ptr=(gpointer)((char *)data_ptr + 3);
+ data_ptr=(gpointer)((char *)data_ptr -
+ (GPOINTER_TO_INT(data_ptr) & 3));
data_ptr=process_get_versioninfo_block (data_ptr, &block);
if(block.data_len==0) {
*/
while(data_len > 0) {
/* align on a 32-bit boundary */
- data_ptr=(gpointer)(((unsigned)data_ptr+3) & (~3));
+ data_ptr=(gpointer)((char *)data_ptr + 3);
+ data_ptr=(gpointer)((char *)data_ptr -
+ (GPOINTER_TO_INT(data_ptr) & 3));
data_ptr=process_get_versioninfo_block (data_ptr, &block);
if(block.data_len==0) {
mono_image_close (image);
}
+/* Only used when UseShellExecute is false */
+static gchar *
+quote_path (const gchar *path)
+{
+ gchar *res = g_shell_quote (path);
+#ifdef PLATFORM_WIN32
+ {
+ gchar *q = res;
+ while (*q) {
+ if (*q == '\'')
+ *q = '\"';
+ q++;
+ }
+ }
+#endif
+ return res;
+}
+
+/* Only used when UseShellExecute is false */
static gboolean
-complete_path (const gunichar2 *appname, gunichar2 **completed)
+complete_path (const gunichar2 *appname, gchar **completed)
{
gchar *utf8app;
gchar *found;
utf8app = g_utf16_to_utf8 (appname, -1, NULL, NULL, NULL);
if (g_path_is_absolute (utf8app)) {
+ *completed = quote_path (utf8app);
g_free (utf8app);
- return FALSE;
+ return TRUE;
}
if (g_file_test (utf8app, G_FILE_TEST_IS_EXECUTABLE) && !g_file_test (utf8app, G_FILE_TEST_IS_DIR)) {
+ *completed = quote_path (utf8app);
g_free (utf8app);
- return FALSE;
+ return TRUE;
}
found = g_find_program_in_path (utf8app);
return FALSE;
}
- *completed = g_utf8_to_utf16 (found, -1, NULL, NULL, NULL);
+ *completed = quote_path (found);
g_free (found);
g_free (utf8app);
return TRUE;
gunichar2 *shell_path = NULL;
gchar *env_vars = NULL;
gboolean free_shell_path = TRUE;
+ gchar *newcmd, *tmp;
MONO_ARCH_SAVE_REGS;
#endif
if (spath != NULL) {
gint dummy;
- gchar *newcmd, *tmp;
gchar *quoted;
shell_path = mono_unicode_from_external (spath, &dummy);
g_free (newcmd);
}
} else {
+ gchar *spath = NULL;
shell_path = mono_string_chars (appname);
- free_shell_path = complete_path (shell_path, &shell_path);
- if (shell_path == NULL) {
+ complete_path (shell_path, &spath);
+ if (spath == NULL) {
process_info->pid = -ERROR_FILE_NOT_FOUND;
return FALSE;
}
+#ifdef PLATFORM_WIN32
+ /* Seems like our CreateProcess does not work as the windows one.
+ * This hack is needed to deal with paths containing spaces */
+ shell_path = NULL;
+ free_shell_path = FALSE;
+ tmp = mono_string_to_utf8 (cmd);
+ newcmd = g_strdup_printf ("%s %s", spath, tmp);
+ cmd = mono_string_new_wrapper (newcmd);
+ g_free (newcmd);
+ g_free (tmp);
+#else
+ shell_path = g_utf8_to_utf16 (spath, -1, NULL, NULL, NULL);
+#endif
+ g_free (spath);
}
if (process_info->env_keys != NULL) {