> Thank you all guys.
I’ll start answering you one by one:
Doron, I have not attached a debugger so far to find out the issue. I’ll
try that.
Tim, I don’t want my service to display the window. But yes, we really
want it to interact
with the graphics driver. That’s needed. Is it really Impossible for a
service??
I am calling the desired function from the OnStart() routine of the
service.
MM, we are not having any procedure for user input, it’s not an
interactive application. I have StartServiceCtrlDispatcher called in the
Run() routine, which registers the executable for a service with the
Service Control Manager and eventually calls OnStart() method. It’s a
WORKING sample service.
Joe, I have “ServiceMain” and “ServiceCtrkHandler” both in my service. I
have a proper service app and it runs fine. In fact, i can see the prints
I have inserted in the Event Viewer when I start or Stop the service.
Apparently, it’s from msdn.
I am using CppWindowsService sample from msdn
(http://code.msdn.microsoft.com/windowsdesktop/CppWindowsService-cacf4948).
I don’t have time to download it, but it sounds like a C++ implementation
of a service framework. Note that the thread which is handling the events
from the ServiceCtrlHandler must not block. It must process the “Start”
request, send an acknowledgement to the SCM, and return. If it calls a
subroutine, then the SCM will time out because it did not get its response
in a timely fashion. The real work of the service should be done in a
separate thread. it is essential that you have this behavior. Otherwise,
you will get timeout notifications. Also, you need to send the proper
status reports, beware of blocking calls with potentially unbounded delays
during any start or continue sequence.
The concept that it is impossible for a service to interact with a driver
is nonsensical. It’s just another app. What is critical is whether or
not the device you are communicating with has ACLs that would block the
service if it is not started in the context of an appropriate user ID.
Note that the default login account for services is not necessarily
granted these privileges, for a variety of security reasons. So in
general, the answer is that, OF COURSE you can interact with a driver,
just like any app can interact with any driver: if you can open it, you
can interact with it, and all you need to open it is a suitable file name
(which you can derive if all you have is the interface GUID for the
device) and the privileges to access that. A service, in that sense, is
absolutely no different than any other app. If you log in with an account
that doesn’t have privileges for a device, you can’t get that device.
Services are the same in that respect.
[There’s another subgenre of this question: “Can I do a kernel call from a
DLL?” or the variant “Can I issue the XXXXXX() call from a DLL?”, which is
just as silly, because a DLL is just more code in the process space.
After many days of back-and-forthing in the newsgroup, it ALWAYS turned
out to be that in the refactoring of their code from the app to the DLL,
they got something wrong about the parameters to the call!]
Your problem is not with being a service; it is with being a service that
has service-related bugs in the code.
As long as you don’t try to draw anything, you will be safe. The issue is
really about “ownership of the screen”. The graphics subsystem owns the
screen, and you cannot bypass it.
I can’t speak as to whether or not the escape call you reference is safe
or not. Someone who knows D3D and graphics will have to answer that.
joe
The first and most important question is: Is it really impossible for a
service to interact with a kernel-mode driver?
My code includes calls to D3DKMTEscape() as it’s a WDDM driver with which
I’m trying to interact.
Thanks!
NTDEV is sponsored by OSR
Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev
OSR is HIRING!! See http://www.osr.com/careers
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer