Главная

Изменение графической заставки загрузчика BeOS

Всем знакома заставка загрузчика BeOS с зажигающимися иконками. Простая, красивая и ненавязчивая. Но если она вам все–таки надоела и вы бы хотели ее поменять или как–то по своему подкорректировать, то такая возможность действительно имеется благодаря подробному руководству, автором которого является некто Pirge.

Вы можете скачать коллекцию уже готовых заставок для R5 и Dano или заняться свободным творчеством. Все что вам нужно, так это иметь под рукой HEX–радактор и строго следовать инструкциям. В любом случае рекоммендуется создать резервную копию файла загрузчика BeOS (/boot/beos/system/zbeos) и предусмотреть возможность его аварийного восстановления (загрузка из другой копии BeOS, например с CD) в случае неудачи.

Вам понадобится знание английского языка, т.к. корректный перевод руководства на русский язык затруднен обилием в нем различных технических терминов.

Документация и коллекция готовых загрузчиков были найдены в сети Сергеем Резниковым, за что ему отдельное спасибо. Итак, приступим.

Reverse Engineering the BeOS Boot Sequence Images by Pirge 16/12/01

1. Introduction to zbeos
2. Layout of images
3. Image Format
4. Customising boot images

1. Introduction to zbeos

zbeos is the beos bootloader and kernel loader. The first 512 bytes are identical to the
first 512 bytes of a linux kernel (vmlinuz). This code is basic boot sequence code.
More can be learnt by looking at the linux source and the beos r3 zbeos source/object code
which is available from be ftp mirrors. This paper deals solely with the
reverse engineering of the boot sequence images contained within zbeos.

From looking at the makefile for the zbeos from beos r3 zbeos source we see that 
zbeos is created by concatenating the boot code and two other files named beos and images.
These are gzipped up (with “gzip -f -9”) before concatenating.

Look at a hex dump of zbeos and search for 'images' and 'beos'. Just before these we
see the following byte sequence 1f 8b 08 — from the gzip docs ( thanks Amino ;) ) we
know that these are two id bytes and the compression method flag. We can use these
to write a c program that will extract the gzip files from zbeos:

/////////////////////////////////////////////////////////
#include
#include

//lazy — for zbeos this is big enough
#define SIZE 2048000

static int ID1 = 0x1f;
static int ID2 = 0x8b;
static int CM = 0x08;
static int ID_BYTES = 3;

int main (int argc, char* args[]){

FILE* fin;
FILE* fout;

char outfile[50];

int i;
int numgzips = 0;
long begin = 2147438647;
long end = 0;
int buf[SIZE];
int finished = 0;

printf("*******************************************
");
printf("*
");
printf("* dezbeos — extracts gzip files from zbeos
");
printf("* — bru::pirge 07–12–2001
");
printf("* — thanks to Amino");
printf("*
");
printf("*******************************************
");

fin = fopen(«zbeos», “rb”);
if(!fin){
printf(«Could not read zbeos!
Please run in the same directory as zbeos
");
exit(1);
}

//read file and extract gzip files
while(!feof(fin)){
//is this a gzip file
if( fgetc(fin) == ID1 && fgetc(fin) == ID2 && fgetc(fin) == CM){
//set begin offset
begin = ftell(fin);
//count gzip files found
numgzips++;
printf(«Found gzip file %d at offsets: start 0x%x ",numgzips,begin–ID_BYTES);
//save gzip we have found////////////////////////////
sprintf(outfile,"found%d.gz",numgzips);

//find end of gzip — eof or another gzip
while(!feof(fin)){
//set end offset
end = ftell(fin);
//is next a gzip id?
if( fgetc(fin) == ID1 && fgetc(fin) == ID2 && fgetc(fin) == CM){
finished = 1;
break;
}
}

//if its the end of file then set end offset
if(finished == 0)
end = ftell(fin);
//reset begin offset to include the two id bytes
//and the file pointer
begin -= ID_BYTES;
fseek(fin,begin,0);

printf(«end 0x%x
",end);

//open out file
fout = fopen(outfile,"wb");
if(!fout){
printf(«could not open %s
",outfile);
exit(1);
}
//write out the rest
fread(buf,sizeof(int),end–begin,fin);
fwrite(buf,sizeof(int),end–begin,fout);
//close new file
close(fout);
//reset file pointer
fseek(fin,end,0);
}
}
//close input
close(fin);
printf(«Use: 'gzip -N -d found*.gz' to decompress the gzip files.
Finished
");
return 0;
}
/////////////////////////////////////////////////////////

From here we just use gzip to decompress the two files as beos and images.
(You can just cut and paste the bytes for images.gz from a hex editor if you want
it goes from offset 0x00010bf5 to the end of the file)

2. Layout of images

Watching the boot sequence we see that there may be five separate images:
Icons, Lit Icons, BeOS text, version, logo
I guessed five separate because of,
the icons lighting,
the version number appearing quite separate from the other images,
for efficiency in keeping the size of zbeos low
AND if you use the set VESA mode app from bebits for unsupported video cards
you can watch the images move relative to each other when the screen resolution
goes from 640x480 to say 1024x768.
Lets take a look.

Using the windows (shame on me) hex editor called Axe we can display the hex bytes as
colours. This is fantastically useful for finding images in executables and I have found
no hex editor under linux or beos which provides this functionality (there's a project).
All we have to do is know how wide the images are! The smaller images are easier to find
so after some experimenting we find this:

Offset Image Dimensions
0x00000348 Row of lit icons 438 x 54
0x00005fbc Title Be Operating System 372 x 86
0x0000dcc4 Row of unlit icons 438 x 54
0x00013938 version 5 99 x 49
0x00014c3b Be logo 94 x 38

Where did I get the dimensions from?
Preceding each image data are 16 bytes (four 32 bit integers?) What are these for? What do we need to
know to display images? — image data, image size, image origin and maybe a palette.

Both the icon images have the same header so it must be common information.
As we have a file with packed images and it seems reasonable to assume these are x, y coordinates and width, height sizes.
for example both the icon images have these bytes preceding the image data:
(remember i386 processor has high byte last)

hex: b6 01 00 00 36 00 00 00 9d 00 00 00 67 00 00 00
dec: 438 54 157 103 //

Отправить комментарий

Содержание этого поля является приватным и не предназначено к показу.
  • Адреса страниц и электронной почты автоматически преобразуются в ссылки.
  • Allowed HTML tags: <a> <em> <i> <img> <strong> <b> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Строки и параграфы переносятся автоматически.

Подробнее о форматировании

CAPTCHA
Введите перечисленные символы, чтобы мы убедились, что вы не робот. Не требуется для зарегистрированных пользователей.
4
q
3
2
L
t
Enter the code without spaces and pay attention to upper/lower case.