From f01b1e98138da6050bc8a7bd79697254a59d2e00 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Mon, 28 Oct 2024 13:17:46 +0100 Subject: [PATCH] [platform] restoring previous machine ID detection algorithm (IJ-CR-147524) (cherry-picked from commit 272156b476949a339bd1878a785ef03e5f6e7fc3) IJ-CR-147524 GitOrigin-RevId: e6a29ce1f58defb40d7d5f91fa506e1d7a741cd2 --- .../statistic/eventLog/fus/MachineIdManager.kt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/platform/statistics/src/com/intellij/internal/statistic/eventLog/fus/MachineIdManager.kt b/platform/statistics/src/com/intellij/internal/statistic/eventLog/fus/MachineIdManager.kt index d0294eb79c04..6dcd9875a534 100644 --- a/platform/statistics/src/com/intellij/internal/statistic/eventLog/fus/MachineIdManager.kt +++ b/platform/statistics/src/com/intellij/internal/statistic/eventLog/fus/MachineIdManager.kt @@ -40,9 +40,15 @@ object MachineIdManager { }.onFailure { LOG.debug(it) }.getOrNull() } - /** See [Win32_ComputerSystemProduct](https://learn.microsoft.com/en-us/windows/win32/cimwin32prov/win32-computersystemproduct). */ + /** + * See [MachineGuid](https://learn.microsoft.com/en-us/answers/questions/1489139/identifying-unique-windows-installation), + * [Win32_ComputerSystemProduct](https://learn.microsoft.com/en-us/windows/win32/cimwin32prov/win32-computersystemproduct). + */ private fun getWindowsMachineId(): String? = runCatching { + Advapi32Util.registryGetStringValue(WinReg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Cryptography", "MachineGuid") + }.recover { + LOG.debug(it) Ole32.INSTANCE.CoInitializeEx(null, Ole32.COINIT_APARTMENTTHREADED) WbemcliUtil.WmiQuery("Win32_ComputerSystemProduct", ComputerSystemProductProperty::class.java) .execute(2000) @@ -50,9 +56,6 @@ object MachineIdManager { if (result.resultCount > 0) result.getValue(ComputerSystemProductProperty.UUID, 0).toString() else null } - }.recover { - LOG.debug(it) - Advapi32Util.registryGetStringValue(WinReg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Cryptography", "MachineGuid") }.getOrThrow() enum class ComputerSystemProductProperty { UUID }