27 lines
569 B
C
27 lines
569 B
C
|
#include "ft_nm.h"
|
||
|
|
||
|
int check_magic_number(Elf64_Ehdr *header) {
|
||
|
if (ft_strncmp((void *)&header->e_ident[EI_MAG0], "\x7f""ELF", 4)) {
|
||
|
return FT_NM_FAILURE;
|
||
|
}
|
||
|
return FT_NM_SUCCESS;
|
||
|
}
|
||
|
|
||
|
int check_format(Elf64_Ehdr *header) {
|
||
|
if (header->e_ident[EI_CLASS] == ELFCLASSNONE) {
|
||
|
printf("problem\n");
|
||
|
return FT_NM_FAILURE;
|
||
|
}
|
||
|
return FT_NM_SUCCESS;
|
||
|
}
|
||
|
|
||
|
int check_header(Elf64_Ehdr *header) {
|
||
|
if (check_magic_number(header) == FT_NM_FAILURE) {
|
||
|
return FT_NM_FAILURE;
|
||
|
}
|
||
|
if (check_format(header) == FT_NM_FAILURE) {
|
||
|
return FT_NM_FAILURE;
|
||
|
}
|
||
|
return FT_NM_SUCCESS;
|
||
|
}
|