Returning custom error from DokanNetMirror #367
Answered
by
Liryna
andreas-eriksson
asked this question in
Q&A
-
Is there a way to return custom errors from a function in DokanNetMirror? NtStatus IDokanOperations.ReadFile(string fileName, byte[] buffer, out int bytesRead, long offset, IDokanFileInfo info)
{
if (info.Context is not FileContext ctx)
{
return ReadFileMemoryMapped(fileName, buffer, out bytesRead, offset);
}
lock (ctx)
{
try
{
ctx.Stream.Position = offset;
bytesRead = ctx.Stream.Read(buffer, 0, buffer.Length);
}
catch (CustomException e)
{
// Here I would like to set a custom error that can be read by a C# application trying to read the file.
bytesRead = 0;
SetLastError(e.Message);
return CustomError;
}
}
return DokanResult.Success;
} |
Beta Was this translation helpful? Give feedback.
Answered by
Liryna
Jan 9, 2025
Replies: 1 comment 3 replies
-
Hi @andreas-eriksson , Is your goal to have to pass some specific information to the reading app that is non standard ? |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes this would work but like I said this could create undefined behavior with system and third party apps. They might even rewrite the error code on the way.
I really wouldn't suggest doing that.