[PATCH] ntdll: Call __finally blocks in __C_specific_handler

Piotr Caban piotr.caban at gmail.com
Fri Aug 5 04:41:15 CDT 2016


Hi,

I was also trying to implement support for finally blocks. My 
implementation differs a little from yours.

On 08/05/16 02:53, Daniel Lehman wrote:
> +    if (rec->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND))
> +    {
> +        for (i = 0; i < table->Count; i++)
> +        {
> +            if (context->Rip >= dispatch->ImageBase + table->ScopeRecord[i].BeginAddress &&
> +                context->Rip < dispatch->ImageBase + table->ScopeRecord[i].EndAddress)
> +            {
> +                if (table->ScopeRecord[i].JumpTarget) continue;
> +
> +                if (rec->ExceptionFlags & EH_TARGET_UNWIND &&
> +                    dispatch->TargetIp < dispatch->ImageBase + table->ScopeRecord[i].EndAddress)
I was also checking if:
dispatch->TargetIp >= dispatch->ImageBase + 
table->ScopeRecord[i].BeginAddress
I'm not sure if this is needed.
> +                {
> +                    break;
> +                }
> +
> +                handler = (PC_LANGUAGE_EXCEPTION_HANDLER)(dispatch->ImageBase + table->ScopeRecord[i].HandlerAddress);
Termination handlers have different signature. I was using following 
definition:
typedef void (WINAPI *TERMINATION_HANDLER)( ULONG flags, ULONG64 frame );
I don't really know what is passed in first argument. I guess that it 
might be BYTE is_abnormal. On Windows flags were set to 0x1101 or 0x1201 
in my test applications (I think that probably only least significant 
BYTE matters).

Thanks,
Piotr



More information about the wine-devel mailing list