[SKEL_SERVICE]
authorEric Kohl <eric.kohl@reactos.org>
Tue, 18 Sep 2012 20:37:51 +0000 (20:37 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Tue, 18 Sep 2012 20:37:51 +0000 (20:37 +0000)
The HandlerEx control handler is DWORD WINAPI, not VOID WINAPI .
Patch by Hermes BELUSCA - MAITO.
Fixes ROSAPPS-243.

svn path=/trunk/; revision=57324

rosapps/templates/skel_service/ServiceMain.c

index 0dc5848..5832ad4 100644 (file)
@@ -100,7 +100,7 @@ CreateServiceThread(PSERVICEINFO pServInfo)
 }
 
 
-VOID WINAPI
+DWORD WINAPI
 ServerCtrlHandler(DWORD dwControl,
                   DWORD dwEventType,
                   LPVOID lpEventData,
@@ -118,29 +118,34 @@ ServerCtrlHandler(DWORD dwControl,
             pServInfo->servStatus.dwWin32ExitCode = 0;
             pServInfo->servStatus.dwWaitHint = 0;
             UpdateStatus(pServInfo, SERVICE_STOP_PENDING, 1);
-            break;
+            return ERROR_SUCCESS;
 
         case SERVICE_CONTROL_PAUSE:
             LogEvent(_T("Setting the service to SERVICE_PAUSED"), 0, 0, LOG_FILE);
             InterlockedExchange((LONG *)&bPause, TRUE);
             UpdateStatus(pServInfo, SERVICE_PAUSED, 0);
-            break;
+            return ERROR_SUCCESS;
 
         case SERVICE_CONTROL_CONTINUE:
             LogEvent(_T("Setting the service to SERVICE_RUNNING"), 0, 0, LOG_FILE);
             InterlockedExchange((LONG *)&bPause, FALSE);
             UpdateStatus(pServInfo, SERVICE_RUNNING, 0);
-            break;
+            return ERROR_SUCCESS;
 
         case SERVICE_CONTROL_INTERROGATE:
-            break;
+            return ERROR_SUCCESS;
 
         default:
-            if (dwControl > 127 && dwControl < 256) /* user defined */
+            if (dwControl >= 128 && dwControl <= 255) /* User defined */
+            {
                 LogEvent(_T("User defined control code"), 0, 0, LOG_FILE);
+                return ERROR_SUCCESS;
+            }
             else
+            {
                 LogEvent(_T("ERROR: Bad control code"), 0, 0, LOG_FILE);
-            break;
+                return ERROR_INVALID_SERVICE_CONTROL;
+            }
     }
 }