c++ - Writing SEH translator -
class seh_exception : public std::exception { public: seh_exception(uint se_code, pexception_pointers se_info); seh_exception(const seh_exception& old); ~seh_exception(); const char *what() const; }; void translate_seh_exception(uint se_code, pexception_pointers se_info) { throw seh_exception(se_code, se_info); }
now, do in constructor? couldn't find information on how long *se_info
exist, means shouldn't save se_info
in private field later use — should copy it. or maybe not?
and what's what()
? supposed conjure underlying string on-demand? again, allocating memory in constructor seems not idea in case.
i've implemented storing se_code
, se_info
without deep-copying, , generating formatted message in constructor, , works, though not know if supposed work.
i intend use in "catch, log happened, terminate" scenario.
you don't need own class achieve this, can throw pexception_pointers
. se_code
available @ se_info->exceptionrecord->exceptioncode
.
so simplest handler just;
void translate_seh_exception(uint se_code, pexception_pointers se_info) { throw se_info; }
you can catch(pexception_pointers se_info)
the exception_pointers
guaranteed exist duration of catch
block, how long need for. per documentation, translator function called once each catch block, is, has re-translate seh exception every function containing try/catch
block.
Comments
Post a Comment