-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
83 lines (60 loc) · 1.52 KB
/
main.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
Модуль main.c.
Главный модуль программы mzinfo отображения информации о MZ-файле.
Панасенко Дмитрий Игоревич, Маткин Илья Александрович 30.04.2020
*/
#include <windows.h>
#include <stdio.h>
#include "disas.h"
#include "mz.h"
//
// Подсказка по использованию.
//
void usage(void) {
printf("mzinfo <filename> <opt>\n");
printf("opt:\n"
"\theader\n"
"\trelocs\n"
"\tsegments\n"
"\tinfo\n"
"\tdisas\n"
"\tall\n");
}
int main(int argc, char *argv[], char *envp[]) {
MZHeaders mz;
char *filename;
if(argc < 3){
usage();
return 1;
}
filename = argv[1];
if (LoadMZFile(filename, &mz) == FALSE) {
return 1;
}
printf("Information about %s\n\n", filename);
if (!strcmp (argv[2], "header")) {
PrintDOSHeader(&mz);
}
if (!strcmp (argv[2], "relocs")) {
PrintRelocsTable(&mz);
}
if (!strcmp (argv[2], "segments")) {
PrintSegments(&mz);
}
if (!strcmp (argv[2], "info")) {
PrintDOSHeader(&mz);
PrintRelocsTable(&mz);
PrintSegments(&mz);
}
if (!strcmp (argv[2], "disas")) {
DisasCodeSeg(&mz);
}
if (!strcmp (argv[2], "all")) {
PrintDOSHeader(&mz);
PrintRelocsTable(&mz);
PrintSegments(&mz);
DisasCodeSeg(&mz);
}
UnloadMZFile(&mz);
return 0;
}