2 bios2dump.c - Was designed to extract BIOS of your PC and save it to file.
3 Usage: as argument requires DOS interrupt number in hexadecimal form.
4 as output - will write 64KB file which will named: SSSS_OOOO.intXX
5 where: SSSS - segment of BIOS interrupt handler
6 OOOO - offset of BIOS interrupt handler
7 XX - interrupt number which was passed as argument
9 Copyright: Nick Kurshev <nickols_k@mail.ru>
14 int main( int argc
, char *argv
[])
16 FILE * fd_mem
, *fd_out
;
17 unsigned short int_seg
,int_off
;
18 unsigned long bios_off
;
25 printf("Usage: %s int_no(in hex)\n",argv
[0]);
28 int_no
= strtol(argv
[1],NULL
,16);
29 if(!(fd_mem
= fopen("/dev/mem","rb")))
31 perror("Can't open file - /dev/mem");
34 fseek(fd_mem
,int_no
*4,SEEK_SET
);
35 fread(&int_off
,sizeof(unsigned short),1,fd_mem
);
36 fread(&int_seg
,sizeof(unsigned short),1,fd_mem
);
37 sprintf(outname
,"%04X_%04X.int%02X",int_seg
,int_off
,int_no
);
38 if(!(fd_out
= fopen(outname
,"wb")))
40 perror("Can't open output file");
44 bios_off
= (int_seg
<< 4) + int_off
;
46 fseek(fd_mem
,bios_off
,SEEK_SET
);
47 for(i
=0;i
<0x10000;i
++)
49 fread(&ch
,1,1,fd_mem
);
50 fwrite(&ch
,1,1,fd_out
);