summaryrefslogtreecommitdiff
path: root/WinKeyRecover/KeyChecker/GetProductDescription.cs
blob: 3a42418c04acfab806e49eae24bea199db050d53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;

namespace WinKeyRecover
{
    internal class GetProductDescription
    {
        public string Get(string aid, string fileXml)
        {
            XmlDocument xmlDocument = new XmlDocument();
            xmlDocument.Load(fileXml);
            Stream inStream = new MemoryStream(Convert.FromBase64String(xmlDocument.GetElementsByTagName("tm:infoBin")[0].InnerText));
            xmlDocument.Load(inStream);
            XmlNamespaceManager xmlNamespaceManager = new XmlNamespaceManager(xmlDocument.NameTable);
            xmlNamespaceManager.AddNamespace("pkc", "http://www.microsoft.com/DRM/PKEY/Configuration/2.0");
            XmlNode xmlNode = xmlDocument.SelectSingleNode("/pkc:ProductKeyConfiguration/pkc:Configurations/pkc:Configuration[pkc:ActConfigId='" + aid + "']", xmlNamespaceManager);
            if (xmlNode == null)
            {
                xmlNode = xmlDocument.SelectSingleNode("/pkc:ProductKeyConfiguration/pkc:Configurations/pkc:Configuration[pkc:ActConfigId='" + aid.ToUpper() + "']", xmlNamespaceManager);
            }
            return xmlNode.ChildNodes.Item(3).InnerText;
        }
    }
}