public static IEnumerable <HarddiskVolumeIdentifier> GetHarddiskVolumes(this NtObjects ntObjects)
        {
            foreach (NtObjectBase objectBase in ntObjects.ListDirectory(StaticStrings.DeviceRoot, filterType: WellKnownType.Device))
            {
                HarddiskVolumeIdentifier obj = objectBase as HarddiskVolumeIdentifier;
                if (obj == null)
                {
                    continue;
                }

                yield return(obj);
            }
        }
예제 #2
0
        public bool TryGetVolume(out HarddiskVolumeIdentifier volumeIdentifier)
        {
            volumeIdentifier = null;

            if (!TryGetSymbolicLinkTarget(out string target))
            {
                return(false);
            }

            NtObjectBase obj = NtObjects.Instance.GetSingleObject(target);

            volumeIdentifier = obj as HarddiskVolumeIdentifier;

            return(volumeIdentifier != null);
        }