Alexandre Julliard : ntdll: Define IsBadStringPtr to handle exceptions in debug traces.
Alexandre Julliard
julliard at winehq.org
Thu Apr 4 15:38:07 CDT 2019
Module: wine
Branch: master
Commit: bb83b68832553ed74f47c07a90ace0ed68d4e04f
URL: https://source.winehq.org/git/wine.git/?a=commit;h=bb83b68832553ed74f47c07a90ace0ed68d4e04f
Author: Alexandre Julliard <julliard at winehq.org>
Date: Thu Apr 4 09:39:14 2019 +0200
ntdll: Define IsBadStringPtr to handle exceptions in debug traces.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ntdll/exception.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
include/wine/debug.h | 6 ------
2 files changed, 44 insertions(+), 6 deletions(-)
diff --git a/dlls/ntdll/exception.c b/dlls/ntdll/exception.c
index 59177b7..8286c9d 100644
--- a/dlls/ntdll/exception.c
+++ b/dlls/ntdll/exception.c
@@ -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;
+}
diff --git a/include/wine/debug.h b/include/wine/debug.h
index c7eb185..bb72827 100644
--- a/include/wine/debug.h
+++ b/include/wine/debug.h
@@ -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++ = '"';
More information about the wine-cvs
mailing list