ntdll: Increase the buffer size dynamically for relay debug lists.

This commit is contained in:
Alexandre Julliard 2007-12-20 16:59:07 +01:00
parent 7593fac632
commit 2835dc9fc9
1 changed files with 41 additions and 59 deletions

View File

@ -27,6 +27,8 @@
#include <stdarg.h>
#include <stdio.h>
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "windef.h"
#include "winternl.h"
#include "wine/exception.h"
@ -133,6 +135,37 @@ static const WCHAR **build_list( const WCHAR *buffer )
return ret;
}
/***********************************************************************
* load_list_value
*
* Load a function list from a registry value.
*/
static const WCHAR **load_list( HKEY hkey, const WCHAR *value )
{
char initial_buffer[4096];
char *buffer = initial_buffer;
DWORD count;
NTSTATUS status;
UNICODE_STRING name;
const WCHAR **list = NULL;
RtlInitUnicodeString( &name, value );
status = NtQueryValueKey( hkey, &name, KeyValuePartialInformation, buffer, sizeof(buffer), &count );
if (status == STATUS_BUFFER_OVERFLOW)
{
buffer = RtlAllocateHeap( GetProcessHeap(), 0, count );
status = NtQueryValueKey( hkey, &name, KeyValuePartialInformation, buffer, count, &count );
}
if (status == STATUS_SUCCESS)
{
WCHAR *str = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)buffer)->Data;
list = build_list( str );
if (list) TRACE( "%s = %s\n", debugstr_w(value), debugstr_w(str) );
}
if (buffer != initial_buffer) RtlFreeHeap( GetProcessHeap(), 0, buffer );
return list;
}
/***********************************************************************
* init_debug_lists
@ -143,10 +176,7 @@ static void init_debug_lists(void)
{
OBJECT_ATTRIBUTES attr;
UNICODE_STRING name;
char buffer[1024];
HANDLE root, hkey;
DWORD count;
WCHAR *str;
static const WCHAR configW[] = {'S','o','f','t','w','a','r','e','\\',
'W','i','n','e','\\',
'D','e','b','u','g',0};
@ -176,62 +206,14 @@ static void init_debug_lists(void)
NtClose( root );
if (!hkey) return;
str = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)buffer)->Data;
RtlInitUnicodeString( &name, RelayIncludeW );
if (!NtQueryValueKey( hkey, &name, KeyValuePartialInformation, buffer, sizeof(buffer), &count ))
{
TRACE("RelayInclude = %s\n", debugstr_w(str) );
debug_relay_includelist = build_list( str );
}
RtlInitUnicodeString( &name, RelayExcludeW );
if (!NtQueryValueKey( hkey, &name, KeyValuePartialInformation, buffer, sizeof(buffer), &count ))
{
TRACE( "RelayExclude = %s\n", debugstr_w(str) );
debug_relay_excludelist = build_list( str );
}
RtlInitUnicodeString( &name, SnoopIncludeW );
if (!NtQueryValueKey( hkey, &name, KeyValuePartialInformation, buffer, sizeof(buffer), &count ))
{
TRACE_(snoop)( "SnoopInclude = %s\n", debugstr_w(str) );
debug_snoop_includelist = build_list( str );
}
RtlInitUnicodeString( &name, SnoopExcludeW );
if (!NtQueryValueKey( hkey, &name, KeyValuePartialInformation, buffer, sizeof(buffer), &count ))
{
TRACE_(snoop)( "SnoopExclude = %s\n", debugstr_w(str) );
debug_snoop_excludelist = build_list( str );
}
RtlInitUnicodeString( &name, RelayFromIncludeW );
if (!NtQueryValueKey( hkey, &name, KeyValuePartialInformation, buffer, sizeof(buffer), &count ))
{
TRACE("RelayFromInclude = %s\n", debugstr_w(str) );
debug_from_relay_includelist = build_list( str );
}
RtlInitUnicodeString( &name, RelayFromExcludeW );
if (!NtQueryValueKey( hkey, &name, KeyValuePartialInformation, buffer, sizeof(buffer), &count ))
{
TRACE( "RelayFromExclude = %s\n", debugstr_w(str) );
debug_from_relay_excludelist = build_list( str );
}
RtlInitUnicodeString( &name, SnoopFromIncludeW );
if (!NtQueryValueKey( hkey, &name, KeyValuePartialInformation, buffer, sizeof(buffer), &count ))
{
TRACE_(snoop)("SnoopFromInclude = %s\n", debugstr_w(str) );
debug_from_snoop_includelist = build_list( str );
}
RtlInitUnicodeString( &name, SnoopFromExcludeW );
if (!NtQueryValueKey( hkey, &name, KeyValuePartialInformation, buffer, sizeof(buffer), &count ))
{
TRACE_(snoop)( "SnoopFromExclude = %s\n", debugstr_w(str) );
debug_from_snoop_excludelist = build_list( str );
}
debug_relay_includelist = load_list( hkey, RelayIncludeW );
debug_relay_excludelist = load_list( hkey, RelayExcludeW );
debug_snoop_includelist = load_list( hkey, SnoopIncludeW );
debug_snoop_excludelist = load_list( hkey, SnoopExcludeW );
debug_from_relay_includelist = load_list( hkey, RelayFromIncludeW );
debug_from_relay_excludelist = load_list( hkey, RelayFromExcludeW );
debug_from_snoop_includelist = load_list( hkey, SnoopFromIncludeW );
debug_from_snoop_excludelist = load_list( hkey, SnoopFromExcludeW );
NtClose( hkey );
}