Hi,
Ive got a problem with a service im writing.
I make the following call:
SERVICE_TABLE_ENTRY DispatchTable[] =
{
{ Name, ServiceMainFunction},
{ NULL, NULL }
};
if (!StartServiceCtrlDispatcher(DispatchTable))
{
}
...
But just as "ServiceMainFunction" is returning i get an error and XP tries to send an error report. The debug message is trying to write to NULL. But nothing happens to cause this:
VOID ServiceMainFunction(DWORD argc, LPTSTR *argv)
{
g_hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)MainServerThread, NULL, 0, &g_dwThreadID);
WaitForSingleObject(g_hThread, INFINITE);
MessageBox(NULL, "Service Finished!", "Test", MB_ICONINFORMATION | MB_OK);
//TerminateThread(g_hThread, 0);
}
The message box gets displayed at the end of the function, and as you can see, there is no further code after that!
Whats going on!?
----
Also, if anyone has any debug tips for services please let me know, as you cant easily debug a service. ie, how do you attach a debugger to a service etc?
Thanks
Ive got a problem with a service im writing.
I make the following call:
SERVICE_TABLE_ENTRY DispatchTable[] =
{
{ Name, ServiceMainFunction},
{ NULL, NULL }
};
if (!StartServiceCtrlDispatcher(DispatchTable))
{
}
...
But just as "ServiceMainFunction" is returning i get an error and XP tries to send an error report. The debug message is trying to write to NULL. But nothing happens to cause this:
VOID ServiceMainFunction(DWORD argc, LPTSTR *argv)
{
g_hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)MainServerThread, NULL, 0, &g_dwThreadID);
WaitForSingleObject(g_hThread, INFINITE);
MessageBox(NULL, "Service Finished!", "Test", MB_ICONINFORMATION | MB_OK);
//TerminateThread(g_hThread, 0);
}
The message box gets displayed at the end of the function, and as you can see, there is no further code after that!
Whats going on!?
----
Also, if anyone has any debug tips for services please let me know, as you cant easily debug a service. ie, how do you attach a debugger to a service etc?
Thanks