ain@j.cc.purdue.edu (Patrick White) (08/02/88)
Submitted by: inria.inria.fr!rouaix(Francois Rouaix) Summary: Converts teh sector dump of a boot block into an executable file. Poster Boy: Patrick White (ain@j.cc.purdue.edu) Archive Name: sources/amiga/volume5/xboot.s.sh.Z Tested. NOTES: Docs are so small that I just packeged them in with the source and binary shars. It was an arc, but is not a shar. I think I tried compiling it under Manx and it worked, but I forgot my notes on that. . -- Pat White (co-moderator comp.sources/binaries.amiga) ARPA/UUCP: j.cc.purdue.edu!ain BITNET: PATWHITE@PURCCVM PHONE: (317) 743-8421 U.S. Mail: 320 Brown St. apt. 406, West Lafayette, IN 47906 [archives at: j.cc.purdue.edu.ARPA] ======================================== # This is a shell archive. # Remove everything above and including the cut line. # Then run the rest of the file through sh. #----cut here-----cut here-----cut here-----cut here----# #!/bin/sh # shar: Shell Archiver # Run the following text with /bin/sh to create: # xboot.doc # xboot.lnk # xboot.c # This archive created: Mon Aug 1 12:24:11 1988 # By: Patrick White (PUCC Land, USA) cat << \SHAR_EOF > xboot.doc This is a VERY simple utility I felt I needed to study those nasty Viruses hanging around... It converts a boot-block into an executable file, so you may use your favorite debugger (Wack, Dis, ...) to study it. SYNTAX: xboot infile outfile CAVEATS: <infile> should be exactly 1024 bytes long. It is normally the dump of blocks 0 and 1 of a floppy disk. DETAILS: The first three longwords of the boot-block are put in the second hunk (data hunk). All other data is thrown into the first hunk (code hunk). This has the disadvantage of breaking the PC-relative adressing for the data (like in ByteBandits virus). COMPILATION NOTES: I used standard AmigaDOS file functions, so that you may compile with amiga.lib before lc.lib, and have a smaller executable. DISTRIBUTION: Free ! This a Public Domain. Do whatever you want with this program. AUTHOR: Francois ROUAIX rouaix@inria.inria.fr SHAR_EOF cat << \SHAR_EOF > xboot.lnk VERBOSE NODEBUG FROM LIB:astartup.obj+xboot.o TO xboot LIB LIB:amiga.lib+LIB:lc.lib SHAR_EOF cat << \SHAR_EOF > xboot.c /* Conversion of a boot-block in an executable */ /* Placed in Public Domain by Francois Rouaix in 1988 */ #include <libraries/dos.h> char buffer[1024] ; long header[12] = { 0x000003f3, /* Hunk_Header */ 0x00000000, /* no hunk_name */ 0x00000002, /* size of hunk_table */ 0x00000000, /* first hunk */ 0x00000001, /* last hunk */ 0x000000fd, /* size of hunk 0 */ 0x00000003, /* size of hunk 1 */ 0x000003e9, /* hunk_code */ 0x000000fd, /* size of hunk_code = 253 */ /* end of header */ 0x000003ea, /* hunk_data */ 0x00000003, /* size */ /* end of header */ 0x000003f2 } ; /* xboot infile outfile */ main(argc,argv) int argc; char *argv[]; { struct FileHandle *infile=0,*outfile=0 ; int b=0; if (argc != 3) { printf("Usage: %s infile outfile \n",argv[0]); Exit(0); } if (!(infile = (struct FileHandle *)Open(argv[1],MODE_OLDFILE))) { printf("Can't open %s\n",argv[1]); Exit(0); } if (!(outfile = (struct FileHandle *)Open(argv[2],MODE_NEWFILE))) { Close(infile); printf("Can't open %s\n",argv[2]); Exit(0); } b = Read(infile,&buffer[0],1024); if (b != 1024) printf("Warning ! Bad File.\n"); Close(infile); Write(outfile,(char *)&header[0],4*9); /* header */ Write(outfile,(char *)&buffer[12],4*253); /* code */ Write(outfile,(char *)&header[11],4); /* hunk_end */ Write(outfile,(char *)&header[9],4*2); /* header for data */ Write(outfile,(char *)&buffer[0],4*3); /* data */ Write(outfile,(char *)&header[11],4); /* hunk_end */ Close(outfile); } SHAR_EOF # End of shell archive exit 0