Commit bb83b688 authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Define IsBadStringPtr to handle exceptions in debug traces.

parent a3cf86a1
......@@ -346,3 +346,47 @@ void __wine_spec_unimplemented_stub( const char *module, const char *function )
record.ExceptionInformation[1] = (ULONG_PTR)function;
for (;;) RtlRaiseException( &record );
}
/*************************************************************
* IsBadStringPtrA
*
* IsBadStringPtrA replacement for ntdll, to catch exception in debug traces.
*/
BOOL WINAPI IsBadStringPtrA( LPCSTR str, UINT_PTR max )
{
if (!str) return TRUE;
__TRY
{
volatile const char *p = str;
while (p != str + max) if (!*p++) break;
}
__EXCEPT_PAGE_FAULT
{
return TRUE;
}
__ENDTRY
return FALSE;
}
/*************************************************************
* IsBadStringPtrW
*
* IsBadStringPtrW replacement for ntdll, to catch exception in debug traces.
*/
BOOL WINAPI IsBadStringPtrW( LPCWSTR str, UINT_PTR max )
{
if (!str) return TRUE;
__TRY
{
volatile const WCHAR *p = str;
while (p != str + max) if (!*p++) break;
}
__EXCEPT_PAGE_FAULT
{
return TRUE;
}
__ENDTRY
return FALSE;
}
......@@ -24,9 +24,7 @@
#include <stdarg.h>
#include <stdio.h>
#include <windef.h>
#ifndef _NTSYSTEM_
#include <winbase.h>
#endif
#ifndef GUID_DEFINED
#include <guiddef.h>
#endif
......@@ -227,9 +225,7 @@ static inline const char *wine_dbgstr_an( const char *str, int n )
if (!str) return "(null)";
if (!((ULONG_PTR)str >> 16)) return wine_dbg_sprintf( "#%04x", LOWORD(str) );
#ifndef _NTSYSTEM_
if (IsBadStringPtrA( str, n )) return "(invalid)";
#endif
if (n == -1) for (n = 0; str[n]; n++) ;
*dst++ = '"';
while (n-- > 0 && dst <= buffer + sizeof(buffer) - 9)
......@@ -271,9 +267,7 @@ static inline const char *wine_dbgstr_wn( const WCHAR *str, int n )
if (!str) return "(null)";
if (!((ULONG_PTR)str >> 16)) return wine_dbg_sprintf( "#%04x", LOWORD(str) );
#ifndef _NTSYSTEM_
if (IsBadStringPtrW( str, n )) return "(invalid)";
#endif
if (n == -1) for (n = 0; str[n]; n++) ;
*dst++ = 'L';
*dst++ = '"';
......
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