Mercurial > mplayer.hg
annotate TOOLS/mem2dump.c @ 12965:520c8675f033
Leftover from the old Matroska demuxer detection removed.
author | mosu |
---|---|
date | Thu, 05 Aug 2004 06:31:42 +0000 |
parents | 51276a7f4ea1 |
children |
rev | line source |
---|---|
2356 | 1 /* |
2 bios2dump.c - Was designed to dump memory block to file. | |
3 Usage: as argument requires absolute address of memory dump and its lenght | |
4 (int hexadecimal form). | |
5 as output - will write file which will named: memADDR_LEN.dump | |
6 where: ADDR - given address of memory | |
7 LEN - given length of memory | |
8 Licence: GNU GPL v2 | |
9 Copyright: Nick Kurshev <nickols_k@mail.ru> | |
10 */ | |
11 #include <stdio.h> | |
12 #include <stdlib.h> | |
13 | |
14 int main( int argc, char *argv[]) | |
15 { | |
16 FILE * fd_mem, *fd_out; | |
17 unsigned long i,addr,len; | |
18 int int_no; | |
19 char outname[80]; | |
20 unsigned char ch; | |
21 if(argc < 3) | |
22 { | |
23 printf("Usage: %s address length (in hex)\n",argv[0]); | |
24 return EXIT_FAILURE; | |
25 } | |
26 addr = strtol(argv[1],NULL,16); | |
27 len = strtol(argv[2],NULL,16); | |
28 if(!(fd_mem = fopen("/dev/mem","rb"))) | |
29 { | |
30 perror("Can't open file - /dev/mem"); | |
31 return EXIT_FAILURE; | |
32 } | |
33 sprintf(outname,"mem%08X_%08X.dump",addr,len); | |
34 if(!(fd_out = fopen(outname,"wb"))) | |
35 { | |
36 perror("Can't open output file"); | |
37 fclose(fd_mem); | |
38 return EXIT_FAILURE; | |
39 } | |
40 fseek(fd_mem,addr,SEEK_SET); | |
41 for(i=0;i<len;i++) | |
42 { | |
43 fread(&ch,1,1,fd_mem); | |
44 fwrite(&ch,1,1,fd_out); | |
45 } | |
46 fclose(fd_out); | |
47 fclose(fd_mem); | |
48 return EXIT_SUCCESS; | |
12923
51276a7f4ea1
cosmetic warning fix (missing newline at end of file)
diego
parents:
2356
diff
changeset
|
49 } |