I need to debug a service, but there's no main() function. So I'm wondering, what is the first function to get called when a Service starts? i.e. what's the Service equivalent of main()?
I need to debug a service, but there's no main() function. So I'm wondering, what is the first function to get called when a Service starts? i.e. what's the Service equivalent of main()?
Thanks.
Now, if I wanted to run this service as a regular program to make it easier to debug, could I just do this:
Right now I see some things like:Code:#ifdef DEBUGGING_SERVICE int main( int argc, char* argv[] ) #else void ServiceMain( DWORD dwNumArgs, LPTSTR* lpServiceArgs ) #endif // DEBUGGING_SERVICE { ... }
in the ServiceMain() function. If I can rename it to main(), I'm assuming I'd have to do something else with the lines like that?Code:theApp.RegisterScmCtrlHandler(*lpServiceArgs, (LPHANDLER_FUNCTION)ControlHandler);
It can actually be anything you want. It is defined when you install the service. A given executable can have multiple services with different ServiceMain function entry points. Look for an entry like this -Originally Posted by MSDN
Code:SERVICE_TABLE_ENTRY DispatchTable[] = { { SVCNAME, (LPSERVICE_MAIN_FUNCTION) SvcMain }, { NULL, NULL } };