From 3170cb7891bd6980695f86349950a03baef958f9 Mon Sep 17 00:00:00 2001 From: short <> Date: Sat, 5 Jul 2003 19:53:26 +0000 Subject: [PATCH] _abnormal_termination() is now "wrap"ed by %fs:[0] protection agains '-1' - there is no toplevel exception handler registered by libcaptive --- src/libcaptive/ke/exports.captivesym | 4 ++-- src/libcaptive/ps/signal.c | 33 +++++++++++++++++++++++---------- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/libcaptive/ke/exports.captivesym b/src/libcaptive/ke/exports.captivesym index d76fea2..b429ed7 100644 --- a/src/libcaptive/ke/exports.captivesym +++ b/src/libcaptive/ke/exports.captivesym @@ -334,8 +334,8 @@ ntoskrnl.exe IoReleaseCancelSpinLock ntoskrnl.exe _global_unwind2 ntoskrnl.exe RtlUnwind ntoskrnl.exe _local_unwind2 pass -# we can use iff "_local_unwind2 pass" as there is registered local handler to %fs:[0]: -ntoskrnl.exe _abnormal_termination pass +# we can pass iff "_local_unwind2 pass" as there is registered local handler to %fs:[0]: +ntoskrnl.exe _abnormal_termination wrap ntoskrnl.exe FsRtlIncrementCcFastReadNoWait ntoskrnl.exe FsRtlResetLargeMcb pass ntoskrnl.exe RtlGetCompressionWorkSpaceSize pass diff --git a/src/libcaptive/ps/signal.c b/src/libcaptive/ps/signal.c index c042f54..1e78c4c 100644 --- a/src/libcaptive/ps/signal.c +++ b/src/libcaptive/ps/signal.c @@ -34,27 +34,40 @@ #include "captive/ldr_exports.h" /* for struct captive_ModuleList_patchpoint */ -#if 0 /* Currently implemented for real by "pass" to native ntoskrnl. */ +int _abnormal_termination_orig(void); +extern greg_t fs_KPCR_ExceptionList; + /** - * _abnormal_termination: + * _abnormal_termination_wrap: + * + * This call can be also accessed as AbnormalTermination() or _abnormal_termination(). + * It is a captive wrapper around _abnormal_termination() function. * - * This call can be also accessed as AbnormalTermination() or abnormal_termination(). + * Returns whether some exception occured in the current #try block we are currently + * #finish -ing. Any functions called from current #finish block will be considered + * for returning zero back again. It is forbidden to call this function outside + * of #finish block, result of such call is undefined. * - * Returns whether some exception occured (FIXME: in what scope?). * Exception handlers are registered from W32 binary in stack frames stored in "fs:[0x00000000]" * value which gets mapped by libcaptive/ps/signal.c to #fs_KPCR_ExceptionList * variable. * - * libcaptive currently does not raise any exceptions therefore this call always returns value %0. - * See RtlpDispatchException(). + * If no exception handler was registered yet this function returns zero. + * + * See also RtlpDispatchException(). * - * Returns: non-zero if some exception is now registered and pending. + * Returns: non-zero if some exception is now being handled as pending. */ -int _abnormal_termination(void) +int _abnormal_termination_wrap(void) { - return 0; + /* No handler registered yet? ntoskrnl _abnormal_termination() does not handle it + * and I do not want to bother with registering toplevel handler. + */ + if (fs_KPCR_ExceptionList==(greg_t)-1) + return 0; + + return _abnormal_termination_orig(); } -#endif #if 0 -- 1.8.3.1