RESUBMIT: GlobalAddAtomA hack

Marcus Meissner meissner at suse.de
Wed Aug 17 05:01:12 CDT 2005


Hi,

Changelog:
	protect GlobalAddAtomA string handling by exception
	handler (for broken programs).

Index: dlls/kernel/atom.c
===================================================================
RCS file: /home/wine/wine/dlls/kernel/atom.c,v
retrieving revision 1.8
diff -u -r1.8 atom.c
--- dlls/kernel/atom.c	10 May 2005 15:15:50 -0000	1.8
+++ dlls/kernel/atom.c	15 Aug 2005 05:35:29 -0000
@@ -38,6 +38,8 @@
 #include "winbase.h"
 #include "winerror.h"
 
+#include "wine/exception.h"
+#include "excpt.h"
 #include "wine/server.h"
 #include "wine/unicode.h"
 #include "kernel_private.h"
@@ -48,6 +50,14 @@
 
 #define MAX_ATOM_LEN 255
 
+/* filter for page-fault exceptions */
+static WINE_EXCEPTION_FILTER(page_fault)
+{
+    if (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION)
+        return EXCEPTION_EXECUTE_HANDLER;
+    return EXCEPTION_CONTINUE_SEARCH;
+}
+
 static struct atom_table* get_local_table(DWORD entries)
 {
     static struct atom_table*   local_table;
@@ -183,7 +193,14 @@
  */
 ATOM WINAPI GlobalAddAtomA( LPCSTR str /* [in] String to add */ )
 {
-    return ATOM_AddAtomA( str, NULL );
+    __TRY {
+	return ATOM_AddAtomA( str, NULL );
+    }
+    __EXCEPT(page_fault) {
+	SetLastError( ERROR_INVALID_PARAMETER );
+	return 0;
+    }
+    __ENDTRY
 }
 
 



More information about the wine-patches mailing list