How do I write an exception filter?

Stefan Kuhr winesku at
Thu Jul 10 15:24:11 CDT 2008

Hello Ove,

On Thu, Jul 10, 2008 at 9:55 PM, Ove Kaaven <ovek at> wrote:
> <snip>
> In general, within Wine code, it's impossible. In standard C, a function
> cannot reference a local variable of another function. It might be possible
> with some trickery (e.g. declaring explicit register/volatile variables), or
> with special compiler support (MSVC obviously has special support for it,
> and perhaps gcc nested functions or something could be used).
> For Wine, you'd have to come up with something else. Whatever the filter
> function needs should be available in some other form than a stack variable,
> like maybe some global or thread-local (TLS) variable, or perhaps from some
> function call.

Maybe there is something I simply don't understand. What I mean is
something like this:

 PDWORD pdwCommStatus = ....;
 PDWORD pdwFaultStatus = ....;
__except(MySpecialFilter(GetExceptionCode(),pdwCommStatus, pdwFaultStatus)  )
  // handle the exception


This is something quite common in Win32, as far as I can tell. As an
alternative, I would like to use the simple ternary operation in the
code snippet in my OP. Maybe I am too ignorant, because I have only
coded for Windows the last 15 years and I have some difficulties now
trying to prepare a patch for WINE, so bear with me, but I cannot see
why that would be trickery.

> Also perhaps consider whether you need a filter function this complex at
> all...

I need that. I would like to implement comm status and fault status
awareness in WINE's rpcrt4, because my applications crash in WINE
because of the lack of proper comm status and fault status awareness
in WINE's RPC implementation. From debugging NdClientCall2 in XP I
deduce I need this.


Stefan Kuhr

More information about the wine-devel mailing list