[WINESYNC] setupapi: Add support for creating registry symlinks from a .inf file.

wine commit id f6b3dba7a08a718f633804da508e4586ae72e6f5 by Alexandre Julliard <julliard@winehq.org>

SYNC NOTE: This is Wine-specific functionality, placed in __WINESRC__
REG_LINK is _NOT_ supported by (official) Windows INF AddReg section.
See the WDK ChkInf.pm tool (from Win2003 up to Win10), for example at:
https://github.com/skycipher/CNGProvider/blob/master/Windows%20Kits/10/Tools/x86/ChkInf/chkinf.pm#L3870
This commit is contained in:
winesync 2024-01-04 12:57:41 +01:00 committed by Hermès Bélusca-Maïto
parent 082862f673
commit e669113b13
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
2 changed files with 31 additions and 10 deletions

View file

@ -381,6 +381,9 @@ static BOOL do_reg_operation( HKEY hkey, const WCHAR *value, INFCONTEXT *context
{
if (!(str = HeapAlloc( GetProcessHeap(), 0, size * sizeof(WCHAR) ))) return FALSE;
SetupGetStringFieldW( context, 5, str, size, NULL );
#ifdef __WINESRC__
if (type == REG_LINK) size--; /* no terminating null for symlinks */
#endif
}
}
@ -476,6 +479,7 @@ static BOOL registry_callback( HINF hinf, PCWSTR field, void *arg )
for (; ok; ok = SetupFindNextLine( &context, &context ))
{
DWORD options = 0;
WCHAR buffer[MAX_INF_STRING_LENGTH];
INT flags;
@ -501,20 +505,37 @@ static BOOL registry_callback( HINF hinf, PCWSTR field, void *arg )
if (!flags) flags = FLG_ADDREG_DELREG_BIT;
else if (!(flags & FLG_ADDREG_DELREG_BIT)) continue; /* ignore this entry */
}
#ifdef __WINESRC__
/* Wine extension: magic support for symlinks */
if (flags >> 16 == REG_LINK) options = REG_OPTION_OPEN_LINK | REG_OPTION_CREATE_LINK;
#endif
if (info->delete || (flags & FLG_ADDREG_OVERWRITEONLY))
{
if (RegOpenKeyW( root_key, buffer, &hkey )) continue; /* ignore if it doesn't exist */
if (RegOpenKeyExW( root_key, buffer, options, MAXIMUM_ALLOWED, &hkey ))
continue; /* ignore if it doesn't exist */
}
#ifdef __REACTOS__
else if (RegCreateKeyExW( root_key, buffer, 0, NULL, 0, MAXIMUM_ALLOWED,
sd ? &security_attributes : NULL, &hkey, NULL ))
#else
else if (RegCreateKeyW( root_key, buffer, &hkey ))
#endif
else
{
ERR( "could not create key %p %s\n", root_key, debugstr_w(buffer) );
continue;
#ifdef __REACTOS__
DWORD res = RegCreateKeyExW( root_key, buffer, 0, NULL, options,
MAXIMUM_ALLOWED,
sd ? &security_attributes : NULL,
&hkey, NULL );
#else
DWORD res = RegCreateKeyExW( root_key, buffer, 0, NULL, options,
MAXIMUM_ALLOWED, NULL, &hkey, NULL );
#endif
#ifdef __WINESRC__
if (res == ERROR_ALREADY_EXISTS && (options & REG_OPTION_CREATE_LINK))
res = RegCreateKeyExW( root_key, buffer, 0, NULL, REG_OPTION_OPEN_LINK,
MAXIMUM_ALLOWED, NULL, &hkey, NULL );
#endif
if (res)
{
ERR( "could not create key %p %s\n", root_key, debugstr_w(buffer) );
continue;
}
}
TRACE( "key %p %s\n", root_key, debugstr_w(buffer) );

View file

@ -5,4 +5,4 @@ files:
dlls/setupapi/misc.c: dll/win32/setupapi/misc.c
dlls/setupapi/stubs.c: dll/win32/setupapi/stubs.c
tags:
wine: c7d4b0c69fb8de9a2344c7d9d4bcda6e3feef094
wine: f6b3dba7a08a718f633804da508e4586ae72e6f5