Signed-off-by: Dmitry Timoshkov dmitry@baikal.ru --- dlls/schedsvc/Makefile.in | 5 +++- dlls/schedsvc/atsvc.c | 52 ++++++++++++++++++++++++++++++++++ dlls/schedsvc/atsvc.idl | 3 ++ dlls/schedsvc/svc_main.c | 38 +++++++++++++++++++++---- include/wine/atsvc.idl | 71 +++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 162 insertions(+), 7 deletions(-) create mode 100644 dlls/schedsvc/atsvc.c create mode 100644 dlls/schedsvc/atsvc.idl create mode 100644 include/wine/atsvc.idl
diff --git a/dlls/schedsvc/Makefile.in b/dlls/schedsvc/Makefile.in index 32ee4e33f8..021cae468a 100644 --- a/dlls/schedsvc/Makefile.in +++ b/dlls/schedsvc/Makefile.in @@ -2,7 +2,10 @@ MODULE = schedsvc.dll IMPORTS = rpcrt4 advapi32 ole32
C_SRCS = \ + atsvc.c \ schedsvc.c \ svc_main.c
-IDL_SRCS = schrpc.idl +IDL_SRCS = \ + atsvc.idl \ + schrpc.idl diff --git a/dlls/schedsvc/atsvc.c b/dlls/schedsvc/atsvc.c new file mode 100644 index 0000000000..6bb8d4c707 --- /dev/null +++ b/dlls/schedsvc/atsvc.c @@ -0,0 +1,52 @@ +/* + * ATSvc RPC API + * + * Copyright 2018 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 "atsvc.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(schedsvc); + +DWORD __cdecl NetrJobAdd(ATSVC_HANDLE server_name, AT_INFO *info, DWORD *jobid) +{ + FIXME("%s,%p,%p: stub\n", debugstr_w(server_name), info, jobid); + return ERROR_NOT_SUPPORTED; +} + +DWORD __cdecl NetrJobDel(ATSVC_HANDLE server_name, DWORD min_jobid, DWORD max_jobid) +{ + FIXME("%s,%u,%u: stub\n", debugstr_w(server_name), min_jobid, max_jobid); + return ERROR_NOT_SUPPORTED; +} + +DWORD __cdecl NetrJobEnum(ATSVC_HANDLE server_name, AT_ENUM_CONTAINER *container, + DWORD max_length, DWORD *total, DWORD *resume) +{ + FIXME("%s,%p,%u,%p,%p: stub\n", debugstr_w(server_name), container, max_length, total, resume); + return ERROR_NOT_SUPPORTED; +} + +DWORD __cdecl NetrJobGetInfo(ATSVC_HANDLE server_name, DWORD jobid, AT_INFO **info) +{ + FIXME("%s,%u,%p: stub\n", debugstr_w(server_name), jobid, info); + return ERROR_NOT_SUPPORTED; +} diff --git a/dlls/schedsvc/atsvc.idl b/dlls/schedsvc/atsvc.idl new file mode 100644 index 0000000000..afb2b86ac4 --- /dev/null +++ b/dlls/schedsvc/atsvc.idl @@ -0,0 +1,3 @@ +#pragma makedep server + +#include "wine/atsvc.idl" diff --git a/dlls/schedsvc/svc_main.c b/dlls/schedsvc/svc_main.c index bd8a29dcd9..8713bdb88a 100644 --- a/dlls/schedsvc/svc_main.c +++ b/dlls/schedsvc/svc_main.c @@ -24,6 +24,7 @@ #include "winbase.h" #include "winsvc.h" #include "rpc.h" +#include "atsvc.h" #include "schrpc.h" #include "wine/debug.h"
@@ -123,22 +124,38 @@ static RPC_BINDING_VECTOR *sched_bindings;
static RPC_STATUS RPC_init(void) { - WCHAR transport[] = SCHEDSVC_TRANSPORT; + static WCHAR ncacn_npW[] = { 'n','c','a','c','n','_','n','p',0 }; + static WCHAR endpoint_npW[] = { '\','p','i','p','e','\','a','t','s','v','c',0 }; + static WCHAR ncalrpcW[] = { 'n','c','a','l','r','p','c',0 }; + static WCHAR endpoint_lrpcW[] = { 'a','t','s','v','c',0 }; RPC_STATUS status;
- TRACE("using %s\n", debugstr_w(transport)); + status = RpcServerRegisterIf(ITaskSchedulerService_v1_0_s_ifspec, NULL, NULL); + if (status != RPC_S_OK) + { + ERR("RpcServerRegisterIf error %#x\n", status); + return status; + }
- status = RpcServerUseProtseqEpW(transport, 0, NULL, NULL); + status = RpcServerRegisterIf(atsvc_v1_0_s_ifspec, NULL, NULL); + if (status != RPC_S_OK) + { + ERR("RpcServerRegisterIf error %#x\n", status); + RpcServerUnregisterIf(ITaskSchedulerService_v1_0_s_ifspec, NULL, FALSE); + return status; + } + + status = RpcServerUseProtseqEpW(ncacn_npW, RPC_C_PROTSEQ_MAX_REQS_DEFAULT, endpoint_npW, NULL); if (status != RPC_S_OK) { ERR("RpcServerUseProtseqEp error %#x\n", status); return status; }
- status = RpcServerRegisterIf(ITaskSchedulerService_v1_0_s_ifspec, 0, 0); + status = RpcServerUseProtseqEpW(ncalrpcW, RPC_C_PROTSEQ_MAX_REQS_DEFAULT, endpoint_lrpcW, NULL); if (status != RPC_S_OK) { - ERR("RpcServerRegisterIf error %#x\n", status); + ERR("RpcServerUseProtseqEp error %#x\n", status); return status; }
@@ -156,6 +173,13 @@ static RPC_STATUS RPC_init(void) return status; }
+ status = RpcEpRegisterW(atsvc_v1_0_s_ifspec, sched_bindings, NULL, NULL); + if (status != RPC_S_OK) + { + ERR("RpcEpRegister error %#x\n", status); + return status; + } + status = RpcServerListen(1, RPC_C_LISTEN_MAX_CALLS_DEFAULT, TRUE); if (status != RPC_S_OK) { @@ -169,8 +193,10 @@ static void RPC_finish(void) { RpcMgmtStopServerListening(NULL); RpcEpUnregister(ITaskSchedulerService_v1_0_s_ifspec, sched_bindings, NULL); + RpcEpUnregister(atsvc_v1_0_s_ifspec, sched_bindings, NULL); RpcBindingVectorFree(&sched_bindings); - RpcServerUnregisterIf(NULL, NULL, FALSE); + RpcServerUnregisterIf(ITaskSchedulerService_v1_0_s_ifspec, NULL, FALSE); + RpcServerUnregisterIf(atsvc_v1_0_s_ifspec, NULL, FALSE); }
void WINAPI ServiceMain(DWORD argc, LPWSTR *argv) diff --git a/include/wine/atsvc.idl b/include/wine/atsvc.idl new file mode 100644 index 0000000000..c1fce98074 --- /dev/null +++ b/include/wine/atsvc.idl @@ -0,0 +1,71 @@ +/* + * ATSvc Service definitions + * + * Copyright 2018 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 + */ + +import "oaidl.idl"; +import "ocidl.idl"; + +[ + uuid(1ff70682-0a51-30e8-076d-740be8cee98b), + implicit_handle(handle_t rpc_handle), + version(1.0), + pointer_default(unique) +] +interface atsvc +{ + typedef [handle] const WCHAR *ATSVC_HANDLE; + + typedef struct _AT_ENUM + { + DWORD JobId; + DWORD_PTR JobTime; + DWORD DaysOfMonth; + unsigned char DaysOfWeek; + unsigned char Flags; + [string] WCHAR *Command; + } AT_ENUM, *PAT_ENUM, *LPAT_ENUM; + + typedef struct _AT_INFO + { + DWORD_PTR JobTime; + DWORD DaysOfMonth; + unsigned char DaysOfWeek; + unsigned char Flags; + [string] WCHAR *Command; + } AT_INFO, *PAT_INFO, *LPAT_INFO; + + typedef struct _AT_ENUM_CONTAINER + { + DWORD EntriesRead; + [size_is(EntriesRead)] LPAT_ENUM Buffer; + } AT_ENUM_CONTAINER, *PAT_ENUM_CONTAINER, *LPAT_ENUM_CONTAINER; + + DWORD NetrJobAdd([in,string,unique] ATSVC_HANDLE ServerName, + [in] LPAT_INFO pAtInfo, [out] LPDWORD pJobId); + + DWORD NetrJobDel([in,string,unique] ATSVC_HANDLE ServerName, + [in] DWORD MinJobId, [in] DWORD MaxJobId); + + DWORD NetrJobEnum([in,string,unique] ATSVC_HANDLE ServerName, + [in,out] LPAT_ENUM_CONTAINER pEnumContainer, [in] DWORD PreferedMaximumLength, + [out] LPDWORD pTotalEntries, [in,out,unique] LPDWORD pResumeHandle); + + DWORD NetrJobGetInfo([in,string,unique] ATSVC_HANDLE ServerName, + [in] DWORD JobId, [out] LPAT_INFO *ppAtInfo); +}