123456789101112131415161718192021222324252627282930313233 |
- #include "elf.h"
- #include <common/unistd.h>
- #include <common/glib.h>
- bool elf_check(void *ehdr)
- {
- Elf32_Ehdr *ptr = (Elf32_Ehdr *)ehdr;
- bool flag = ptr->e_ident[EI_MAG0] == ELFMAG0 && ptr->e_ident[EI_MAG1] == ELFMAG1 && ptr->e_ident[EI_MAG2] == ELFMAG2 && ptr->e_ident[EI_MAG3] == ELFMAG3;
-
- if (!flag)
- return false;
-
- if (ptr->e_ident[EI_CLASS] == 0 || ptr->e_ident[EI_CLASS] > 2)
- return false;
-
-
- if (ptr->e_ident[EI_DATA] == 0 || ptr->e_ident[EI_DATA] > 2)
- return false;
-
-
- if(ptr->e_ident[EI_VERSION]==EV_NONE)
- return false;
-
- return true;
- }
|