From c73ed3c6d5f79fb73f829ed1d57ec06101b0c48d Mon Sep 17 00:00:00 2001 From: Ulf Lamping Date: Sun, 22 Jan 2006 02:22:14 +0000 Subject: add Win32 Structured Exception Handling (SEH) at the same place we're already doing the Portable Exception Handling. This way we (hopefully) can continue dissecting with the next packet, even if a more serious exception had occured, e.g. a memory access violation or a divide by zero exception. Obviously, not all problems solved, as SEH won't protect us from other problems, e.g. endless loops and such svn path=/trunk/; revision=17070 --- epan/dissectors/packet-frame.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/epan/dissectors/packet-frame.c b/epan/dissectors/packet-frame.c index 9c1bd9b957..03dabf2d17 100644 --- a/epan/dissectors/packet-frame.c +++ b/epan/dissectors/packet-frame.c @@ -267,9 +267,15 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) } } + /* Portable Exception Handling to trap Ethereal specific exceptions like BoundsError exceptions */ TRY { - if (!dissector_try_port(wtap_encap_dissector_table, pinfo->fd->lnk_t, - tvb, pinfo, parent_tree)) { +#ifdef _WIN32 + /* WIN32 Structured Exception Handling (SEH) to trap hardware exceptions like memory access violations */ + /* (a running debugger will be called before the except part below) */ + __try { +#endif + if (!dissector_try_port(wtap_encap_dissector_table, pinfo->fd->lnk_t, + tvb, pinfo, parent_tree)) { if (check_col(pinfo->cinfo, COL_PROTOCOL)) col_set_str(pinfo->cinfo, COL_PROTOCOL, "UNKNOWN"); @@ -278,6 +284,24 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) pinfo->fd->lnk_t); call_dissector(data_handle,tvb, pinfo, parent_tree); } +#ifdef _WIN32 + } __except(TRUE /* handle all exceptions */) { + switch(GetExceptionCode()) { + case(STATUS_ACCESS_VIOLATION): + show_exception(tvb, pinfo, parent_tree, DissectorError, + "STATUS_ACCESS_VIOLATION: dissector accessed an invalid memory address"); + break; + case(STATUS_INTEGER_DIVIDE_BY_ZERO): + show_exception(tvb, pinfo, parent_tree, DissectorError, + "STATUS_INTEGER_DIVIDE_BY_ZERO: dissector tried an integer division by zero"); + break; + /* XXX - add other hardware exception codes as required */ + default: + show_exception(tvb, pinfo, parent_tree, DissectorError, + g_strdup_printf("dissector caused an unknown exception: %u", GetExceptionCode())); + } + } +#endif } CATCH_ALL { show_exception(tvb, pinfo, parent_tree, EXCEPT_CODE, GET_MESSAGE); -- cgit v1.2.3