Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > Coding Releases > Coding Snippets
You last visited: Today at 06:26

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[C#] HWID Generator [based on epvp's algo]

Discussion on [C#] HWID Generator [based on epvp's algo] within the Coding Snippets forum part of the Coding Releases category.

Reply
 
Old   #1



 
Shawak's Avatar
 
elite*gold: 0
The Black Market: 259/0/0
Join Date: Apr 2010
Posts: 10,289
Received Thanks: 3,613
[C#] HWID Generator [based on epvp's algo]

Code:
/* HWID generator lib for C# [based on epvp's algo]
 * By Shawak - 30.03.2014
 */

using System;
using System.Text;
using System.Security.Cryptography;
using System.Runtime.InteropServices;

public class HWID
{
    [Flags()]
    private enum DockInfo
    {
        DOCKINFO_DOCKED = 0x2,
        DOCKINFO_UNDOCKED = 0x1,
        DOCKINFO_USER_SUPPLIED = 0x4,
        DOCKINFO_USER_DOCKED = 0x5,
        DOCKINFO_USER_UNDOCKED = 0x6
    }

    [StructLayout(LayoutKind.Sequential)]
    private class HW_PROFILE_INFO
    {
        [MarshalAs(UnmanagedType.U4)]
        public Int32 dwDockInfo;

        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 39)]
        public string szHwProfileGuid;

        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)]
        public string szHwProfileName;
    }

    [DllImport("advapi32.dll", SetLastError = true)]
    private static extern bool GetCurrentHwProfile(IntPtr lpHwProfileInfo);
    [DllImport("kernel32", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
    private static extern long GetVolumeInformationA(string PathName, StringBuilder VolumeNameBuffer, Int32 VolumeNameSize, ref Int32 VolumeSerialNumber, ref Int32 MaximumComponentLength, ref Int32 FileSystemFlags, StringBuilder FileSystemNameBuffer, Int32 FileSystemNameSize);

    private static HW_PROFILE_INFO ProfileInfo()
    {
        HW_PROFILE_INFO profile = null;
        IntPtr profilePtr = IntPtr.Zero;
        try
        {
            profile = new HW_PROFILE_INFO();
            profilePtr = Marshal.AllocHGlobal(Marshal.SizeOf(profile));
            Marshal.StructureToPtr(profile, profilePtr, false);

            if (!GetCurrentHwProfile(profilePtr))
            {
                throw new Exception("Error cant get current hw profile!");
            }
            else
            {
                Marshal.PtrToStructure(profilePtr, profile);
                return profile;
            }
        }
        catch (Exception e)
        {
            throw new Exception(e.ToString());
        }
        finally
        {
            if (profilePtr != IntPtr.Zero)
            {
                Marshal.FreeHGlobal(profilePtr);
            }
        }
    }

    private static string GetVolumeSerial(string strDriveLetter)
    {
        int serNum = 0, maxCompLen = 0, VolFlags = 0;
        StringBuilder VolLabel = new StringBuilder(256), FSName = new StringBuilder(256);
        GetVolumeInformationA(strDriveLetter + ":\\", VolLabel, VolLabel.Capacity, ref serNum, ref maxCompLen, ref VolFlags, FSName, FSName.Capacity);
        return Convert.ToString(serNum);
    }

    private static string MD5(string str)
    {
        var bytes = Encoding.UTF8.GetBytes(str);
        using (var md5 = new MD5CryptoServiceProvider())
            bytes = md5.ComputeHash(bytes);
        return BitConverter.ToString(bytes).Replace("-", "").ToLower();
    }

    /// <summary>
    /// Generates the computer's HWID based on elitepvpers algorithm.
    /// </summary>
    /// <returns>Returns the computer's HWID</returns>
    public static string Generate()
    {
        var profileInfo = ProfileInfo();
        var profileGuid = profileInfo.szHwProfileGuid.ToString();
        var volumeSerial = GetVolumeSerial(Environment.SystemDirectory.Substring(0, 1));
        return MD5(profileGuid + volumeSerial);
    }

}
Will return the same hwid as mentioned here:



Regards,
Shawak
Shawak is offline  
Thanks
3 Users
Reply


Similar Threads Similar Threads
Serial Key Generator Für euer HWID System.
11/13/2012 - elite*gold Trading - 2 Replies
Hey Leute ! Ich möchte hier meinen Serial Key Generator für euer HWID System. Es Generiert einfach zufällige zahlen um formal : xxxx-xxxx-xxxx-xxxx. Diese Key's könnt ihr dann für euer HWID System benutzen. http://www.fotos-hochladen.net/uploads/unbenanntx rys2u56m4.png Treasure|Preis No permission|10E*Gold No permission|10E*Gold
HWID Generator & Dev-Tools für e*pvp's HWID System
01/28/2011 - Main - 0 Replies
Hier die Downloads passend zum News-Thread, da das Attachen von Daten an News-Threads nicht möglich ist ;) News-Thread: http://www.elitepvpers.com/forum/e-pvp-news-de/981 343-hwid-system-f-r-entwickler.html Credits für den 2. Generator gehen an Anfang! Lg, Ende!



All times are GMT +1. The time now is 06:28.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.