How to open a file with with a object path containing UNICODE non-ascii characters with ZwOpenFile?

Hello,

Based on the Storport Miniport example I have created a virtual file backed USB block storage. It works well, when the underlying file is stored in a path, which only contains ascii-like characters.

Now I created a path which contains arabic unicode symbols (e.g to allow for different locales) and try to open the file in the Kernel with ZwOpenFile resulting in NTSTATUS Code STATUS_OBJECT_PATH_NOT_FOUND (0xc000003a).

The file is created in the user space code and visible with i.e. Windows Explorer. Strings in the code are represented as wchar_t arrays.
The user space code then prepends L"\DosDevices\" to the absolute file path and sends it into the Kernel space.
Hexdumps of the UNICODE String Buffer in the Kernel and the wchar_t in the userspace are identical and the path printed with DebugView seems correct.
(If the DebugView output is stored to a log file, a unicode capable editor shows the correct path.)

I am not sure if the “conversion” to a DosDevice is correct. My understanding is that \DosDevices\C: is a link to the C: drive and the I do not need to modify the following path. Is this correct?

Has anyone experience how to deal with UNICODE paths in Kernel space?

Shouldn’t be anything special that needs done. Is the request making it to the file system?

Hi Scott,
Thank you very much for your reply. Some moments ago I saw an error in my unicode codepage in user space. So the Kernel was correct that the path is not available. I do not fully understand why my logfile was able to show the correct string, but the issue itself is resolved. You are absolutely right: Nothing special to it, if you control your unicode :wink:

Sorry for the discussion. If possible we should close it.

Nice! Glad it’s fixed, thanks for following up.