[2020-02] Avoid following invalid pointers in mono_w32process_get_modules on Darwin...
[mono-project.git] / mono / metadata / w32process-unix-haiku.c
blobdbd312c8d8643075c2d0dbc0c7ed2f7ac9e9fdf1
1 /**
2 * \file
3 */
5 #include "w32process.h"
6 #include "w32process-unix-internals.h"
8 #ifdef USE_HAIKU_BACKEND
10 /* KernelKit.h doesn't include the right headers? */
11 #include <os/kernel/image.h>
13 gchar*
14 mono_w32process_get_name (pid_t pid)
16 image_info imageInfo;
17 int32 cookie = 0;
19 if (get_next_image_info ((team_id) pid, &cookie, &imageInfo) != B_OK)
20 return NULL;
22 return g_strdup (imageInfo.name);
25 gchar*
26 mono_w32process_get_path (pid_t pid)
28 return mono_w32process_get_name (pid);
31 GSList*
32 mono_w32process_get_modules (pid_t pid)
34 GSList *ret = NULL;
35 MonoW32ProcessModule *mod;
36 gint32 cookie = 0;
37 image_info imageInfo;
39 while (get_next_image_info (B_CURRENT_TEAM, &cookie, &imageInfo) == B_OK) {
40 mod = g_new0 (MonoW32ProcessModule, 1);
41 mod->device = imageInfo.device;
42 mod->inode = imageInfo.node;
43 mod->filename = g_strdup (imageInfo.name);
44 mod->address_start = MIN (imageInfo.text, imageInfo.data);
45 mod->address_end = MAX ((uint8_t*)imageInfo.text + imageInfo.text_size,
46 (uint8_t*)imageInfo.data + imageInfo.data_size);
47 mod->perms = g_strdup ("r--p");
48 mod->address_offset = 0;
50 if (g_slist_find_custom (ret, mod, mono_w32process_module_equals) == NULL) {
51 ret = g_slist_prepend (ret, mod);
52 } else {
53 mono_w32process_module_free (mod);
57 return g_slist_reverse (ret);
60 void
61 mono_w32process_platform_init_once (void)
65 #else
67 MONO_EMPTY_SOURCE_FILE (w32process_unix_haiku);
69 #endif