[io-layer] Extract Process runtime support (#3859)
[mono.git] / mono / metadata / w32process-unix-haiku.c
1
2 #include "w32process.h"
3 #include "w32process-unix-internals.h"
4
5 #ifdef USE_HAIKU_BACKEND
6
7 #include <KernelKit.h>
8
9 gchar*
10 mono_w32process_get_name (pid_t pid)
11 {
12         image_info imageInfo;
13         int32 cookie = 0;
14
15         if (get_next_image_info ((team_id) pid, &cookie, &imageInfo) != B_OK)
16                 return NULL;
17
18         return g_strdup (imageInfo.name);
19 }
20
21 gchar*
22 mono_w32process_get_path (pid_t pid)
23 {
24         return mono_w32process_get_name (pid);
25 }
26
27 GSList*
28 mono_w32process_get_modules (pid_t pid)
29 {
30         GSList *ret = NULL;
31         MonoW32ProcessModule *mod;
32         gint32 cookie = 0;
33         image_info imageInfo;
34
35         while (get_next_image_info (B_CURRENT_TEAM, &cookie, &imageInfo) == B_OK) {
36                 mod = g_new0 (MonoW32ProcessModule, 1);
37                 mod->device = imageInfo.device;
38                 mod->inode = imageInfo.node;
39                 mod->filename = g_strdup (imageInfo.name);
40                 mod->address_start = MIN (imageInfo.text, imageInfo.data);
41                 mod->address_end = MAX ((uint8_t*)imageInfo.text + imageInfo.text_size,
42                         (uint8_t*)imageInfo.data + imageInfo.data_size);
43                 mod->perms = g_strdup ("r--p");
44                 mod->address_offset = 0;
45
46                 if (g_slist_find_custom (ret, mod, mono_w32process_module_equals) == NULL) {
47                         ret = g_slist_prepend (ret, mod);
48                 } else {
49                         mono_w32process_module_free (mod);
50                 }
51         }
52
53         return g_slist_reverse (ret);
54 }
55
56 #endif