[C#] Decrypt Office 2010 Digital Product ID

Discussion in 'Mixed Languages' started by Josh Cell, Jul 11, 2011.

  1. Josh Cell

    Josh Cell MDL Developer

    Jan 8, 2011
    3,519
    7,100
    120
    #1 Josh Cell, Jul 11, 2011
    Last edited by a moderator: Apr 20, 2017
    Hi, Well I'm planning an update to Advanced Tokens Manager, and then came this problem;

    I found nothing about it, the more I tried did not work well :/

    formload decrypt code, this is an example

    Code:
    
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using Microsoft.Win32;
    using System.Collections;
    
    namespace Get_Office_ProductKey
    {
        public partial class PKeys : Form
        {
    
            public enum Key { Windows, XP, Office10, Office11, Office14 };
            public static byte[] GetRegistryDigitalProductId(Key key)
            {
                byte[] digitalProductId = null;
                RegistryKey registry = null;
                switch (key)
                {
                    // Open the XP subkey readonly.
                    case Key.XP:
                        registry =
                          Registry.LocalMachine.
                            OpenSubKey(
                              @"SOFTWARE\Microsoft\Windows NT\CurrentVersion",
                                false);
                        break;
                    // Open the Office 10 subkey readonly.
                    case Key.Office10:
                        registry =
                          Registry.LocalMachine.
                            OpenSubKey(
                              @"SOFTWARE\Microsoft\Office\10.0\Registration\" +
                              @"{90280409-6000-11D3-8CFE-0050048383C9}",
                              false);
                       break;
                    // Open the Office 11 subkey readonly.
                    case Key.Office11:
                       break;
                    // Open the Windows subkey readonly.
                    case Key.Windows:
                        registry =
                          Registry.LocalMachine.
                            OpenSubKey(
                              @"SOFTWARE\Microsoft\Windows NT\CurrentVersion",
                                false);
                        break;
                    // Open the Office 14 subkey readonly.
                    case Key.Office14:
                        registry =
                          Registry.LocalMachine.
                            OpenSubKey(
                              @"SOFTWARE\Microsoft\Office\14.0\Registration\" +
                              @"{90140000-0011-0000-0000-0000000FF1CE}",
                              false);
                        break;
                }
                if (registry != null)
                {
                    // TODO: For other products, key name maybe different.
                    digitalProductId = registry.GetValue("DigitalProductId")
                      as byte[];
                    registry.Close();
                }
                return digitalProductId;
            }
            public static string DecodeProductKey(byte[] digitalProductId)
            {
                // 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.
                char[] digits = new char[]
          {
            'B', 'C', 'D', 'F', 'G', 'H', 'J', 'K', 'M', 'P', 'Q', 'R', 
            'T', 'V', 'W', 'X', 'Y', '2', '3', '4', '6', '7', '8', '9',
          };
                // 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.
                char[] decodedChars = new char[decodeLength];
                // Extract byte 52 to 67 inclusive.
                ArrayList hexPid = new ArrayList();
                for (int i = keyStartIndex; i <= keyEndIndex; i++)
                {
                    hexPid.Add(digitalProductId);
                }
                for (int i = decodeLength - 1; i >= 0; i--)
                {
                    // Every sixth char is a separator.
                    if ((i + 1) % 6 == 0)
                    {
                        decodedChars = '-';
                    }
                    else
                    {
                        // Do the actual decoding.
                        int digitMapIndex = 0;
                        for (int j = decodeStringLength - 1; j >= 0; j--)
                        {
                            int byteValue = (digitMapIndex << 8) | (byte)hexPid[j];
                            hexPid[j] = (byte)(byteValue / 24);
                            digitMapIndex = byteValue % 24;
                            decodedChars = digits[digitMapIndex];
                        }
                    }
                }
                return new string(decodedChars);
            }  
       
            public PKeys()
            {
                InitializeComponent();
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
    
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                //Usage
                byte[] results = PKeys.GetRegistryDigitalProductId(PKeys.Key.Office14); // Change product here, ie: Office14, windows, XP etc..
               textBox1.Text = PKeys.DecodeProductKey(results);
            }
        }
    }
    
    
    


    Thanks for alphawaves for the code example

    By putting the code in action, displays a set of 25 characters, divided into five dashes

    The key shown is incorrect, it isn't the real key installed

    I tried it with VL keys, same problem with Retail

    With "keyfinders", is shown the correct serial

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. user_hidden

    user_hidden MDL Expert

    Dec 18, 2007
    1,026
    973
    60
    To retrieve the Office 2010 key , microsoft made a modification in binary data so you must extract the bytes range
    from 808 to 822 from REG_BINARY value of DigitalProductID at the registry path instead of the default Range from 52 to 66.
     
  3. user_hidden

    user_hidden MDL Expert

    Dec 18, 2007
    1,026
    973
    60
    #3 user_hidden, Jul 11, 2011
    Last edited by a moderator: Apr 20, 2017
    btw, MAK keys will not be listed i don't think but KMS, Retail and OEM will.
    MAK key may show default KMS key as stored in registry.
    For the above I presume CODY & Bosch made their backup tool ask the user for the key?

    here is a simple VBS code snippet:


    Code:
     
     const HKEY_LOCAL_MACHINE = &H80000002  
     strKeyPath = "SOFTWARE\Microsoft\Office\14.0\Registration\{90140000-0011-0000-0000-0000000FF1CE}"
     strValueName = "DigitalProductId" 
     strComputer = "." 
     dim iValues() 
     Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _  
           strComputer & "\root\default:StdRegProv") 
     oReg.GetBinaryValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,iValues 
     Dim arrDPID 
     arrDPID = Array() 
     For i = 808 to 822
     ReDim Preserve arrDPID( UBound(arrDPID) + 1 ) 
     arrDPID( UBound(arrDPID) ) = iValues(i) 
     Next 
    
     Dim arrChars 
     arrChars = Array("B","C","D","F","G","H","J","K","M","P","Q","R","T","V","W","X","Y","2","3","4","6","7","8","9") 
      
     For i = 24 To 0 Step -1 
     k = 0 
     For j = 14 To 0 Step -1 
      k = k * 256 Xor arrDPID(j) 
      arrDPID(j) = Int(k / 24) 
      k = k Mod 24 
     Next 
     strProductKey = arrChars(k) & strProductKey 
     If i Mod 5 = 0 And i <> 0 Then strProductKey = "-" & strProductKey 
     Next 
     strFinalKey = strProductKey 
    
     Set wshShell=CreateObject("wscript.shell") 
     strPopupMsg = "Your Microsoft Office 2010 Product Key is:" & vbNewLine & vbNewLine & strFinalKey 
     strPopupTitle = "Product Key" 
     wshShell.Popup strPopupMsg,,strPopupTitle,vbCancelOnly+vbinformation 
     WScript.Quit 
    
     
  4. CODYQX4

    CODYQX4 MDL Developer

    Sep 4, 2009
    4,801
    44,952
    150
    #4 CODYQX4, Jul 11, 2011
    Last edited by a moderator: Apr 20, 2017
    Here is a modded version of what I use. Given there can be multiple products, it returns a list as opposed to one key.
    Code:
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.IO;
    using System.Management;
    using System.Text;
    using Microsoft.Win32;
    
    namespace OfficeToolkit.Logic
    {
        public class KeyOfficePartial
        {
            public static string OfficeArchitecture;
    
            public static string GetOfficeArch()
            {
                string architecture;
                try
                {
                    RegistryKey localEnvironment = Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment");
                    String processorArchitecture = (String)localEnvironment.GetValue("PROCESSOR_ARCHITECTURE");
                    if (processorArchitecture.Equals("x86"))
                    {
                        architecture = "x86";
                    }
                    else
                    {
                        RegistryKey OfficeArchCheck = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Wow6432Node\\Microsoft\\Office\\14.0\\Common\\InstallRoot");
                        if (OfficeArchCheck != null)
                        {
                            String installPath = (String)OfficeArchCheck.GetValue("Path");
                            if (installPath != null && installPath.Length > 0)
                                architecture = "x86-64";
                            else
                                architecture = "x64";
                        }
                        else
                        {
                            architecture = "x64";
                        }
                    }
                }
                catch (Exception ex)
                {
                    ex.GetType();
                    architecture = string.Empty;
                }
    
                return architecture;
            }
            public static List<string> GetKeysFromRegistry()
            {
                List<string> DetectedKeys = new List<string>();
                OfficeArchitecture = GetOfficeArch();
    
                string RegistrationPath;
                string FullRegistryPath;
                if (Common.OfficeArchitecture != "x86-64")
                {
                    RegistrationPath = "SOFTWARE\\Microsoft\\Office\\14.0\\Registration";
                }
                else
                {
                    RegistrationPath = "SOFTWARE\\Wow6432Node\\Microsoft\\Office\\14.0\\Registration";
                }
    
    
                RegistryKey registry = Registry.LocalMachine.OpenSubKey(RegistrationPath, false);
                foreach (string SubKeyName in registry.GetSubKeyNames())
                {
                    RegistryKey registryfull = Registry.LocalMachine.OpenSubKey(RegistrationPath + "\\" + SubKeyName, false);
                    if (registryfull.GetValue("DigitalProductID") != null)
                    {
                        FullRegistryPath = RegistrationPath + "\\" + SubKeyName;
                        DetectedKeys.Add(DecodeProductKey(GetRegistryDigitalProductId(FullRegistryPath)));
                    }
                }
    
                return DetectedKeys;
            }
    
            public static byte[] GetRegistryDigitalProductId(string RegistryPath)
            {
                byte[] digitalProductId = null;
                RegistryKey registry = Registry.LocalMachine.OpenSubKey(RegistryPath, false);
    
                if (registry != null)
                {
                    digitalProductId = registry.GetValue("DigitalProductID") as byte[];
                    registry.Close();
                }
                return digitalProductId;
            }
            public static string DecodeProductKey(byte[] digitalProductId)
            {
                const int keyStartIndex = 0x328;
                const int keyEndIndex = keyStartIndex + 15;
    
                // Possible alpha-numeric characters in product key.
                char[] digits = new char[]
                {
                  'B', 'C', 'D', 'F', 'G', 'H', 'J', 'K', 'M', 'P', 'Q', 'R', 
                  'T', 'V', 'W', 'X', 'Y', '2', '3', '4', '6', '7', '8', '9',
                };
    
                // 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.
                char[] decodedChars = new char[decodeLength];
    
                // Extract byte 52 to 67 inclusive.
                ArrayList hexPid = new ArrayList();
                for (int i = keyStartIndex; i <= keyEndIndex; i++)
                {
                    hexPid.Add(digitalProductId);
                }
                for (int i = decodeLength - 1; i >= 0; i--)
                {
                    // Every sixth char is a separator.
                    if ((i + 1) % 6 == 0)
                    {
                        decodedChars = '-';
                    }
                    else
                    {
                        // Do the actual decoding.
                        int digitMapIndex = 0;
                        for (int j = decodeStringLength - 1; j >= 0; j--)
                        {
                            int byteValue = (digitMapIndex << 8) | (byte)hexPid[j];
                            hexPid[j] = (byte)(byteValue / 24);
                            digitMapIndex = byteValue % 24;
                            decodedChars = digits[digitMapIndex];
                        }
                    }
                }
                return new string(decodedChars);
            }
    
        }
    }
    


    One thing to keep in mind in case you are heavily dependent on the key: The key might not be in the registry, as only if it has been entered in the setup.exe will it enter the registry. So if you install VL and use a MAK, the registry is KMS unless you entered the MAK in setup for office (not any tool/script/ospp.vbs).


    Basically what I do, is I use WMI (WMICodeCreator) to get the last 5 digits of an installed key and see if it in in the list. If not I prompt the user for the key. I use a shortcut in that I know if it is KMS that I know the key and save it but it relies on a lot of code used for multiple purposes.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. CODYQX4

    CODYQX4 MDL Developer

    Sep 4, 2009
    4,801
    44,952
    150
    Another thing in your source is it will only get VL Key for one product on one architecture. The key is different for every product, this varies further with OS Architecture and whether it is VL or Retail. But my source will get whatever is there no matter what. Just regard what I said about the registry key not necessarily being the one in use or even there.

    You can get last 5 digits via WMI and make use of that however necessary, like what I said about comparing the list. In my backup I save all keys, and reinstall them.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. Josh Cell

    Josh Cell MDL Developer

    Jan 8, 2011
    3,519
    7,100
    120
    #6 Josh Cell, Jul 12, 2011
    Last edited by a moderator: Apr 20, 2017
    (OP)


    Thanks user_hidden and CODY, I worked to adapt the code, currently running, thanks for aphawaves for logical interpretations

    Code:
    
            public enum Key { Windows, Office };
            public static byte[] GetRegistryDigitalProductId(Key key)
            {
                byte[] digitalProductId = null;
                RegistryKey registry = null;
                switch (key)
                {
                    // Open the Windows subkey readonly.
                    case Key.Windows:
                        registry =
                          Registry.LocalMachine.
                            OpenSubKey(
                              @"SOFTWARE\Microsoft\Windows NT\CurrentVersion",
                                false);
                        break;
                    case Key.Office:
                        registry =
                          Registry.LocalMachine.
                            OpenSubKey(
                              @"SOFTWARE\Microsoft\Office\14.0\Registration\" +
                              @"{90140000-0011-0000-0000-0000000FF1CE}",
                              false);
                        break;
                }
                if (registry != null)
                {
                    // TODO: For other products, key name maybe different.
                    digitalProductId = registry.GetValue("DigitalProductId")
                      as byte[];
                    registry.Close();
                }
                return digitalProductId;
            }
            public static string DecodeWindowsProductKey(byte[] digitalProductId)
            {
                // 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.
                char[] digits = new char[]
          {
            'B', 'C', 'D', 'F', 'G', 'H', 'J', 'K', 'M', 'P', 'Q', 'R', 
            'T', 'V', 'W', 'X', 'Y', '2', '3', '4', '6', '7', '8', '9',
          };
                // 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.
                char[] decodedChars = new char[decodeLength];
                // Extract byte 52 to 67 inclusive.
                ArrayList hexPid = new ArrayList();
                for (int i = keyStartIndex; i <= keyEndIndex; i++)
                {
                    hexPid.Add(digitalProductId);
                }
                for (int i = decodeLength - 1; i >= 0; i--)
                {
                    // Every sixth char is a separator.
                    if ((i + 1) % 6 == 0)
                    {
                        decodedChars = '-';
                    }
                    else
                    {
                        // Do the actual decoding.
                        int digitMapIndex = 0;
                        for (int j = decodeStringLength - 1; j >= 0; j--)
                        {
                            int byteValue = (digitMapIndex << 8) | (byte)hexPid[j];
                            hexPid[j] = (byte)(byteValue / 24);
                            digitMapIndex = byteValue % 24;
                            decodedChars = digits[digitMapIndex];
                        }
                    }
                }
                return new string(decodedChars);
            }
            public static string DecodeOfficeProductKey(byte[] digitalProductId)
            {
                const int keyStartIndex = 0x328;
                const int keyEndIndex = keyStartIndex + 15;
    
                // Possible alpha-numeric characters in product key.
                char[] digits = new char[]
                {
                  'B', 'C', 'D', 'F', 'G', 'H', 'J', 'K', 'M', 'P', 'Q', 'R', 
                  'T', 'V', 'W', 'X', 'Y', '2', '3', '4', '6', '7', '8', '9',
                };
    
                // 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.
                char[] decodedChars = new char[decodeLength];
    
                // Extract byte 52 to 67 inclusive.
                ArrayList hexPid = new ArrayList();
                for (int i = keyStartIndex; i <= keyEndIndex; i++)
                {
                    hexPid.Add(digitalProductId);
                }
                for (int i = decodeLength - 1; i >= 0; i--)
                {
                    // Every sixth char is a separator.
                    if ((i + 1) % 6 == 0)
                    {
                        decodedChars = '-';
                    }
                    else
                    {
                        // Do the actual decoding.
                        int digitMapIndex = 0;
                        for (int j = decodeStringLength - 1; j >= 0; j--)
                        {
                            int byteValue = (digitMapIndex << 8) | (byte)hexPid[j];
                            hexPid[j] = (byte)(byteValue / 24);
                            digitMapIndex = byteValue % 24;
                            decodedChars = digits[digitMapIndex];
                        }
                    }
                }
                return new string(decodedChars);
            }
    
    


    usage:

    Code:
    
                byte[] wresults = Form1.GetRegistryDigitalProductId(ATM.Key.Windows);
                windowslabel.Text = Form1.DecodeWindowsProductKey(wresults);
                byte[] oresults = Form1.GetRegistryDigitalProductId(ATM.Key.Office);
                officelabel.Text = Form1.DecodeOfficeProductKey(oresults);
    
    
    Thanks for the code, very helpful

    @user_hidden

    VBS code is great script :)

    Thanks for the range info.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. CODYQX4

    CODYQX4 MDL Developer

    Sep 4, 2009
    4,801
    44,952
    150
    OK just keep in mind that your changes limit it to getting only Pro Plus VL 32 Bit on 32 Bit OS.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  8. Josh Cell

    Josh Cell MDL Developer

    Jan 8, 2011
    3,519
    7,100
    120
    #8 Josh Cell, Jul 12, 2011
    Last edited by a moderator: Apr 20, 2017
    (OP)
    Hmm

    Updated code

    Code:
    
            public enum Key { Windows, Office, OfficeWOW };
            public static byte[] GetRegistryDigitalProductId(Key key)
            {
                byte[] digitalProductId = null;
                RegistryKey registry = null;
                switch (key)
                {
                    // Open the Windows subkey readonly.
                    case Key.Windows:
                        registry =
                          Registry.LocalMachine.
                            OpenSubKey(
                              @"SOFTWARE\Microsoft\Windows NT\CurrentVersion",
                                false);
                        break;
                    case Key.Office:
                        registry =
                          Registry.LocalMachine.
                            OpenSubKey(
                              @"SOFTWARE\Microsoft\Office\14.0\Registration\" +
                              @"{90140000-0011-0000-0000-0000000FF1CE}",
                              false);
                        break;
                    case Key.OfficeWOW:
                        registry =
                          Registry.LocalMachine.
                            OpenSubKey(
                              @"SOFTWARE\Wow6432Node\Microsoft\Office\14.0\Registration\" +
                              @"{90140000-0011-0000-0000-0000000FF1CE}",
                              false);
                        break;
                }
                if (registry != null)
                {
                    // TODO: For other products, key name maybe different.
                    digitalProductId = registry.GetValue("DigitalProductId")
                      as byte[];
                    registry.Close();
                }
                return digitalProductId;
            }
            public static string DecodeWindowsProductKey(byte[] digitalProductId)
            {
                // 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.
                char[] digits = new char[]
          {
            'B', 'C', 'D', 'F', 'G', 'H', 'J', 'K', 'M', 'P', 'Q', 'R', 
            'T', 'V', 'W', 'X', 'Y', '2', '3', '4', '6', '7', '8', '9',
          };
                // 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.
                char[] decodedChars = new char[decodeLength];
                // Extract byte 52 to 67 inclusive.
                ArrayList hexPid = new ArrayList();
                for (int i = keyStartIndex; i <= keyEndIndex; i++)
                {
                    hexPid.Add(digitalProductId);
                }
                for (int i = decodeLength - 1; i >= 0; i--)
                {
                    // Every sixth char is a separator.
                    if ((i + 1) % 6 == 0)
                    {
                        decodedChars = '-';
                    }
                    else
                    {
                        // Do the actual decoding.
                        int digitMapIndex = 0;
                        for (int j = decodeStringLength - 1; j >= 0; j--)
                        {
                            int byteValue = (digitMapIndex << 8) | (byte)hexPid[j];
                            hexPid[j] = (byte)(byteValue / 24);
                            digitMapIndex = byteValue % 24;
                            decodedChars = digits[digitMapIndex];
                        }
                    }
                }
                return new string(decodedChars);
            }
            public static string DecodeOfficeProductKey(byte[] digitalProductId)
            {
                const int keyStartIndex = 0x328;
                const int keyEndIndex = keyStartIndex + 15;
    
                // Possible alpha-numeric characters in product key.
                char[] digits = new char[]
                {
                  'B', 'C', 'D', 'F', 'G', 'H', 'J', 'K', 'M', 'P', 'Q', 'R', 
                  'T', 'V', 'W', 'X', 'Y', '2', '3', '4', '6', '7', '8', '9',
                };
    
                // 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.
                char[] decodedChars = new char[decodeLength];
    
                // Extract byte 52 to 67 inclusive.
                ArrayList hexPid = new ArrayList();
                for (int i = keyStartIndex; i <= keyEndIndex; i++)
                {
                    hexPid.Add(digitalProductId);
                }
                for (int i = decodeLength - 1; i >= 0; i--)
                {
                    // Every sixth char is a separator.
                    if ((i + 1) % 6 == 0)
                    {
                        decodedChars = '-';
                    }
                    else
                    {
                        // Do the actual decoding.
                        int digitMapIndex = 0;
                        for (int j = decodeStringLength - 1; j >= 0; j--)
                        {
                            int byteValue = (digitMapIndex << 8) | (byte)hexPid[j];
                            hexPid[j] = (byte)(byteValue / 24);
                            digitMapIndex = byteValue % 24;
                            decodedChars = digits[digitMapIndex];
                        }
                    }
                }
                return new string(decodedChars);
            }
    
    


    Usage

    Code:
                //for any Windows Platform
                byte[] wresults = Form1.GetRegistryDigitalProductId(ATM.Key.Windows);
                windowslabel.Text = Form1.DecodeWindowsProductKey(wresults);
                //for x86 office on x86 systems, and x64 office on x64 systems
                byte[] oresults = Form1.GetRegistryDigitalProductId(ATM.Key.Office);
                officelabel.Text = Form1.DecodeOfficeProductKey(oresults);
                //for x86 office on x64 systems
                byte[] owowresults = Form1.GetRegistryDigitalProductId(ATM.Key.OfficeWOW);
                officelabel.Text = Form1.DecodeOfficeProductKey(oresults);
    
    
    :D
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  9. Josh Cell

    Josh Cell MDL Developer

    Jan 8, 2011
    3,519
    7,100
    120
    This is method works on Retail licences?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  10. CODYQX4

    CODYQX4 MDL Developer

    Sep 4, 2009
    4,801
    44,952
    150
    Take a look at my code. I have it set to choose the path to the "registration" key based on whether it is WOW (like your code) or normal place. I then loop through all subkeys looking for digitalproductid. You simply post the {90... part for one product (as in it is different code for different product, or even if the product is 32/64 or VL/Retail.

    What you could do is use my means and make the key output box a selection list that shows all the keys in the list (in my code a list is returned but you have edited that out).
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  11. Josh Cell

    Josh Cell MDL Developer

    Jan 8, 2011
    3,519
    7,100
    120
    #11 Josh Cell, Jul 22, 2011
    Last edited by a moderator: Apr 20, 2017
    (OP)


    Cody, can you tell how to use your code?

    I'm having problems with my code, because DigitalProductID isn't in the same key in other Office builds

    I added your code on my assembly as Logic.cs, and changed the Namespace to Logic, class is KeyOfficePartial...

    It is missing just like decode product key...
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  12. CODYQX4

    CODYQX4 MDL Developer

    Sep 4, 2009
    4,801
    44,952
    150
    Well my code only works on 2010 and puts the keys in a list. Try using it the way it was posted, and get the list it returns, and display the first thing in the list if anything.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  13. Josh Cell

    Josh Cell MDL Developer

    Jan 8, 2011
    3,519
    7,100
    120
    #13 Josh Cell, Jul 22, 2011
    Last edited by a moderator: Apr 20, 2017
    (OP)
    Ok, more like I will apply within the code?

    I tried these forms can not decode product key;
    Code:
                List<string> serial = new List<string>();
                serial = Logic.KeyOfficePartial.GetRegistryDigitalProductId(KeyOfficePartial.GetKeysFromRegistry);
                textbox1.Text = Logic.KeyOfficePartial.DecodeProductKey(serial);
    Based in my code structure

    Code:
                    byte[] oresults = ATM.GetRegistryDigitalProductId(ATM.Key.OfficeWOW);
                         textbox1.Text = ATM.DecodeOfficeProductKey(oresults);
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  14. CODYQX4

    CODYQX4 MDL Developer

    Sep 4, 2009
    4,801
    44,952
    150
    #14 CODYQX4, Jul 23, 2011
    Last edited by a moderator: Apr 20, 2017
    Well the textbox.Text is supposed to get a string, not a list of strings, so you want to check if the list is empty, if not, then pass the first value to it like serial[0] (like an array).
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  15. Josh Cell

    Josh Cell MDL Developer

    Jan 8, 2011
    3,519
    7,100
    120
    I'm not getting to make it work;

    The biggest problem is search the registry key DigitalProductID, which varies from place to each build of the office ...
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  16. CODYQX4

    CODYQX4 MDL Developer

    Sep 4, 2009
    4,801
    44,952
    150
    Not sure about the non 2010 products but my original, unmodified code gets it. I see one mistake in it in that the check at Common.OfficeArchiteture needs to lose the Common. part. But you call a list<string> but you need to call the GetKeysFromRegistry() function not the others (those are helper functions). Again my code is not meant to do earlier than 2010 so keep your old code and use mine for 2010.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  17. Josh Cell

    Josh Cell MDL Developer

    Jan 8, 2011
    3,519
    7,100
    120
    I solved the problem another way, using an external program;

    Thank you for your attention.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  18. steve6341

    steve6341 MDL Novice

    Jul 25, 2011
    1
    0
    0
    Just wanted to throw my 2 cents in. I had been looking for a solution to the problem of an invalid product key being extracted...

    The blurb about
    fixed my problems.

    Just out of curiosity, how do know that or find that?!?

    Thanks
     
  19. user_hidden

    user_hidden MDL Expert

    Dec 18, 2007
    1,026
    973
    60
    by using "the force"
     
  20. Josh Cell

    Josh Cell MDL Developer

    Jan 8, 2011
    3,519
    7,100
    120
    Using brute force against the windows :p
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...