Author: ekohl Date: Sun Oct 31 10:00:21 2010 New Revision: 49371
URL: http://svn.reactos.org/svn/reactos?rev=49371&view=rev Log: [SERVICES] Revert r49366.
Modified: trunk/reactos/base/system/services/database.c trunk/reactos/base/system/services/rpcserver.c trunk/reactos/base/system/services/services.h
Modified: trunk/reactos/base/system/services/database.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/databa... ============================================================================== --- trunk/reactos/base/system/services/database.c [iso-8859-1] (original) +++ trunk/reactos/base/system/services/database.c [iso-8859-1] Sun Oct 31 10:00:21 2010 @@ -678,10 +678,66 @@
DWORD -ScmSendServiceCommand(PSERVICE Service, - DWORD dwControl, - DWORD argc, - LPWSTR *argv) +ScmControlService(PSERVICE Service, + DWORD dwControl) +{ + PSCM_CONTROL_PACKET ControlPacket; + SCM_REPLY_PACKET ReplyPacket; + + DWORD dwWriteCount = 0; + DWORD dwReadCount = 0; + DWORD TotalLength; + DWORD dwError = ERROR_SUCCESS; + + DPRINT("ScmControlService() called\n"); + + TotalLength = wcslen(Service->lpServiceName) + 1; + + ControlPacket = (SCM_CONTROL_PACKET*)HeapAlloc(GetProcessHeap(), + HEAP_ZERO_MEMORY, + sizeof(SCM_CONTROL_PACKET) + (TotalLength * sizeof(WCHAR))); + if (ControlPacket == NULL) + return ERROR_NOT_ENOUGH_MEMORY; + + ControlPacket->dwControl = dwControl; + ControlPacket->dwSize = TotalLength; + ControlPacket->hServiceStatus = (SERVICE_STATUS_HANDLE)Service; + wcscpy(&ControlPacket->szArguments[0], Service->lpServiceName); + + /* Send the control packet */ + WriteFile(Service->ControlPipeHandle, + ControlPacket, + sizeof(SCM_CONTROL_PACKET) + (TotalLength * sizeof(WCHAR)), + &dwWriteCount, + NULL); + + /* Read the reply */ + ReadFile(Service->ControlPipeHandle, + &ReplyPacket, + sizeof(SCM_REPLY_PACKET), + &dwReadCount, + NULL); + + /* Release the contol packet */ + HeapFree(GetProcessHeap(), + 0, + ControlPacket); + + if (dwReadCount == sizeof(SCM_REPLY_PACKET)) + { + dwError = ReplyPacket.dwError; + } + + DPRINT("ScmControlService() done\n"); + + return dwError; +} + + +static DWORD +ScmSendStartCommand(PSERVICE Service, + DWORD argc, + LPWSTR *argv) { PSCM_CONTROL_PACKET ControlPacket; SCM_REPLY_PACKET ReplyPacket; @@ -694,7 +750,7 @@ DWORD dwError = ERROR_SUCCESS; DWORD i;
- DPRINT("ScmSendServiceCommand() called\n"); + DPRINT("ScmSendStartCommand() called\n");
/* Calculate the total length of the start command line */ TotalLength = wcslen(Service->lpServiceName) + 1; @@ -718,7 +774,7 @@ if (ControlPacket == NULL) return ERROR_NOT_ENOUGH_MEMORY;
- ControlPacket->dwControl = dwControl; + ControlPacket->dwControl = SERVICE_CONTROL_START; ControlPacket->hServiceStatus = (SERVICE_STATUS_HANDLE)Service; ControlPacket->dwSize = TotalLength; Ptr = &ControlPacket->szArguments[0]; @@ -763,7 +819,7 @@ dwError = ReplyPacket.dwError; }
- DPRINT("ScmSendServiceCommand() done\n"); + DPRINT("ScmSendStartCommand() done\n");
return dwError; } @@ -942,10 +998,7 @@ DPRINT("Received service process ID %lu\n", dwProcessId);
/* Send start command */ - dwError = ScmSendServiceCommand(Service, - SERVICE_CONTROL_START, - argc, - argv); + dwError = ScmSendStartCommand(Service, argc, argv); } } else @@ -1174,10 +1227,7 @@ CurrentService->Status.dwCurrentState == SERVICE_START_PENDING) { /* shutdown service */ - ScmSendServiceCommand(CurrentService, - SERVICE_CONTROL_STOP, - 0, - NULL); + ScmControlService(CurrentService, SERVICE_CONTROL_STOP); }
ServiceEntry = ServiceEntry->Flink;
Modified: trunk/reactos/base/system/services/rpcserver.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/rpcser... ============================================================================== --- trunk/reactos/base/system/services/rpcserver.c [iso-8859-1] (original) +++ trunk/reactos/base/system/services/rpcserver.c [iso-8859-1] Sun Oct 31 10:00:21 2010 @@ -699,10 +699,8 @@ }
/* Send control code to the service */ - dwError = ScmSendServiceCommand(lpService, - dwControl, - 0, - NULL); + dwError = ScmControlService(lpService, + dwControl);
/* Return service status information */ RtlCopyMemory(lpServiceStatus, @@ -2866,10 +2864,7 @@ }
/* Start the service */ - dwError = ScmSendServiceCommand(lpService, - SERVICE_CONTROL_START, - argc, - (LPWSTR *)argv); + dwError = ScmStartService(lpService, argc, (LPWSTR *)argv);
return dwError; } @@ -4077,10 +4072,7 @@ /* FIXME: Convert argument vector to Unicode */
/* Start the service */ - dwError = ScmSendServiceCommand(lpService, - SERVICE_CONTROL_START, - 0, - NULL); + dwError = ScmStartService(lpService, 0, NULL);
/* FIXME: Free argument vector */
Modified: trunk/reactos/base/system/services/services.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/servic... ============================================================================== --- trunk/reactos/base/system/services/services.h [iso-8859-1] (original) +++ trunk/reactos/base/system/services/services.h [iso-8859-1] Sun Oct 31 10:00:21 2010 @@ -104,10 +104,9 @@ VOID ScmGetBootAndSystemDriverState(VOID); VOID ScmAutoStartServices(VOID); VOID ScmAutoShutdownServices(VOID); -DWORD ScmSendServiceCommand(PSERVICE Service, - DWORD dwControl, - DWORD argc, - LPWSTR *argv); +DWORD ScmStartService(PSERVICE Service, + DWORD argc, + LPWSTR *argv);
PSERVICE ScmGetServiceEntryByName(LPCWSTR lpServiceName); PSERVICE ScmGetServiceEntryByDisplayName(LPCWSTR lpDisplayName); @@ -116,6 +115,9 @@ PSERVICE *lpServiceRecord); VOID ScmDeleteServiceRecord(PSERVICE lpService); DWORD ScmMarkServiceForDelete(PSERVICE pService); + +DWORD ScmControlService(PSERVICE Service, + DWORD dwControl);
BOOL ScmLockDatabaseExclusive(VOID); BOOL ScmLockDatabaseShared(VOID);