Connects the main thread of a service process to the service control manager, which causes the thread to be the service control dispatcher thread for the calling process.
BOOL WINAPI StartServiceCtrlDispatcher( _In_ const SERVICE_TABLE_ENTRY *lpServiceTable );
- lpServiceTable [in]
- A pointer to an array of SERVICE_TABLE_ENTRY structures containing one entry for each service that can execute in the calling process. The members of the last entry in the table must have NULL values to designate the end of the table.
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
The following error code can be set by the service control manager. Other error codes can be set by the registry functions that are called by the service control manager.
|ERROR_FAILED_SERVICE_CONTROLLER_CONNECT||This error is returned if the program is being run as a console application rather than as a service. If the program will be run as a console application for debugging purposes, structure it such that service-specific code is not called when this error is returned.|
|ERROR_INVALID_DATA||The specified dispatch table contains entries that are not in the proper format.|
|ERROR_SERVICE_ALREADY_RUNNING||The process has already called StartServiceCtrlDispatcher. Each process can call StartServiceCtrlDispatcher only one time.|
.text:00401003 lea eax, [esp+10h+ServiceStartTable] .text:00401007 mov [esp+10h+ServiceStartTable.lpServiceName], offset aMalservice ; "MalService" .text:0040100F push eax ; lpServiceStartTable .text:00401010 mov [esp+14h+ServiceStartTable.lpServiceProc], offset sub_401040 .text:00401018 mov [esp+14h+var_8], 0 .text:00401020 mov [esp+14h+var_4], 0 .text:00401028 call ds:StartServiceCtrlDispatcherA