Esempio n. 1
0
 /// <summary>
 /// IOCTL_ATA_PASS_THROUGH IOCTL ( https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/content/ntddscsi/ni-ntddscsi-ioctl_ata_pass_through )
 /// </summary>
 /// <param name="IoControl"></param>
 /// <param name="Header"></param>
 /// <param name="Data"></param>
 /// <returns></returns>
 public static bool AtaPassThroughSmartData(this IoControl IoControl, out IAtaPassThroughEx <SmartData> value, out uint ReturnBytes)
 {
     if (IntPtr.Size == 4)
     {
         var request = new AtaPassThroughEx32WithSmartData(
             AtaFlags: AtaFlags.DataIn | AtaFlags.NoMultiple,
             TimeOutValue: 3,
             Feature: 0xd0,
             Cylinder: 0xc24f,
             Command: 0xb0
             );
         System.Diagnostics.Debug.Assert(request.DataTransferLength == 512, "データが不正");
         var ptr    = new StructPtr <AtaPassThroughEx32WithSmartData>(request);
         var result = IoControl.AtaPassThrough(ptr, out ReturnBytes);
         value = ptr.Get();
         return(result);
     }
     else if (IntPtr.Size == 8)
     {
         var request = new AtaPassThroughExWithSmartData(
             AtaFlags: AtaFlags.DataIn | AtaFlags.NoMultiple,
             TimeOutValue: 3,
             Feature: 0xd0,
             Cylinder: 0xc24f,
             Command: 0xb0
             );
         System.Diagnostics.Debug.Assert(request.DataTransferLength == 512, "データが不正");
         var ptr    = new StructPtr <AtaPassThroughExWithSmartData>(request);
         var result = IoControl.AtaPassThrough(ptr, out ReturnBytes);
         value = ptr.Get();
         return(result);
     }
     throw new NotSupportedException();
 }
Esempio n. 2
0
 /// <summary>
 /// IOCTL_ATA_PASS_THROUGH IOCTL ( https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/content/ntddscsi/ni-ntddscsi-ioctl_ata_pass_through )
 /// </summary>
 /// <param name="IoControl"></param>
 /// <param name="Header"></param>
 /// <param name="Data"></param>
 /// <returns></returns>
 public static bool AtaPassThroughIdentifyDevice(this IoControl IoControl, out IAtaPassThroughEx <IdentifyDevice> value, out uint ReturnBytes)
 {
     if (IntPtr.Size == 4)
     {
         var ptr = new StructPtr <AtaPassThroughEx32WithIdentifyDevice>(new AtaPassThroughEx32WithIdentifyDevice(
                                                                            AtaFlags: AtaFlags.DataIn | AtaFlags.NoMultiple,
                                                                            TimeOutValue: 3,
                                                                            Feature: 0,
                                                                            Cylinder: 0,
                                                                            Command: 0xEC
                                                                            ));
         var result = IoControl.AtaPassThrough(ptr, out ReturnBytes);
         value = ptr.Get();
         return(result);
     }
     else if (IntPtr.Size == 8)
     {
         var ptr = new StructPtr <AtaPassThroughExWithIdentifyDevice>(new AtaPassThroughExWithIdentifyDevice(
                                                                          AtaFlags: AtaFlags.DataIn | AtaFlags.NoMultiple,
                                                                          TimeOutValue: 3,
                                                                          Feature: 0,
                                                                          Cylinder: 0,
                                                                          Command: 0xEC
                                                                          ));
         var result = IoControl.AtaPassThrough(ptr, out ReturnBytes);
         value = ptr.Get();
         return(result);
     }
     throw new NotSupportedException();
 }
Esempio n. 3
0
 public void SetPtrTest(StructPtr <TestData> StructPtr, TestData data)
 {
     using (StructPtr.CreatePtr(out var Ptr, out var Size))
     {
         StructPtr.SetPtr(Ptr, Size);
         Assert.AreEqual(data, StructPtr.Get());
     }
 }
Esempio n. 4
0
        public static bool AtaPassThroughCheckPowerMode(this IoControl IoControl, out IAtaPassThroughEx value, out uint ReturnBytes)
        {
            var AtaFlags = Controller.AtaFlags.DataIn | Controller.AtaFlags.NoMultiple;

            if (IntPtr.Size == 4)
            {
                var _value = new AtaPassThroughEx32WithMiniBuffer(
                    AtaFlags: AtaFlags,
                    TimeOutValue: 20,
                    TaskFile: new TaskFile(
                        AtaFlags: AtaFlags,
                        Feature: 0,
                        Cylinder: 0,
                        DeviceHead: 0,
                        Command: 0xE5
                        )
                    );
                var ptr    = new StructPtr <AtaPassThroughEx32WithMiniBuffer>(_value);
                var result = IoControl.AtaPassThrough(ptr, out ReturnBytes);
                value = ptr.Get();
                return(result);
            }
            else if (IntPtr.Size == 8)
            {
                var _value = new AtaPassThroughExWithMiniBuffer(
                    AtaFlags: AtaFlags,
                    TimeOutValue: 20,
                    TaskFile: new TaskFile(
                        AtaFlags: AtaFlags,
                        Feature: 0,
                        Cylinder: 0,
                        DeviceHead: 0x0,
                        Command: 0xE5
                        )
                    );
                var ptr    = new StructPtr <AtaPassThroughExWithMiniBuffer>(_value);
                var result = IoControl.AtaPassThrough(ptr, out ReturnBytes);
                value = ptr.Get();
                return(result);
            }
            throw new NotSupportedException();
        }