Commit 4f3b7f84 authored by Alexandre Julliard's avatar Alexandre Julliard

msvcrt: Implement _invalid_parameter and fix the handler definitions.

parent a1e99f54
......@@ -42,7 +42,7 @@
@ stub ?_ValidateWrite@@YAHPAXI@Z
@ cdecl __uncaught_exception() msvcrt.__uncaught_exception
@ stub ?_inconsistency@@YAXXZ
@ stub ?_invalid_parameter@@YAXPBG00II@Z
@ cdecl ?_invalid_parameter@@YAXPBG00II@Z(wstr wstr wstr long long) msvcrt._invalid_parameter
@ stub ?_is_exception_typeof@@YAHABVtype_info@@PAU_EXCEPTION_POINTERS@@@Z
@ stub ?_name_internal_method@type_info@@QBEPBDPAU__type_info_node@@@Z
@ varargs ?_open@@YAHPBDHH@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
......
......@@ -42,7 +42,7 @@
@ stub ?_ValidateWrite@@YAHPAXI@Z
@ cdecl __uncaught_exception() msvcrt.__uncaught_exception
@ stub ?_inconsistency@@YAXXZ
@ stub ?_invalid_parameter@@YAXPBG00II@Z
@ cdecl ?_invalid_parameter@@YAXPBG00II@Z(wstr wstr wstr long long) msvcrt._invalid_parameter
@ stub ?_is_exception_typeof@@YAHABVtype_info@@PAU_EXCEPTION_POINTERS@@@Z
@ stub ?_name_internal_method@type_info@@QBEPBDPAU__type_info_node@@@Z
@ varargs ?_open@@YAHPBDHH@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
......
......@@ -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)
......
......@@ -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;
}
......@@ -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 */
......@@ -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
......
......@@ -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;
}
......
......@@ -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 */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment