From da3c38792b69d3429a4b26b109ab99f16eb7e980 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sat, 16 Aug 2008 22:07:33 +0000 Subject: [PATCH] Slightly more defensive approach to searching for the image. Thanks Axel :) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26995 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../platform/bios_ia32/makebootable.cpp | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/bin/makebootable/platform/bios_ia32/makebootable.cpp b/src/bin/makebootable/platform/bios_ia32/makebootable.cpp index 6593b243de..293996918c 100644 --- a/src/bin/makebootable/platform/bios_ia32/makebootable.cpp +++ b/src/bin/makebootable/platform/bios_ia32/makebootable.cpp @@ -179,6 +179,24 @@ write_boot_code_part(const char *fileName, int fd, off_t imageOffset, } +#ifdef __HAIKU__ +static status_t +find_own_image(image_info *info) +{ + int32 cookie = 0; + while (get_next_image_info(B_CURRENT_TEAM, &cookie, info) == B_OK) { + if (((uint32)info->text <= (uint32)find_own_image + && (uint32)info->text + info->text_size > + (uint32)find_own_image)) { + return B_OK; + } + } + + return B_NAME_NOT_FOUND; +} +#endif + + // main int main(int argc, const char *const *argv) @@ -234,8 +252,7 @@ main(int argc, const char *const *argv) bootCodeData = read_boot_code_data(argv[0]); #else image_info info; - int32 cookie = 0; - if (get_next_image_info(0, &cookie, &info) == B_OK) + if (find_own_image(&info) == B_OK) bootCodeData = read_boot_code_data(info.name); #endif if (!bootCodeData) {