コード例 #1
0
        public static void Emit(StreamWriter m_outFile, Win32LogicalDisk aaaaa)
        {
            MemoryStream    stream1    = new MemoryStream();
            BinaryFormatter formatter1 = new BinaryFormatter();

            //			formatter1.set_AssemblyFormat(0);
            formatter1.AssemblyFormat = System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Simple;
            Console.WriteLine("Serialising the parser");

            //formatter1.Serialize(stream1, aaaaa.YxDictionAccess);
            //formatter1.Serialize(stream1, aaaaa.dictionDriveType);
            //formatter1.Serialize(stream1, aaaaa.dictionMediaType);

            stream1.Position = 0;
            int num1 = 0;

            for (int num2 = 0; num2 < stream1.Length; num2++)
            {
                int num3 = stream1.ReadByte();
                if (num1++ == 10)
                {
                    m_outFile.WriteLine();
                    num1 = 0;
                }
                m_outFile.Write("{0},", num3);
            }
            m_outFile.WriteLine("0};");
        }
コード例 #2
0
        protected override void FillFloppyDriveInfo()
        {
            ManagementObjectCollection moc = this.GetAllInfo(this.WSql);

            foreach (ManagementObject mo in moc)
            {
                Win32LogicalDisk csp = new Win32LogicalDisk();
                if (mo != null)
                {
                    csp.Access                  = GetManagementObject <ushort>(mo, "Access");
                    csp.Availability            = GetManagementObject <ushort>(mo, "Availability");
                    csp.BlockSize               = GetManagementObject <ulong>(mo, "BlockSize");
                    csp.Caption                 = GetManagementObject <string>(mo, "Caption");
                    csp.Compressed              = GetManagementObject <bool>(mo, "Compressed");
                    csp.ConfigManagerErrorCode  = GetManagementObject <uint>(mo, "ConfigManagerErrorCode");
                    csp.ConfigManagerUserConfig = GetManagementObject <bool>(mo, "ConfigManagerUserConfig");
                    csp.CreationClassName       = GetManagementObject <string>(mo, "CreationClassName");
                    csp.Description             = GetManagementObject <string>(mo, "Description");
                    csp.DeviceID                = GetManagementObject <string>(mo, "DeviceID");
                    csp.DriveType               = GetManagementObject <uint>(mo, "DriveType");
                    csp.ErrorCleared            = GetManagementObject <bool>(mo, "ErrorCleared");
                    csp.ErrorDescription        = GetManagementObject <string>(mo, "ErrorDescription");
                    csp.ErrorMethodology        = GetManagementObject <string>(mo, "ErrorMethodology");
                    csp.FileSystem              = GetManagementObject <string>(mo, "FileSystem");
                    csp.FreeSpace               = GetManagementObject <ulong>(mo, "FreeSpace");
                    csp.Cim_InstallDate         = GetManagementObject <string>(mo, "InstallDate");
                    csp.LastErrorCode           = GetManagementObject <uint>(mo, "LastErrorCode");
                    csp.MaximumComponentLength  = GetManagementObject <uint>(mo, "MaximumComponentLength");
                    csp.MediaType               = GetManagementObject <uint>(mo, "MediaType");
                    csp.Name           = GetManagementObject <string>(mo, "Name");
                    csp.NumberOfBlocks = GetManagementObject <ulong>(mo, "NumberOfBlocks");
                    csp.PNPDeviceID    = GetManagementObject <string>(mo, "PNPDeviceID");
                    csp.PowerManagementCapabilities = GetManagementObject <ushort[]>(mo, "PowerManagementCapabilities");
                    csp.PowerManagementSupported    = GetManagementObject <bool>(mo, "PowerManagementSupported");
                    csp.ProviderName                 = GetManagementObject <string>(mo, "ProviderName");
                    csp.Purpose                      = GetManagementObject <string>(mo, "Purpose");
                    csp.QuotasDisabled               = GetManagementObject <bool>(mo, "QuotasDisabled");
                    csp.QuotasIncomplete             = GetManagementObject <bool>(mo, "QuotasIncomplete");
                    csp.QuotasRebuilding             = GetManagementObject <bool>(mo, "QuotasRebuilding");
                    csp.Size                         = GetManagementObject <ulong>(mo, "Size");
                    csp.Status                       = GetManagementObject <string>(mo, "Status");
                    csp.StatusInfo                   = GetManagementObject <ushort>(mo, "StatusInfo");
                    csp.SupportsDiskQuotas           = GetManagementObject <bool>(mo, "SupportsDiskQuotas");
                    csp.SupportsFileBasedCompression = GetManagementObject <bool>(mo, "SupportsFileBasedCompression");
                    csp.SystemCreationClassName      = GetManagementObject <string>(mo, "SystemCreationClassName");
                    csp.SystemName                   = GetManagementObject <string>(mo, "SystemName");
                    csp.VolumeDirty                  = GetManagementObject <bool>(mo, "VolumeDirty");
                    csp.VolumeName                   = GetManagementObject <string>(mo, "VolumeName");
                    csp.VolumeSerialNumber           = GetManagementObject <string>(mo, "VolumeSerialNumber");


                    ps.Add(csp);
                }
            }
            moc.Dispose();
        }
コード例 #3
0
        static void cMain(string[] args)
        {
            StreamWriter     sw = new StreamWriter("d:/b.txt");
            Win32LogicalDisk a  = new Win32LogicalDisk();

            //a.YxDictionAccess = new Dictionary<ushort, string>();
            //a.YxDictionAccess.Add(1, "Unknown");
            //a.YxDictionAccess.Add(2, "Readable");
            //a.YxDictionAccess.Add(3, "Writeable");
            //a.YxDictionAccess.Add(4, "Read/write supported");
            //a.YxDictionAccess.Add(5, "Write once");

            //a.dictionDriveType = new Dictionary<uint, string>();
            //a.dictionDriveType.Add(0, "Unknown");
            //a.dictionDriveType.Add(1, "No Root Directory");
            //a.dictionDriveType.Add(2, "Removable Disk");
            //a.dictionDriveType.Add(3, "Local Disk");
            //a.dictionDriveType.Add(4, "Network Drive");
            //a.dictionDriveType.Add(5, "Compact Disc");
            //a.dictionDriveType.Add(6, "RAM Disk");

            //a.dictionMediaType = new Dictionary<uint, string>();
            //a.dictionMediaType.Add(0, "Unknown:Format is unknown");
            //a.dictionMediaType.Add(1, "F5_1Pt2_512:51/4-Inch Floppy Disk - 1.2Mb - 512 bytes/sector");
            //a.dictionMediaType.Add(2, "F3_1Pt44_512:31/2-Inch Floppy Disk - 1.44Mb -512 bytes/sector");
            //a.dictionMediaType.Add(3, "F3_2Pt88_512:31/2-Inch Floppy Disk - 2.88Mb - 512 bytes/sector");
            //a.dictionMediaType.Add(4, "F3_20Pt8_512:31/2-Inch Floppy Disk - 20.8Mb - 512 bytes/sector");
            //a.dictionMediaType.Add(5, "F3_720_512:31/2-Inch Floppy Disk - 720Kb - 512 bytes/sector");
            //a.dictionMediaType.Add(6, "F5_360_512:51/4-Inch Floppy Disk - 360Kb - 512 bytes/sector");
            //a.dictionMediaType.Add(7, "F5_320_512:51/4-Inch Floppy Disk - 320Kb - 512 bytes/sector");
            //a.dictionMediaType.Add(8, "F5_320_1024:51/4-Inch Floppy Disk - 320Kb - 1024 bytes/sector");
            //a.dictionMediaType.Add(9, "F5_180_512:51/4-Inch Floppy Disk - 180Kb - 512 bytes/sector");
            //a.dictionMediaType.Add(10, "F5_160_512:51/4-Inch Floppy Disk - 160Kb - 512 bytes/sector");
            //a.dictionMediaType.Add(11, "Removable media other than floppy");
            //a.dictionMediaType.Add(12, "Fixed hard disk media");
            //a.dictionMediaType.Add(13, "F3_120M_512:31/2-Inch Floppy Disk - 120Mb - 512 bytes/sector");
            //a.dictionMediaType.Add(14, "F3_640_512:31/2-Inch Floppy Disk - 640Kb - 512 bytes/sector");
            //a.dictionMediaType.Add(15, "F5_640_512:51/4-Inch Floppy Disk - 640Kb - 512 bytes/sector");
            //a.dictionMediaType.Add(16, "F5_720_512:51/4-Inch Floppy Disk - 720Kb - 512 bytes/sector");
            //a.dictionMediaType.Add(17, "F3_1Pt2_512:31/2-Inch Floppy Disk - 1.2Mb - 512 bytes/sector");
            //a.dictionMediaType.Add(18, "F3_1Pt23_1024:31/2-Inch Floppy Disk - 1.23Mb - 1024 bytes/sector");
            //a.dictionMediaType.Add(19, "F5_1Pt23_1024:51/4-Inch Floppy Disk - 1.23Mb - 1024 bytes/sector");
            //a.dictionMediaType.Add(20, "F3_128Mb_512:31/2-Inch Floppy Disk - 128Mb - 512 bytes/sector");
            //a.dictionMediaType.Add(21, "F3_230Mb_512:31/2-Inch Floppy Disk - 230Mb - 512 bytes/sector");
            //a.dictionMediaType.Add(22, "F8_256_128:8-Inch Floppy Disk - 256Kb - 128 bytes/sector");



            Emit(sw, a);
            sw.WriteLine();
            sw.Close();
        }
コード例 #4
0
        private void FillInStorageDeviceDirectoryType(TreeNode parentNode, Win32DiskDrive win32Disk)
        {
            TreeNode thisNode = new TreeNode
            {
                Text = win32Disk.Caption,
                Tag  = win32Disk
            };

            parentNode.Nodes.Add(thisNode);

            using RawDisk disk = new RawDisk(win32Disk.DeviceId);
            FillInStorageDeviceDirectoryType(thisNode, disk);

            var partitionQueryText =
                $"associators of {{{win32Disk.RelativePath}}} where AssocClass = Win32_DiskDriveToDiskPartition";

            var partitionQuery = new ManagementObjectSearcher(partitionQueryText);

            foreach (ManagementObject p in partitionQuery.Get())
            {
                var logicalDriveQueryText =
                    $"associators of {{{p.Path.RelativePath}}} where AssocClass = Win32_LogicalDiskToPartition";
                var logicalDriveQuery = new ManagementObjectSearcher(logicalDriveQueryText);
                foreach (ManagementObject ld in logicalDriveQuery.Get())
                {
                    Win32LogicalDisk ldp  = new Win32LogicalDisk(ld);
                    TreeNode         part = new TreeNode
                    {
                        Text = string.Concat(ldp.VolumeName, @" -> ", ldp.Caption),
                        Tag  = ldp
                    };

                    thisNode.Nodes.Add(part);
                }
            }
        }