OpenSCManager() never returns
I've written a custom smart card credential provider for Vista log
on / log off. To facilitate smart card removal behavior once the
user's successfully logged on, I've written a service with a thread
that watches for smart card removal and acts depending on the card
removal settings (lock, log off, shutdown, do nothing).
The service is started in the cred prov's ReportResult(), immediately
before the user is logged on, after winlogon has verified the users
credentials.
In stress testing, when performing repeated card removal -> pc lock ->
fast user switches to different accounts, I'm intermittently seeing
the DoStartSvc() stop at OpenSCManager() and never return. There's no
return value from the function at all, the whole service starting
mechanism just dies and the service never starts.
How can a function of this category just not return? Could it be an
issue with the service control manager's status? If so, is there a
way to wait for the manager to start, using something like
NotifyServiceStatusChange()?
VOID DoStartSvc(LPTSTR szCardSettings)
{
SERVICE_STATUS_PROCESS ssStatus;
DWORD dwOldCheckPoint;
DWORD dwStartTickCount;
DWORD dwWaitTime;
DWORD dwBytesNeeded;
// Get a handle to the SCM database.
schSCManager = OpenSCManager(
NULL,
NULL,
SC_MANAGER_ALL_ACCESS)));
// etc, etc
}
date: Tue, 9 Sep 2008 15:56:08 -0700 (PDT)
author: alexsd