Overlooked features of Windows CE services.exe


The main job of services.exe on Windows CE is to host service DLLs and provide a nice interprocess communication mechanism between them and applications.  To a large extent it's very much like device.exe and in fact we've tried to make it easy to move dlls back and forth between them.


There are 3 services/networking/COM type features that are specific to services.exe since we think that they reflect what people are doing in services and make their lives easier.


Super services -- services.exe can be configured to listen on a TCP port or ports, IPV4+V6, for incoming network connections.  This allows it to spin up one thread for all listening sockets in a process rather than having each process spin up its own thread.


http://msdn.microsoft.com/library/en-us/wcecomm5/html/wce50conSuperServices.asp?frame=true


Local Address Change Notification -- If your service needs to take some special action when the CE device's IP address becomes available or unavailable, rather than spinning up a worker thread to listen for the various events it can instead rely upon the IOCTL_SERVICE_NOTIFY_ADDR_CHANGE.  Services.exe already spins up a thread to detect IP addr notifications and automatically calls your service with this IOCTL when such a change occurs.


http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcecomm5/html/wce50lrfioctlservicenotifyaddrchange.asp


CoFreeUnusedLibraries - Again to try and minimize the number of worker threads and/or maintenance done per service, services.exe spins up a thread that every few minutes calls CoFreeUnusedLibraries().  (CE4.0->5.0 it's every 2 minutes, CE 6.0 it'll be every 15 minutes.)  So a service never needs to make this call itself.


[Author: John Spaith]

Comments (1)

  1. Note: This is more of a geeky article for people who want to know how stuff works under the hood in Windows

Skip to main content