mirror of
https://github.com/reactos/reactos.git
synced 2024-07-03 03:04:22 +00:00
[SERVICES]:
- Fix build. - Remove now deprecated code (since we use RPC for service commands since revision r13xxx). svn path=/trunk/; revision=73402
This commit is contained in:
parent
49284f4696
commit
d73bbf218c
|
@ -659,7 +659,7 @@ ScmDeleteRegKey(
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
dwError = ScmDeleteServiceKey(hSubKey, pszName);
|
dwError = ScmDeleteRegKey(hSubKey, pszName);
|
||||||
if (dwError != ERROR_SUCCESS)
|
if (dwError != ERROR_SUCCESS)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,9 +21,6 @@ int WINAPI RegisterServicesProcess(DWORD ServicesProcessId);
|
||||||
|
|
||||||
/* GLOBALS ******************************************************************/
|
/* GLOBALS ******************************************************************/
|
||||||
|
|
||||||
#define PIPE_BUFSIZE 1024
|
|
||||||
#define PIPE_TIMEOUT 1000
|
|
||||||
|
|
||||||
/* Defined in include/reactos/services/services.h */
|
/* Defined in include/reactos/services/services.h */
|
||||||
// #define SCM_START_EVENT L"SvcctrlStartEvent_A3752DX"
|
// #define SCM_START_EVENT L"SvcctrlStartEvent_A3752DX"
|
||||||
#define SCM_AUTOSTARTCOMPLETE_EVENT L"SC_AutoStartComplete"
|
#define SCM_AUTOSTARTCOMPLETE_EVENT L"SC_AutoStartComplete"
|
||||||
|
@ -105,182 +102,6 @@ ScmWaitForLsa(VOID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BOOL
|
|
||||||
ScmNamedPipeHandleRequest(PVOID Request,
|
|
||||||
DWORD RequestSize,
|
|
||||||
PVOID Reply,
|
|
||||||
LPDWORD ReplySize)
|
|
||||||
{
|
|
||||||
DbgPrint("SCM READ: %p\n", Request);
|
|
||||||
|
|
||||||
*ReplySize = 0;
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
DWORD WINAPI
|
|
||||||
ScmNamedPipeThread(LPVOID Context)
|
|
||||||
{
|
|
||||||
CHAR chRequest[PIPE_BUFSIZE];
|
|
||||||
CHAR chReply[PIPE_BUFSIZE];
|
|
||||||
DWORD cbReplyBytes;
|
|
||||||
DWORD cbBytesRead;
|
|
||||||
DWORD cbWritten;
|
|
||||||
BOOL bSuccess;
|
|
||||||
HANDLE hPipe;
|
|
||||||
|
|
||||||
hPipe = (HANDLE)Context;
|
|
||||||
|
|
||||||
DPRINT("ScmNamedPipeThread(%p) - Accepting SCM commands through named pipe\n", hPipe);
|
|
||||||
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
bSuccess = ReadFile(hPipe,
|
|
||||||
&chRequest,
|
|
||||||
PIPE_BUFSIZE,
|
|
||||||
&cbBytesRead,
|
|
||||||
NULL);
|
|
||||||
if (!bSuccess || cbBytesRead == 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ScmNamedPipeHandleRequest(&chRequest, cbBytesRead, &chReply, &cbReplyBytes))
|
|
||||||
{
|
|
||||||
bSuccess = WriteFile(hPipe,
|
|
||||||
&chReply,
|
|
||||||
cbReplyBytes,
|
|
||||||
&cbWritten,
|
|
||||||
NULL);
|
|
||||||
if (!bSuccess || cbReplyBytes != cbWritten)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DPRINT("ScmNamedPipeThread(%p) - Disconnecting named pipe connection\n", hPipe);
|
|
||||||
|
|
||||||
FlushFileBuffers(hPipe);
|
|
||||||
DisconnectNamedPipe(hPipe);
|
|
||||||
CloseHandle(hPipe);
|
|
||||||
|
|
||||||
DPRINT("ScmNamedPipeThread(%p) - Done.\n", hPipe);
|
|
||||||
|
|
||||||
return ERROR_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
BOOL
|
|
||||||
ScmCreateNamedPipe(VOID)
|
|
||||||
{
|
|
||||||
DWORD dwThreadId;
|
|
||||||
BOOL bConnected;
|
|
||||||
HANDLE hThread;
|
|
||||||
HANDLE hPipe;
|
|
||||||
|
|
||||||
DPRINT("ScmCreateNamedPipe() - CreateNamedPipe(\"\\\\.\\pipe\\Ntsvcs\")\n");
|
|
||||||
|
|
||||||
hPipe = CreateNamedPipeW(L"\\\\.\\pipe\\Ntsvcs",
|
|
||||||
PIPE_ACCESS_DUPLEX,
|
|
||||||
PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
|
|
||||||
PIPE_UNLIMITED_INSTANCES,
|
|
||||||
PIPE_BUFSIZE,
|
|
||||||
PIPE_BUFSIZE,
|
|
||||||
PIPE_TIMEOUT,
|
|
||||||
NULL);
|
|
||||||
if (hPipe == INVALID_HANDLE_VALUE)
|
|
||||||
{
|
|
||||||
DPRINT("CreateNamedPipe() failed (%lu)\n", GetLastError());
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
DPRINT("CreateNamedPipe() - calling ConnectNamedPipe(%p)\n", hPipe);
|
|
||||||
bConnected = ConnectNamedPipe(hPipe,
|
|
||||||
NULL) ? TRUE : (GetLastError() == ERROR_PIPE_CONNECTED);
|
|
||||||
DPRINT("CreateNamedPipe() - ConnectNamedPipe() returned %d\n", bConnected);
|
|
||||||
|
|
||||||
if (bConnected)
|
|
||||||
{
|
|
||||||
DPRINT("Pipe connected\n");
|
|
||||||
hThread = CreateThread(NULL,
|
|
||||||
0,
|
|
||||||
ScmNamedPipeThread,
|
|
||||||
(LPVOID)hPipe,
|
|
||||||
0,
|
|
||||||
&dwThreadId);
|
|
||||||
if (!hThread)
|
|
||||||
{
|
|
||||||
DPRINT("Could not create thread (%lu)\n", GetLastError());
|
|
||||||
DisconnectNamedPipe(hPipe);
|
|
||||||
CloseHandle(hPipe);
|
|
||||||
DPRINT("CreateNamedPipe() - returning FALSE\n");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
CloseHandle(hThread);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DPRINT("Pipe not connected\n");
|
|
||||||
CloseHandle(hPipe);
|
|
||||||
DPRINT("CreateNamedPipe() - returning FALSE\n");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
DPRINT("CreateNamedPipe() - returning TRUE\n");
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
DWORD WINAPI
|
|
||||||
ScmNamedPipeListenerThread(LPVOID Context)
|
|
||||||
{
|
|
||||||
// HANDLE hPipe;
|
|
||||||
DPRINT("ScmNamedPipeListenerThread(%p) - aka SCM.\n", Context);
|
|
||||||
|
|
||||||
// hPipe = (HANDLE)Context;
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
DPRINT("SCM: Waiting for new connection on named pipe...\n");
|
|
||||||
/* Create named pipe */
|
|
||||||
if (!ScmCreateNamedPipe())
|
|
||||||
{
|
|
||||||
DPRINT1("\nSCM: Failed to create named pipe\n");
|
|
||||||
break;
|
|
||||||
//ExitThread(0);
|
|
||||||
}
|
|
||||||
DPRINT("\nSCM: named pipe session created.\n");
|
|
||||||
Sleep(10);
|
|
||||||
}
|
|
||||||
DPRINT("\n\nWARNING: ScmNamedPipeListenerThread(%p) - Aborted.\n\n", Context);
|
|
||||||
return ERROR_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
BOOL
|
|
||||||
StartScmNamedPipeThreadListener(VOID)
|
|
||||||
{
|
|
||||||
DWORD dwThreadId;
|
|
||||||
HANDLE hThread;
|
|
||||||
|
|
||||||
hThread = CreateThread(NULL,
|
|
||||||
0,
|
|
||||||
ScmNamedPipeListenerThread,
|
|
||||||
NULL, /*(LPVOID)hPipe,*/
|
|
||||||
0,
|
|
||||||
&dwThreadId);
|
|
||||||
if (!hThread)
|
|
||||||
{
|
|
||||||
DPRINT1("SERVICES: Could not create thread (Status %lx)\n", GetLastError());
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
CloseHandle(hThread);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
BOOL WINAPI
|
BOOL WINAPI
|
||||||
ShutdownHandlerRoutine(DWORD dwCtrlType)
|
ShutdownHandlerRoutine(DWORD dwCtrlType)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue