Hello everyone !!
I have a problem
Since i am newbie to this driver development,
i hope i can get some answers without any frustration
I have a legacy driver
i want to load the driver, and note down the debug information
i have created some services and made some registry entries
i am able to install and start the service
but not able to stop the service
I have defined SERVICE_ALL_ACCESS but could not get to know how i could
not stop the service
when i try this through net stop…it gives a message saying… U dont have
access to stop or pause the service
my code looks somehow like this …
BOOL InstallFunc(IN SC_HANDLE SCManager, IN LPCTSTR DriverName, IN LPCTSTR
DriverBinary)
{
SC_HANDLE SCService;
printf(“\n Entering InstallFunc() “);
printf(”\nthe DriverName is %s”, DriverName);
printf(“\n the DriverBinary is %s”,DriverBinary);
SCService = CreateService(SCManager,DriverName, DriverName,
SERVICE_ALL_ACCESS, SERVICE_KERNEL_DRIVER,
SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL,
DriverBinary, NULL, NULL, NULL, NULL, NULL );
if (!SCService)
{
return FALSE;
}
CloseServiceHandle(SCService);
return TRUE;
}
BOOL StartFunc(IN SC_HANDLE SCManager, IN LPCTSTR DriverName)
{
SC_HANDLE SCService;
BOOL bStart;
SCService = OpenService(SCManager,DriverName,SERVICE_ALL_ACCESS);
if (!SCService)
{
printf(“\n Service cannot be opened”);
return FALSE;
}
bStart = StartService( SCService, 0, NULL )
|| GetLastError() == ERROR_SERVICE_ALREADY_RUNNING
|| GetLastError() == ERROR_SERVICE_DISABLED;
if (bStart)
{
printf(“\n The Service is started”);
}
CloseServiceHandle(SCService);
return bStart;
}
BOOL StopFunc(IN SC_HANDLE SCManager, IN LPCTSTR DriverName)
{
SC_HANDLE SCService;
SERVICE_STATUS schStatus;
BOOL bStop;
SCService = OpenService(SCManager, DriverName,SERVICE_ALL_ACCESS ); if
(SCService==NULL)
return FALSE;
bStop = ControlService(SCService, SERVICE_CONTROL_STOP,
&schStatus );
if (bStop)
{
printf(“\n Service Stopped”);
}
CloseServiceHandle(SCService);
return bStop;
}
i am sorry , if i am asking something silly
but pls help me out
thanx in advance
Maneel