wevtsvc: Add EventLog service stub.

Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Dmitry Timoshkov 2020-09-23 21:15:21 +03:00 committed by Alexandre Julliard
parent 595600b6c1
commit 7e7e81f0c6
7 changed files with 161 additions and 0 deletions

2
configure vendored
View File

@ -1645,6 +1645,7 @@ enable_wdscore
enable_webservices
enable_wer
enable_wevtapi
enable_wevtsvc
enable_wiaservc
enable_wimgapi
enable_windowscodecs
@ -21007,6 +21008,7 @@ wine_fn_config_makefile dlls/webservices/tests enable_tests
wine_fn_config_makefile dlls/wer enable_wer
wine_fn_config_makefile dlls/wer/tests enable_tests
wine_fn_config_makefile dlls/wevtapi enable_wevtapi
wine_fn_config_makefile dlls/wevtsvc enable_wevtsvc
wine_fn_config_makefile dlls/wiaservc enable_wiaservc
wine_fn_config_makefile dlls/wiaservc/tests enable_tests
wine_fn_config_makefile dlls/wimgapi enable_wimgapi

View File

@ -3790,6 +3790,7 @@ WINE_CONFIG_MAKEFILE(dlls/webservices/tests)
WINE_CONFIG_MAKEFILE(dlls/wer)
WINE_CONFIG_MAKEFILE(dlls/wer/tests)
WINE_CONFIG_MAKEFILE(dlls/wevtapi)
WINE_CONFIG_MAKEFILE(dlls/wevtsvc)
WINE_CONFIG_MAKEFILE(dlls/wiaservc)
WINE_CONFIG_MAKEFILE(dlls/wiaservc/tests)
WINE_CONFIG_MAKEFILE(dlls/wimgapi)

View File

@ -2678,6 +2678,51 @@ static void test_refcount(void)
CloseServiceHandle(scm_handle);
}
static void test_EventLog(void)
{
SC_HANDLE scm_handle, svc_handle;
DWORD size;
BOOL ret;
QUERY_SERVICE_CONFIGA *config;
scm_handle = OpenSCManagerA(NULL, NULL, GENERIC_READ);
ok(scm_handle != NULL, "OpenSCManager error %u\n", GetLastError());
svc_handle = OpenServiceA(scm_handle, "EventLog", GENERIC_READ);
ok(svc_handle != NULL, "OpenService error %u\n", GetLastError());
SetLastError(0xdeadbeef);
ret = QueryServiceConfigA(svc_handle, NULL, 0, &size);
ok(!ret, "QueryServiceConfig should fail\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got %u\n", GetLastError());
config = HeapAlloc(GetProcessHeap(), 0, size);
ret = QueryServiceConfigA(svc_handle, config, size, &size);
ok(ret, "QueryServiceConfig error %u\n", GetLastError());
ok(config->dwServiceType == SERVICE_WIN32_SHARE_PROCESS, "got %#x\n", config->dwServiceType);
ok(config->dwStartType == SERVICE_AUTO_START, "got %u\n", config->dwStartType);
ok(config->dwErrorControl == SERVICE_ERROR_NORMAL, "got %u\n", config->dwErrorControl);
ok(!strcmpi(config->lpBinaryPathName, "C:\\windows\\system32\\services.exe") /* XP */ ||
!strcmpi(config->lpBinaryPathName, "C:\\windows\\system32\\svchost.exe -k LocalServiceNetworkRestricted") /* Vista+ */ ||
!strcmpi(config->lpBinaryPathName, "C:\\windows\\system32\\svchost.exe -k LocalServiceNetworkRestricted -p") /* Win10 */,
"got %s\n", config->lpBinaryPathName);
todo_wine
ok(!strcmpi(config->lpLoadOrderGroup, "Event Log"), "got %s\n", config->lpLoadOrderGroup);
ok(config->dwTagId == 0, "Expected 0, got %d\n", config->dwTagId);
ok(!config->lpDependencies[0], "lpDependencies is not empty\n");
ok(!strcmp(config->lpServiceStartName, "LocalSystem") /* XP */ ||
!strcmp(config->lpServiceStartName, "NT AUTHORITY\\LocalService"),
"got %s\n", config->lpServiceStartName);
ok(!strcmp(config->lpDisplayName, "Event Log") /* XP */ ||
!strcmp(config->lpDisplayName, "Windows Event Log") /* Vista+ */, "got %s\n", config->lpDisplayName);
HeapFree(GetProcessHeap(), 0, config);
CloseServiceHandle(svc_handle);
CloseServiceHandle(scm_handle);
}
static DWORD WINAPI ctrl_handler(DWORD ctl, DWORD type, void *data, void *user)
{
HANDLE evt = user;
@ -2775,4 +2820,5 @@ START_TEST(service)
* and what the rules are
*/
test_refcount();
test_EventLog();
}

7
dlls/wevtsvc/Makefile.in Normal file
View File

@ -0,0 +1,7 @@
MODULE = wevtsvc.dll
IMPORTS = rpcrt4 advapi32
EXTRADLLFLAGS = -mno-cygwin
C_SRCS = \
wevtsvc.c

87
dlls/wevtsvc/wevtsvc.c Normal file
View File

@ -0,0 +1,87 @@
/*
* Event Log Service
*
* Copyright 2020 Dmitry Timoshkov
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winsvc.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(eventlog);
static SERVICE_STATUS_HANDLE svc_handle;
static HANDLE done_event;
static void eventlog_update_status(DWORD state)
{
SERVICE_STATUS status;
status.dwServiceType = SERVICE_WIN32;
status.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN;
status.dwWin32ExitCode = 0;
status.dwServiceSpecificExitCode = 0;
status.dwCheckPoint = 0;
status.dwWaitHint = 0;
status.dwControlsAccepted = 0;
status.dwCurrentState = state;
SetServiceStatus(svc_handle, &status);
}
static void WINAPI eventlog_handler(DWORD control)
{
TRACE("%#x\n", control);
switch (control)
{
case SERVICE_CONTROL_STOP:
case SERVICE_CONTROL_SHUTDOWN:
eventlog_update_status(SERVICE_STOP_PENDING);
SetEvent(done_event);
break;
default:
eventlog_update_status(SERVICE_RUNNING);
break;
}
}
void WINAPI ServiceMain(DWORD argc, LPWSTR *argv)
{
TRACE("starting Event Log Service\n");
svc_handle = RegisterServiceCtrlHandlerW(L"EventLog", eventlog_handler);
if (!svc_handle)
{
ERR("RegisterServiceCtrlHandler error %u\n", GetLastError());
return;
}
eventlog_update_status(SERVICE_RUNNING);
done_event = CreateEventW(NULL, TRUE, FALSE, NULL);
WaitForSingleObject(done_event, INFINITE);
CloseHandle(done_event);
eventlog_update_status(SERVICE_STOPPED);
TRACE("exiting Event Log Service\n");
}

View File

@ -0,0 +1 @@
@ stdcall -private ServiceMain(long ptr)

View File

@ -149,6 +149,7 @@ WineFakeDlls=FakeDllsWin32
[DefaultInstall.Services]
AddService=BITS,0,BITSService
AddService=EventLog,0,EventLogService
AddService=HTTP,0,HTTPService
AddService=MSIServer,0,MSIService
AddService=MountMgr,0x800,MountMgrService
@ -167,6 +168,7 @@ AddService=NDIS,0x800,NDISService
[DefaultInstall.NT.Services]
AddService=BITS,0,BITSService
AddService=EventLog,0,EventLogService
AddService=HTTP,0,HTTPService
AddService=MSIServer,0,MSIService
AddService=MountMgr,0x800,MountMgrService
@ -185,6 +187,7 @@ AddService=NDIS,0x800,NDISService
[DefaultInstall.ntamd64.Services]
AddService=BITS,0,BITSService
AddService=EventLog,0,EventLogService
AddService=HTTP,0,HTTPService
AddService=MSIServer,0,MSIService
AddService=MountMgr,0x800,MountMgrService
@ -203,6 +206,7 @@ AddService=NDIS,0x800,NDISService
[DefaultInstall.ntarm64.Services]
AddService=BITS,0,BITSService
AddService=EventLog,0,EventLogService
AddService=HTTP,0,HTTPService
AddService=MSIServer,0,MSIService
AddService=MountMgr,0x800,MountMgrService
@ -3609,6 +3613,15 @@ ServiceType=16
StartType=3
ErrorControl=1
[EventLogService]
AddReg=EventLogServiceKeys
Description="Event Log"
DisplayName="Event Log"
ServiceBinary="%11%\svchost.exe -k LocalServiceNetworkRestricted"
ServiceType=32
StartType=2
ErrorControl=1
[HTTPService]
Description="HTTP server"
DisplayName="HTTP"
@ -3696,6 +3709,10 @@ ErrorControl=1
HKR,Parameters,"ServiceDll",,"%11%\qmgr.dll"
HKLM,%CurrentVersionNT%\SvcHost,"netsvcs",0x00010000,"BITS"
[EventLogServiceKeys]
HKR,Parameters,"ServiceDll",,"%11%\wevtsvc.dll"
HKLM,%CurrentVersionNT%\SvcHost,"LocalServiceNetworkRestricted",0x00010000,"EventLog"
[StiServiceKeys]
HKR,Parameters,"ServiceDll",,"%11%\wiaservc.dll"
HKLM,%CurrentVersionNT%\SvcHost,"imgsvc",0x00010000,"StiSvc"