Can we catch access violation exceptions in tests?

Damjan Jovanovic damjan.jov at gmail.com
Mon May 7 06:09:15 CDT 2007


On 5/7/07, Mikołaj Zalewski <mikolaj at zalewski.pl> wrote:
>   I'm trying to write a tests for invalid cbSize in Shell_NotifyIcon.
> The behaviour under Windows XP is to assume in such a case that the size
> is NOTIFYICONDATA_V1_SIZE. AFAIK Shell_NotifyIcon doesn't provide a way
> to read icon data to check that the data introduced after Win95 is not
> modified. So I'm using VirtualAlloc+VirtualProtect to make
> Shell_NotifyIcon fail if it tries to access this data.
>   I'd like to catch the exception to make a tests fail if something goes
> wrong instead of crashing the testsuite. However __try doesn't work
> under gcc and using wine/exception.h gives an unresolved symbol
> '__wine_handle_exception'. Is it possible to catch exceptions in tests?
>
> Mikolaj Zalewski

#include "wine/exception.h"

__TRY
{
    /* code that can segfault */
}
__EXCEPT_PAGE_FAULT
{
    /* actions to take on segfault */
}
__ENDTRY

I'm not sure which library you have to link with.

Enjoy
Damjan


More information about the wine-devel mailing list