summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-10-24 22:53:14 -0400
committermidipix <writeonce@midipix.org>2016-11-10 23:35:54 -0500
commit0d161c919f4c78f4218fc303e69afc64410da732 (patch)
tree42b5b65ea603e7749ade7cca6f9ff7772abbdccf
parentb0d024b2b8e1c1ef88b57240afdec7e85ae9d482 (diff)
downloadperk-0d161c919f4c78f4218fc303e69afc64410da732.tar.bz2
perk-0d161c919f4c78f4218fc303e69afc64410da732.tar.xz
pe_output_error(): added descriptive custom error strings.
-rw-r--r--src/output/pe_output_error.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/output/pe_output_error.c b/src/output/pe_output_error.c
index 21843b0..33e2b7a 100644
--- a/src/output/pe_output_error.c
+++ b/src/output/pe_output_error.c
@@ -17,6 +17,20 @@ static const char aclr_green[] = "\x1b[32m";
static const char aclr_blue[] = "\x1b[34m";
static const char aclr_magenta[] = "\x1b[35m";
+static const char const * const pe_error_strings[PERK_ERR_CAP] = {
+ [PERK_ERR_FLOW_ERROR] = "flow error: unexpected condition or other",
+ [PERK_ERR_FLEE_ERROR] = "flees and bugs and cats and mice",
+ [PERK_ERR_NULL_CONTEXT] = "null driver or unit context",
+ [PERK_ERR_NULL_IMAGE] = "null image base pointer",
+ [PERK_ERR_INVALID_CONTEXT] = "invalid driver or unit context",
+ [PERK_ERR_INVALID_IMAGE] = "invalid PE image",
+ [PERK_ERR_IMAGE_SIZE_ZERO] = "PE image size cannot be zero",
+ [PERK_ERR_IMAGE_MALFORMED] = "malformed PE image detected",
+ [PERK_ERR_BAD_DOS_HEADER] = "bad DOS header",
+ [PERK_ERR_BAD_COFF_HEADER] = "bad COFF header",
+ [PERK_ERR_BAD_IMAGE_TYPE] = "bad PE image type",
+};
+
static const char * pe_output_error_header(const struct pe_error_info * erri)
{
if (erri->flags & PERK_ERROR_CHILD)
@@ -35,7 +49,9 @@ static const char * pe_output_error_header(const struct pe_error_info * erri)
static const char * pe_output_strerror(const struct pe_error_info * erri)
{
if (erri->flags & PERK_ERROR_CUSTOM)
- return "flow error: unexpected condition or other";
+ return ((erri->liberror < 0) || (erri->liberror >= PERK_ERR_CAP))
+ ? "internal error: please report to the maintainer"
+ : pe_error_strings[erri->liberror];
else if (erri->flags & PERK_ERROR_NESTED)
return "";