微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

安装两个虚拟机只为验证一个猜测,结果不出所料Unity | deviceUniqueIdentifier | 设备ID相同

一、前言

嗨,大家好,我是新发。
项目发布了Windows平台的版本,运行过程中发现有部分玩家的设备ID是相同的。
莫非这些玩家破解了代码,篡改了获取设备ID的逻辑,使之相同。

在这里插入图片描述


没理由,如果是为了刷号,正常是修改成不同的设备ID才对。
直觉告诉我,问题可能是虚拟机,如果我安装两个虚拟机,那么这两个虚拟机的设备ID是一样的吗?好奇心驱使我做了下面的实验。

二、Unity获取设备ID

Unity官方提供了SystemInfo类,方便开发者获取系统信息,其中就包括我们说的设备标识符,也就设备IDSystemInfo.deviceUniqueIdentifier
我们可以通过反射的方式把SystemInfo类的所有成员答应出来。
例:

using System;
using System.Reflection;
using System.Text;
using UnityEngine;

public class PrintSystemInfo : MonoBehavIoUr
{
    void Start()
    {
        Type type = typeof(SystemInfo);
        PropertyInfo[] propertyInfos = type.GetProperties(BindingFlags.Static | 
            BindingFlags.Public | BindingFlags.GetProperty);

        StringBuilder sbr = new StringBuilder();
        sbr.AppendLine("总共" + propertyInfos.Length + "个成员");
        for (int i = 0; i < propertyInfos.Length; i++)
        {
            sbr.AppendFormat("{0:D2}. {1,-50} = ", i + 1, propertyInfos[i].Name);
            sbr.Append(type.InvokeMember(propertyInfos[i].Name, BindingFlags.Static | 
                BindingFlags.Public | BindingFlags.GetProperty, null, null));
            sbr.AppendLine();
        }
        Debug.Log(sbr.ToString());
    }
}

输出如下:

总共89个成员
01. batterylevel                                       = -1
02. batteryStatus                                      = Charging
03. operatingSystem                                    = Windows 10  (10.0.18363) 64bit
04. operatingSystemFamily                              = Windows
05. processorType                                      = Intel(R) Core(TM) i5-4590 cpu @ 3.30GHz
06. processorFrequency                                 = 3292
07. processorCount                                     = 4
08. systemMemorySize                                   = 16284
09. deviceUniqueIdentifier                             = f54dd0ef5a143be2fb44a65178603d0b37e126aa
10. deviceName                                         = LINXINFAPC
11. deviceModel                                        = B85M-D2V (Gigabyte Technology Co.,Ltd.)
12. supportsAccelerometer                              = False
13. supportsgyroscope                                  = False
14. supportsLocationService                            = False
15. supportsVibration                                  = False
16. supportsAudio                                      = True
17. deviceType                                         = Desktop
18. graphicsMemorySize                                 = 2007
19. graphicsDeviceName                                 = NVIDIA GeForce GT 740
20. graphicsDevicevendor                               = NVIDIA
21. graphicsdeviceid                                   = 4040
22. graphicsDevicevendorID                             = 4318
23. graphicsDeviceType                                 = Direct3D11
24. graphicsUvstartsAtTop                              = True
25. graphicsDeviceVersion                              = Direct3D 11.0 [level 11.0]
26. graphicsShaderLevel                                = 50
27. graphicsMultiThreaded                              = True
28. renderingThreadingMode                             = MultiThreaded
29. hasHiddenSurfaceRemovalOnGPU                       = False
30. hasDynamicUniformArrayIndexingInFragmentShaders    = True
31. supportsShadows                                    = True
32. supportsRawShadowDepthSampling                     = True
33. supportsMotionVectors                              = True
34. supports3DTextures                                 = True
35. supportsCompressed3DTextures                       = True
36. supports2DArrayTextures                            = True
37. supports3DRenderTextures                           = True
38. supportsCubemapArrayTextures                       = True
39. copyTextureSupport                                 = Basic,copy3D,DifferentTypes,TexturetoRT,RTToTexture
40. supportsComputeShaders                             = True
41. supportsConservativeRaster                         = False
42. supportsMultiview                                  = False
43. supportsGeometryShaders                            = True
44. supportstessellationShaders                        = True
45. supportsrendertargetArrayIndexFromVertexShader     = False
46. supportsInstancing                                 = True
47. supportsHardwareQuadTopology                       = False
48. supports32bitsIndexBuffer                          = True
49. supportssparseTextures                             = True
50. supportedrendertargetCount                         = 8
51. supportsSeparatedrendertargetsBlend                = True
52. supportedRandomWriteTargetCount                    = 8
53. supportsMultisampledTextures                       = 1
54. supportsMultisampled2DArrayTextures                = True
55. supportsMultisampleAutoResolve                     = False
56. supportsTextureWrapMirrorOnce                      = 1
57. usesReversedZBuffer                                = True
58. npotSupport                                        = Full
59. maxTextureSize                                     = 16384
60. maxCubemapSize                                     = 16384
61. maxComputeBufferInputsvertex                       = 128
62. maxComputeBufferInputsFragment                     = 128
63. maxComputeBufferInputsGeometry                     = 128
64. maxComputeBufferInputsDomain                       = 128
65. maxComputeBufferInputsHull                         = 128
66. maxComputeBufferInputsCompute                      = 32
67. maxComputeWorkGroupSize                            = 1024
68. maxComputeWorkGroupSizeX                           = 1024
69. maxComputeWorkGroupSizeY                           = 1024
70. maxComputeWorkGroupSizeZ                           = 64
71. supportsAsyncCompute                               = False
72. supportsGpuRecorder                                = True
73. supportsGraphicsFence                              = True
74. supportsAsyncGPUReadback                           = True
75. supportsRayTracing                                 = False
76. supportsSetConstantBuffer                          = True
77. constantBufferOffsetAlignment                      = 0
78. minConstantBufferOffsetAlignment                   = False
79. hasMipMaxLevel                                     = True
80. supportsMipStreaming                               = True
81. usesLoadStoreActions                               = False
82. hdrdisplaySupportFlags                             = Supported,RuntimeSwitchable,AutomaticTonemapping
83. supportsRenderTextures                             = True
84. supportsRenderToCubemap                            = True
85. supportsImageEffects                               = True
86. supportsstencil                                    = 1
87. graphicsPixelFillrate                              = -1
88. supportsvertexPrograms                             = True
89. supportsGPUFence                                   = False

可以看到我的电脑的设备IDf54dd0ef5a143be2fb44a65178603d0b37e126aa

关于SystemInfo更多的说明,可以参见我之前写的这篇文章《Unity获取系统信息SystemInfo(CPU、显卡、操作系统等信息)》

三、安装虚拟机

系统镜像下载:https://msdn.itellyou.cn/
我在上面那个网站中下载了win7系统镜像。

在这里插入图片描述


通过Oracle VM VirtualBox安装了两个win7虚拟机。

在这里插入图片描述

关于Oracle VM VirtualBox安装虚拟机,可以参见我之前写的这篇文章《手把手教,使用Oracle VM VirtualBox虚拟机安装Windows XP系统,爷青回》

四、虚拟机中测试deviceUniqueIdentifier

弄个测试脚本,获取设备ID,如下:

using UnityEngine;
using UnityEngine.UI;

public class NewBehavIoUrScript : MonoBehavIoUr
{
    public Text text;

    void Start()
    {
        text.text = SystemInfo.deviceUniqueIdentifier;
    }
}

在我的本机(win10系统)中运行结果如下:

在这里插入图片描述


我发布到windows平台,然后弄到两台虚拟机中。运行效果如下:

在这里插入图片描述


虚拟机与本地机的设备ID不同,但两台虚拟机的设备ID是相同的。
下次再有出现相同设备ID的,就可以怀疑对方是否使用了虚拟机啦。

五、结束语

喜欢Unity的同学,不要忘记点击关注,如果有什么Unity相关的技术难题,也欢迎留言或私信~

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐