1/*
2 * Copyright 2006-2008, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 *		Axel Dörfler, axeld@pinc-software.de
7 */
8
9#include <string.h>
10
11#include <image.h>
12#include <OS.h>
13
14#include <r5_compatibility.h>
15
16
17static void
18find_own_image()
19{
20	int32 cookie = 0;
21	image_info info;
22	while (get_next_image_info(B_CURRENT_TEAM, &cookie, &info) == B_OK) {
23		if (((addr_t)info.text <= (addr_t)find_own_image
24			&& (addr_t)info.text + (size_t)info.text_size > (addr_t)find_own_image)) {
25			// found us
26			__gNetAPIStart = (addr_t)min_c(info.text, info.data);
27			__gNetAPIEnd = min_c((addr_t)info.text + info.text_size,
28				(addr_t)info.data + info.data_size);
29			break;
30		}
31	}
32}
33
34
35extern "C" void
36initialize_before()
37{
38	// If in compatibility mode get our code address range.
39	if (__gR5Compatibility)
40		find_own_image();
41}
42