Example #1
0
        private ProductSuite GetProductSuite(Kernel32.OSVERSIONINFOEX osVersion)
        {
            ProductSuite suite = (ProductSuite)osVersion.SuiteMask;

            // Query system metrics to detect other sku data...
            if (SystemMetrics.GetSystemMetric(SystemMetric.TabletPC) != 0)
            {
                suite |= ProductSuite.TabletPC;
            }

            if (SystemMetrics.GetSystemMetric(SystemMetric.MediaCenter) != 0)
            {
                suite |= ProductSuite.MediaCenter;
            }

            if (SystemMetrics.GetSystemMetric(SystemMetric.StarterEdition) != 0)
            {
                suite |= ProductSuite.StarterEdition;
            }

            if (SystemMetrics.GetSystemMetric(SystemMetric.ServerR2) != 0)
            {
                suite |= ProductSuite.ServerR2;
            }

            return(suite);
        }
Example #2
0
 /// <inheritdoc cref="RtlGetVersion(ref Kernel32.OSVERSIONINFO)"/>
 public static unsafe NTSTATUS RtlGetVersion(ref Kernel32.OSVERSIONINFOEX versionInformation)
 {
     fixed(Kernel32.OSVERSIONINFOEX *versionInformationLocal = &versionInformation)
     {
         return(RtlGetVersion(versionInformationLocal));
     }
 }
Example #3
0
        private Win32.Kernel32.OSVERSIONINFOEX GetOSVersion()
        {
            Kernel32.OSVERSIONINFOEX versionInfo = new Kernel32.OSVERSIONINFOEX();
            versionInfo.Size = Marshal.SizeOf(typeof(Kernel32.OSVERSIONINFOEX));

            if (!Kernel32.GetVersionEx(ref versionInfo))
            {
                throw new Win32Exception();
            }

            return(versionInfo);
        }
Example #4
0
        /// <summary>
        /// Initializes a new instance of this class.
        /// </summary>
        private SystemInformation()
        {
            osVersionInfo    = GetOSVersion();
            product          = GetProduct(osVersionInfo);
            productSuite     = GetProductSuite(osVersionInfo);
            vistaProductType = GetVistaProductType(osVersionInfo);

            // calculate the build revision number by examining the file version of kernel32.dll
            // Environment.SpecialFolder.System
            string kernel32Path = Environment.GetFolderPath(Environment.SpecialFolder.System) + "\\kernel32.dll";

            kernel32Version = FileVersionInfo.GetVersionInfo(kernel32Path);
        }
Example #5
0
        private VistaProductType GetVistaProductType(Kernel32.OSVERSIONINFOEX osVersion)
        {
            VistaProductType vistaProduct = VistaProductType.None;

            // if this is a vista or longhorn install, call the new GetProductInfo API to retreive SKU data...
            if (osVersion.MajorVersion >= 6)
            {
                int productType = 0;
                if (Kernel32.GetProductInfo(osVersion.MajorVersion, osVersion.MinorVersion, osVersion.ServicePackMajor, osVersion.ServicePackMinor, ref productType) != 0)
                {
                    if (productType != 0)
                    {
                        vistaProduct = (VistaProductType)productType;
                    }
                    else
                    {
                        vistaProduct = VistaProductType.StorageEnterpriseServer;
                    }
                }
            }

            return(vistaProduct);
        }
Example #6
0
        private Product GetProduct(Kernel32.OSVERSIONINFOEX osVersion)
        {
            Product product = Product.None;

            //Get the product
            switch (osVersion.MajorVersion)
            {
            case 4:
                product = Product.WindowsNT4;
                break;

            case 5:
                switch (osVersion.MinorVersion)
                {
                case 0:
                    product = Product.Windows2000;
                    break;

                case 1:
                    product = Product.WindowsXP;
                    break;

                case 2:
                    //Windows XP x64 actually has version 5.2
                    if (OSProductType != OSProductType.Workstation)
                    {
                        product = Product.WindowsServer2003;
                    }
                    else
                    {
                        product = Product.WindowsXP;
                    }
                    break;

                default:
                    product = Product.None;
                    break;
                }
                break;

            case 6:
                switch (osVersion.MinorVersion)
                {
                case 0:
                    //Both Vista and LH Server have major version 6. "LH Server" is Windows Server 2008.
                    if (OSProductType == OSProductType.Workstation && Environment.OSVersion.Platform == PlatformID.Win32NT)
                    {
                        product = Product.WindowsVista;
                    }
                    else
                    {
                        product = Product.LHServer;
                    }
                    break;

                case 1:
                    if (OSProductType == OSProductType.Workstation && Environment.OSVersion.Platform == PlatformID.Win32NT)
                    {
                        product = Product.Windows7;
                    }
                    else
                    {
                        product = Product.WindowsServer2008R2;
                    }
                    break;

                case 2:
                    product = Product.Windows8;
                    break;
                }
                break;

            default:
                product = Product.None;
                break;
            }

            return(product);
        }