skrev i meddelandet news:xxxxx@ntfsd…
> Hello everyone,
>
> I do not know if this is a kernel question but here it comes:
> When I block a file ?Access is denied? is coming up to the user, is it
> possible to change this message to a custom one?
>
You might have some success with IoRaiseInformationalHardError.
But, I still think that you will have to handle the IoCompleteRequest /
IoStatus-path in a standard way (no custom NTSTATUS).
If you study the section “Defining New NTSTATUS Values” in the WDK,
there is a footnote: “Drivers cannot use custom NTSTATUS values for IRPs
that can be received in user-mode, because only the system-defined values
can be translated into Win32 error codes.”
>
> I have made a new NTSTATUS message and pointing out the file
> (myDriver.sys) in the register but the only message I get is this:
> ?The system cannot find message text for message number 0x%1 in the
> message file for %2?
> I think that means that the system could not find the path to myDriver.sys
> file, but I do not know.
That’s probably reserved for the EventLog-facility which is available
for kernel-mode drivers by using IoAllocateErrorLogEntry.
If you check the sections named “Defining Custom Error Types” and
“Registering as a Source of Error Messages”, you will see a reference how-to
properly activate message sources.
> Is it impossible to change the error message when blocking a file access?
>
> Or:
> Could I block the file and suppress the ?Access is denied? message so the
> user do not get any message at all?
>
Have you tried some different NTSTATUS:values, like STATUS_UNSUCCESSFUL etc?
Good luck,
Andreas Nilsson
C2SAT communications AB
You may want to look through all the defined status codes and figure if
there is one that is most appropriate for what you are trying to indicate.
Also you need to consider the application compatibility risk that your
driver can introduce when you return a new failure code or simply one
that is different than one usually returned on that path.
Not all applications are written to handle all error codes gracefully -
let alone an error code that does not exist in the system.
Regards,
Sarosh.
File System Filter Lead
Microsoft Corp
This posting is provided “AS IS” with no warranties, and confers no Rights
Andreas Nilsson wrote:
skrev i meddelandet
> news:xxxxx@ntfsd…
>> Hello everyone,
>>
>> I do not know if this is a kernel question but here it comes:
>> When I block a file ?Access is denied? is coming up to the user, is it
>> possible to change this message to a custom one?
>>
>
> You might have some success with IoRaiseInformationalHardError.
> But, I still think that you will have to handle the IoCompleteRequest /
> IoStatus-path in a standard way (no custom NTSTATUS).
>
> If you study the section “Defining New NTSTATUS Values” in the WDK,
> there is a footnote: “Drivers cannot use custom NTSTATUS values for IRPs
> that can be received in user-mode, because only the system-defined
> values can be translated into Win32 error codes.”
>
>
>>
>> I have made a new NTSTATUS message and pointing out the file
>> (myDriver.sys) in the register but the only message I get is this:
>> ?The system cannot find message text for message number 0x%1 in the
>> message file for %2?
>> I think that means that the system could not find the path to
>> myDriver.sys file, but I do not know.
>
> That’s probably reserved for the EventLog-facility which is available
> for kernel-mode drivers by using IoAllocateErrorLogEntry.
>
> If you check the sections named “Defining Custom Error Types” and
> “Registering as a Source of Error Messages”, you will see a reference
> how-to properly activate message sources.
>
>> Is it impossible to change the error message when blocking a file access?
>>
>> Or:
>> Could I block the file and suppress the ?Access is denied? message so
>> the user do not get any message at all?
>>
>
> Have you tried some different NTSTATUS:values, like STATUS_UNSUCCESSFUL
> etc?
>
>
> Good luck,
>
> Andreas Nilsson
> C2SAT communications AB
>