Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="IoControl"></param>
        /// <param name="PropertyId"></param>
        /// <param name="QueryType"></param>
        /// <param name="AdditionalParameters"></param>
        /// <param name="descriptor"></param>
        /// <param name="ReturnBytes"></param>
        /// <returns></returns>
        public static bool StorageQueryProperty(this IoControl IoControl, StoragePropertyId PropertyId, StorageQueryType QueryType, byte[] AdditionalParameters, out IStorageDescriptor descriptor, out uint ReturnBytes)
        {
            var genericType = PropertyId.GetDestType() ?? typeof(StorageDescriptor);

            var query    = new StoragePropertyQuery(PropertyId, QueryType, AdditionalParameters);
            var argument = new object[] { IoControl, query, null, null };
            var result   = (bool)typeof(MassStorageExtensions)
                           .GetMethods(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static)
                           .FirstOrDefault(mi => mi.Name == nameof(StorageQueryProperty) && mi.IsGenericMethodDefinition)
                           .MakeGenericMethod(genericType)
                           .Invoke(null, argument);

            descriptor  = (IStorageDescriptor)argument[2];
            ReturnBytes = (uint)argument[3];
            return(result);
        }
Esempio n. 2
0
 public StoragePropertyQuery(StoragePropertyId PropertyId, StorageQueryType QueryType = default, byte[] AdditionalParameters = null)
 => (this.PropertyId, this.QueryType, this.AdditionalParameters) = (PropertyId, QueryType, AdditionalParameters ?? new byte[1]);
Esempio n. 3
0
 public static Type GetDestType(this StoragePropertyId PropertyId) => PropertyId.GetType().GetField(PropertyId.ToString()).GetCustomAttributes(typeof(StoragePropertyAttribute), false).Cast <StoragePropertyAttribute>().FirstOrDefault()?.DestType;
Esempio n. 4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="IoControl"></param>
 /// <param name="PropertyId"></param>
 /// <param name="QueryType"></param>
 /// <param name="AdditionalParameters"></param>
 /// <returns></returns>
 public static IStorageDescriptor StorageQueryProperty(this IoControl IoControl, StoragePropertyId PropertyId, StorageQueryType QueryType = default, params byte[] AdditionalParameters)
 {
     if (!StorageQueryProperty(IoControl, PropertyId, QueryType, AdditionalParameters, out var descriptor, out var ReturnBytes) && ReturnBytes == 0)
     {
         Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
     }
     return(descriptor);
 }
 public void StorageQueryPropertyTest(IoControl IoControl, StoragePropertyId StoragePropertyId, StorageQueryType StorageQueryType) => Trace.WriteLine(IoControl.StorageQueryProperty(StoragePropertyId, StorageQueryType));