public VolumeRecord(List <DatabaseRecordFragment> fragments) : base(fragments) { // Data begins at 0x10 (VBLK header is at 0x00) int offset = 0x00; // relative to Data ReadCommonFields(this.Data, ref offset); if (RecordRevision != 5) { throw new NotImplementedException("Unsupported record revision"); } VolumeTypeString = ReadVarString(this.Data, ref offset); DisableDriverLetterAssignmentString = ReadVarString(this.Data, ref offset); StateString = ByteReader.ReadAnsiString(this.Data, ref offset, 14).Trim('\0'); ReadPolicy = (ReadPolicyName)ByteReader.ReadByte(this.Data, ref offset); VolumeNumber = ReadVarUInt(this.Data, ref offset); VolumeFlags = (VolumeFlags)BigEndianReader.ReadUInt32(this.Data, ref offset); NumberOfComponents = ReadVarUInt(this.Data, ref offset); CommitTransactionID = BigEndianReader.ReadUInt64(this.Data, ref offset); UnknownTransactionID = BigEndianReader.ReadUInt64(this.Data, ref offset); SizeLBA = ReadVarULong(this.Data, ref offset); offset += 4; PartitionType = (PartitionType)ByteReader.ReadByte(this.Data, ref offset); VolumeGuid = BigEndianReader.ReadGuid(this.Data, ref offset); if (HasUnknownID1Flag) { UnknownID1 = ReadVarULong(this.Data, ref offset); } if (HasUnknownID2Flag) { UnknownID2 = ReadVarULong(this.Data, ref offset); } if (HasColumnSizeFlag) { ColumnSizeLBA = ReadVarULong(this.Data, ref offset); } if (HasMountHintFlag) { MountHint = ReadVarString(this.Data, ref offset); } }
public void Refresh() { // Set defaults largeIcon = null; smallIcon = null; volLabel = ""; volType = VolumeTypes.Invalid; serNum = 0; maxCompLen = 0; volFlags = VolumeFlags.Unknown; fsName = ""; // Get the volume type volType = (VolumeTypes)GetDriveType(uri.LocalPath); // If not successful, throw an exception if (volType == VolumeTypes.Invalid) { throw new InvalidVolumeException(uri); } // Declare Receiving Variables StringBuilder VolLabel = new StringBuilder(256); // Label UInt32 VolFlags = new UInt32(); StringBuilder FSName = new StringBuilder(256); // File System Name // Attempt to retreive the information long Ret = GetVolumeInformation(uri.LocalPath, VolLabel, (UInt32)VolLabel.Capacity, ref serNum, ref maxCompLen, ref VolFlags, FSName, (UInt32)FSName.Capacity); // if (Ret != 0) throw new VolumeAccessException(); // Move to regular variables volLabel = VolLabel.ToString(); volFlags = (VolumeFlags)VolFlags; fsName = FSName.ToString(); // Attempt to get icons largeIcon = GetIcon(true); smallIcon = GetIcon(false); }
/********************************************************** * Utility Methods *********************************************************/ private bool FlagSet(VolumeFlags Flag) { return((volFlags & Flag) == Flag); }
public VolumeInformationRecord(byte[] buffer, int offset) : base(buffer, offset) { MajorVersion = ByteReader.ReadByte(this.Data, 0x08); MinorVersion = ByteReader.ReadByte(this.Data, 0x09); VolumeFlags = (VolumeFlags)LittleEndianConverter.ToUInt16(this.Data, 0x0A); }
private void OnVolumeChanged(DeviceEvent eventType, char driveLetter, VolumeFlags flags) { Debug.Print("Hardware.OnVolumeChanged(): {0} {1}: {2}", eventType, driveLetter, flags); var eh = VolumeChanged; if (eh != null) { var changeType = (eventType == DeviceEvent.DeviceArrival) ? VolumeChangedArgs.ChangeType.Added : VolumeChangedArgs.ChangeType.Removed; var args = new VolumeChangedArgs(driveLetter, changeType); eh(this, args); } }