Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / metadata / w32process-unix-haiku.c
1 /**
2  * \file
3  */
4
5 #include "w32process.h"
6 #include "w32process-unix-internals.h"
7
8 #ifdef USE_HAIKU_BACKEND
9
10 /* KernelKit.h doesn't include the right headers? */
11 #include <os/kernel/image.h>
12
13 gchar*
14 mono_w32process_get_name (pid_t pid)
15 {
16         image_info imageInfo;
17         int32 cookie = 0;
18
19         if (get_next_image_info ((team_id) pid, &cookie, &imageInfo) != B_OK)
20                 return NULL;
21
22         return g_strdup (imageInfo.name);
23 }
24
25 gchar*
26 mono_w32process_get_path (pid_t pid)
27 {
28         return mono_w32process_get_name (pid);
29 }
30
31 GSList*
32 mono_w32process_get_modules (pid_t pid)
33 {
34         GSList *ret = NULL;
35         MonoW32ProcessModule *mod;
36         gint32 cookie = 0;
37         image_info imageInfo;
38
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;
49
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);
54                 }
55         }
56
57         return g_slist_reverse (ret);
58 }
59
60 #endif