1 /*
2  * PROJECT:     ReactOS CRT library
3  * LICENSE:     MIT (https://spdx.org/licenses/MIT)
4  * PURPOSE:     _invalid_parameter implementation
5  * COPYRIGHT:   Timo Kreuzer <timo.kreuzer@reactos.org>
6  */
7 
8 #include <precomp.h>
9 
10 #ifdef _MSVCRTEX_
11 #undef TRACE
12 #undef ERR
13 #define TRACE(...)
14 #define ERR(...)
15 #endif
16 
17 static _invalid_parameter_handler invalid_parameter_handler = NULL;
18 
19 /******************************************************************************
20  *		_invalid_parameter (MSVCRT.@)
21  */
22 void __cdecl _invalid_parameter(const wchar_t *expr, const wchar_t *func,
23                                 const wchar_t *file, unsigned int line, uintptr_t arg)
24 {
25     if (invalid_parameter_handler) invalid_parameter_handler( expr, func, file, line, arg );
26     else
27     {
28         ERR( "%s:%u %s: %s %lx\n", debugstr_w(file), line, debugstr_w(func), debugstr_w(expr), arg );
29 #if _MSVCR_VER > 0 // FIXME: possible improvement: use a global variable in the DLL
30         RaiseException( STATUS_INVALID_CRUNTIME_PARAMETER, EXCEPTION_NONCONTINUABLE, 0, NULL );
31 #endif
32     }
33 }
34 
35 /* _get_invalid_parameter_handler - not exported in native msvcrt, added in msvcr80 */
36 _invalid_parameter_handler CDECL _get_invalid_parameter_handler(void)
37 {
38     TRACE("\n");
39     return invalid_parameter_handler;
40 }
41 
42 /* _set_invalid_parameter_handler - not exproted in native msvcrt, added in msvcr80 */
43 _invalid_parameter_handler CDECL _set_invalid_parameter_handler(
44         _invalid_parameter_handler handler)
45 {
46     _invalid_parameter_handler old = invalid_parameter_handler;
47 
48     TRACE("(%p)\n", handler);
49 
50     invalid_parameter_handler = handler;
51     return old;
52 }
53