Module: wine Branch: master Commit: 1e5eee0fc318459d7ef071998e8ed05f2530d2c3 URL: https://source.winehq.org/git/wine.git/?a=commit;h=1e5eee0fc318459d7ef071998...
Author: Alexandre Julliard julliard@winehq.org Date: Mon May 24 21:35:12 2021 +0200
ntdll: Fetch the debug channels from the PEB memory block on the PE side.
Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/ntdll/thread.c | 30 +++++++++++++++++++++++++++++- dlls/ntdll/unix/loader.c | 1 - dlls/ntdll/unixlib.h | 3 +-- 3 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c index a95880ca4bd..bcf010724c4 100644 --- a/dlls/ntdll/thread.c +++ b/dlls/ntdll/thread.c @@ -37,6 +37,16 @@ WINE_DECLARE_DEBUG_CHANNEL(thread);
struct _KUSER_SHARED_DATA *user_shared_data = (void *)0x7ffe0000;
+static int nb_debug_options; +static struct __wine_debug_channel *debug_options; + +static void init_options(void) +{ + unsigned int offset = page_size * (sizeof(void *) / 4); + + debug_options = (struct __wine_debug_channel *)((char *)NtCurrentTeb()->Peb + offset); + while (debug_options[nb_debug_options].name[0]) nb_debug_options++; +}
/*********************************************************************** * __wine_dbg_get_channel_flags (NTDLL.@) @@ -45,7 +55,25 @@ struct _KUSER_SHARED_DATA *user_shared_data = (void *)0x7ffe0000; */ unsigned char __cdecl __wine_dbg_get_channel_flags( struct __wine_debug_channel *channel ) { - return unix_funcs->dbg_get_channel_flags( channel ); + int min, max, pos, res; + unsigned char default_flags; + + if (!debug_options) init_options(); + + min = 0; + max = nb_debug_options - 1; + while (min <= max) + { + pos = (min + max) / 2; + res = strcmp( channel->name, debug_options[pos].name ); + if (!res) return debug_options[pos].flags; + if (res < 0) max = pos - 1; + else min = pos + 1; + } + /* no option for this channel */ + default_flags = debug_options[nb_debug_options].flags; + if (channel->flags & (1 << __WINE_DBCL_INIT)) channel->flags = default_flags; + return default_flags; }
/*********************************************************************** diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index 1b79b71b252..ff49cd5f26b 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -1840,7 +1840,6 @@ static struct unix_funcs unix_funcs = init_builtin_dll, init_unix_lib, unwind_builtin_dll, - __wine_dbg_get_channel_flags, __wine_dbg_strdup, __wine_dbg_output, __wine_dbg_header, diff --git a/dlls/ntdll/unixlib.h b/dlls/ntdll/unixlib.h index 04ae8230b1a..d0f2f4ed508 100644 --- a/dlls/ntdll/unixlib.h +++ b/dlls/ntdll/unixlib.h @@ -26,7 +26,7 @@ struct _DISPATCHER_CONTEXT;
/* increment this when you change the function table */ -#define NTDLL_UNIXLIB_VERSION 120 +#define NTDLL_UNIXLIB_VERSION 121
struct unix_funcs { @@ -80,7 +80,6 @@ struct unix_funcs CONTEXT *context );
/* debugging functions */ - unsigned char (CDECL *dbg_get_channel_flags)( struct __wine_debug_channel *channel ); const char * (CDECL *dbg_strdup)( const char *str ); int (CDECL *dbg_output)( const char *str ); int (CDECL *dbg_header)( enum __wine_debug_class cls, struct __wine_debug_channel *channel,