Hallo, some program (/cdroms/yama9911/autoptn/auto-g.exe) crashes, e.g. when exiting,) like: Call KERNEL32.446: GlobalHandle(41de5d04) ret=0f725ce0 fs=071f Ret KERNEL32.446: GlobalHandle() retval=41de5cde ret=0f725ce0 fs=071f Call KERNEL32.453: GlobalUnlock(00005cde) ret=0f725cee fs=071f Unhandled exception: page fault on read access to 0x00005cdc in 32-bit code (0x40406b14) (fs=0000071f). The return value from GlobalHandle is willingly chopped of its high word with "movzx edi, ax" with eax being the return value of GlobalHandle and edi is push as argument to GlobalUnlock on the stack. A similar thing happens with Globalfree. Is the following patch with the addition of an Exception handler a valid approach? B.t.w.: It seems as if the Exception handler isn't active if I run the application with native users and friends . Strange. Bye Uwe Bonnes [EMAIL PROTECTED] Free Software: If you contribute nothing, expect nothing -- Index: wine/memory/global.c =================================================================== RCS file: /home/wine/wine/memory/global.c,v retrieving revision 1.29 diff -u -r1.29 global.c --- wine/memory/global.c 2000/02/10 22:15:24 1.29 +++ wine/memory/global.c 2000/03/01 16:38:34 @@ -12,6 +12,7 @@ #include <string.h> #include "wine/winbase16.h" +#include "wine/exception.h" #include "global.h" #include "heap.h" #include "toolhelp.h" @@ -22,6 +23,14 @@ #include "debugtools.h" #include "winerror.h" +/* filter for page-fault exceptions */ +static WINE_EXCEPTION_FILTER(page_fault) +{ + if (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION) + return EXCEPTION_EXECUTE_HANDLER; + return EXCEPTION_CONTINUE_SEARCH; +} + DEFAULT_DEBUG_CHANNEL(global); /* Global arena block */ @@ -1107,6 +1116,8 @@ return FALSE; /* HeapLock(GetProcessHeap()); */ + __TRY + { pintern=HANDLE_TO_INTERN(hmem); if(pintern->Magic==MAGIC_GLOBAL_USED) @@ -1116,11 +1127,15 @@ locked=(pintern->LockCount==0) ? FALSE : TRUE; } - else + } + __EXCEPT(page_fault) { WARN("invalid handle\n"); - locked=FALSE; + SetLastError( ERROR_INVALID_PARAMETER ); + return FALSE; } + __ENDTRY + /* HeapUnlock(GetProcessHeap()); */ return locked; } @@ -1288,8 +1303,11 @@ ) { PGLOBAL32_INTERN pintern; HGLOBAL hreturned = 0; - HANDLE heap = GLOBAL_GetHeap( hmem ); + HANDLE heap; + __TRY + { + heap = GLOBAL_GetHeap( hmem ); if(ISPOINTER(hmem)) /* POINTER */ { if(!HeapFree(heap, 0, (LPVOID) hmem)) hmem = 0; @@ -1316,6 +1334,14 @@ } /* HeapUnlock(heap); */ } + } + __EXCEPT(page_fault) + { + WARN("invalid handle\n"); + SetLastError( ERROR_INVALID_PARAMETER ); + hreturned=hmem; + } + __ENDTRY return hreturned; }