void ves_icall_System_Globalization_CultureData_fill_culture_data (MonoCultureData *this_obj, gint32 datetime_index) { MonoError error; MonoDomain *domain; const DateTimeFormatEntry *dfe; g_assert (datetime_index >= 0); dfe = &datetime_format_entries [datetime_index]; domain = mono_domain_get (); MONO_OBJECT_SETREF (this_obj, AMDesignator, mono_string_new (domain, idx2string (dfe->am_designator))); MONO_OBJECT_SETREF (this_obj, PMDesignator, mono_string_new (domain, idx2string (dfe->pm_designator))); MONO_OBJECT_SETREF (this_obj, TimeSeparator, mono_string_new (domain, idx2string (dfe->time_separator))); MonoArray *long_time_patterns = create_names_array_idx_dynamic (dfe->long_time_patterns, NUM_LONG_TIME_PATTERNS, &error); if (mono_error_set_pending_exception (&error)) return; MONO_OBJECT_SETREF (this_obj, LongTimePatterns, long_time_patterns); MonoArray *short_time_patterns = create_names_array_idx_dynamic (dfe->short_time_patterns, NUM_SHORT_TIME_PATTERNS, &error); if (mono_error_set_pending_exception (&error)) return; MONO_OBJECT_SETREF (this_obj, ShortTimePatterns, short_time_patterns); this_obj->FirstDayOfWeek = dfe->first_day_of_week; this_obj->CalendarWeekRule = dfe->calendar_week_rule; }
MonoBoolean ves_icall_System_Globalization_CultureInfo_construct_internal_locale_from_name (MonoCultureInfo *this_obj, MonoString *name) { MonoError error; const CultureInfoNameEntry *ne; char *n; n = mono_string_to_utf8_checked (name, &error); if (mono_error_set_pending_exception (&error)) return FALSE; ne = (const CultureInfoNameEntry *)mono_binary_search (n, culture_name_entries, NUM_CULTURE_ENTRIES, sizeof (CultureInfoNameEntry), culture_name_locator); if (ne == NULL) { /*g_print ("ne (%s) is null\n", n);*/ g_free (n); return FALSE; } g_free (n); if (!construct_culture (this_obj, &culture_entries [ne->culture_entry_index], &error)) { mono_error_set_pending_exception (&error); return FALSE; } return TRUE; }
/* http://www.dotnet247.com/247reference/msgs/39/195403.aspx // internal static string[] WindowsIdentity._GetRoles (IntPtr token) */ MonoArray* ves_icall_System_Security_Principal_WindowsIdentity_GetRoles (gpointer token) { MonoError error; MonoArray *array = NULL; MonoDomain *domain = mono_domain_get (); #ifdef HOST_WIN32 gint32 size = 0; GetTokenInformation (token, TokenGroups, NULL, size, (PDWORD)&size); if (size > 0) { TOKEN_GROUPS *tg = g_malloc0 (size); if (GetTokenInformation (token, TokenGroups, tg, size, (PDWORD)&size)) { int i=0; int num = tg->GroupCount; array = mono_array_new_checked (domain, mono_get_string_class (), num, &error); if (mono_error_set_pending_exception (&error)) { g_free (tg); return NULL; } for (i=0; i < num; i++) { gint32 size = 0; gunichar2 *uniname = GetSidName (NULL, tg->Groups [i].Sid, &size); if (uniname) { MonoString *str = mono_string_new_utf16_checked (domain, uniname, size, &error); if (!is_ok (&error)) { g_free (uniname); g_free (tg); mono_error_set_pending_exception (&error); return NULL; } mono_array_setref (array, i, str); g_free (uniname); } } } g_free (tg); } #else /* POSIX-compliant systems should use IsMemberOfGroupId or IsMemberOfGroupName */ g_warning ("WindowsIdentity._GetRoles should never be called on POSIX"); #endif if (!array) { /* return empty array of string, i.e. string [0] */ array = mono_array_new_checked (domain, mono_get_string_class (), 0, &error); mono_error_set_pending_exception (&error); } return array; }
void ves_icall_System_Globalization_CultureData_fill_number_data (MonoNumberFormatInfo* number, gint32 number_index) { MonoError error; MonoDomain *domain; const NumberFormatEntry *nfe; g_assert (number_index >= 0); nfe = &number_format_entries [number_index]; domain = mono_domain_get (); number->currencyDecimalDigits = nfe->currency_decimal_digits; MONO_OBJECT_SETREF (number, currencyDecimalSeparator, mono_string_new (domain, idx2string (nfe->currency_decimal_separator))); MONO_OBJECT_SETREF (number, currencyGroupSeparator, mono_string_new (domain, idx2string (nfe->currency_group_separator))); MonoArray *currency_sizes_arr = create_group_sizes_array (nfe->currency_group_sizes, GROUP_SIZE, &error); if (mono_error_set_pending_exception (&error)) return; MONO_OBJECT_SETREF (number, currencyGroupSizes, currency_sizes_arr); number->currencyNegativePattern = nfe->currency_negative_pattern; number->currencyPositivePattern = nfe->currency_positive_pattern; MONO_OBJECT_SETREF (number, currencySymbol, mono_string_new (domain, idx2string (nfe->currency_symbol))); MONO_OBJECT_SETREF (number, naNSymbol, mono_string_new (domain, idx2string (nfe->nan_symbol))); MONO_OBJECT_SETREF (number, negativeInfinitySymbol, mono_string_new (domain, idx2string (nfe->negative_infinity_symbol))); MONO_OBJECT_SETREF (number, negativeSign, mono_string_new (domain, idx2string (nfe->negative_sign))); number->numberDecimalDigits = nfe->number_decimal_digits; MONO_OBJECT_SETREF (number, numberDecimalSeparator, mono_string_new (domain, idx2string (nfe->number_decimal_separator))); MONO_OBJECT_SETREF (number, numberGroupSeparator, mono_string_new (domain, idx2string (nfe->number_group_separator))); MonoArray *number_sizes_arr = create_group_sizes_array (nfe->number_group_sizes, GROUP_SIZE, &error); if (mono_error_set_pending_exception (&error)) return; MONO_OBJECT_SETREF (number, numberGroupSizes, number_sizes_arr); number->numberNegativePattern = nfe->number_negative_pattern; number->percentNegativePattern = nfe->percent_negative_pattern; number->percentPositivePattern = nfe->percent_positive_pattern; MONO_OBJECT_SETREF (number, percentSymbol, mono_string_new (domain, idx2string (nfe->percent_symbol))); MONO_OBJECT_SETREF (number, perMilleSymbol, mono_string_new (domain, idx2string (nfe->per_mille_symbol))); MONO_OBJECT_SETREF (number, positiveInfinitySymbol, mono_string_new (domain, idx2string (nfe->positive_infinity_symbol))); MONO_OBJECT_SETREF (number, positiveSign, mono_string_new (domain, idx2string (nfe->positive_sign))); }
/* this is an icall */ void * mono_mmap_open_handle (void *input_fd, MonoString *mapName, gint64 *capacity, int access, int options, int *ioerror) { MonoError error; MmapHandle *handle; if (!mapName) { handle = (MmapHandle *)open_file_map (NULL, GPOINTER_TO_INT (input_fd), FILE_MODE_OPEN, capacity, access, options, ioerror); } else { char *c_mapName = mono_string_to_utf8_checked (mapName, &error); if (mono_error_set_pending_exception (&error)) return NULL; named_regions_lock (); handle = (MmapHandle*)g_hash_table_lookup (named_regions, c_mapName); if (handle) { *ioerror = FILE_ALREADY_EXISTS; handle = NULL; } else { //XXX we're exploiting wapi HANDLE == FD equivalence. THIS IS FRAGILE, create a _wapi_handle_to_fd call handle = (MmapHandle *)open_file_map (NULL, GPOINTER_TO_INT (input_fd), FILE_MODE_OPEN, capacity, access, options, ioerror); handle->name = g_strdup (c_mapName); g_hash_table_insert (named_regions, handle->name, handle); } named_regions_unlock (); g_free (c_mapName); } return handle; }
gboolean mono_process_get_shell_arguments (MonoProcessStartInfo *proc_start_info, gunichar2 **shell_path, MonoString **cmd) { gchar *spath = NULL; gchar *new_cmd, *cmd_utf8; MonoError mono_error; *shell_path = NULL; *cmd = proc_start_info->arguments; mono_process_complete_path (mono_string_chars (proc_start_info->filename), &spath); if (spath != NULL) { /* Seems like our CreateProcess does not work as the windows one. * This hack is needed to deal with paths containing spaces */ if (*cmd) { cmd_utf8 = mono_string_to_utf8_checked (*cmd, &mono_error); if (!mono_error_set_pending_exception (&mono_error)) { new_cmd = g_strdup_printf ("%s %s", spath, cmd_utf8); *cmd = mono_string_new_wrapper (new_cmd); g_free (cmd_utf8); g_free (new_cmd); } else { *cmd = NULL; } } else { *cmd = mono_string_new_wrapper (spath); } g_free (spath); } return (*cmd != NULL) ? TRUE : FALSE; }
void ves_icall_System_Security_SecureString_EncryptInternal (MonoArray* data, MonoObject *scope) { MonoError error; invoke_protected_memory_method (data, scope, TRUE, &error); mono_error_set_pending_exception (&error); }
/* This is an icall */ void * mono_mmap_open_file (MonoString *path, int mode, MonoString *mapName, gint64 *capacity, int access, int options, int *ioerror) { MonoError error; MmapHandle *handle = NULL; g_assert (path || mapName); if (!mapName) { char * c_path = mono_string_to_utf8_checked (path, &error); if (mono_error_set_pending_exception (&error)) return NULL; handle = open_file_map (c_path, -1, mode, capacity, access, options, ioerror); g_free (c_path); return handle; } char *c_mapName = mono_string_to_utf8_checked (mapName, &error); if (mono_error_set_pending_exception (&error)) return NULL; if (path) { named_regions_lock (); handle = (MmapHandle*)g_hash_table_lookup (named_regions, c_mapName); if (handle) { *ioerror = FILE_ALREADY_EXISTS; handle = NULL; } else { char *c_path = mono_string_to_utf8_checked (path, &error); if (is_ok (&error)) { handle = (MmapHandle *)open_file_map (c_path, -1, mode, capacity, access, options, ioerror); if (handle) { handle->name = g_strdup (c_mapName); g_hash_table_insert (named_regions, handle->name, handle); } } else { handle = NULL; } g_free (c_path); } named_regions_unlock (); } else handle = open_memory_map (c_mapName, mode, capacity, access, options, ioerror); g_free (c_mapName); return handle; }
MonoString * ves_icall_System_String_InternalAllocateStr (gint32 length) { MonoError error; MonoString *str = mono_string_new_size_checked (mono_domain_get (), length, &error); mono_error_set_pending_exception (&error); return str; }
gint32 mono_icall_wait_for_input_idle (gpointer handle, gint32 milliseconds) { MonoError mono_error; mono_error_init (&mono_error); g_unsupported_api ("WaitForInputIdle"); mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, "WaitForInputIdle"); mono_error_set_pending_exception (&mono_error); return WAIT_TIMEOUT; }
guint32 mono_icall_drive_info_get_drive_type (MonoString *root_path_name) { MonoError mono_error; mono_error_init (&mono_error); g_unsupported_api ("GetDriveType"); mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, "GetDriveType"); mono_error_set_pending_exception (&mono_error); return DRIVE_UNKNOWN; }
MonoString * ves_icall_System_String_InternalIntern (MonoString *str) { MonoError error; MonoString *res; res = mono_string_intern_checked (str, &error); if (!res) { mono_error_set_pending_exception (&error); return NULL; } return res; }
int ves_icall_System_IO_InotifyWatcher_AddWatch (int fd, MonoString *name, gint32 mask) { MonoError error; char *str, *path; int retval; if (name == NULL) return -1; str = mono_string_to_utf8_checked (name, &error); if (mono_error_set_pending_exception (&error)) return -1; path = mono_portability_find_file (str, TRUE); if (!path) path = str; retval = inotify_add_watch (fd, path, mask); if (retval < 0) { switch (errno) { case EACCES: errno = ERROR_ACCESS_DENIED; break; case EBADF: errno = ERROR_INVALID_HANDLE; break; case EFAULT: errno = ERROR_INVALID_ACCESS; break; case EINVAL: errno = ERROR_INVALID_DATA; break; case ENOMEM: errno = ERROR_NOT_ENOUGH_MEMORY; break; case ENOSPC: errno = ERROR_TOO_MANY_OPEN_FILES; break; default: errno = ERROR_GEN_FAILURE; break; } mono_marshal_set_last_error (); } if (path != str) g_free (path); g_free (str); return retval; }
MonoBoolean mono_icall_get_process_working_set_size (gpointer handle, gsize *min, gsize *max) { MonoError mono_error; mono_error_init (&mono_error); g_unsupported_api ("GetProcessWorkingSetSize"); mono_error_set_not_supported(&mono_error, G_UNSUPPORTED_API, "GetProcessWorkingSetSize"); mono_error_set_pending_exception (&mono_error); SetLastError (ERROR_NOT_SUPPORTED); return FALSE; }
void mono_icall_broadcast_setting_change (void) { MonoError mono_error; mono_error_init (&mono_error); g_unsupported_api ("SendMessageTimeout"); mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, "SendMessageTimeout"); mono_error_set_pending_exception (&mono_error); SetLastError (ERROR_NOT_SUPPORTED); return; }
MonoArray * mono_icall_get_logical_drives (void) { MonoError mono_error; mono_error_init (&mono_error); g_unsupported_api ("GetLogicalDriveStrings"); mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, "GetLogicalDriveStrings"); mono_error_set_pending_exception (&mono_error); SetLastError (ERROR_NOT_SUPPORTED); return NULL; }
gpointer ves_icall_System_Security_Principal_WindowsIdentity_GetCurrentToken (void) { MonoError mono_error; mono_error_init (&mono_error); g_unsupported_api ("OpenThreadToken, OpenProcessToken"); mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, "OpenThreadToken, OpenProcessToken"); mono_error_set_pending_exception (&mono_error); SetLastError (ERROR_NOT_SUPPORTED); return NULL; }
gboolean ves_icall_System_Security_Principal_WindowsImpersonationContext_RevertToSelf (void) { MonoError mono_error; mono_error_init (&mono_error); g_unsupported_api ("RevertToSelf"); mono_error_set_not_supported(&mono_error, G_UNSUPPORTED_API, "RevertToSelf"); mono_error_set_pending_exception (&mono_error); SetLastError (ERROR_NOT_SUPPORTED); return FALSE; }
MonoArray* ves_icall_System_Security_Principal_WindowsIdentity_GetRoles (gpointer token) { MonoError mono_error; mono_error_init (&mono_error); g_unsupported_api ("GetTokenInformation"); mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, "GetTokenInformation"); mono_error_set_pending_exception (&mono_error); SetLastError (ERROR_NOT_SUPPORTED); return NULL; }
gpointer ves_icall_System_Security_Principal_WindowsImpersonationContext_DuplicateToken (gpointer token) { MonoError mono_error; mono_error_init (&mono_error); g_unsupported_api ("DuplicateToken"); mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, "DuplicateToken"); mono_error_set_pending_exception (&mono_error); SetLastError (ERROR_NOT_SUPPORTED); return NULL; }
gint32 mono_security_win_get_token_name (gpointer token, gunichar2 ** uniname) { MonoError mono_error; mono_error_init (&mono_error); g_unsupported_api ("GetTokenInformation"); mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, "GetTokenInformation"); mono_error_set_pending_exception (&mono_error); SetLastError (ERROR_NOT_SUPPORTED); return 0; }
gboolean mono_security_win_protect_user (gunichar2 *path) { MonoError mono_error; mono_error_init (&mono_error); g_unsupported_api ("BuildTrusteeWithSid, SetEntriesInAcl, SetNamedSecurityInfo, LocalFree"); mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, "BuildTrusteeWithSid, SetEntriesInAcl, SetNamedSecurityInfo, LocalFree"); mono_error_set_pending_exception (&mono_error); SetLastError (ERROR_NOT_SUPPORTED); return FALSE; }
gboolean ves_icall_System_Security_Principal_WindowsImpersonationContext_SetCurrentToken (gpointer token) { MonoError mono_error; mono_error_init (&mono_error); g_unsupported_api ("ImpersonateLoggedOnUser"); mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, "ImpersonateLoggedOnUser"); mono_error_set_pending_exception (&mono_error); SetLastError (ERROR_NOT_SUPPORTED); return FALSE; }
MonoBoolean mono_icall_set_priority_class (gpointer handle, gint32 priorityClass) { MonoError mono_error; mono_error_init (&mono_error); g_unsupported_api ("SetPriorityClass"); mono_error_set_not_supported(&mono_error, G_UNSUPPORTED_API, "SetPriorityClass"); mono_error_set_pending_exception (&mono_error); SetLastError (ERROR_NOT_SUPPORTED); return FALSE; }
gboolean mono_security_win_is_user_protected (gunichar2 *path) { MonoError mono_error; mono_error_init (&mono_error); g_unsupported_api ("GetNamedSecurityInfo, LocalFree"); mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, "GetNamedSecurityInfo, LocalFree"); mono_error_set_pending_exception (&mono_error); SetLastError (ERROR_NOT_SUPPORTED); return FALSE; }
MonoBoolean ves_icall_System_Globalization_CultureInfo_construct_internal_locale_from_lcid (MonoCultureInfo *this_obj, gint lcid) { MonoError error; const CultureInfoEntry *ci; ci = culture_info_entry_from_lcid (lcid); if(ci == NULL) return FALSE; if (!construct_culture (this_obj, ci, &error)) { mono_error_set_pending_exception (&error); return FALSE; } return TRUE; }
MonoArray* ves_icall_System_Security_Principal_WindowsIdentity_GetRoles (gpointer token) { ERROR_DECL (error); MonoArray *array = NULL; MonoDomain *domain = mono_domain_get (); /* POSIX-compliant systems should use IsMemberOfGroupId or IsMemberOfGroupName */ g_warning ("WindowsIdentity._GetRoles should never be called on POSIX"); if (!array) { /* return empty array of string, i.e. string [0] */ array = mono_array_new_checked (domain, mono_get_string_class (), 0, error); mono_error_set_pending_exception (error); } return array; }
void ves_icall_System_Globalization_CompareInfo_assign_sortkey (MonoCompareInfo *this_obj, MonoSortKey *key, MonoString *source, gint32 options) { MonoError error; MonoArray *arr; gint32 keylen, i; keylen=mono_string_length (source); arr=mono_array_new_checked (mono_domain_get (), mono_get_byte_class (), keylen, &error); if (mono_error_set_pending_exception (&error)) return; for(i=0; i<keylen; i++) { mono_array_set (arr, guint8, i, mono_string_chars (source)[i]); } MONO_OBJECT_SETREF (key, key, arr); }
MonoArray * ves_icall_System_Diagnostics_Process_GetProcesses_internal (void) { MonoError error; MonoArray *procs; gboolean ret; DWORD needed; int count; DWORD *pids; count = 512; do { pids = g_new0 (DWORD, count); ret = mono_process_win_enum_processes (pids, count * sizeof (guint32), &needed); if (ret == FALSE) { MonoException *exc; g_free (pids); pids = NULL; exc = mono_get_exception_not_supported ("This system does not support EnumProcesses"); mono_set_pending_exception (exc); return NULL; } if (needed < (count * sizeof (guint32))) break; g_free (pids); pids = NULL; count = (count * 3) / 2; } while (TRUE); count = needed / sizeof (guint32); procs = mono_array_new_checked (mono_domain_get (), mono_get_int32_class (), count, &error); if (mono_error_set_pending_exception (&error)) { g_free (pids); return NULL; } memcpy (mono_array_addr (procs, guint32, 0), pids, needed); g_free (pids); pids = NULL; return procs; }
MonoString* ves_icall_System_Security_Principal_WindowsIdentity_GetTokenName (gpointer token) { MonoError error; MonoString *result = NULL; gunichar2 *uniname = NULL; gint32 size = 0; mono_error_init (&error); #ifdef HOST_WIN32 GetTokenInformation (token, TokenUser, NULL, size, (PDWORD)&size); if (size > 0) { TOKEN_USER *tu = g_malloc0 (size); if (GetTokenInformation (token, TokenUser, tu, size, (PDWORD)&size)) { uniname = GetSidName (NULL, tu->User.Sid, &size); } g_free (tu); } #else gchar *uname = GetTokenName ((uid_t) GPOINTER_TO_INT (token)); if (uname) { size = strlen (uname); uniname = g_utf8_to_utf16 (uname, size, NULL, NULL, NULL); g_free (uname); } #endif /* HOST_WIN32 */ if (size > 0) { result = mono_string_new_utf16_checked (mono_domain_get (), uniname, size, &error); } else result = mono_string_new (mono_domain_get (), ""); if (uniname) g_free (uniname); mono_error_set_pending_exception (&error); return result; }