# Registering new device handlers

Before any device can be used, it must be registered with the library. When the library is initialized, some devices are registered for you:

- On the PC, every drive that has a letter mapped to it is registered. Internally, the GetLogicalDrives() function is used to get this information.
- On the Xenon system, only the D: drive is registered.

If you want the library to use other devices, you have to derive a new class from the `rw::core::filesys::DeviceDriver` abstract class and pass an instance of your derived class to `rw::core::filesys::Manager::RegisterDevice`. The new device object must have a name which ends in a colon (e.g., comm:). If you want the library to search the new device for non-qualified file names, add it to the search path using `rw::core::filesys::Manager::AddSearchLocation`.

Devices can be registered with a flag indicating that they are either physical or virtual devices. The distinction between a physical and virtual device is that a physical device processes operations on its own thread whereas a virtual device processes operations on the calling thread. Historically virtual devices, such as .big file devices, are considered virtual as they only perform minor bookkeeping and then proxy to a physical device to get the necessary data. However it can be beneficial to add device drivers, like rwfilesystem's HTTP driver, as physical in order for them to offload processing onto another thread.

Device driver implementations cannot be assumed threadsafe if they are registered as virtual; for example, the memmap driver is not safe to write to from multiple threads when registered as virtual. If it is registered as physical then it would be thread safe as all operations are processed only on the device thread.

When you are finished with a device, use `rw::core::filesys::Manager::UnregisterDevice` to remove it. There must be no open handles on the device when it is removed from the library. After the device has been removed, you can delete the object from the system.