-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcmpr.c
59 lines (54 loc) · 1.07 KB
/
cmpr.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
* this is a crude utility that compares two files
*/
#include <io.h>
#include <fcntl.h>
#define SEEK_SET 0
#define TABLESIZE 20000
char src[TABLESIZE];
char dst[TABLESIZE];
#define FILE_S "dosidle.exe"
#define FILE_D "dosidlen.exe"
#define DIFF (0x7AE - 0x5AE)
main()
{
int i,j;
int ifs, ifd;
int reads, readd;
ifs = open(FILE_S,O_RDONLY|O_BINARY);
if (ifs == 0) {
puts("src file !");
exit(1);
}
ifd = open(FILE_D,O_RDONLY|O_BINARY);
if (ifd == 0) {
puts("dst file !");
exit(1);
}
lseek(ifs, 0, SEEK_SET);
lseek(ifd, 0, SEEK_SET);
reads = read(ifs, src, TABLESIZE);
readd = read(ifd, dst, TABLESIZE);
printf("read %d bytes\n",reads);
if (reads != readd) {
close (ifs);
close (ifd);
puts("src and dst file size");
exit(1);
}
for (i=0; i <reads; i++) {
unsigned char s,d;
s = src[i];
d = dst[i];
if (s == d)
continue;
j = i - DIFF;
if (j < 0)
printf("!%6x '%x' '%x'\n", i ,s ,d);
else
printf("%6x '%x' '%x'\n", j ,s ,d);
}
close (ifs);
close (ifd);
return 0;
}