Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
c5129d6f
Commit
c5129d6f
authored
Nov 19, 2020
by
Rémi Bernon
Committed by
Alexandre Julliard
Nov 20, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Reimplement DbgPrint* using DBG_PRINTEXCEPTION_C.
Signed-off-by:
Rémi Bernon
<
rbernon@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
1425363b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
24 deletions
+46
-24
rtl.c
dlls/ntdll/rtl.c
+39
-17
rtl.c
dlls/ntdll/tests/rtl.c
+7
-7
No files found.
dlls/ntdll/rtl.c
View file @
c5129d6f
...
@@ -39,6 +39,7 @@
...
@@ -39,6 +39,7 @@
#include "ddk/ntddk.h"
#include "ddk/ntddk.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
ntdll
);
WINE_DEFAULT_DEBUG_CHANNEL
(
ntdll
);
WINE_DECLARE_DEBUG_CHANNEL
(
debugstr
);
/* CRC polynomial 0xedb88320 */
/* CRC polynomial 0xedb88320 */
static
const
DWORD
CRC_table
[
256
]
=
static
const
DWORD
CRC_table
[
256
]
=
...
@@ -297,21 +298,24 @@ void WINAPI RtlDumpResource(LPRTL_RWLOCK rwl)
...
@@ -297,21 +298,24 @@ void WINAPI RtlDumpResource(LPRTL_RWLOCK rwl)
* misc functions
* misc functions
*/
*/
static
LONG
WINAPI
debug_exception_handler
(
EXCEPTION_POINTERS
*
eptr
)
{
EXCEPTION_RECORD
*
rec
=
eptr
->
ExceptionRecord
;
return
(
rec
->
ExceptionCode
==
DBG_PRINTEXCEPTION_C
)
?
EXCEPTION_EXECUTE_HANDLER
:
EXCEPTION_CONTINUE_SEARCH
;
}
/******************************************************************************
/******************************************************************************
* DbgPrint [NTDLL.@]
* DbgPrint [NTDLL.@]
*/
*/
NTSTATUS
WINAPIV
DbgPrint
(
LPCSTR
fmt
,
...)
NTSTATUS
WINAPIV
DbgPrint
(
LPCSTR
fmt
,
...)
{
{
char
buf
[
512
];
NTSTATUS
ret
;
__ms_va_list
args
;
__ms_va_list
args
;
__ms_va_start
(
args
,
fmt
);
_vsnprintf
(
buf
,
sizeof
(
buf
),
fmt
,
args
);
__ms_va_end
(
args
);
MESSAGE
(
"DbgPrint says: %s"
,
buf
);
__ms_va_start
(
args
,
fmt
);
/* hmm, raise exception? */
ret
=
vDbgPrintEx
(
0
,
DPFLTR_ERROR_LEVEL
,
fmt
,
args
);
return
STATUS_SUCCESS
;
__ms_va_end
(
args
);
return
ret
;
}
}
...
@@ -342,18 +346,36 @@ NTSTATUS WINAPI vDbgPrintEx( ULONG id, ULONG level, LPCSTR fmt, __ms_va_list arg
...
@@ -342,18 +346,36 @@ NTSTATUS WINAPI vDbgPrintEx( ULONG id, ULONG level, LPCSTR fmt, __ms_va_list arg
*/
*/
NTSTATUS
WINAPI
vDbgPrintExWithPrefix
(
LPCSTR
prefix
,
ULONG
id
,
ULONG
level
,
LPCSTR
fmt
,
__ms_va_list
args
)
NTSTATUS
WINAPI
vDbgPrintExWithPrefix
(
LPCSTR
prefix
,
ULONG
id
,
ULONG
level
,
LPCSTR
fmt
,
__ms_va_list
args
)
{
{
char
buf
[
1024
];
ULONG
level_mask
=
level
<=
31
?
(
1
<<
level
)
:
level
;
SIZE_T
len
=
strlen
(
prefix
);
char
buf
[
1024
],
*
end
;
_vsnprintf
(
buf
,
sizeof
(
buf
),
fmt
,
args
);
strcpy
(
buf
,
prefix
);
len
+=
_vsnprintf
(
buf
+
len
,
sizeof
(
buf
)
-
len
,
fmt
,
args
);
end
=
buf
+
len
-
1
;
switch
(
level
&
DPFLTR_MASK
)
WARN_
(
debugstr
)(
*
end
==
'\n'
?
"%08x:%08x: %s"
:
"%08x:%08x: %s
\n
"
,
id
,
level_mask
,
buf
);
if
(
level_mask
&
(
1
<<
DPFLTR_ERROR_LEVEL
)
&&
NtCurrentTeb
()
->
Peb
->
BeingDebugged
)
{
{
case
DPFLTR_ERROR_LEVEL
:
ERR
(
"%s%x: %s"
,
prefix
,
id
,
buf
);
break
;
__TRY
case
DPFLTR_WARNING_LEVEL
:
WARN
(
"%s%x: %s"
,
prefix
,
id
,
buf
);
break
;
{
case
DPFLTR_TRACE_LEVEL
:
EXCEPTION_RECORD
record
;
case
DPFLTR_INFO_LEVEL
:
record
.
ExceptionCode
=
DBG_PRINTEXCEPTION_C
;
default:
TRACE
(
"%s%x: %s"
,
prefix
,
id
,
buf
);
break
;
record
.
ExceptionFlags
=
0
;
record
.
ExceptionRecord
=
NULL
;
record
.
ExceptionAddress
=
RtlRaiseException
;
record
.
NumberParameters
=
2
;
record
.
ExceptionInformation
[
1
]
=
(
ULONG_PTR
)
buf
;
record
.
ExceptionInformation
[
0
]
=
strlen
(
buf
)
+
1
;
RtlRaiseException
(
&
record
);
}
__EXCEPT
(
debug_exception_handler
)
{
}
__ENDTRY
}
}
return
STATUS_SUCCESS
;
return
STATUS_SUCCESS
;
}
}
...
...
dlls/ntdll/tests/rtl.c
View file @
c5129d6f
...
@@ -3541,19 +3541,19 @@ static void test_DbgPrint(void)
...
@@ -3541,19 +3541,19 @@ static void test_DbgPrint(void)
test_dbg_print_except_ret
=
(
LONG
)
EXCEPTION_EXECUTE_HANDLER
;
test_dbg_print_except_ret
=
(
LONG
)
EXCEPTION_EXECUTE_HANDLER
;
status
=
DbgPrint
(
"test_DbgPrint: %s"
,
"Hello World"
);
status
=
DbgPrint
(
"test_DbgPrint: %s"
,
"Hello World"
);
ok
(
!
status
,
"DbgPrint returned %x
\n
"
,
status
);
ok
(
!
status
,
"DbgPrint returned %x
\n
"
,
status
);
todo_wine
ok
(
test_dbg_print_except
,
"DBG_PRINTEXCEPTION_C not received
\n
"
);
ok
(
test_dbg_print_except
,
"DBG_PRINTEXCEPTION_C not received
\n
"
);
test_dbg_print_except
=
FALSE
;
test_dbg_print_except
=
FALSE
;
test_dbg_print_except_ret
=
(
LONG
)
EXCEPTION_CONTINUE_EXECUTION
;
test_dbg_print_except_ret
=
(
LONG
)
EXCEPTION_CONTINUE_EXECUTION
;
status
=
DbgPrint
(
"test_DbgPrint: %s"
,
"Hello World"
);
status
=
DbgPrint
(
"test_DbgPrint: %s"
,
"Hello World"
);
ok
(
!
status
,
"DbgPrint returned %x
\n
"
,
status
);
ok
(
!
status
,
"DbgPrint returned %x
\n
"
,
status
);
todo_wine
ok
(
test_dbg_print_except
,
"DBG_PRINTEXCEPTION_C not received
\n
"
);
ok
(
test_dbg_print_except
,
"DBG_PRINTEXCEPTION_C not received
\n
"
);
test_dbg_print_except
=
FALSE
;
test_dbg_print_except
=
FALSE
;
test_dbg_print_except_ret
=
(
LONG
)
EXCEPTION_CONTINUE_SEARCH
;
test_dbg_print_except_ret
=
(
LONG
)
EXCEPTION_CONTINUE_SEARCH
;
status
=
DbgPrint
(
"test_DbgPrint: %s"
,
"Hello World"
);
status
=
DbgPrint
(
"test_DbgPrint: %s"
,
"Hello World"
);
ok
(
!
status
,
"DbgPrint returned %x
\n
"
,
status
);
ok
(
!
status
,
"DbgPrint returned %x
\n
"
,
status
);
todo_wine
ok
(
test_dbg_print_except
,
"DBG_PRINTEXCEPTION_C not received
\n
"
);
ok
(
test_dbg_print_except
,
"DBG_PRINTEXCEPTION_C not received
\n
"
);
/* FIXME: NtSetDebugFilterState / DbgSetDebugFilterState are probably what's controlling these */
/* FIXME: NtSetDebugFilterState / DbgSetDebugFilterState are probably what's controlling these */
...
@@ -3562,7 +3562,7 @@ static void test_DbgPrint(void)
...
@@ -3562,7 +3562,7 @@ static void test_DbgPrint(void)
test_dbg_print_except_ret
=
(
LONG
)
EXCEPTION_EXECUTE_HANDLER
;
test_dbg_print_except_ret
=
(
LONG
)
EXCEPTION_EXECUTE_HANDLER
;
status
=
DbgPrintEx
(
0
,
DPFLTR_ERROR_LEVEL
,
"test_DbgPrint: %s"
,
"Hello World"
);
status
=
DbgPrintEx
(
0
,
DPFLTR_ERROR_LEVEL
,
"test_DbgPrint: %s"
,
"Hello World"
);
ok
(
!
status
,
"DbgPrintEx returned %x
\n
"
,
status
);
ok
(
!
status
,
"DbgPrintEx returned %x
\n
"
,
status
);
todo_wine
ok
(
test_dbg_print_except
,
"DBG_PRINTEXCEPTION_C not received
\n
"
);
ok
(
test_dbg_print_except
,
"DBG_PRINTEXCEPTION_C not received
\n
"
);
test_dbg_print_except
=
FALSE
;
test_dbg_print_except
=
FALSE
;
test_dbg_print_except_ret
=
(
LONG
)
EXCEPTION_EXECUTE_HANDLER
;
test_dbg_print_except_ret
=
(
LONG
)
EXCEPTION_EXECUTE_HANDLER
;
...
@@ -3574,7 +3574,7 @@ static void test_DbgPrint(void)
...
@@ -3574,7 +3574,7 @@ static void test_DbgPrint(void)
test_dbg_print_except_ret
=
(
LONG
)
EXCEPTION_EXECUTE_HANDLER
;
test_dbg_print_except_ret
=
(
LONG
)
EXCEPTION_EXECUTE_HANDLER
;
status
=
DbgPrintEx
(
0
,
DPFLTR_MASK
|
(
1
<<
DPFLTR_ERROR_LEVEL
),
"test_DbgPrint: %s"
,
"Hello World"
);
status
=
DbgPrintEx
(
0
,
DPFLTR_MASK
|
(
1
<<
DPFLTR_ERROR_LEVEL
),
"test_DbgPrint: %s"
,
"Hello World"
);
ok
(
!
status
,
"DbgPrintEx returned %x
\n
"
,
status
);
ok
(
!
status
,
"DbgPrintEx returned %x
\n
"
,
status
);
todo_wine
ok
(
test_dbg_print_except
,
"DBG_PRINTEXCEPTION_C not received
\n
"
);
ok
(
test_dbg_print_except
,
"DBG_PRINTEXCEPTION_C not received
\n
"
);
test_dbg_print_except
=
FALSE
;
test_dbg_print_except
=
FALSE
;
test_dbg_print_except_ret
=
(
LONG
)
EXCEPTION_EXECUTE_HANDLER
;
test_dbg_print_except_ret
=
(
LONG
)
EXCEPTION_EXECUTE_HANDLER
;
...
@@ -3587,13 +3587,13 @@ static void test_DbgPrint(void)
...
@@ -3587,13 +3587,13 @@ static void test_DbgPrint(void)
test_dbg_print_except_ret
=
(
LONG
)
EXCEPTION_EXECUTE_HANDLER
;
test_dbg_print_except_ret
=
(
LONG
)
EXCEPTION_EXECUTE_HANDLER
;
status
=
test_vDbgPrintEx
(
0
,
0xFFFFFFFF
,
"test_DbgPrint: %s"
,
"Hello World"
);
status
=
test_vDbgPrintEx
(
0
,
0xFFFFFFFF
,
"test_DbgPrint: %s"
,
"Hello World"
);
ok
(
!
status
,
"vDbgPrintEx returned %x
\n
"
,
status
);
ok
(
!
status
,
"vDbgPrintEx returned %x
\n
"
,
status
);
todo_wine
ok
(
test_dbg_print_except
,
"DBG_PRINTEXCEPTION_C not received
\n
"
);
ok
(
test_dbg_print_except
,
"DBG_PRINTEXCEPTION_C not received
\n
"
);
test_dbg_print_except
=
FALSE
;
test_dbg_print_except
=
FALSE
;
test_dbg_print_except_ret
=
(
LONG
)
EXCEPTION_EXECUTE_HANDLER
;
test_dbg_print_except_ret
=
(
LONG
)
EXCEPTION_EXECUTE_HANDLER
;
status
=
test_vDbgPrintExWithPrefix
(
"test_"
,
0
,
0xFFFFFFFF
,
"DbgPrint: %s"
,
"Hello World"
);
status
=
test_vDbgPrintExWithPrefix
(
"test_"
,
0
,
0xFFFFFFFF
,
"DbgPrint: %s"
,
"Hello World"
);
ok
(
!
status
,
"vDbgPrintExWithPrefix returned %x
\n
"
,
status
);
ok
(
!
status
,
"vDbgPrintExWithPrefix returned %x
\n
"
,
status
);
todo_wine
ok
(
test_dbg_print_except
,
"DBG_PRINTEXCEPTION_C not received
\n
"
);
ok
(
test_dbg_print_except
,
"DBG_PRINTEXCEPTION_C not received
\n
"
);
Peb
->
BeingDebugged
=
debugged
;
Peb
->
BeingDebugged
=
debugged
;
RtlRemoveVectoredExceptionHandler
(
handler
);
RtlRemoveVectoredExceptionHandler
(
handler
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment