What error code should I pass to ECBFSError exception constructor thrown in OnCreateFile to inform the system that file or folder can not be created?
private void CbFsCreateFile(…)
{
...
throw new ECBFSError(ERROR_CANNOT_MAKE);
}

But they all show same popup in Windows Explorer:
Unable to create folder ‘New Folder’
A device attached to the system is not functioning.

How do I show a meaningful message using predefined windows error codes? I want to show something similar to “The file or folder cannot be created.”or “File or folder with such name already exists” popup.

The problem is in the CallbackFS driver code. We convert the win32 error codes into the native ones using the table of errors that doesn't contain all error pairs yet. That's why some errors are converted into the default value STATUS_UNSUCCESSFUL.

Found interesting MS KB article that describes the opposite mapping:
"Mapping NT Status Error Codes to Win32 Error Codes"
http://support.microsoft.com/kb/113996
Though it's quite old (2005), I don't think it changed significantly (maybe extended), and still can be used to understand what to expect from windows applications that work with CBFS-mounted disk.
Foe example, throwing ECBFSError with code ERROR_BAD_UNIT inside CBFS callback, will cause driver to report STATUS_NO_SUCH_DEVICE, which according to the article will be finally passed to windows app as ERROR_FILE_NOT_FOUND.

One more question then. According to your code ECBFSError with ERROR_INVALID_FUNCTION code will be translated into STATUS_NOT_SUPPORTED status, and then will be translated by Windows to ERROR_NOT_SUPPORTED win32 error code.

Wouldn't it be more correct to translate ERROR_INVALID_FUNCTION to STATUS_ILLEGAL_FUNCTION or other NT status code that will be brought to WinAPI as ERROR_INVALID_FUNCTION too?

The same applies to ERROR_SHARING_VIOLATION which is translated to STATUS_RETRY instead of STATUS_SHARING_VIOLATION

We use cookies to help provide you with the best possible online experience. By using this site, you agree that we may store and access cookies on your device. You can find out more about and set your own preferences here.