Use of _set_invalid_parameter_handler() RRS feed

  • Question

  • I have found code like:

    wchar_t formattedMessageText[MAX_PRINT_TEXT_SIZE];
    vswprintf_s(formattedMessageText, MAX_PRINT_TEXT_SIZE, format, arglist);

    Causes a Prefetch Abort if the formatted text exceeded the buffer size so  I have installed an invalid parameter handler with the following code:

    void __cdecl invalidParameterHandler(const wchar_t* expression,
       const wchar_t* function, 
       const wchar_t* file, 
       unsigned int line, 
       uintptr_t pReserved)
    	wprintf(L"Invalid parameter detected in function %s. File: %s Line: %d Expression %s\n", function, file, line, expression);

    However although I reach my invalid parameter handler all of the parameters are null. This is an improvement over the Prefetch Abort but I would prefer to display some useful information.

    Any ideas?

    Wednesday, May 13, 2015 7:56 AM