zoukankan      html  css  js  c++  java
  • Windows Product Key还原 CDKey

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion 的"digitalProductId" 作为输入 
    void DecodeProductKey(unsigned char * digitalProductId, int dsize)
    {
        // Offset of first byte of encoded product key in 
        // 'DigitalProductIdxxx" REG_BINARY value. Offset = 34H.
        const int keyStartIndex = 52;
        // Offset of last byte of encoded product key in 
        // 'DigitalProductIdxxx" REG_BINARY value. Offset = 43H.
        const int keyEndIndex = keyStartIndex + 15;
        // Possible alpha-numeric characters in product key.
        const char *digits="BCDFGHJKMPQRTVWXY2346789";
        // Length of decoded product key
        const int decodeLength = 29;
        // Length of decoded product key in byte-form.
        // Each byte represents 2 chars.
        const int decodeStringLength = 15;
        // Array of containing the decoded product key.
        unsigned char * decodedChars = new unsigned char[decodeLength+1];
        
        // Extract byte 52 to 67 inclusive.
        unsigned char * hexPid = new unsigned char[15];
        int n=0;
        int i;
        for (i = keyStartIndex; i <= keyEndIndex; i++)
        {
            hexPid[n]=(digitalProductId[i]);
            n++;
        }
        for (i = decodeLength - 1; i >= 0; i--)
        {
            // Every sixth char is a separator.
            if ((i + 1) % 6 == 0)
            {
                decodedChars[i] = '-';
            }
            else
            {
                // Do the actual decoding.
                int digitMapIndex = 0;
                for (int j = decodeStringLength - 1; j >= 0; j--)
                {
                    int byteValue = (digitMapIndex << 8) | (unsigned char)hexPid[j];
                    hexPid[j] = (unsigned char)(byteValue / 24);
                    digitMapIndex = byteValue % 24;
                    decodedChars[i] = digits[digitMapIndex];
                }
                
            }
        }
        //让字符串正常结束
        decodedChars[decodeLength]=NULL;
        printf("Window 密钥:%s/n",decodedChars);
        delete hexPid;
        delete decodedChars;
    }
  • 相关阅读:
    ng4中碰到的问题以及原因
    微信小程序安卓固定弹窗中textarea的placeholder会被弹出去
    微信小程序movable-view移动图片和双指缩放
    微信小程序滑动删除(真机测试)
    C语言编程100例JavaScript版(0~20)
    spring boot上传图片至七牛云服务器做存储
    spring boot 打包部署到tomcat上
    Uncaught SyntaxError: Unexpected token <
    在eclipse里新建一个maven工程,使用spring boot框架
    将一个数组展为树形结构的数据并将其展示在页面上
  • 原文地址:https://www.cnblogs.com/ahuo/p/2538518.html
Copyright © 2011-2022 走看看