image.h: Add B_{APP,CURRENT}_IMAGE_SYMBOL macros
* Those can be used in cases where a pointer to an image symbol is required. * Adjust BResources::SetToImage() accordingly.
This commit is contained in:
@@ -56,6 +56,12 @@ typedef struct {
|
|||||||
#define B_TERM_BEFORE_FUNCTION_NAME "terminate_before"
|
#define B_TERM_BEFORE_FUNCTION_NAME "terminate_before"
|
||||||
#define B_TERM_AFTER_FUNCTION_NAME "terminate_after"
|
#define B_TERM_AFTER_FUNCTION_NAME "terminate_after"
|
||||||
|
|
||||||
|
#define B_APP_IMAGE_SYMBOL ((void*)(addr_t)0)
|
||||||
|
// value that can be used instead of a pointer to a symbol in the program
|
||||||
|
// image.
|
||||||
|
#define B_CURRENT_IMAGE_SYMBOL ((void*)&__haiku_init_before)
|
||||||
|
// pointer to a symbol in the callers image
|
||||||
|
|
||||||
// flags for _kern_load_image() (private API)
|
// flags for _kern_load_image() (private API)
|
||||||
enum {
|
enum {
|
||||||
B_WAIT_TILL_LOADED = 0x01,
|
B_WAIT_TILL_LOADED = 0x01,
|
||||||
@@ -91,6 +97,9 @@ status_t _get_image_info(image_id image, image_info *info, size_t size);
|
|||||||
status_t _get_next_image_info(team_id team, int32 *cookie, image_info *info,
|
status_t _get_next_image_info(team_id team, int32 *cookie, image_info *info,
|
||||||
size_t size);
|
size_t size);
|
||||||
|
|
||||||
|
/* private */
|
||||||
|
void __haiku_init_before(image_id id);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -204,19 +204,18 @@ status_t
|
|||||||
BResources::SetToImage(const void* codeOrDataPointer, bool clobber)
|
BResources::SetToImage(const void* codeOrDataPointer, bool clobber)
|
||||||
{
|
{
|
||||||
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
||||||
if (!codeOrDataPointer)
|
|
||||||
return B_BAD_VALUE;
|
|
||||||
|
|
||||||
// iterate through the images and find the one in question
|
// iterate through the images and find the one in question
|
||||||
addr_t address = (addr_t)codeOrDataPointer;
|
addr_t address = (addr_t)codeOrDataPointer;
|
||||||
image_info info;
|
image_info info;
|
||||||
int32 cookie = 0;
|
int32 cookie = 0;
|
||||||
|
|
||||||
while (get_next_image_info(B_CURRENT_TEAM, &cookie, &info) == B_OK) {
|
while (get_next_image_info(B_CURRENT_TEAM, &cookie, &info) == B_OK) {
|
||||||
if (((addr_t)info.text <= address
|
if (address == 0
|
||||||
&& address - (addr_t)info.text < (addr_t)info.text_size)
|
? info.type == B_APP_IMAGE
|
||||||
|| ((addr_t)info.data <= address
|
: (((addr_t)info.text <= address
|
||||||
&& address - (addr_t)info.data < (addr_t)info.data_size)) {
|
&& address - (addr_t)info.text < (addr_t)info.text_size)
|
||||||
|
|| ((addr_t)info.data <= address
|
||||||
|
&& address - (addr_t)info.data < (addr_t)info.data_size))) {
|
||||||
return SetTo(info.name, clobber);
|
return SetTo(info.name, clobber);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user