Reputation: 35
In user mode application in windows application I can get the mime type from a file path with the FindMimeFromData
But I would like to avoid going into user mode every time I have to control the mime type,
So I would like to know if there is way to get the mime type from PCFLT_RELATED_OBJECTS or PFLT_CALLBACK_DATA in my driver in kernel mode
From these data I know I can get the file extension but the application will be provided the mime type that the user will enter and not extension.
Upvotes: 0
Views: 31
Reputation: 180145
If you look at the linked documentation, you'll see that the functionality is provided by Urlmon.dll, part of Internet Explorer. That is very much user-mode code. The reason is also clear when you look at the description: MIME type determination works via "data sniffing", which is certainly not something you should be doing in kernel mode.
I agree that "going into user mode every time" would be a bad idea. But that doesn't mean you should do it from kernel mode. Instead, you should defer the MIME type determination in kernel mode, and do it asynchronously in user mode (i.e. at a later time).
It sounds like you already have suitable user-mode code: "the application will be provided the mime type that the user will enter". The user enters that in user-mode, and the application receives it in user-mode. Why is there even kernel mode code in between?
Upvotes: 0