mirror of
https://gitlab.winehq.org/wine/wine.git
synced 2024-11-21 17:09:06 -07:00
kernelbase: Factor out get_key_name().
This commit is contained in:
parent
0a98b57783
commit
d01eb50114
1 changed files with 19 additions and 12 deletions
|
@ -112,20 +112,15 @@ static BOOL is_classes_root( const UNICODE_STRING *name )
|
|||
return (len >= classes_root_len - 1 && !wcsnicmp( name->Buffer, classes_root, min( len, classes_root_len ) ));
|
||||
}
|
||||
|
||||
static BOOL is_classes_wow6432node( HKEY key )
|
||||
static KEY_NAME_INFORMATION *get_key_name( HKEY key, char *buffer, DWORD len )
|
||||
{
|
||||
char buffer[256], *buf_ptr = buffer;
|
||||
char *buf_ptr = buffer;
|
||||
KEY_NAME_INFORMATION *info = (KEY_NAME_INFORMATION *)buffer;
|
||||
DWORD len = sizeof(buffer);
|
||||
UNICODE_STRING name;
|
||||
NTSTATUS status;
|
||||
BOOL ret = FALSE;
|
||||
|
||||
/* Obtain the name of the root key */
|
||||
status = NtQueryKey( key, KeyNameInformation, info, len, &len );
|
||||
if (status && status != STATUS_BUFFER_OVERFLOW) return FALSE;
|
||||
status = NtQueryKey( key, KeyNameInformation, buf_ptr, len, &len );
|
||||
if (status && status != STATUS_BUFFER_OVERFLOW) return NULL;
|
||||
|
||||
/* Retry with a dynamically allocated buffer */
|
||||
while (status == STATUS_BUFFER_OVERFLOW)
|
||||
{
|
||||
if (buf_ptr != buffer) heap_free( buf_ptr );
|
||||
|
@ -133,9 +128,22 @@ static BOOL is_classes_wow6432node( HKEY key )
|
|||
info = (KEY_NAME_INFORMATION *)buf_ptr;
|
||||
status = NtQueryKey( key, KeyNameInformation, info, len, &len );
|
||||
}
|
||||
if (!status) return (KEY_NAME_INFORMATION *)buf_ptr;
|
||||
if (buf_ptr != buffer) heap_free( buf_ptr );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static BOOL is_classes_wow6432node( HKEY key )
|
||||
{
|
||||
KEY_NAME_INFORMATION *info;
|
||||
char buffer[256];
|
||||
UNICODE_STRING name;
|
||||
BOOL ret = FALSE;
|
||||
|
||||
if (!(info = get_key_name( key, buffer, sizeof(buffer) ))) return FALSE;
|
||||
|
||||
/* Check if the key ends in Wow6432Node and if the root is the Classes key*/
|
||||
if (!status && info->NameLength / sizeof(WCHAR) >= 11)
|
||||
if (info->NameLength / sizeof(WCHAR) >= 11)
|
||||
{
|
||||
name.Buffer = info->Name + info->NameLength / sizeof(WCHAR) - 11;
|
||||
name.Length = 11 * sizeof(WCHAR);
|
||||
|
@ -146,8 +154,7 @@ static BOOL is_classes_wow6432node( HKEY key )
|
|||
ret = is_classes_root( &name );
|
||||
}
|
||||
}
|
||||
|
||||
if (buf_ptr != buffer) heap_free( buf_ptr );
|
||||
if ((char *)info != buffer) heap_free( info );
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue