Hi

anybody know how to do a BitBlt from inside a Win2k/NT service...?

We use the standard but nothing happens: ie we try to copy a part from the screen to another part (using GetDC (NULL)) but we see nothing on screen :)


Also any simple services examples in C ?
hehe or in ASM will do ;)
Posted on 2002-06-04 16:40:50 by BogdanOntanu
I think that if your service runs in ring3 (usermode) that you can then use GDI else in kernelmode you'd have to use the layer underneath which would be DDI.

I think :|
Posted on 2002-06-04 17:22:33 by Hiroshimator
Yes, this service is in user mode but starts before any user has even login. (on win2k)

It looks like there is a special "desktop" for services as any Bitblt we do is not shown on "screen" but also no error...
Posted on 2002-06-04 18:14:43 by BogdanOntanu
Bogdan,
according to MSDN You are correct. You may however change your desktop using SetThreadDesktop and OpenDesktop. This code works in user mode. According to MSDN it should work in normal mode also. You may or may not need the window station stuff. I left it in just in case. Experiment. :)


.DATA
def db "DEFAULT_DESKTOP",0


.CODE
start:
invoke GetProcessWindowStation
invoke SetProcessWindowStation, eax
invoke OpenDesktop, addr def, DF_ALLOWOTHERACCOUNTHOOK, TRUE, MAXIMUM_ALLOWED
invoke SwitchDesktop, eax

Here's some MSDN stuff to chew on...

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/services_2uwj.asp

Oh.... I almost forgot. If you are trying to blit to the screen before any users have logged in there may be more to it. AFAIK the login screen is on a whole seperate desktop running in its own window station. You may have to use EnumWindowStations and EnumDesktops to find it.

Here is a tute on NT services from Iczelions site.

http://spiff.tripnet.se/~iczelion/beepserv.txt

Oops.... Inside that tute I linked too theres a clear explantion of an easier way to fix this....

"Strangely by default services run under their own desktop.
This is controled through the SERVICE_INTERACTIVE_PROCESS
flag to the dwServiceType parameter of the CreateService
function. Unless this flag is set the service cannot
interact with the users desktop. This means no GUI no
dialog boxes. Only the MessageBox function will work and
only with the MB_SERVICE_NOTIFICATION flag set. This can be
a source of great frustration (personal experience here)."
Posted on 2002-06-05 07:51:01 by emonk
Thx man! :)

the SERVICE_INTERACTIVE_PROCESS worked fine for us ...

Maybe the other stuff with Windowstations and SwitchDesktop should work also but it did not for us

Hope this will avoid lots of frustrations for others also ;)
Posted on 2002-06-05 09:37:36 by BogdanOntanu
Bogdan,

"Hope this will avoid lots of frustrations for others also "

Yeah, but now I have to go back and "fix" my own code to do stuff the "right" way :) ....
Posted on 2002-06-05 10:09:28 by emonk