Page 2 of 3 FirstFirst 123 LastLast
Results 41 to 80 of 106

Thread: [RESOLVED] Identify computer

  1. #41
    Frenzied Member VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    1,886

    Re: Identify computer

    Well, for one, that string is editable so anyone can put anything in there. And second, laptops are used in a lot of different places so it's not uncommon for people to use the Ethernet adapter at home and the WiFi adapter in other places. Some may even use USB WiFi adapters and when they unplug those the MACAddress is gone. I guess the conclusion is MACAddresses are not very reliable to identify a computer in the way you wanted.

  2. #42
    Frenzied Member 2kaud's Avatar
    Join Date
    May 2014
    Location
    England
    Posts
    1,094

    Re: Identify computer

    It returns nothing.
    What do you get if you use:

    Code:
    ipconfig /all | more
    You should see at least one line that starts with:

    Code:
       Physical Address. . . . . . . . . : xx-xx-xx-xx-xx-xx
    where xx-xx-xx-xx-xx-xx is the MAC address for that adaptor.

    If you don't see at least one line like this then what does ipconfig display? if you do see then there's an issue with the command as entered.
    All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  3. #43

    Thread Starter
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,240

    Re: Identify computer

    Quote Originally Posted by 2kaud View Post
    What do you get if you use:

    Code:
    ipconfig /all | more
    Name:  MACAdd.jpg
Views: 565
Size:  45.8 KB

  4. #44
    Frenzied Member VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    1,886

    Re: Identify computer

    Quote Originally Posted by Eduardo- View Post
    It returns nothing.
    LoL that screenshot explains why it didn't return anything. There's no "physical" in Spanish!

  5. #45

    Thread Starter
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,240

    Re: Identify computer

    Quote Originally Posted by VanGoghGaming View Post
    LoL that screenshot explains why it didn't return anything. There's no "physical" in Spanish!
    What?

    Name:  MACAdd2.png
Views: 583
Size:  28.2 KB

  6. #46
    Frenzied Member 2kaud's Avatar
    Join Date
    May 2014
    Location
    England
    Posts
    1,094

    Re: Identify computer

    Ah so. For the Spanish version you need:

    Code:
    ipconfig /all | findstr /i fisica
    All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  7. #47
    Frenzied Member VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    1,886

    Cool Re: Identify computer

    Quote Originally Posted by 2kaud View Post
    Ah so. For the Spanish version you need:

    Code:
    ipconfig /all | findstr /i fisica
    That will also return nothing. "fisica" <> "física"

  8. #48
    Frenzied Member VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    1,886

    Red face Re: Identify computer

    The "ipconfig" is an OS command sure, but the pipe thing "|" tells "findstr" to search for a string in the output which is in Spanish. Do yourself a favor and install Windows in English like a proper developer, saves you a lot of trouble! Most translations are weird and forced.

  9. #49

    Thread Starter
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,240

    Re: Identify computer

    Name:  MACAdd3.jpg
Views: 563
Size:  11.2 KB

    I can't believe it. These commands of the OS are now localized.

    But too bad, the English version should keep also working.

    Anyway, it now works but returns the same result.

  10. #50
    Frenzied Member VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    1,886

    Talking Re: Identify computer

    Quote Originally Posted by Eduardo- View Post
    Anyway, it now works but returns the same result.
    Obviously, that is your physical network adapter. Probably you changed your MACAddress in the past to look like that and you forgot about it.

  11. #51
    PowerPoster
    Join Date
    Nov 2017
    Posts
    3,324

    Re: Identify computer

    Not just you. Sounds like ASUS sold a whole bunch of boards without properly ensuring the embedded NIC had its MAC address "uniqueified".

    https://community.intel.com/t5/Ether...8/td-p/1315059

    Edit: Also, more info below. Could be fallout from a BIOS flash issue.

    https://askubuntu.com/questions/1338...t-888888888788
    Last edited by OptionBase1; Jun 26th, 2024 at 07:41 AM.

  12. #52

    Thread Starter
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,240

    Re: Identify computer

    Quote Originally Posted by VanGoghGaming View Post
    Do yourself a favor and install Windows in English like a proper developer, saves you a lot of trouble! Most translations are weird and forced.
    Why don't you install Windows in Spanish or French, you need to test your programs with other localizations.

    I prefer to have it in Spanish, so I can tell other people (users might be...) something without guessing the right name in Spanish in the OS.
    Also, I don't see any disadvantage... well, now that I'm thinking there are some disadvantages: when I read how to do something in Windows in English web pages, I have to translate every step to Spanish mostly guessing.

    I have most of the programs in English, but also Windows... IDK, it seems too much. Anyway, I remember that it is very easy now to change the language (but it may require a restart).

    Quote Originally Posted by VanGoghGaming View Post
    Most translations are weird and forced.
    That is true for most programs. Not for Windows.

  13. #53
    Frenzied Member VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    1,886

    Re: Identify computer

    Best compromise in Windows in English and you install other language packs for typing foreign text (press Alt-Shift to change current typing language).

  14. #54

    Thread Starter
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,240

    Re: Identify computer

    Quote Originally Posted by VanGoghGaming View Post
    Obviously, that is your physical network adapter. Probably you changed your MACAddress in the past to look like that and you forgot about it.
    I never changed anything.

    Quote Originally Posted by OptionBase1 View Post
    Not just you. Sounds like ASUS sold a whole bunch of boards without properly ensuring the embedded NIC had its MAC address "uniqueified".

    https://community.intel.com/t5/Ether...8/td-p/1315059

    Edit: Also, more info below. Could be fallout from a BIOS flash issue.

    https://askubuntu.com/questions/1338...t-888888888788
    That's crazy.

    But this one is MSI.
    Carbon Gaming Pro (or something like that is the name of the mobo)

  15. #55

    Thread Starter
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,240

    Re: Identify computer

    So conclusion: The Mac address is not reliable as an identifier.

  16. #56

    Thread Starter
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,240

    Re: Identify computer

    From here:

    There is a BIOS flashing bug that affects all sorts of motherboards, ASUS, MSI, GIGABYTE. It leaves the Intel NIC with an invalid MAC after BIOS flash.
    I had to flash the BIOS at some point (like two years ago).

  17. #57
    Frenzied Member VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    1,886

    Re: Identify computer

    Quote Originally Posted by Eduardo- View Post
    So conclusion: The Mac address is not reliable as an identifier.
    Yep, told you so from post #2 in this thread (revisit it)! I've also mentioned in there what info you could use to make your unique license code. Take those strings, concatenate them together, use "HashData" to make your code, done!

  18. #58
    PowerPoster
    Join Date
    Nov 2017
    Posts
    3,324

    Re: Identify computer

    Quote Originally Posted by VanGoghGaming View Post
    Yep, told you so from post #2 in this thread (revisit it)! I've also mentioned in there what info you could use to make your unique license code. Take those strings, concatenate them together, use "HashData" to make your code, done!
    Won't that break if any single item is changed, like swapping out a RAM stick? As Eduardo has made it clear multiple times in this thread, the solution should be able to tolerate "some" hardware changes.

    So whatever the solution is, it must store an identifying hash/something for every individual component that is part of this process, and then count up how many of those things are still the same vs. how many things may have changed, and if that sum is greater than some threshold, treat the device as a brand new, unrecognized, unlicensed device, and force the user to get a new license for it.

  19. #59

    Thread Starter
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,240

    Re: Identify computer

    Exactly.
    I will generate one number for: CPU, mobo and MAC. All these would count for the same thing: the mobo.
    Another number could be for one disk.
    And a third one might be a memory serial, if I can get those.
    Or alternatively, another disk if there are another.

    The third number should be optional, because I'm not sure that for every machine it will be able get a third identifier.

    I'm thinking in three things (as described above), anyone of these three that matches, it would be considered the same machine, so the license would be OK.

  20. #60

    Thread Starter
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,240

    Re: Identify computer

    For the first number I could use several things at the same time, specially if there is no serial number.
    For example: MAC + micro model + mobo manufacturer + mobo model + bios date

  21. #61
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,407

    Re: Identify computer

    Here are some notes on "Unique Machine ID" from research I did:

    - Official supported way using WinRT (Franky?) - https://devblogs.microsoft.com/oldne...31-00/?p=97945

    - Official supported way using WMI (obscure, not sure if works) - https://learn.microsoft.com/bg-bg/wi...for-a-computer

    - Using hardware data gathered by Windows Activation to identity machine (PowerShell w/ admin rights) - https://www.nextofwindows.com/the-be...indows-machine

    Code:
    PS C:\Users\wqw> (Get-CimInstance -Namespace root/cimv2/mdm/dmmap -Class MDM_DevDetail_Ext01 -Filter "InstanceID='Ext' AND ParentID='./DevDetail'").DeviceHardwareData
    T0EXBAEAHAAAAAoAWA5dWAAACgCVDl1YHOEOLgwCCQgCABAACQABABAAGAABAAAAIgAPAAIBCAAQAAAIAAgABQAZACAAAAAAAAAAAAEAAAAAAAAEAAEAAwMA
    EQBHZW51aW5lSW50ZWwABAA0ADEydGggR2VuIEludGVsKFIpIENvcmUoVE0pIGk5LTEyOTAwSwAAAAAAAAAAAAAAAAYAEADQBwAAAAAAAAgAAAEGABAAoA8A
    AAAAAAALAAEABwAfAFZvbHVtZTF8UmFpZCAwIFZvbHVtZXxJbnRlbAcALgAgICAgIFdELVdDQzdLN1VYWVVKUHxXREMgV0Q0MEVGUlgtNjhOMzJOMHwIABoA
    DgAAAFDr9ia6UQgAAABQAEMASQAAAAoACQADAQEAAA0ATwBUUE0tVmVyc2lvbjoyLjAgLUxldmVsOjAtUmV2aXNpb246MS4zOC1WZW5kb3JJRDonSU5UQyct
    RmlybXdhcmU6MzkzMjE2MTguMAAZAAQB2/61mZ4Pn/lD48PiH22TRLOgXw2RizGp+uoVLs6dY8oKFJ9dG8vaAmx8RJeHTZhigGdOxBcXqjFgZ/but8fqlbsW
    EXwv0Cyx1ZREwBvZovPgLi+KzhUWGepgIlAO+qHNi/MogXqe7alMbEXFKcZ7OT8prpX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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    - After retrieving this binary blob you can hash it to a smaller 16-64 bytes hash (i.e. MD5->16, SHA1->20, SHA256->32, SHA512->64).

    cheers,
    </wqw>

  22. #62
    Frenzied Member VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    1,886

    Re: Identify computer

    Some ideas:

    One number could be ProcessorId + MotherboardManufacturer + MotherBoardModel
    Second number could be the serial number of the HDD that contains the boot partition since that is less likely to change (I gave you the code above)
    Third number could be the serial number of a RAM stick (code is similar to above if you keep using the WMI object)
    Fourth number could be the MAC (difficult to decide which MAC is Ethernet and which is WiFi when you have multiple MACs so you need to concatenate all of them).

  23. #63
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,407

    Re: Identify computer

    Quote Originally Posted by VanGoghGaming View Post
    Some ideas:

    One number could be ProcessorId + MotherboardManufacturer + MotherBoardModel
    Second number could be the serial number of the HDD that contains the boot partition since that is less likely to change (I gave you the code above)
    Third number could be the serial number of a RAM stick (code is similar to above if you keep using the WMI object)
    Fourth number could be the MAC (difficult to decide which MAC is Ethernet and which is WiFi when you have multiple MACs so you need to concatenate all of them).
    This is just too simple to cut it IMO. If you peruse Raymond Chen article above they have Source property implemented on the Machine ID returned to indicate if its origin is from TPM, UEFI or other not so reliable source so the problem is real.

    cheers,
    </wqw>

  24. #64
    Frenzied Member VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    1,886

    Cool Re: Identify computer

    Quote Originally Posted by wqweto View Post
    This is just too simple to cut it IMO.
    And I was afraid it was too complicated! My impression was that Eduardo was saddled with this (somewhat unwanted) task and wanted something simple to get rid of it and move on!

  25. #65

  26. #66
    Frenzied Member 2kaud's Avatar
    Join Date
    May 2014
    Location
    England
    Posts
    1,094

    Re: Identify computer

    I had to flash the BIOS at some point
    Careful. If you have duplicate mac addresses on your network you'll probably get problems at some point as data is transferred to/from mac addresses.
    All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  27. #67
    Frenzied Member VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    1,886

    Talking Re: Identify computer

    Quote Originally Posted by VanGoghGaming View Post
    Lemme see if I can whip up Raymond Chen's example in VB6.
    Here it is, paste this code in a module in an empty project. It will execute the "Sub Main" and print the SystemIdentification code for your computer (along with its Source: TPM, UEFI or Registry):

    mdlSystemIdentificationInfo.bas
    Code:
    Option Explicit
    
    Private Const PTR_SIZE As Long = 4, CC_STDCALL As Long = 4, FORMAT_MESSAGE_ALLOCATE_BUFFER As Long = &H100, FORMAT_MESSAGE_FROM_SYSTEM As Long = &H1000, _
                  FORMAT_MESSAGE_IGNORE_INSERTS As Long = &H200, FORMAT_MESSAGE_MAX_WIDTH_MASK As Long = &HFF
    
    Private Const WindowsSystemProfileSystemIdentification As String = "Windows.System.Profile.SystemIdentification"
    Private Const WindowsSecurityCryptographyCryptographicBuffer As String = "Windows.Security.Cryptography.CryptographicBuffer"
    
    Private Enum vtbInterfaceOffsets
    '    ISystemIdentificationStatics
        ISystemIdentificationStatics_GetSystemIdForPublisher = 6 * PTR_SIZE
    '   ISystemIdentificationInfo
        ISystemIdentificationInfo_GetId = 6 * PTR_SIZE
        ISystemIdentificationInfo_GetSource = 7 * PTR_SIZE
    '    ICryptographicBufferStatics
        ICryptographicBufferStatics_EncodeToHexString = 12 * PTR_SIZE
    End Enum
    
    Private Enum HRESULT
        S_OK
        S_FALSE
    End Enum
    
    Public Enum SystemIdentificationSources
        eNone
        eTPM
        eUEFI
        eRegistry
    End Enum
    
    Private Declare Function RoGetActivationFactory Lib "combase" (ByVal activatableClassId As Long, ByVal rIID As Long, objFactory As IUnknown) As Long
    Private Declare Function WindowsCreateString Lib "combase" (ByVal sourceString As Long, ByVal Length As Long, hString As Long) As Long
    Private Declare Function WindowsDeleteString Lib "combase" (ByVal hString As Long) As Long
    Private Declare Function WindowsGetStringRawBuffer Lib "combase" (ByVal hString As Long, Length As Long) As Long
    Private Declare Function FormatMessageW Lib "kernel32" (ByVal dwFlags As Long, ByVal lpSource As Long, ByVal dwMessageId As Long, ByVal dwLanguageId As Long, lpBuffer As Long, ByVal nSize As Long, ByVal Arguments As Long) As Long
    Private Declare Function LocalFree Lib "kernel32" (ByVal hMem As Long) As Long
    Private Declare Function DispCallFunc Lib "oleaut32" Alias "#146" (ByVal pvInstance As Long, ByVal oVft As Long, ByVal cc As Long, ByVal vtReturn As VbVarType, ByVal cActuals As Long, prgvt As Any, prgpvarg As Any, pvargResult As Variant) As Long
    Private Declare Function SysReAllocString Lib "oleaut32" Alias "#3" (ByVal pBSTR As Long, ByVal pStr As Long) As Long
    Private Declare Sub SetLastError Lib "kernel32" (ByVal dwErrCode As Long)
    
    Private IID_ISystemIdentificationStatics(0 To 1) As Currency, IID_ICryptographicBufferStatics(0 To 1) As Currency, ParamTypes(0 To 10) As Integer, ParamValues(0 To 10) As Long, _
            lParamCount As Long, lpInterface As Long, vParams As Variant
    
    Public Sub Main()
    Dim eSystemIdentificationSource As SystemIdentificationSources
        Debug.Print eSystemIdentificationSource, GetSystemIdentificationInfo(eSystemIdentificationSource)
    End Sub
    
    Public Function GetSystemIdentificationInfo(Optional eSystemIdentificationSource As SystemIdentificationSources) As String
    Dim objISystemIdentification As IUnknown, objISystemIdentificationInfo As IUnknown, objId As IUnknown, objICryptographicBufferStatics As IUnknown, hString As Long
        If IID_ISystemIdentificationStatics(0) = 0 Then IID_ISystemIdentificationStatics(0) = 559004451866266.5258@: IID_ISystemIdentificationStatics(1) = 10285753081610.1795@: IID_ICryptographicBufferStatics(0) = 553921279414052.4066@: IID_ICryptographicBufferStatics(1) = -148477987870543.7818@
        If GetActivationFactory(WindowsSystemProfileSystemIdentification, VarPtr(IID_ISystemIdentificationStatics(0)), objISystemIdentification) Then
            If InvokePtr(ObjPtr(objISystemIdentification), ISystemIdentificationStatics_GetSystemIdForPublisher, VarPtr(objISystemIdentificationInfo)) = S_OK Then
                If InvokePtr(ObjPtr(objISystemIdentificationInfo), ISystemIdentificationInfo_GetSource, VarPtr(eSystemIdentificationSource)) = S_OK Then
                    If InvokePtr(ObjPtr(objISystemIdentificationInfo), ISystemIdentificationInfo_GetId, VarPtr(objId)) = S_OK Then
                        If GetActivationFactory(WindowsSecurityCryptographyCryptographicBuffer, VarPtr(IID_ICryptographicBufferStatics(0)), objICryptographicBufferStatics) Then
                            If InvokePtr(ObjPtr(objICryptographicBufferStatics), ICryptographicBufferStatics_EncodeToHexString, objId, VarPtr(hString)) = S_OK Then
                                SysReAllocString VarPtr(GetSystemIdentificationInfo), WindowsGetStringRawBuffer(hString, 0): hString = WindowsDeleteString(hString)
                            End If
                        End If
                    End If
                End If
            End If
        End If
    End Function
    
    Private Function GetActivationFactory(sClassName As String, lpIID As Long, objFactory As IUnknown) As Boolean
    Dim hString As Long, lRet As Long
        If WindowsCreateString(StrPtr(sClassName), Len(sClassName), hString) = S_OK Then
            lRet = RoGetActivationFactory(hString, lpIID, objFactory): GetActivationFactory = lRet = S_OK: hString = WindowsDeleteString(hString)
            #If bInIDE Then
                If Not GetActivationFactory Then Debug.Print Hex$(lRet), GetLastErrorMessage(lRet)
            #End If
        End If
    End Function
    
    Private Function InvokePtr(lpInterface As Long, vtbOffset As Long, ParamArray ParamsArray() As Variant) As Variant
    Dim lRet As Long
        If lpInterface Then
            vParams = ParamsArray
            For lParamCount = 0 To UBound(vParams): ParamTypes(lParamCount) = VarType(vParams(lParamCount)): ParamValues(lParamCount) = VarPtr(vParams(lParamCount)): Next lParamCount
            lRet = DispCallFunc(lpInterface, vtbOffset, CC_STDCALL, vbLong, lParamCount, ParamTypes(0), ParamValues(0), InvokePtr)
            If lRet < 0 Then
                InvokePtr = S_FALSE: SetLastError lRet
            #If bInIDE Then
                Debug.Print Hex$(lRet), GetLastErrorMessage(lRet)
            ElseIf InvokePtr < 0 Then
                Debug.Print Hex$(InvokePtr), GetLastErrorMessage(InvokePtr)
            #End If
            End If
        Else
            InvokePtr = S_FALSE
        End If
    End Function
    
    Private Function GetLastErrorMessage(ByVal lLastError As Long) As String
    Dim lpBuffer As Long
        If FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER Or FORMAT_MESSAGE_FROM_SYSTEM Or FORMAT_MESSAGE_IGNORE_INSERTS Or FORMAT_MESSAGE_MAX_WIDTH_MASK, 0, lLastError, 0, lpBuffer, 0, 0) Then
            If lpBuffer Then SysReAllocString VarPtr(GetLastErrorMessage), lpBuffer: LocalFree lpBuffer
        End If
    End Function

  28. #68
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,407

    Re: Identify computer

    Here is my take on same GetSystemIdentificationInfo:

    Code:
    Option Explicit
    DefObj A-Z
    
    Private Declare Function RoGetActivationFactory Lib "combase" (ByVal activatableClassId As Long, rIID As Any, lpFactory As Any) As Long
    Private Declare Function WindowsCreateString Lib "combase" (ByVal sourceString As Long, ByVal Length As Long, hString As Long) As Long
    Private Declare Function WindowsDeleteString Lib "combase" (ByVal hString As Long) As Long
    Private Declare Function WindowsGetStringRawBuffer Lib "combase" (ByVal hString As Long, Length As Long) As Long
    Private Declare Function IIDFromString Lib "ole32" (ByVal lpString As Long, rIID As Any) As Long
    Private Declare Function SysReAllocString Lib "oleaut32" Alias "#3" (ByVal pBSTR As Long, ByVal pStr As Long) As Long
    Private Declare Function DispCallFunc Lib "oleaut32" (ByVal pvInstance As Long, ByVal oVft As Long, ByVal lCc As Long, ByVal vtReturn As VbVarType, ByVal cActuals As Long, prgvt As Any, prgpvarg As Any, pvargResult As Variant) As Long
    
    Private IID_ISystemIdentificationStatics(0 To 3) As Long
    Private IID_ICryptographicBufferStatics(0 To 3) As Long
    
    Public Function GetSystemIdentificationInfo2(Optional lSource As Long) As String
        Const SystemIdentification          As String = "Windows.System.Profile.SystemIdentification"
        Const SystemIdentificationInfo      As String = "Windows.System.Profile.SystemIdentificationInfo"
        Const CryptographicBuffer           As String = "Windows.Security.Cryptography.CryptographicBuffer"
        Const IDX_GetSystemIdForPublisher   As Long = 6
        Const IDX_GetId                     As Long = 6
        Const IDX_GetSource                 As Long = 7
        Const IDX_EncodeToHexString         As Long = 12
        Dim pSysIdent       As stdole.IUnknown
        Dim pInfo           As stdole.IUnknown
        Dim pId             As stdole.IUnknown
        Dim pCryptoBuf      As stdole.IUnknown
        Dim hString         As Long
        Dim hResult         As Long
        Dim sApiSource      As String
        
        On Error GoTo EH
        If IID_ISystemIdentificationStatics(0) = 0 Then
            Call IIDFromString(StrPtr("{5581F42A-D3DF-4D93-A37D-C41A616C6D01}"), IID_ISystemIdentificationStatics(0))
            Call IIDFromString(StrPtr("{320B7E22-3CB0-4CDF-8663-1D28910065EB}"), IID_ICryptographicBufferStatics(0))
        End If
        '--- auto id = Windows::System::Profile::SystemIdentification::GetSystemIdForPublisher()->Id
        Set pSysIdent = CreateFactory(SystemIdentification, IID_ISystemIdentificationStatics(0))
        If pSysIdent Is Nothing Then
            GoTo QH
        End If
        hResult = DispCallByVtbl(pSysIdent, IDX_GetSystemIdForPublisher, VarPtr(pInfo))
        If hResult < 0 Then
            sApiSource = SystemIdentification & ".GetSystemIdForPublisher"
            GoTo QH
        End If
        hResult = DispCallByVtbl(pInfo, IDX_GetId, VarPtr(pId))
        If hResult < 0 Then
            sApiSource = SystemIdentificationInfo & ".GetId"
            GoTo QH
        End If
        hResult = DispCallByVtbl(pInfo, IDX_GetSource, VarPtr(lSource))
        If hResult < 0 Then
            sApiSource = SystemIdentificationInfo & ".GetSource"
            GoTo QH
        End If
        '--- auto asHex = Windows::Security::Cryptography::CryptographicBuffer::EncodeToHexString(id)
        Set pCryptoBuf = CreateFactory(CryptographicBuffer, IID_ICryptographicBufferStatics(0))
        If pCryptoBuf Is Nothing Then
            GoTo QH
        End If
        hResult = DispCallByVtbl(pCryptoBuf, IDX_EncodeToHexString, ObjPtr(pId), VarPtr(hString))
        If hResult < 0 Then
            sApiSource = CryptographicBuffer & ".EncodeToHexString"
            GoTo QH
        End If
        Call SysReAllocString(VarPtr(GetSystemIdentificationInfo2), WindowsGetStringRawBuffer(hString, 0))
    QH:
        If hString <> 0 Then
            hString = WindowsDeleteString(hString)
        End If
        If LenB(sApiSource) <> 0 Then
            Err.Raise hResult, sApiSource
        End If
        Exit Function
    EH:
        hResult = Err.Number
        sApiSource = Err.Source
        Resume QH
    End Function
    
    Private Function CreateFactory(sClassID As String, rIID As Long) As stdole.IUnknown
        Dim hString         As Long
        Dim hResult         As Long
        Dim sApiSource      As String
        
        On Error GoTo EH
        hResult = WindowsCreateString(StrPtr(sClassID), Len(sClassID), hString)
        If hResult < 0 Then
            sApiSource = "WindowsCreateString"
            GoTo QH
        End If
        hResult = RoGetActivationFactory(hString, rIID, CreateFactory)
        If hResult < 0 Then
            sApiSource = "RoGetActivationFactory"
            GoTo QH
        End If
    QH:
        If hString <> 0 Then
            hString = WindowsDeleteString(hString)
        End If
        If LenB(sApiSource) <> 0 Then
            Err.Raise hResult, sApiSource
        End If
        Exit Function
    EH:
        hResult = Err.Number
        sApiSource = Err.Source
        Resume QH
    End Function
    
    Private Function DispCallByVtbl(pUnk As IUnknown, ByVal lIndex As Long, ParamArray A() As Variant) As Variant
        Const CC_STDCALL    As Long = 4
        Dim lIdx            As Long
        Dim vParam()        As Variant
        Dim vType(0 To 63)  As Integer
        Dim vPtr(0 To 63)   As Long
        Dim hResult         As Long
        
        vParam = A
        For lIdx = 0 To UBound(vParam)
            vType(lIdx) = VarType(vParam(lIdx))
            vPtr(lIdx) = VarPtr(vParam(lIdx))
        Next
        hResult = DispCallFunc(ObjPtr(pUnk), lIndex * 4, CC_STDCALL, vbLong, lIdx, vType(0), vPtr(0), DispCallByVtbl)
        If hResult < 0 Then
            Err.Raise hResult, "DispCallFunc"
        End If
    End Function
    
    cheers,
    </wqw>

  29. #69
    Frenzied Member VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    1,886

    Thumbs up Re: Identify computer

    Yep, it's clear that Raymond Chen's approach has many benefits. Since it's based on the TPM module or UEFI Bios (which are present in any computer from the last decade or so) this means the user can change pretty much any hardware component except the motherboard and the code stays the same.

    If the user's computer is really old and doesn't have an UEFI Bios then the code will be based on the Registry and subject to change when Windows is reinstalled. In this case the program could fallback to another method of generating a code (from the suggestions above).

    Probably the code will also change when the Bios is updated with a newer version but this needs to be tested. I know for sure that Bitlocker keys stored in the TPM are wiped out in case of a Bios update...

    This method could also work with Virtual Machines when coupled with the MACAddress and ProcessorId (which change when the virtual machine is cloned).

    *Later Edit*

    Just realized that Windows 7 is out of the equation now since WinRT classes require Windows 10 or newer...

  30. #70

    Thread Starter
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,240

    Re: Identify computer

    Quote Originally Posted by VanGoghGaming View Post
    Yep, it's clear that Raymond Chen's approach has many benefits. Since it's based on the TPM module or UEFI Bios (which are present in any computer from the last decade or so) this means the user can change pretty much any hardware component except the motherboard and the code stays the same.

    If the user's computer is really old and doesn't have an UEFI Bios then the code will be based on the Registry and subject to change when Windows is reinstalled. In this case the program could fallback to another method of generating a code (from the suggestions above).

    Probably the code will also change when the Bios is updated with a newer version but this needs to be tested. I know for sure that Bitlocker keys stored in the TPM are wiped out in case of a Bios update...

    This method could also work with Virtual Machines when coupled with the MACAddress and ProcessorId (which change when the virtual machine is cloned).

    *Later Edit*

    Just realized that Windows 7 is out of the equation now since WinRT classes require Windows 10 or newer...
    I think these are good ideas. To use the best method on Windows 10+ and use an alternative method on previous versions.

    One added difficulty is being able to test it on several machines: in some old ones with Windows 7, also in laptops connected to a lan with a wire, laptops connected with Wi-Fi, etc.
    But here the people of the forum could help testing I guess.
    Once we have something working right, we could post it in the Codebank.
    I guess you are already doing something but I'll keep researching.

    Like someone said in the linked article that I'm reading, "it’s a lot complicated than what I initially thought.".

    Quote Originally Posted by VanGoghGaming View Post
    My impression was that Eduardo was saddled with this (somewhat unwanted) task and wanted something simple to get rid of it and move on!
    Exactly, you've read my mind (or maybe what I wrote here )

    Quote Originally Posted by 2kaud View Post
    Careful. If you have duplicate mac addresses on your network you'll probably get problems at some point as data is transferred to/from mac addresses.
    For now there will be no problem, it is not in a lan. Also, even if some day it is, it would be a real coincidence that another machine that also flashed the BIOS and that has the same issue, they both meet in the same local network. But I'll keep that in mind.

    Thanks wqweto and everybody.

  31. #71

    Thread Starter
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,240

    Re: Identify computer

    Hello. I'm trying to convert the C++ code for GetSystemIdForPublisher from Raymond Chen's page but I don't get the right rationale in the logic.

    So far I have:

    Code:
    Option Explicit
    
    Private Type GUID
        data1 As Long
        data2 As Long
        data3 As Long
        data4 As Long
    End Type
    
    Private Declare Function CLSIDFromString Lib "ole32.dll" (ByVal pstring As Long, ByRef pCLSID As GUID) As Long
    Private Declare Function RoGetActivationFactory Lib "Combase.dll" (ByVal activatableClassId As Long, ByRef riid As GUID, ByRef factory As Long) As Long
    Private Declare Function WindowsCreateString Lib "Combase.dll" (ByVal sourceString As Long, ByVal lenght As Long, ByRef hString As Long) As Long
    Private Declare Function WindowsDeleteString Lib "Combase.dll" (ByVal hString As Long) As Long
    Private Declare Function DispCallFunc Lib "Oleaut32.dll" (ByVal pvInstance As Long, ByVal oVft As Long, ByVal cc As Long, ByVal vtReturn As VbVarType, ByVal cActuals As Long, ByVal prgvt As Any, ByVal prgpvarg As Any, ByRef pvargResult As Variant) As Long
    
    Private Const S_OK As Long = &H0&
    Private Const CC_STDCALL As Long = &H4&
    Private Const cRuntimeClass_Windows_System_Profile_SystemIdentification As String = "Windows.System.Profile.SystemIdentification"
    Private Const cIID_ISystemIdentificationStatics As String = "{5581f42a-d3df-4d93-a37d-c41a616c6d01}"
    Private Const cIID_ISystemIdentificationInfo As String = "{0c659e7d-c3c2-4d33-a2df-21bc41916eb3}"
    
    Private Enum vtb_Interfaces
        
        ' IUnknown
        IUnknown_QueryInterface = 0
        IUnknown_Release = 2
    
        ' IInspectable
        IInspectable_GetIids = 3
        IInspectable_GetRuntimeClassName = 4
        IInspectable_GetTrustLevel = 5
        
        ' IAsyncInfo
        IAsyncInfo_GetStatus = 7
        IAsyncInfo_Close = 10
    
        ' IAsyncInterface
        IAsyncInterface_GetResults = 8
        
        ' IClosable
        IClosable_Close = 6
        
        ' IInitializeWithWindow
        IInitializeWithWindow_Initialize = 3
        
    End Enum
    
    Private mISystemIdentificationStatics As Long
    Private mISystemIdentificationInfo As Long
    
    Private Function GetActivationFactory(ByVal className As String, ByVal Iid As String, ByRef pFactory As Long) As Boolean
        Dim hString As Long
        
        hString = CreateWindowsString(className)
        If RoGetActivationFactory(hString, Str2Guid(Iid), pFactory) = S_OK Then
            GetActivationFactory = True
        End If
        Call DeleteWindowsString(hString)
    End Function
    
    Private Function CreateWindowsString(ByVal Value As String) As Long
        Call WindowsCreateString(StrPtr(Value), Len(Value), CreateWindowsString)
    End Function
    
    Private Function DeleteWindowsString(ByRef hString As Long) As Boolean
        If WindowsDeleteString(hString) = S_OK Then
            hString = 0&
            DeleteWindowsString = True
        End If
    End Function
    
    Private Function Str2Guid(ByVal strGUID As String) As GUID
        If Len(strGUID) = 38 Then
            Call CLSIDFromString(StrPtr(strGUID), Str2Guid)
        End If
    End Function
    
    Public Function GetSystemIdForPublisher() As String
        If GetActivationFactory(cRuntimeClass_Windows_System_Profile_SystemIdentification, cIID_ISystemIdentificationStatics, mISystemIdentificationStatics) Then
            
            'If Invoke(mISystemIdentificationStatics, ISystemIdentificationInfo_get_Id, VarPtr(mISystemIdentificationInfo)) = S_OK Then
                
            'End If
        
           'Call ReleaseIfc(mISystemIdentificationStatics)
        End If
    End Function
    
    
    Private Sub ReleaseIfc(ByRef pInterface As Long)
        If pInterface <> 0& Then
            Dim Ret As Long
            If DispCallFunc(pInterface, IUnknown_Release, CC_STDCALL, vbLong, 0&, 0&, 0&, Ret) = S_OK Then
                pInterface = 0&
            End If
        End If
    End Sub
    
    Private Function Invoke(ByVal pInterface As Long, ByVal vtb As vtb_Interfaces, ParamArray var()) As Variant
        If pInterface <> 0& Then
            Invoke = OleInvoke(pInterface, vtb, var)
        End If
    End Function
    
    Private Function OleInvoke(ByVal pInterface As Long, ByVal lngCmd As Long, ParamArray aParam()) As Variant
        Dim varParam As Variant
        Dim varRet As Variant
        Dim lngCount As Long
        Dim lngItem As Long
        Dim olePtr(10) As Long
        Dim oleTyp(10) As Integer
        
        If pInterface <> 0& Then
            If UBound(aParam) >= 0& Then
                varParam = aParam
                If IsArray(varParam) Then varParam = varParam(0)
                lngCount = UBound(varParam)
                For lngItem = 0& To lngCount
                    oleTyp(lngItem) = VarType(varParam(lngItem))
                    olePtr(lngItem) = VarPtr(varParam(lngItem))
                Next
            End If
            If DispCallFunc(pInterface, lngCmd * 4, CC_STDCALL, vbLong, lngItem, VarPtr(oleTyp(0)), VarPtr(olePtr(0)), varRet) <> S_OK Then
                'Debug.Print "Fehler beim Aufrufen der Interface-Funktion!"
            End If
    
    '        If varRet <> S_OK Then
    '            Debug.Print "0x" & Hex$(varRet)
    '        End If
        End If
        OleInvoke = varRet
    End Function

  32. #72
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,407

    Re: Identify computer

    Your code works here. (I almost completed it but the IDE crashed so no code survived.)

    Once you have mISystemIdentificationStatics you populate mISystemIdentificationInfo by invoking get_SystemIdForPublisher = 6.

    Once you have mISystemIdentificationInfo invoke get_Source = 7 (return long) and get_Id = 6 (returns IBuffer reference).

    To convert this IBuffer to hex you have to acquire CryptographicBuffer statics by calling GetActivationFactory for "Windows.Security.Cryptography.CryptographicBuffer"

    Once you have pCryptoBuf you can invoke EncodeToHexString = 12 for the IBuffer reference and receive an hString.

    Use WindowsGetStringRawBuffer on this hString to get raw LPSTR which you have numerous ways to convert to VB's native String (i.e. BSTR).

    cheers,
    </wqw>

  33. #73
    Frenzied Member VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    1,886

    Lightbulb Re: Identify computer

    Quote Originally Posted by Eduardo- View Post
    Hello. I'm trying to convert the C++ code for GetSystemIdForPublisher from Raymond Chen's page but I don't get the right rationale in the logic.
    Usually it's more intuitive to convert the C# code rather than C++ although in this case they are almost the same. Also by declaring variables as "IUnknown" instead of "Long" they will be released automatically when going out of scope so you won't need a separate "Release" function.

    Franky's code is as good a starting point as any but his usage of both an "Invoke" and "OleInvoke" functions can be optimized a lot since you want to squeeze as much performance as possible from the already slow "DispCallFunc"...

    You will need to install the Windows SDK if you want any of this to make sense. For example you can find the "EncodeToHexString" method as well as the IID for the "ICryptographicBufferStatics" interface in the "windows.security.cryptography.idl" file from the SDK:

    Code:
                [uuid(320B7E22-3CB0-4CDF-8663-1D28910065EB)]
                interface ICryptographicBufferStatics : IInspectable
                {
                    HRESULT Compare([in] Windows.Storage.Streams.IBuffer* object1, [in] Windows.Storage.Streams.IBuffer* object2, [out] [retval] boolean* isEqual);
                    HRESULT GenerateRandom([in] UINT32 length, [out] [retval] Windows.Storage.Streams.IBuffer** buffer);
                    HRESULT GenerateRandomNumber([out] [retval] UINT32* value);
                    HRESULT CreateFromByteArray([in] UINT32 __valueSize, [in] [size_is(__valueSize)] BYTE* value, [out] [retval] Windows.Storage.Streams.IBuffer** buffer);
                    HRESULT CopyToByteArray([in] Windows.Storage.Streams.IBuffer* buffer, [out] UINT32* __valueSize, [out] [size_is(, *__valueSize)] BYTE** value);
                    HRESULT DecodeFromHexString([in] HSTRING value, [out] [retval] Windows.Storage.Streams.IBuffer** buffer);
                    HRESULT EncodeToHexString([in] Windows.Storage.Streams.IBuffer* buffer, [out] [retval] HSTRING* value);
                    HRESULT DecodeFromBase64String([in] HSTRING value, [out] [retval] Windows.Storage.Streams.IBuffer** buffer);
                    HRESULT EncodeToBase64String([in] Windows.Storage.Streams.IBuffer* buffer, [out] [retval] HSTRING* value);
                    HRESULT ConvertStringToBinary([in] HSTRING value, [in] Windows.Security.Cryptography.BinaryStringEncoding encoding, [out] [retval] Windows.Storage.Streams.IBuffer** buffer);
                    HRESULT ConvertBinaryToString([in] Windows.Security.Cryptography.BinaryStringEncoding encoding, [in] Windows.Storage.Streams.IBuffer* buffer, [out] [retval] HSTRING* value);
                }
    That's what I used to whip up the example above (in post #67).

  34. #74
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,407

    Re: Identify computer

    Btw, C++ code is actually just two lines of code (can be abbreviated to a single line) which I left as comments in #68

    First auto id = Windows::System::Profile::SystemIdentification::GetSystemIdForPublisher()->Id;

    Then just auto asHex = Windows::Security::Cryptography::CryptographicBuffer::EncodeToHexString(id);

    Unfortunately with manual DispCallFunc method calls and manual reference management and manual instantiation and manual string management the code explodes in VBx incl. all the helper functions and class names and IIDs and consts.

    cheers,
    </wqw>

  35. #75
    Frenzied Member VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    1,886

    Wink Re: Identify computer

    Yeah but if you have the necessary know-how you could encapsulate all this in a small TLB and then the VB6 code will be as short as the C++ code! Not sure if this is worth the hassle though.

  36. #76

    Thread Starter
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,240

    Re: Identify computer

    Thanks guys, I'll continue later.

  37. #77

    Thread Starter
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,240

    Re: Identify computer

    I've tested code from VanGoghGaming's post #67 and wqweto's post #68 and both return the ID. Thanks a lot .

    I was thinking if the source is 1 or 2 use that ID, otherwise maybe is not a good ID and use a fallback instead? I need a fallback anyway to support older OSs, like Windows 7.

    Anyone has a virtual machine to check if the ID that the code returns from the virtual machine is the same that from the normal Windows in the same PC or not?

  38. #78
    Frenzied Member VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    1,886

    Re: Identify computer

    I tested it in a VMWare virtual machine with Windows 10. The source was 2 (UEFI) and the code was obviously different from the host machine. However the code is identical on a clone of this virtual machine (VMs have an option to clone themselves as many times as you want and those clones can be distributed to others).

    I told you above that for virtual machines this code needs to be hashed together with the MACAddress and ProcessorId. This will address the cloning issue if it's considered a problem.

  39. #79

    Thread Starter
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,240

    Re: Identify computer

    Quote Originally Posted by VanGoghGaming View Post
    ProcessorId
    I found that with WMI code it is too slow to get the ProcessorId, and could not make to work properly the GetCPUIDInfo function from the Trick.

    This is my code (not working):

    Code:
    Option Explicit
    
    Private Declare Function VirtualAlloc Lib "kernel32" (ByVal lpAddress As Long, ByVal dwSize As Long, ByVal flAllocationType As Long, ByVal flProtect As Long) As Long
    Private Declare Function VirtualFree Lib "kernel32" (ByVal lpAddress As Long, ByVal dwSize As Long, ByVal dwFreeType As Long) As Long
    Private Declare Function GetMem8 Lib "msvbvm60.dll" (ByRef Src As Currency, ByVal Dest As Long) As Long
    Private Declare Function DispCallFunc Lib "oleaut32" (ByVal PPV As Long, ByVal oVft As Long, ByVal cc As Long, ByVal rtTYP As VbVarType, ByVal paCNT As Long, ByVal paTypes As Long, ByVal paValues As Long, ByRef fuReturn As Variant) As Long
    
    
    Private Function GetCPUIDInfo( _
                     ByRef bData() As Byte) As Boolean
        Dim pCode       As Long
        Dim types()     As Integer
        Dim list()      As Long
        Dim param()     As Variant
        Const MEM_COMMIT As Long = &H1000&
        Const MEM_RESERVE As Long = &H2000&
        Const PAGE_EXECUTE_READWRITE As Long = &H40&
        Const CC_STDCALL As Long = 4&
        Const MEM_RELEASE As Long = &H8000&
        
        pCode = VirtualAlloc(0&, &H1000, MEM_COMMIT Or MEM_RESERVE, PAGE_EXECUTE_READWRITE)
        If pCode = 0 Then Exit Function
        
        GetMem8 -842598367924536.4653@, ByVal pCode
        GetMem8 -857273203654571.5132@, ByVal pCode + 8
        GetMem8 88933012021608.5599@, ByVal pCode + &H10
        GetMem8 3762050.5183@, ByVal pCode + &H18
        
        ReDim bData(&H20 - 1)
        ReDim types(1)
        ReDim list(1)
        ReDim param(1)
        
        param(0) = VarPtr(bData(0)):    param(1) = 0&
        types(0) = vbLong:              types(1) = vbLong
        list(0) = VarPtr(param(0)):     list(1) = VarPtr(param(1))
        
        DispCallFunc 0, pCode, CC_STDCALL, vbEmpty, 2, VarPtr(types(0)), VarPtr(list(0)), Null
        
        param(0) = VarPtr(bData(&H10)): param(1) = 1&
        
        DispCallFunc 0, pCode, CC_STDCALL, vbEmpty, 2, VarPtr(types(0)), VarPtr(list(0)), Null
        
        VirtualFree pCode, 0, MEM_RELEASE
        
        GetCPUIDInfo = True
        
    End Function
    
    Private Sub Form_Load()
        Dim b() As Byte
        Dim s As String
        
        GetCPUIDInfo b
        s = StrConv(b, vbUnicode)
        Debug.Print s
        Stop
    End Sub
    It also seems to be the case that the ProcessorId is shared by entire families of processors, so I think some other data like the mobo_model/BIOS_date could be good to be added too, besides SystemIdForPublisher&MACAddress&ProcessorID

  40. #80
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,407

    Re: Identify computer

    It's legally dubious to use VM clones with the same Windows product activation key. That was the reason why binding your activation scheme to Windows activation by using same source data/blob/hash used for Windows activation make a lot of sense.

    Admins cannot mindlessly clone and distribute Windows VMs without considering OS level activation unless they don't care which means they won't care for your product activation too which generally means you can do nothing to prevent piracy as they usually have more time and resources to crack anything you throw at them.

    cheers,
    </wqw>

Page 2 of 3 FirstFirst 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width