Bootblock.library version 3.1 3324 bytes Released the 26th of June 1993 Programmed by Johan Eliasson, SHI member. Copyright © Safe Hex International 1992, 1993, 1994. INTRODUCTION ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The Bootblock.library/brainfile is made by SHI to make life a little bit easier for programmers of anti-virus utilities, diskcopy programs, directory utilities, disk packers and for whoever who wants to check the bootblock of some device, and of course for you, the user, who are dead- tired of those %$£&%$& viruses... The library has some easy-to-use functions to read the brainfile, and to check a bootblock with it. The brainfile will be kept in memory for you by the library, so that more than one program can use it simultaneously. I know this doc is short, but take a look at my CheckDrive.c source and you will get it. If not, write me a letter! Each bootblock is identified with a checksum of four strategically chosen longwords. I have about 600+ non-virus-bootblocks that I check every new version of the brainfile with, and so far there has been no false alarms! Note that this is not a standard auto-doc file. It is typed by hand! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ LEGAL STUFF ~~~~~~~~~~~ The BBBF package is freely distributable as long as all of its files are included in their original form without additions, deletions, or modifications of any kind, with the following exception: If your program uses the Bootblock.library/Bootblock.brainfile then they may be distributed along with it. If you use this library in your program you must give credit to SHI (like the note below) and the programmer in your documentation. The BBBF package may not be used in a commercial program without written permission by Safe Hex International. Only a nominal fee (maximum 6$) may be charged for the distribution of BBBF. This software is provided "AS IS" without warranty of any kind, either expressed or implied. By using the BBBF package, you agree to accept the entire risk as to the quality and performance of the program. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TABLE OF CONTENTS Bootblock.library/ReadBBBF Bootblock.library/FreeBBBF Bootblock.library/CheckBoot Bootblock.library/GetBBBFInfo Bootblock.library/ListBBBF Bootblock.library/ReadBoot Bootblock.library/WriteBoot Bootblock.library/InstallBoot ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Bootblock.library/ReadBBBF result = ReadBBBF(name); long ReadBBBF(char *); A0 DESCRIPTION Will read the Bootblock.brainfile from name, and keep it in memory for you until you FreeBBBF() it. INPUTS name = "L:Bootblock.brainfile" or wherever you want to load it from. RESULT result = errorcode. if result > 0 then result is the code returned by IoErr() in case of an IO error. if result = 0 then the brainfile is successfully loaded and everything's fine. if result = -1 It was no brainfile...strange... -2 Corrupted brainfile. Someone has fiddled with it. -3 Already loaded by someone else! -4 No memory for brainfile. Free some and try again... ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Bootblock.library/FreeBBBF result = FreeBBBF(); void FreeBBBF(void); DESCRIPTION Will free the memory used for the brainfile, ie. unload it. If the brainfile is not loaded the function will just return. You don't HAVE to do this. If you don't, it will be done when the library is flushed. INPUTS none RESULT none ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Bootblock.library/CheckBoot Boot = CheckBoot(buffer,&status); struct Bootblock *CheckBoot(char *,ULONG); A0 A1 DESCRIPTION INPUTS buffer = simply the bootblock that you want to check. status = address of an ULONG. Status will afterwards contain one of the following values: -1 : Error - The brainfile is not loaded. 0 : The bootblock is unknown. 1 : The bootblock is a virus! Kill it! 2 : The bootblock is not bootable... RESULT Boot Bootblock struct that contains the name of the bootblock etc. If status != 1 then Boot will be NULL. NOTES If the bootblock is a virus, then you'll have to append ' virus!' to the name from the Bootblock struct. It saved me quite a lot of bytes in the brainfile. 200 ' virus!' would be 1400 bytes... I hope you don't mind! 8-) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Bootblock.library/GetBBBFInfo result = GetBBBFInfo(&virus,version); long GetBBBFInfo(USHORT,char[30]); A0 A1 DESCRIPTION INPUTS virus = will be the number of viruses known to this brainfile. version = string that will contain the brainfile version-string, without the '$VER: '. RESULT result If result == -1 then the brainfile is not loaded. If success then result will be 0. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Bootblock.library/ListBBBF Boot = ListBBBF() struct Bootblock *ListBBBF(void) DESCRIPTION This function returns the pointer to the first Bootblock structure. Useful for listing all known bootblocks etc. INPUTS none RESULT Boot Pointer to the first Bootblock structure, or NULL == the brainfile is not loaded. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Bootblock.library/ReadBoot result = ReadBoot(drive,buffer); ULONG ReadBoot(ULONG,char *); D0 A0 DESCRIPTION This function will read the bootblock from the desired drive, using the trackdisk.device and CMD_READ. INPUTS drive = drive number (0-3) buffer = the destination of the bootblock. Must be at least 1024 bytes. Note that it must be in chip ram if running under kickstart V36 or below. RESULT result = either NULL = success, or an errorcode returned by IoErr(), Can occur during the OpenDevice() (see or the bootread (see ) It can also be 103 (out of memory). ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Bootblock.library/WriteBoot result = WriteBoot(drive,buffer); ULONG WriteBoot(ULONG,char *); D0 A0 DESCRIPTION This function will write the bootblock to the selected drive. INPUTS drive = drive number (0-3) buffer = the bootblock. Note that it must be in chip ram if running under kickstart V36 or below. RESULT result = either NULL = success, or an errorcode returned by IoErr(), Can occur during the OpenDevice() (see or the bootwrite (see ) It can also be 103 (out of memory). ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Bootblock.library/InstallBoot result = InstallBoot(drive,bootnumber); long = InstallBoot(ULONG,USHORT) D0 D1 DESCRIPTION This function will install an AmigaDOS bootblock to the selected drive. INPUTS drive : drive number (0-3) bootnumber : 0 = 1.x OFS 1 = 1.3 FFS 2 = 2.0 OFS 3 = 2.0 FFS 4 = 2.0 OFS International 5 = 2.0 FFS International 6 = 3.0 OFS DirCache 7 = 3.0 FFS DirCache RESULT result : either NULL = success, or an errorcode returned by IoErr(), Can occur during the OpenDevice() (see or the bootwrite (see ) It can also be 103 (out of memory), or -99 = illegal bootnumber (must be 0 - 7). ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ LIBRARY HISTORY ~~~~~~~~~~~~~~~ Version 0.9 beta ~~~~~~~~~~~~~~~~ First version. Version 0.91 beta ~~~~~~~~~~~~~~~~~ Removed all non-virus bootblocks from the brainfile upon request from Erik Loevendahl Soerensen. Now you will only be alerted if the bootblock contains a virus, anti-virus, or any other suspicious resident program. This is for speed and so that the user won't be bothered with messages like 'This bootblock is the MegaSuperDemoLoader 32.84' all the time. The GetBBBFInfo() function is changed accordingly. I have tried to clean up this doc a bit too. There were a few obvious mistakes that I guess you spotted. BBBF now knows 171 original viruses, and a vast number of clones. Version 0.92 beta (15.10.92) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ V 0.91 didn't recognize the Chameleon (little Sven) virus correctly. Instead of adding a short piece of code to deal with that, I rewrote the complete brainfile-system, so it will be easier to add new viruses to the brainfile from now on. As a result of that, the Bootblock structure has changed a bit. Also, ReadBBBF() and CheckBoot() are a little bit slower, and the brainfile is 656 bytes bigger......but a lot safer! BBBF now knows 164 original viruses, and a vast number + 7 clones. Version 0.93 beta (05.11.92) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Bug fix: If the brainfile-reading was interrupted due to lack of memory, the already allocated memory would not be freed correctly. Version 1.0 (11.11.92) ~~~~~~~~~~~~~~~~~~~~~~ New function - ReadBoot(). I also optimized the library down to 2876 bytes! Version 1.01 (12.12.92) ~~~~~~~~~~~~~~~~~~~~~~~ Now you don't HAVE to free the memory with FreeBBBF() when you exit. If you don't, it will be freed automagically when the library is flushed. Version 2.00 (16.12.92) ~~~~~~~~~~~~~~~~~~~~~~~ New function - WriteBoot(). I learned that OpenLibrary() is case-sensitive. And I have spelled Bootblock.library with a capital B... so if your OpenLibrary() fails, that might be the cause... Version 3.00 (02.03.93) ~~~~~~~~~~~~~~~~~~~~~~~ New function - InstallBoot() Version 3.1 (26.06.93) ~~~~~~~~~~~~~~~~~~~~~~ Corrected the version-string as you can see. Changed a few other internal things. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Please, SHI need your opinions! Even if you have no complaints nor ideas it's nice just to hear that it works... 8-) Send new viruses, ideas, threats and harddrives to: SHI MAIN CENTRAL VIRUS CENTRE: ----------------------------- Erik Loevendahl Soerensen Snaphanevej 10 DK-4720 Praestoe Denmark Phone : +45 55 992512 Fax : +45 55 993498 Fidonet : 2:236/116.17 Amiganet: 39:141/127.17 Thanks goes to Magnus Holmgren and Tommy Hallgren for helping out with my C problems, Tommy Hallgren and Mats Erlandsson for testing! Erik Loevendahl Soerensen at SHI for all his support. John Lohmeyer, whose Interpret.library I used as a model when designing this library. Thanks guys! END OF DOC.