Physical drives have various features. From these features, TPhysicalDrive abstracts some of them those are needed to Naraeon SSD Tools. Internally, the object just passes the request to right object. There are objects process these requests. Firstly, there is an object that issue adequate command to the bus directly(ATA, SCSI, NVMe, …). And there is another object that has functions can be done with other ioctls. Former one is TBusPhysicalDrive, and latter one is TOSPhysicalDrive.
In whole code, this object is used in IPhysicalDrive interface form, not TPhysicalDrive object form. Because in Delphi, inteface has reference counting based resource management feature. This project uses interface only by that reason.
But when not directly inherited TInterfacedObject, reference counting feature must be implemented manually. And Delphi doesn’t support multiple inheritance. So I just copied+pasted the implementation from VCL source. Delphi users have rights to use VCL source legally. When implementing the same thing in other languages, just use smart pointers.
Commands that can be issued only with low-level ioctls: TBusPhysicalDrive
TBusPhysicalDrive gets basic things of the drive. For example, model, serial, capacity, SMART values, SATA speed, etc. In fact, TCommandSet issues the command and TBufferInterpreter translates the buffer into readable form. But information about them will be written in future.
When low-level passthrough isn’t neccessary: TOSPhysicalDrive
TOSPhysicalDrive gets information that can be got from simple OS request. Like availability, user size, partition list, NCQ availability. OS can quickly and easily give us these information.
TNCQAvailabilityGetter gets NCQ availability of the drive. It uses IOCTL_STORAGE_QUERY_PROPERTY ioctl code. Internally it uses BusType and CommandQueueing to decide whether NCQ is available or not. The condition is got from test result of drivers at that time.