Returns a handle to a directory on disk from which the driver can read and write files. The files in that directory apply to a specific driver object.
NTSTATUS IoGetDriverDirectory( PDRIVER_OBJECT DriverObject, DRIVER_DIRECTORY_TYPE DirectoryType, ULONG Flags, PHANDLE DriverDirectoryHandle );
[In] A pointer to the driver object (DRIVER_OBJECT structure) of the calling driver.
[In] A _DRIVER_DIRECTORY_TYPE-type value that indicates the type of requested directory.
[In] Must be 0.
[Out] A pointer to a variable that receives a HANDLE to the requested driver directory. The caller must not pass NULL.
Returns an appropriate NTSTATUS value. Possible values include:
|STATUS_SUCCESS||The call successfully opened a handle to the requested driver directory.|
|STATUS_INVALID_PARAMETER||An input value to this function is invalid. For example, DriverObject or DriverDirectoryHandle is NULL; Flags is not 0.|
If IoGetDriverDirectory is called before the required disks and volumes have been started, the function does not open a handle and returns an error.
Drivers typically use ZwOpenFile and ZwCreateFile to access/create files. One of the parameters for those functions is an OBJECT_ATTRIBUTES structure, which contains the object name and a root directory. If the root directory is NULL, then the object name must be a fully qualified path. However, if you provide a handle for the root directory, then the object name must be relative to the object (in the case of files, the directory), that the handle represents.
The driver must call ZwClose to close the received handle when access is no longer required.
Callers of IoGetDriverDirectory must be running at IRQL = PASSIVE_LEVEL in the context of a system thread.
We'd love to hear your thoughts. Choose the type you'd like to provide:
Our feedback system is built on GitHub Issues. Read more on our blog.