diff --git a/include/perk/perk.h b/include/perk/perk.h index bb2a05b..5951fa6 100644 --- a/include/perk/perk.h +++ b/include/perk/perk.h @@ -28,10 +28,6 @@ extern "C" { #define PERK_BAD_OPT_VAL 0x03 #define PERK_IO_ERROR 0xA0 #define PERK_MAP_ERROR 0xA1 -#define PERK_BAD_DOS_HEADER 0xA2 -#define PERK_BAD_COFF_HEADER 0xA3 -#define PERK_BAD_IMAGE_TYPE 0xA4 -#define PERK_MALFORMED_IMAGE 0xA5 /* driver flags */ #define PERK_DRIVER_VERBOSITY_NONE 0x0000 @@ -52,6 +48,21 @@ extern "C" { #define PERK_ERROR_CHILD 0x0004 #define PERK_ERROR_CUSTOM 0x0008 +enum pe_custom_error { + PERK_ERR_FLOW_ERROR, + PERK_ERR_FLEE_ERROR, + PERK_ERR_NULL_CONTEXT, + PERK_ERR_NULL_IMAGE, + PERK_ERR_INVALID_CONTEXT, + PERK_ERR_INVALID_IMAGE, + PERK_ERR_IMAGE_SIZE_ZERO, + PERK_ERR_IMAGE_MALFORMED, + PERK_ERR_BAD_DOS_HEADER, + PERK_ERR_BAD_COFF_HEADER, + PERK_ERR_BAD_IMAGE_TYPE, + PERK_ERR_CAP, +}; + struct pe_source_version { int major; int minor; diff --git a/src/logic/pe_get_image_meta.c b/src/logic/pe_get_image_meta.c index 8d90353..6302f70 100644 --- a/src/logic/pe_get_image_meta.c +++ b/src/logic/pe_get_image_meta.c @@ -105,7 +105,7 @@ int pe_get_image_meta( if ((i >= 0) && (i != s)) return pe_free_image_meta_impl(m, - PERK_CUSTOM_ERROR(dctx,PERK_MALFORMED_IMAGE)); + PERK_CUSTOM_ERROR(dctx,PERK_ERR_IMAGE_MALFORMED)); if (s >= 0) { m->hedata = &m->sectbl[s]; @@ -128,7 +128,7 @@ int pe_get_image_meta( if ((i >= 0) && (i != s)) return pe_free_image_meta_impl(m, - PERK_CUSTOM_ERROR(dctx,PERK_MALFORMED_IMAGE)); + PERK_CUSTOM_ERROR(dctx,PERK_ERR_IMAGE_MALFORMED)); if (s >= 0) { m->hidata = &m->sectbl[s]; diff --git a/src/reader/pe_read_coff_header.c b/src/reader/pe_read_coff_header.c index 619c1cc..5ee62e3 100644 --- a/src/reader/pe_read_coff_header.c +++ b/src/reader/pe_read_coff_header.c @@ -15,7 +15,7 @@ int pe_read_coff_header(const struct pe_coff_file_hdr * p, struct pe_meta_coff_f uint16_t * pzero = (uint16_t *)&p->signature[2]; if ((p->signature[0] != 'P') || (p->signature[1] != 'E') || *pzero) - return PERK_BAD_COFF_HEADER; + return PERK_ERR_BAD_COFF_HEADER; if (PERK_LITTLE_ENDIAN) { diff --git a/src/reader/pe_read_dos_header.c b/src/reader/pe_read_dos_header.c index 0fd0367..7aa9ba5 100644 --- a/src/reader/pe_read_dos_header.c +++ b/src/reader/pe_read_dos_header.c @@ -13,7 +13,7 @@ int pe_read_dos_header(const struct pe_image_dos_hdr * p, struct pe_meta_image_dos_hdr * m) { if ((p->dos_magic[0] != 'M') || (p->dos_magic[1] != 'Z')) - return PERK_BAD_DOS_HEADER; + return PERK_ERR_BAD_DOS_HEADER; if (PERK_LITTLE_ENDIAN) { diff --git a/src/reader/pe_read_import_header.c b/src/reader/pe_read_import_header.c index 645a375..d2b3acd 100644 --- a/src/reader/pe_read_import_header.c +++ b/src/reader/pe_read_import_header.c @@ -47,6 +47,6 @@ int pe_read_import_lookup_item( return 0; default: - return PERK_BAD_IMAGE_TYPE; + return PERK_ERR_BAD_IMAGE_TYPE; } } diff --git a/src/reader/pe_read_optional_header.c b/src/reader/pe_read_optional_header.c index 24aa95b..25c1b34 100644 --- a/src/reader/pe_read_optional_header.c +++ b/src/reader/pe_read_optional_header.c @@ -25,7 +25,7 @@ static int pe_read_optional_header_little_endian(const union pe_opt_hdr * p, str memcpy(&m->ldr,&p->opt_hdr_32.loader_flags,sizeof(struct pe_meta_opt_hdr_ldr)); if (m->ldr.rva_and_sizes > 0x10) - return PERK_BAD_IMAGE_TYPE; + return PERK_ERR_BAD_IMAGE_TYPE; else memcpy(&m->dirs,&p->opt_hdr_32.export_tbl,sizeof(struct pe_meta_opt_hdr_dirs)); @@ -38,14 +38,14 @@ static int pe_read_optional_header_little_endian(const union pe_opt_hdr * p, str memcpy(&m->ldr,&p->opt_hdr_64.loader_flags,sizeof(struct pe_meta_opt_hdr_ldr)); if (m->ldr.rva_and_sizes > 0x10) - return PERK_BAD_IMAGE_TYPE; + return PERK_ERR_BAD_IMAGE_TYPE; else memcpy(&m->dirs,&p->opt_hdr_64.export_tbl,sizeof(struct pe_meta_opt_hdr_dirs)); break; default: - return PERK_BAD_IMAGE_TYPE; + return PERK_ERR_BAD_IMAGE_TYPE; } return 0; @@ -80,7 +80,7 @@ static int pe_read_optional_header_big_endian(const union pe_opt_hdr * p, struct break; default: - return PERK_BAD_IMAGE_TYPE; + return PERK_ERR_BAD_IMAGE_TYPE; } /* std */