changeset 2355:77d81e5c186d

re-eng tool
author nick
date Mon, 22 Oct 2001 07:15:04 +0000
parents 0e2f4c4e55d4
children 04c80ace9581
files TOOLS/bios2dump.c TOOLS/c
diffstat 2 files changed, 56 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TOOLS/bios2dump.c	Mon Oct 22 07:15:04 2001 +0000
@@ -0,0 +1,55 @@
+/*
+    bios2dump.c - Was designed to extract BIOS of your PC and save it to file.
+    Usage: as argument requires DOS interrupt number in hexadecimal form.
+    as output - will write 64KB file which will named: SSSS_OOOO.intXX
+    where: SSSS - segment of BIOS interrupt handler
+           OOOO - offset of BIOS interrupt handler
+	   XX   - interrupt number which was passed as argument
+    Licence: GNU GPL v2
+    Copyright: Nick Kurshev <nickols_k@mail.ru>
+*/
+#include <stdio.h>
+#include <stdlib.h>
+
+int main( int argc, char *argv[])
+{
+  FILE * fd_mem, *fd_out;
+  unsigned short int_seg,int_off;
+  unsigned long bios_off;
+  int int_no;
+  size_t i;
+  char outname[80];
+  unsigned char ch;
+  if(argc < 2)
+  {
+    printf("Usage: %s int_no(in hex)\n",argv[0]);
+    return EXIT_FAILURE;
+  }
+  int_no = strtol(argv[1],NULL,16);
+  if(!(fd_mem = fopen("/dev/mem","rb")))
+  {
+    perror("Can't open file - /dev/mem");
+    return EXIT_FAILURE;
+  }
+  fseek(fd_mem,int_no*4,SEEK_SET);
+  fread(&int_off,sizeof(unsigned short),1,fd_mem);
+  fread(&int_seg,sizeof(unsigned short),1,fd_mem);
+  sprintf(outname,"%04X_%04X.int%02X",int_seg,int_off,int_no);
+  if(!(fd_out = fopen(outname,"wb")))
+  {
+    perror("Can't open file - /dev/mem");
+    fclose(fd_mem);
+    return EXIT_FAILURE;
+  }
+  bios_off = (int_seg << 4) + int_off;
+  bios_off &= 0xf0000;
+  fseek(fd_mem,bios_off,SEEK_SET);
+  for(i=0;i<0x10000;i++)
+  {
+    fread(&ch,1,1,fd_mem);
+    fwrite(&ch,1,1,fd_out);
+  }
+  fclose(fd_out);
+  fclose(fd_mem);
+  return EXIT_SUCCESS;
+}
\ No newline at end of file
--- a/TOOLS/c	Sun Oct 21 23:53:23 2001 +0000
+++ b/TOOLS/c	Mon Oct 22 07:15:04 2001 +0000
@@ -1,3 +1,4 @@
+gcc bios2dump.c -o bios2dump
 
 gcc subreader.c -o subreader
 gcc movinfo.c -o movinfo