-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patherrors.h
49 lines (44 loc) · 1.16 KB
/
errors.h
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
#ifndef WW_ERRORS_H
# define WW_ERRORS_H
# include <errno.h>
# include <stdbool.h>
// Error messages to display. The index is synchronized with the error code array below.
# define WW_ERROR_MSG_ARRAY \
{ \
"Wrong number of arguments", \
"Unknown argument(s)", \
"open: Failed to open the binary file", \
"malloc: Failed to allocate memory", \
"mmap: Failed to map the file", \
"munmap: Failed to unmap the file", \
"File architecture not suported. 64-bit ELF files only", \
"lseek: Failed to read file", \
"write: Failed to write to the file", \
"open: Failed to open/create output file", \
"No .text section found! Aborting...", \
"Corrupted program header", \
"Corrupted ELF header", \
"Unrecognized option", \
"Cannot inject into padding: not sufficient padding space",\
};
// Error codes
enum ww_e_errors
{
WW_ERR_BADARGNBR,
WW_ERR_BADARG,
WW_ERR_OPENBIN,
WW_ERR_ALLOCMEM,
WW_ERR_MMAP,
WW_ERR_MUNMAP,
WW_ERR_NOT64BITELF,
WW_ERR_LSEEK,
WW_ERR_WRITEFILE,
WW_ERR_OUTFILE,
WW_ERR_NOTEXTSEC,
WW_ERR_CORRUPTPHDR,
WW_ERR_CORRUPTEHDR,
WW_ERR_UNRECOGNIZEDOPT,
WW_ERR_CANNOTINJECTPADDING
};
void ww_print_error_and_exit(enum ww_e_errors err_code);
#endif