How do I write an exception filter?

Stefan Kuhr winesku at googlemail.com
Thu Jul 10 15:30:44 CDT 2008


Hi everyone,

On Thu, Jul 10, 2008 at 10:24 PM, Stefan Kuhr <winesku at googlemail.com> wrote:
> Hello Ove,
>
> On Thu, Jul 10, 2008 at 9:55 PM, Ove Kaaven <ovek at arcticnet.no> 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:
>
> __try
> {
>  PDWORD pdwCommStatus = ....;
>  PDWORD pdwFaultStatus = ....;
>  doSomething();
> }
> __except(MySpecialFilter(GetExceptionCode(),pdwCommStatus, pdwFaultStatus)  )
> {
>  // handle the exception
>
> }


Oh stupid me.

PDWORD pdwCommStatus = ....;
PDWORD pdwFaultStatus = ....;


should be placed outside the try block.

-- 
Stefan Kuhr



More information about the wine-devel mailing list