Alexandre Julliard : msvcrt: Implement _invalid_parameter and fix the handler definitions.

Alexandre Julliard julliard at winehq.org
Wed Apr 14 11:24:59 CDT 2010


Module: wine
Branch: master
Commit: 4f3b7f844564c75aa29114d8e6b57070f9be28eb
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=4f3b7f844564c75aa29114d8e6b57070f9be28eb

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Wed Apr 14 14:34:27 2010 +0200

msvcrt: Implement _invalid_parameter and fix the handler definitions.

---

 dlls/msvcr80/msvcr80.spec    |    4 ++--
 dlls/msvcr90/msvcr90.spec    |    4 ++--
 dlls/msvcr90/tests/msvcr90.c |    4 ++--
 dlls/msvcrt/errno.c          |   29 +++++++++++++++++++++++++----
 dlls/msvcrt/msvcrt.h         |    5 +++--
 dlls/msvcrt/msvcrt.spec      |    2 +-
 dlls/msvcrt/string.c         |    4 ++--
 include/msvcrt/stdlib.h      |   10 ++++++----
 8 files changed, 43 insertions(+), 19 deletions(-)

diff --git a/dlls/msvcr80/msvcr80.spec b/dlls/msvcr80/msvcr80.spec
index 75c0f3a..ea5e65c 100644
--- a/dlls/msvcr80/msvcr80.spec
+++ b/dlls/msvcr80/msvcr80.spec
@@ -42,7 +42,7 @@
 @ stub ?_ValidateWrite@@YAHPAXI at Z
 @ cdecl __uncaught_exception() msvcrt.__uncaught_exception
 @ stub ?_inconsistency@@YAXXZ
-@ stub ?_invalid_parameter@@YAXPBG00II at Z
+@ cdecl ?_invalid_parameter@@YAXPBG00II at Z(wstr wstr wstr long long) msvcrt._invalid_parameter
 @ stub ?_is_exception_typeof@@YAHABVtype_info@@PAU_EXCEPTION_POINTERS@@@Z
 @ stub ?_name_internal_method at type_info@@QBEPBDPAU__type_info_node@@@Z
 @ varargs ?_open@@YAHPBDHH at Z(str long) msvcrt._open
@@ -533,7 +533,7 @@
 @ stub _inp
 @ stub _inpd
 @ stub _inpw
-@ stub _invalid_parameter
+@ cdecl _invalid_parameter(wstr wstr wstr long long) msvcrt._invalid_parameter
 @ stub _invalid_parameter_noinfo
 @ stub _invoke_watson
 @ extern _iob msvcrt._iob
diff --git a/dlls/msvcr90/msvcr90.spec b/dlls/msvcr90/msvcr90.spec
index ed5a4bf..3082230 100644
--- a/dlls/msvcr90/msvcr90.spec
+++ b/dlls/msvcr90/msvcr90.spec
@@ -42,7 +42,7 @@
 @ stub ?_ValidateWrite@@YAHPAXI at Z
 @ cdecl __uncaught_exception() msvcrt.__uncaught_exception
 @ stub ?_inconsistency@@YAXXZ
-@ stub ?_invalid_parameter@@YAXPBG00II at Z
+@ cdecl ?_invalid_parameter@@YAXPBG00II at Z(wstr wstr wstr long long) msvcrt._invalid_parameter
 @ stub ?_is_exception_typeof@@YAHABVtype_info@@PAU_EXCEPTION_POINTERS@@@Z
 @ stub ?_name_internal_method at type_info@@QBEPBDPAU__type_info_node@@@Z
 @ varargs ?_open@@YAHPBDHH at Z(str long) msvcrt._open
@@ -521,7 +521,7 @@
 @ stub _inp
 @ stub _inpd
 @ stub _inpw
-@ stub _invalid_parameter
+@ cdecl _invalid_parameter(wstr wstr wstr long long) msvcrt._invalid_parameter
 @ stub _invalid_parameter_noinfo
 @ stub _invoke_watson
 @ extern _iob msvcrt._iob
diff --git a/dlls/msvcr90/tests/msvcr90.c b/dlls/msvcr90/tests/msvcr90.c
index e094b1a..2b4fae4 100644
--- a/dlls/msvcr90/tests/msvcr90.c
+++ b/dlls/msvcr90/tests/msvcr90.c
@@ -46,13 +46,13 @@ int cb_called[4];
 
 void __cdecl test_invalid_parameter_handler(const wchar_t *expression,
         const wchar_t *function, const wchar_t *file,
-        unsigned line, unsigned *res)
+        unsigned line, uintptr_t arg)
 {
     ok(expression == NULL, "expression is not NULL\n");
     ok(function == NULL, "function is not NULL\n");
     ok(file == NULL, "file is not NULL\n");
     ok(line == 0, "line = %u\n", line);
-    ok(res == NULL, "res = %p\n", res);
+    ok(arg == 0, "arg = %lx\n", (UINT_PTR)arg);
 }
 
 static int __cdecl initterm_cb0(void)
diff --git a/dlls/msvcrt/errno.c b/dlls/msvcrt/errno.c
index 80dcab6..4d97051 100644
--- a/dlls/msvcrt/errno.c
+++ b/dlls/msvcrt/errno.c
@@ -20,8 +20,14 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <stdarg.h>
 
+#include "ntstatus.h"
+#define WIN32_NO_STATUS
+#include "windef.h"
+#include "winternl.h"
 #include "msvcrt.h"
+#include "excpt.h"
 #include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
@@ -117,7 +123,8 @@ char *MSVCRT__sys_errlist[] =
 };
 
 unsigned int MSVCRT__sys_nerr = sizeof(MSVCRT__sys_errlist)/sizeof(MSVCRT__sys_errlist[0]) - 1;
-MSVCRT_invalid_parameter_handler MSVCRT_invalid_parameter = NULL;
+
+static MSVCRT_invalid_parameter_handler invalid_parameter_handler = NULL;
 
 /* INTERNAL: Set the crt and dos errno's from the OS error given. */
 void msvcrt_set_errno(int err)
@@ -287,21 +294,35 @@ void CDECL _seterrormode(int mode)
     SetErrorMode( mode );
 }
 
+/******************************************************************************
+ *		_invalid_parameter (MSVCRT.@)
+ */
+void __cdecl MSVCRT__invalid_parameter(const MSVCRT_wchar_t *expr, const MSVCRT_wchar_t *func,
+                                       const MSVCRT_wchar_t *file, unsigned int line, MSVCRT_uintptr_t arg)
+{
+    if (invalid_parameter_handler) invalid_parameter_handler( expr, func, file, line, arg );
+    else
+    {
+        ERR( "%s:%u %s: %s %lx\n", debugstr_w(file), line, debugstr_w(func), debugstr_w(expr), arg );
+        RaiseException( STATUS_INVALID_CRUNTIME_PARAMETER, EXCEPTION_NONCONTINUABLE, 0, NULL );
+    }
+}
+
 /* _get_invalid_parameter_handler - not exported in native msvcrt, added in msvcr80 */
 MSVCRT_invalid_parameter_handler CDECL _get_invalid_parameter_handler(void)
 {
     TRACE("\n");
-    return MSVCRT_invalid_parameter;
+    return invalid_parameter_handler;
 }
 
 /* _set_invalid_parameter_handler - not exproted in native msvcrt, added in msvcr80 */
 MSVCRT_invalid_parameter_handler CDECL _set_invalid_parameter_handler(
         MSVCRT_invalid_parameter_handler handler)
 {
-    MSVCRT_invalid_parameter_handler old = MSVCRT_invalid_parameter;
+    MSVCRT_invalid_parameter_handler old = invalid_parameter_handler;
 
     TRACE("(%p)\n", handler);
 
-    MSVCRT_invalid_parameter = handler;
+    invalid_parameter_handler = handler;
     return old;
 }
diff --git a/dlls/msvcrt/msvcrt.h b/dlls/msvcrt/msvcrt.h
index 6c298d3..0318012 100644
--- a/dlls/msvcrt/msvcrt.h
+++ b/dlls/msvcrt/msvcrt.h
@@ -78,7 +78,7 @@ typedef void (*__cdecl MSVCRT__se_translator_function)(unsigned int code, struct
 typedef void (*__cdecl MSVCRT__beginthread_start_routine_t)(void *);
 typedef unsigned int (__stdcall *MSVCRT__beginthreadex_start_routine_t)(void *);
 typedef int (*__cdecl MSVCRT__onexit_t)(void);
-typedef void (__cdecl *MSVCRT_invalid_parameter_handler)(const wchar_t*, const wchar_t*, const wchar_t*, unsigned, unsigned*);
+typedef void (__cdecl *MSVCRT_invalid_parameter_handler)(const MSVCRT_wchar_t*, const MSVCRT_wchar_t*, const MSVCRT_wchar_t*, unsigned, MSVCRT_uintptr_t);
 
 typedef struct {long double x;} MSVCRT__LDOUBLE;
 
@@ -128,7 +128,6 @@ extern LCID MSVCRT_current_lc_all_lcid;
 extern WORD MSVCRT__ctype [257];
 extern WORD MSVCRT_current_ctype[257];
 extern WORD* MSVCRT__pctype;
-extern MSVCRT_invalid_parameter_handler MSVCRT_invalid_parameter;
 
 void   msvcrt_set_errno(int);
 
@@ -825,6 +824,8 @@ int     __cdecl MSVCRT__pipe(int *, unsigned int, int);
 MSVCRT_wchar_t* __cdecl _wgetenv(const MSVCRT_wchar_t*);
 void __cdecl    _wsearchenv(const MSVCRT_wchar_t*, const MSVCRT_wchar_t*, MSVCRT_wchar_t*);
 MSVCRT_intptr_t __cdecl MSVCRT__spawnvpe(int, const char*, const char* const*, const char* const*);
+void __cdecl MSVCRT__invalid_parameter(const MSVCRT_wchar_t *expr, const MSVCRT_wchar_t *func,
+                                       const MSVCRT_wchar_t *file, unsigned int line, MSVCRT_uintptr_t arg);
 #endif
 
 #endif /* __WINE_MSVCRT_H */
diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec
index 9af243f..d61e250 100644
--- a/dlls/msvcrt/msvcrt.spec
+++ b/dlls/msvcrt/msvcrt.spec
@@ -479,7 +479,7 @@
 @ stub _inp #(long) -i386
 @ stub _inpd #(long) -i386
 @ stub _inpw #(long) -i386
-@ stub _invalid_parameter
+@ cdecl _invalid_parameter(wstr wstr wstr long long) MSVCRT__invalid_parameter
 @ extern _iob MSVCRT__iob
 # stub _isalnum_l
 # stub _isalpha_l
diff --git a/dlls/msvcrt/string.c b/dlls/msvcrt/string.c
index 5432a30..a241bab 100644
--- a/dlls/msvcrt/string.c
+++ b/dlls/msvcrt/string.c
@@ -341,7 +341,7 @@ __int64 CDECL MSVCRT_strtoi64_l(const char *nptr, char **endptr, int base, MSVCR
     TRACE("(%s %p %d %p)\n", nptr, endptr, base, locale);
 
     if(!nptr || base<0 || base>36 || base==1) {
-        MSVCRT_invalid_parameter(NULL, NULL, NULL, 0, NULL);
+        MSVCRT__invalid_parameter(NULL, NULL, NULL, 0, 0);
         return 0;
     }
 
@@ -421,7 +421,7 @@ unsigned __int64 CDECL MSVCRT_strtoui64_l(const char *nptr, char **endptr, int b
     TRACE("(%s %p %d %p)\n", nptr, endptr, base, locale);
 
     if(!nptr || base<0 || base>36 || base==1) {
-        MSVCRT_invalid_parameter(NULL, NULL, NULL, 0, NULL);
+        MSVCRT__invalid_parameter(NULL, NULL, NULL, 0, 0);
         return 0;
     }
 
diff --git a/include/msvcrt/stdlib.h b/include/msvcrt/stdlib.h
index 617bd1c..6633ee9 100644
--- a/include/msvcrt/stdlib.h
+++ b/include/msvcrt/stdlib.h
@@ -218,6 +218,12 @@ __msvcrt_ulong __cdecl wcstoul(const wchar_t*,wchar_t**,int);
 int           __cdecl wctomb(char*,wchar_t);
 #endif /* _WSTDLIB_DEFINED */
 
+typedef void (__cdecl *_invalid_parameter_handler)(const wchar_t*, const wchar_t*, const wchar_t*, unsigned, uintptr_t);
+_invalid_parameter_handler __cdecl _set_invalid_parameter_handler(_invalid_parameter_handler);
+_invalid_parameter_handler __cdecl _get_invalid_parameter_handler(void);
+void __cdecl _invalid_parameter(const wchar_t *expr, const wchar_t *func, const wchar_t *file,
+                                unsigned int line, uintptr_t arg);
+
 #ifdef __cplusplus
 }
 #endif
@@ -261,8 +267,4 @@ static inline ldiv_t __wine_msvcrt_ldiv(__msvcrt_long num, __msvcrt_long denom)
 
 #include <poppack.h>
 
-typedef void (__cdecl *_invalid_parameter_handler)(const wchar_t*, const wchar_t*, const wchar_t*, unsigned, unsigned*);
-_invalid_parameter_handler __cdecl _set_invalid_parameter_handler(_invalid_parameter_handler);
-_invalid_parameter_handler __cdecl _get_invalid_parameter_handler(void);
-
 #endif /* __WINE_STDLIB_H */




More information about the wine-cvs mailing list