PDA

View Full Version : Calling QT dll from device driver



AmolShinde_8
8th September 2010, 07:49
Hi,

I have written a QT dll and that dll needs to be called by printer device driver so that a UI can be shown. But loading of dll gets failed when I call LoadLibrary. I have tried with normal dll written in c++ and it gets loaded successfully from printer driver. Is it possible to load QT dll from printer driver. If yes, can you please suggest a way to load it.

Thanks.

squidge
8th September 2010, 10:32
You really shouldn't be doing this. The OS uses seperate rings for device drivers and user applications, and you should abide by this. You device driver should do nothing apart from communicating from the printer to user space and vice versa. An application running in ring 3 (user space) should handle the UI and communicate with the device driver via the usual means. This also means that an error in the user space application doesn't take down the entire system like it would if you did it in the driver.

AmolShinde_8
8th September 2010, 12:20
Hi,
Many thanks for quick reply.
However my driver is in USER MODE. Also I tried creating MFC dll which contains dialog and it gets successfully called and the dialog is shown from driver.
I don't know why the QT dll is not getting loaded. Any help is really appreciated.

Thanks and Regards
Amol.

tbscope
8th September 2010, 12:23
But loading of dll gets failed when I call LoadLibrary.

Can you please tell wich error you get?

ChrisW67
9th September 2010, 06:23
Is the calling process driver running in an environment in which the Qt DLLs are found in the path? Paths provided to system processes etc. are deliberately limited.

AmolShinde_8
13th September 2010, 13:35
I have copied the neccassary QT standard dlls into the driver path. QT dll gets loaded successfully but when the exported function is called it crashes in the middle neither in driver nor in dll.

squidge
13th September 2010, 14:13
However my driver is in USER MODE. Also I tried creating MFC dll which contains dialog and it gets successfully called and the dialog is shown from driver.
I don't know why the QT dll is not getting loaded. Any help is really appreciated.Not sure what you mean, a driver is typically a .sys file which is loaded by the kernel, and thus is resident in kernel memory. Unless you don't mean a driver in the typical sense.

What function are you calling from Qt that is crashing? If you use WinDbg, it will tell you exactly where it is crashing also, and also the call stack of what called it.

AmolShinde_8
14th September 2010, 08:56
Hi,

Manz thanks for helping me out.
I am modifying the DDK provided printer driver named oemui. When you compile this it creates .dll file and I have put this dll into C:\WINDOWS\system32\spool\drivers\w32x86\3 using addprinter and provided INF file.
For other Question, I have just created a simple QT dll and exported a function and calling this function from this oemui.dll. I have copied this sample dll and other std QT dll into C:\WINDOWS\system32\spool\drivers\w32x86\3 folder. This sample dll gets loaded successfully but when I call the exported function oemui dll crashed. What I see here is the sample qt dlläs exported function is not called. However when I create a simple MFC UI dll this dll gets loaded successfully.
Also I tried to create a normal window application and called this sample QT dlläs exported function still I see the crash.
I think the problem here is we need to initialize QCoreApplication object in DLL. Can you please me in sorting this.