-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfile_header.cc
More file actions
26 lines (24 loc) · 1.13 KB
/
file_header.cc
File metadata and controls
26 lines (24 loc) · 1.13 KB
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
#include "file_header.h"
#include "convert_value.h"
#include "extra_checks.h"
fh_returndata get_file_header(std::ifstream &file) {
fh_returndata returndata;
FileHeader current_fh[1];
file.read(reinterpret_cast<char*>(¤t_fh), sizeof(current_fh));
std::cout << current_fh->machine << std::endl;
check_machine(current_fh->machine, &returndata);
check_valid_uefi_machine_type(current_fh->machine);
convert_filechars(current_fh->chars, &returndata);
convert_time(current_fh->timedatestamp, &returndata);
/* get_optional_header(file); */
do_return_data(current_fh, &returndata);
return returndata;
}
void do_return_data(FileHeader *current_fh, fh_returndata *returndata) {
/* Write filedata to output structure */
/* No machine since that is done in check_machine() */
returndata->numberofsections = std::to_string(current_fh->numberofsections);
convert_to_hex(current_fh->pointertosymboltable, &(returndata->pointertosymboltable));
convert_to_hex(current_fh->numberofsymbols, &(returndata->numberofsymbols));
convert_to_hex(current_fh->sizeofoptional, &(returndata->sizeofoptional));
}