Merge pull request #4444 from lateralusX/jlorenss/windows-unwind-info
[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 /* KernelKit.h doesn't include the right headers? */
8 #include <os/kernel/image.h>
9
10 gchar*
11 mono_w32process_get_name (pid_t pid)
12 {
13         image_info imageInfo;
14         int32 cookie = 0;
15
16         if (get_next_image_info ((team_id) pid, &cookie, &imageInfo) != B_OK)
17                 return NULL;
18
19         return g_strdup (imageInfo.name);
20 }
21
22 gchar*
23 mono_w32process_get_path (pid_t pid)
24 {
25         return mono_w32process_get_name (pid);
26 }
27
28 GSList*
29 mono_w32process_get_modules (pid_t pid)
30 {
31         GSList *ret = NULL;
32         MonoW32ProcessModule *mod;
33         gint32 cookie = 0;
34         image_info imageInfo;
35
36         while (get_next_image_info (B_CURRENT_TEAM, &cookie, &imageInfo) == B_OK) {
37                 mod = g_new0 (MonoW32ProcessModule, 1);
38                 mod->device = imageInfo.device;
39                 mod->inode = imageInfo.node;
40                 mod->filename = g_strdup (imageInfo.name);
41                 mod->address_start = MIN (imageInfo.text, imageInfo.data);
42                 mod->address_end = MAX ((uint8_t*)imageInfo.text + imageInfo.text_size,
43                         (uint8_t*)imageInfo.data + imageInfo.data_size);
44                 mod->perms = g_strdup ("r--p");
45                 mod->address_offset = 0;
46
47                 if (g_slist_find_custom (ret, mod, mono_w32process_module_equals) == NULL) {
48                         ret = g_slist_prepend (ret, mod);
49                 } else {
50                         mono_w32process_module_free (mod);
51                 }
52         }
53
54         return g_slist_reverse (ret);
55 }
56
57 #endif