From 113a63d374336025d7a4eb5248525bdc3852ae1b Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Fri, 31 Jul 2015 05:59:32 +0200 Subject: [PATCH] Use alternative approach to create MachineGuid registry key during wineprefix startup. --- patches/patchinstall.sh | 60 +++++++++------ ...-drive-serial-number-during-prefix-.patch} | 0 .../definition | 1 - ...ot-Create-MachineGuid-registry-value.patch | 77 ------------------- ...a-dummy-context-to-force-creation-of.patch | 39 ++++++++++ patches/wintrust-MachineGuid/definition | 1 + 6 files changed, 78 insertions(+), 100 deletions(-) rename patches/{wineboot-MachineGuid/0002-wineboot-Assign-a-drive-serial-number-during-prefix-.patch => wineboot-DriveSerial/0001-wineboot-Assign-a-drive-serial-number-during-prefix-.patch} (100%) rename patches/{wineboot-MachineGuid => wineboot-DriveSerial}/definition (52%) delete mode 100644 patches/wineboot-MachineGuid/0001-wineboot-Create-MachineGuid-registry-value.patch create mode 100644 patches/wintrust-MachineGuid/0001-wintrust-Create-a-dummy-context-to-force-creation-of.patch create mode 100644 patches/wintrust-MachineGuid/definition diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index 0f11bded..82930520 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -246,8 +246,8 @@ patch_enable_all () enable_wiaservc_IEnumWIA_DEV_INFO="$1" enable_wine_inf_Performance="$1" enable_wine_inf_ProfileList_UserSID="$1" + enable_wineboot_DriveSerial="$1" enable_wineboot_HKEY_DYN_DATA="$1" - enable_wineboot_MachineGuid="$1" enable_wineboot_drivers_etc_Stubs="$1" enable_winecfg_Libraries="$1" enable_winecfg_Staging="$1" @@ -281,6 +281,7 @@ patch_enable_all () enable_winmm_Delay_Import_Depends="$1" enable_winscard_SCardListReaders="$1" enable_winsta_WinStationEnumerateW="$1" + enable_wintrust_MachineGuid="$1" enable_wpcap_Dynamic_Linking="$1" enable_ws2_32_APC_Performance="$1" enable_ws2_32_Connect_Time="$1" @@ -817,12 +818,12 @@ patch_enable () wine.inf-ProfileList_UserSID) enable_wine_inf_ProfileList_UserSID="$2" ;; + wineboot-DriveSerial) + enable_wineboot_DriveSerial="$2" + ;; wineboot-HKEY_DYN_DATA) enable_wineboot_HKEY_DYN_DATA="$2" ;; - wineboot-MachineGuid) - enable_wineboot_MachineGuid="$2" - ;; wineboot-drivers_etc_Stubs) enable_wineboot_drivers_etc_Stubs="$2" ;; @@ -922,6 +923,9 @@ patch_enable () winsta-WinStationEnumerateW) enable_winsta_WinStationEnumerateW="$2" ;; + wintrust-MachineGuid) + enable_wintrust_MachineGuid="$2" + ;; wpcap-Dynamic_Linking) enable_wpcap_Dynamic_Linking="$2" ;; @@ -4803,6 +4807,21 @@ if test "$enable_wine_inf_ProfileList_UserSID" -eq 1; then ) >> "$patchlist" fi +# Patchset wineboot-DriveSerial +# | +# | This patchset fixes the following Wine bugs: +# | * [#17823] Assign a drive serial number during prefix creation/update +# | +# | Modified files: +# | * programs/wineboot/wineboot.c +# | +if test "$enable_wineboot_DriveSerial" -eq 1; then + patch_apply wineboot-DriveSerial/0001-wineboot-Assign-a-drive-serial-number-during-prefix-.patch + ( + echo '+ { "Sebastian Lackner", "wineboot: Assign a drive serial number during prefix creation/update.", 1 },'; + ) >> "$patchlist" +fi + # Patchset wineboot-HKEY_DYN_DATA # | # | This patchset fixes the following Wine bugs: @@ -4818,24 +4837,6 @@ if test "$enable_wineboot_HKEY_DYN_DATA" -eq 1; then ) >> "$patchlist" fi -# Patchset wineboot-MachineGuid -# | -# | This patchset fixes the following Wine bugs: -# | * [#38508] Create HKLM\Software\Microsoft\Cryptography\MachineGuid registry key -# | * [#17823] Assign a drive serial number during prefix creation/update -# | -# | Modified files: -# | * programs/wineboot/Makefile.in, programs/wineboot/wineboot.c -# | -if test "$enable_wineboot_MachineGuid" -eq 1; then - patch_apply wineboot-MachineGuid/0001-wineboot-Create-MachineGuid-registry-value.patch - patch_apply wineboot-MachineGuid/0002-wineboot-Assign-a-drive-serial-number-during-prefix-.patch - ( - echo '+ { "Michael Müller", "wineboot: Create MachineGuid registry value.", 1 },'; - echo '+ { "Sebastian Lackner", "wineboot: Assign a drive serial number during prefix creation/update.", 1 },'; - ) >> "$patchlist" -fi - # Patchset wineboot-drivers_etc_Stubs # | # | This patchset fixes the following Wine bugs: @@ -5733,6 +5734,21 @@ if test "$enable_winsta_WinStationEnumerateW" -eq 1; then ) >> "$patchlist" fi +# Patchset wintrust-MachineGuid +# | +# | This patchset fixes the following Wine bugs: +# | * [#38508] Create HKLM\Software\Microsoft\Cryptography\MachineGuid registry key +# | +# | Modified files: +# | * dlls/wintrust/register.c +# | +if test "$enable_wintrust_MachineGuid" -eq 1; then + patch_apply wintrust-MachineGuid/0001-wintrust-Create-a-dummy-context-to-force-creation-of.patch + ( + echo '+ { "Sebastian Lackner", "wintrust: Create a dummy context to force creation of MachineGuid registry key.", 1 },'; + ) >> "$patchlist" +fi + # Patchset wpcap-Dynamic_Linking # | # | Modified files: diff --git a/patches/wineboot-MachineGuid/0002-wineboot-Assign-a-drive-serial-number-during-prefix-.patch b/patches/wineboot-DriveSerial/0001-wineboot-Assign-a-drive-serial-number-during-prefix-.patch similarity index 100% rename from patches/wineboot-MachineGuid/0002-wineboot-Assign-a-drive-serial-number-during-prefix-.patch rename to patches/wineboot-DriveSerial/0001-wineboot-Assign-a-drive-serial-number-during-prefix-.patch diff --git a/patches/wineboot-MachineGuid/definition b/patches/wineboot-DriveSerial/definition similarity index 52% rename from patches/wineboot-MachineGuid/definition rename to patches/wineboot-DriveSerial/definition index d7e6e82e..6a905be2 100644 --- a/patches/wineboot-MachineGuid/definition +++ b/patches/wineboot-DriveSerial/definition @@ -1,3 +1,2 @@ -Fixes: [38508] Create HKLM\Software\Microsoft\Cryptography\MachineGuid registry key Fixes: [17823] Assign a drive serial number during prefix creation/update #Category: stable diff --git a/patches/wineboot-MachineGuid/0001-wineboot-Create-MachineGuid-registry-value.patch b/patches/wineboot-MachineGuid/0001-wineboot-Create-MachineGuid-registry-value.patch deleted file mode 100644 index c9c083b8..00000000 --- a/patches/wineboot-MachineGuid/0001-wineboot-Create-MachineGuid-registry-value.patch +++ /dev/null @@ -1,77 +0,0 @@ -From 0c883377270217830a782ba89958c39b25f81da0 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Michael=20M=C3=BCller?= -Date: Sun, 3 May 2015 18:47:30 +0200 -Subject: wineboot: Create MachineGuid registry value. - ---- - programs/wineboot/Makefile.in | 2 +- - programs/wineboot/wineboot.c | 33 +++++++++++++++++++++++++++++++++ - 2 files changed, 34 insertions(+), 1 deletion(-) - -diff --git a/programs/wineboot/Makefile.in b/programs/wineboot/Makefile.in -index f6da0f9..525abde 100644 ---- a/programs/wineboot/Makefile.in -+++ b/programs/wineboot/Makefile.in -@@ -1,7 +1,7 @@ - MODULE = wineboot.exe - APPMODE = -mconsole - IMPORTS = uuid advapi32 --DELAYIMPORTS = shell32 shlwapi version user32 -+DELAYIMPORTS = shell32 shlwapi version user32 rpcrt4 - - C_SRCS = \ - shutdown.c \ -diff --git a/programs/wineboot/wineboot.c b/programs/wineboot/wineboot.c -index 4d70ea9..24bc872 100644 ---- a/programs/wineboot/wineboot.c -+++ b/programs/wineboot/wineboot.c -@@ -361,6 +361,38 @@ static void create_environment_registry_keys( void ) - RegCloseKey( env_key ); - } - -+/* create Cryptography registry keys */ -+static void create_cryptography_registry_keys( void ) -+{ -+ static const WCHAR CryptographyW[] = {'S','o','f','t','w','a','r','e','\\', -+ 'M','i','c','r','o','s','o','f','t','\\', -+ 'C','r','y','p','t','o','g','r','a','p','h','y',0}; -+ static const WCHAR MachineGuidW[] = {'M','a','c','h','i','n','e','G','u','i','d',0}; -+ static const WCHAR formatW[] = -+ { -+ '%','0','8','x','-','%','0','4','x','-','%','0','4','x','-','%','0', -+ '2','x','%','0','2','x','-','%','0','2','x','%','0','2','x','%','0','2', -+ 'x','%','0','2','x','%','0','2','x','%','0','2','x',0 -+ }; -+ -+ HKEY crypt_key; -+ WCHAR buffer[37]; -+ UUID uuid; -+ -+ if (RegCreateKeyW( HKEY_LOCAL_MACHINE, CryptographyW, &crypt_key )) return; -+ -+ if (RegQueryValueExW( crypt_key, MachineGuidW, NULL, NULL, NULL, NULL )) -+ { -+ UuidCreate( &uuid ); -+ wsprintfW( buffer, formatW, uuid.Data1, uuid.Data2, uuid.Data3, -+ uuid.Data4[0], uuid.Data4[1], uuid.Data4[2], uuid.Data4[3], -+ uuid.Data4[4], uuid.Data4[5], uuid.Data4[6], uuid.Data4[7] ); -+ RegSetValueExW( crypt_key, MachineGuidW, 0, REG_SZ, (BYTE *)buffer, sizeof(buffer) ); -+ } -+ -+ RegCloseKey( crypt_key ); -+} -+ - static void create_volatile_environment_registry_key(void) - { - static const WCHAR VolatileEnvW[] = {'V','o','l','a','t','i','l','e',' ','E','n','v','i','r','o','n','m','e','n','t',0}; -@@ -1236,6 +1268,7 @@ int main( int argc, char *argv[] ) - create_hardware_registry_keys(); - create_dynamic_registry_keys(); - create_environment_registry_keys(); -+ create_cryptography_registry_keys(); - wininit(); - pendingRename(); - --- -2.4.2 - diff --git a/patches/wintrust-MachineGuid/0001-wintrust-Create-a-dummy-context-to-force-creation-of.patch b/patches/wintrust-MachineGuid/0001-wintrust-Create-a-dummy-context-to-force-creation-of.patch new file mode 100644 index 00000000..79c71fea --- /dev/null +++ b/patches/wintrust-MachineGuid/0001-wintrust-Create-a-dummy-context-to-force-creation-of.patch @@ -0,0 +1,39 @@ +From 8c028847d81f5dbd4ffc7f56e21b9a4141eef89e Mon Sep 17 00:00:00 2001 +From: Sebastian Lackner +Date: Fri, 31 Jul 2015 05:43:45 +0200 +Subject: wintrust: Create a dummy context to force creation of MachineGuid + registry key. + +--- + dlls/wintrust/register.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/dlls/wintrust/register.c b/dlls/wintrust/register.c +index 9981fbc..0dbb99c 100644 +--- a/dlls/wintrust/register.c ++++ b/dlls/wintrust/register.c +@@ -960,6 +960,8 @@ HRESULT WINAPI DllRegisterServer(void) + HRESULT CryptRegisterRes = S_OK; + HRESULT TrustProviderRes = S_OK; + HRESULT SIPAddProviderRes = S_OK; ++ HCRYPTPROV crypt_provider; ++ BOOL ret; + + TRACE("\n"); + +@@ -1077,6 +1079,12 @@ add_trust_providers: + * a trust provider without a diagnostic policy). + */ + ++ /* Acquire a dummy context to ensure that the MachineGuid registry key ++ * is created immediately after the creation of a new Wineprefix. */ ++ ret = CryptAcquireContextW(&crypt_provider, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT); ++ if (ret) CryptReleaseContext(crypt_provider, 0); ++ else ERR("Failed to acquire cryptographic context: %u\n", GetLastError()); ++ + /* If CryptRegisterRes is not S_OK it will always overrule the return value. */ + if (CryptRegisterRes != S_OK) + return CryptRegisterRes; +-- +2.5.0 + diff --git a/patches/wintrust-MachineGuid/definition b/patches/wintrust-MachineGuid/definition new file mode 100644 index 00000000..7f5ef0df --- /dev/null +++ b/patches/wintrust-MachineGuid/definition @@ -0,0 +1 @@ +Fixes: [38508] Create HKLM\Software\Microsoft\Cryptography\MachineGuid registry key