2014-03-07 04:10:28 +01:00
|
|
|
/*
|
|
|
|
* Task Scheduler Service
|
|
|
|
*
|
|
|
|
* Copyright 2014 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 "rpc.h"
|
2018-04-05 09:55:39 +02:00
|
|
|
#include "atsvc.h"
|
2014-03-07 04:10:28 +01:00
|
|
|
#include "schrpc.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
2017-03-09 16:12:10 +01:00
|
|
|
#include "schedsvc_private.h"
|
|
|
|
|
2014-03-07 04:10:28 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(schedsvc);
|
|
|
|
|
2014-03-14 04:58:16 +01:00
|
|
|
static const WCHAR scheduleW[] = {'S','c','h','e','d','u','l','e',0};
|
2014-03-07 04:10:28 +01:00
|
|
|
static SERVICE_STATUS_HANDLE schedsvc_handle;
|
2018-05-31 06:21:34 +02:00
|
|
|
static HANDLE done_event, hjob_queue;
|
|
|
|
|
|
|
|
void add_process_to_queue(HANDLE process)
|
|
|
|
{
|
|
|
|
if (!AssignProcessToJobObject(hjob_queue, process))
|
2018-06-01 11:12:28 +02:00
|
|
|
ERR("AssignProcessToJobObject failed\n");
|
2018-05-31 06:21:34 +02:00
|
|
|
}
|
2014-03-07 04:10:28 +01:00
|
|
|
|
2018-04-17 09:12:03 +02:00
|
|
|
static DWORD WINAPI tasks_monitor_thread(void *arg)
|
|
|
|
{
|
|
|
|
static const WCHAR tasksW[] = { '\\','T','a','s','k','s','\\',0 };
|
|
|
|
WCHAR path[MAX_PATH];
|
2018-06-06 08:34:32 +02:00
|
|
|
HANDLE htasks, hport, htimer;
|
2018-06-26 13:09:13 +02:00
|
|
|
JOBOBJECT_ASSOCIATE_COMPLETION_PORT job_info;
|
2018-04-17 09:12:03 +02:00
|
|
|
OVERLAPPED ov;
|
2018-06-06 08:34:32 +02:00
|
|
|
LARGE_INTEGER period;
|
2018-06-26 13:09:13 +02:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
FILE_NOTIFY_INFORMATION data;
|
|
|
|
WCHAR name_buffer[MAX_PATH];
|
|
|
|
} info;
|
|
|
|
|
|
|
|
/* the buffer must be DWORD aligned */
|
|
|
|
C_ASSERT(!(sizeof(info) & 3));
|
2018-04-17 09:12:03 +02:00
|
|
|
|
|
|
|
TRACE("Starting...\n");
|
|
|
|
|
2018-06-08 09:43:51 +02:00
|
|
|
load_at_tasks();
|
2018-06-08 09:43:55 +02:00
|
|
|
check_missed_task_time();
|
2018-06-08 09:43:51 +02:00
|
|
|
|
2018-06-06 08:34:32 +02:00
|
|
|
htimer = CreateWaitableTimerW(NULL, FALSE, NULL);
|
|
|
|
if (htimer == NULL)
|
|
|
|
{
|
|
|
|
ERR("CreateWaitableTimer failed\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2018-04-17 09:12:03 +02:00
|
|
|
GetWindowsDirectoryW(path, MAX_PATH);
|
|
|
|
lstrcatW(path, tasksW);
|
|
|
|
|
|
|
|
htasks = CreateFileW(path, FILE_LIST_DIRECTORY, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
|
|
|
|
NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED, NULL);
|
2018-04-24 10:13:20 +02:00
|
|
|
if (htasks == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
ERR("Couldn't start monitoring %s for tasks, error %u\n", debugstr_w(path), GetLastError());
|
|
|
|
/* Probably this is an old prefix with disabled updates */
|
|
|
|
if (GetLastError() == ERROR_PATH_NOT_FOUND || GetLastError() == ERROR_FILE_NOT_FOUND)
|
|
|
|
ERR("Please create the directory manually\n");
|
|
|
|
return -1;
|
|
|
|
}
|
2018-04-17 09:12:03 +02:00
|
|
|
|
2018-05-31 06:21:34 +02:00
|
|
|
hjob_queue = CreateJobObjectW(NULL, NULL);
|
|
|
|
if (!hjob_queue)
|
|
|
|
{
|
2018-06-01 11:12:28 +02:00
|
|
|
ERR("CreateJobObject failed\n");
|
2018-05-31 06:21:34 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
hport = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 1);
|
|
|
|
if (!hport)
|
|
|
|
{
|
2018-06-01 11:12:28 +02:00
|
|
|
ERR("CreateIoCompletionPort failed\n");
|
2018-05-31 06:21:34 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2018-06-26 13:09:13 +02:00
|
|
|
job_info.CompletionKey = hjob_queue;
|
|
|
|
job_info.CompletionPort = hport;
|
|
|
|
if (!SetInformationJobObject(hjob_queue, JobObjectAssociateCompletionPortInformation, &job_info, sizeof(job_info)))
|
2018-05-31 06:21:34 +02:00
|
|
|
{
|
2018-06-01 11:12:28 +02:00
|
|
|
ERR("SetInformationJobObject failed\n");
|
2018-05-31 06:21:34 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2018-04-17 09:12:03 +02:00
|
|
|
memset(&ov, 0, sizeof(ov));
|
|
|
|
ov.hEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
|
|
|
|
|
2018-06-26 13:09:13 +02:00
|
|
|
memset(&info, 0, sizeof(info));
|
|
|
|
ReadDirectoryChangesW(htasks, &info, sizeof(info), FALSE,
|
|
|
|
FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_SIZE | FILE_NOTIFY_CHANGE_LAST_WRITE,
|
|
|
|
NULL, &ov, NULL);
|
|
|
|
|
2018-04-17 09:12:03 +02:00
|
|
|
for (;;)
|
|
|
|
{
|
2018-06-06 08:34:32 +02:00
|
|
|
HANDLE events[4];
|
2018-04-17 09:12:03 +02:00
|
|
|
DWORD ret;
|
|
|
|
|
|
|
|
events[0] = done_event;
|
2018-06-06 08:34:32 +02:00
|
|
|
events[1] = htimer;
|
2018-05-31 06:21:34 +02:00
|
|
|
events[2] = hport;
|
2018-06-06 08:34:32 +02:00
|
|
|
events[3] = ov.hEvent;
|
2018-04-17 09:12:03 +02:00
|
|
|
|
2018-06-06 08:34:32 +02:00
|
|
|
ret = WaitForMultipleObjects(4, events, FALSE, INFINITE);
|
|
|
|
/* Done event */
|
2018-04-17 09:12:03 +02:00
|
|
|
if (ret == WAIT_OBJECT_0) break;
|
|
|
|
|
2018-06-06 08:34:32 +02:00
|
|
|
/* Next runtime timer */
|
|
|
|
if (ret == WAIT_OBJECT_0 + 1)
|
|
|
|
{
|
|
|
|
check_task_time();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Job queue */
|
2018-05-31 06:21:34 +02:00
|
|
|
if (ret == WAIT_OBJECT_0 + 2)
|
|
|
|
{
|
|
|
|
DWORD msg;
|
|
|
|
ULONG_PTR dummy, pid;
|
|
|
|
|
|
|
|
if (GetQueuedCompletionStatus(hport, &msg, &dummy, (OVERLAPPED **)&pid, 0))
|
|
|
|
{
|
|
|
|
if (msg == JOB_OBJECT_MSG_EXIT_PROCESS)
|
|
|
|
{
|
|
|
|
TRACE("got message: process %#lx has terminated\n", pid);
|
|
|
|
update_process_status(pid);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
FIXME("got message %#x from the job\n", msg);
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2018-06-26 13:09:13 +02:00
|
|
|
if (info.data.NextEntryOffset)
|
|
|
|
FIXME("got multiple entries\n");
|
|
|
|
|
2018-06-06 08:34:32 +02:00
|
|
|
/* Directory change notification */
|
2018-05-08 11:40:41 +02:00
|
|
|
info.data.FileName[info.data.FileNameLength/sizeof(WCHAR)] = 0;
|
|
|
|
|
2018-04-17 09:12:03 +02:00
|
|
|
switch (info.data.Action)
|
|
|
|
{
|
2018-04-17 09:12:06 +02:00
|
|
|
case FILE_ACTION_ADDED:
|
|
|
|
TRACE("FILE_ACTION_ADDED %s\n", debugstr_w(info.data.FileName));
|
|
|
|
|
|
|
|
GetWindowsDirectoryW(path, MAX_PATH);
|
|
|
|
lstrcatW(path, tasksW);
|
|
|
|
lstrcatW(path, info.data.FileName);
|
|
|
|
add_job(path);
|
2018-04-17 09:12:08 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case FILE_ACTION_REMOVED:
|
|
|
|
TRACE("FILE_ACTION_REMOVED %s\n", debugstr_w(info.data.FileName));
|
|
|
|
GetWindowsDirectoryW(path, MAX_PATH);
|
|
|
|
lstrcatW(path, tasksW);
|
|
|
|
lstrcatW(path, info.data.FileName);
|
|
|
|
remove_job(path);
|
2018-05-04 05:39:26 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case FILE_ACTION_MODIFIED:
|
|
|
|
TRACE("FILE_ACTION_MODIFIED %s\n", debugstr_w(info.data.FileName));
|
|
|
|
|
|
|
|
GetWindowsDirectoryW(path, MAX_PATH);
|
|
|
|
lstrcatW(path, tasksW);
|
|
|
|
lstrcatW(path, info.data.FileName);
|
2018-05-11 06:36:26 +02:00
|
|
|
remove_job(path);
|
|
|
|
add_job(path);
|
2018-04-17 09:12:06 +02:00
|
|
|
break;
|
|
|
|
|
2018-04-17 09:12:03 +02:00
|
|
|
default:
|
|
|
|
FIXME("%s: action %#x not handled\n", debugstr_w(info.data.FileName), info.data.Action);
|
|
|
|
break;
|
|
|
|
}
|
2018-05-31 06:21:34 +02:00
|
|
|
|
|
|
|
check_task_state();
|
2018-06-06 08:34:32 +02:00
|
|
|
|
|
|
|
if (get_next_runtime(&period))
|
|
|
|
{
|
|
|
|
if (!SetWaitableTimer(htimer, &period, 0, NULL, NULL, FALSE))
|
|
|
|
ERR("SetWaitableTimer failed\n");
|
|
|
|
}
|
2018-06-26 13:09:13 +02:00
|
|
|
|
|
|
|
memset(&info, 0, sizeof(info));
|
|
|
|
if (!ReadDirectoryChangesW(htasks, &info, sizeof(info), FALSE,
|
|
|
|
FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_SIZE | FILE_NOTIFY_CHANGE_LAST_WRITE,
|
|
|
|
NULL, &ov, NULL)) break;
|
2018-04-17 09:12:03 +02:00
|
|
|
}
|
|
|
|
|
2018-06-06 08:34:32 +02:00
|
|
|
CancelWaitableTimer(htimer);
|
|
|
|
CloseHandle(htimer);
|
2018-04-17 09:12:03 +02:00
|
|
|
CloseHandle(ov.hEvent);
|
2018-05-31 06:21:34 +02:00
|
|
|
CloseHandle(hport);
|
|
|
|
CloseHandle(hjob_queue);
|
2018-04-17 09:12:03 +02:00
|
|
|
CloseHandle(htasks);
|
|
|
|
|
|
|
|
TRACE("Finished.\n");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-03-14 04:58:16 +01:00
|
|
|
void schedsvc_auto_start(void)
|
|
|
|
{
|
|
|
|
static DWORD start_type;
|
|
|
|
SC_HANDLE scm, service;
|
|
|
|
QUERY_SERVICE_CONFIGW *cfg;
|
|
|
|
DWORD cfg_size;
|
|
|
|
|
|
|
|
if (start_type == SERVICE_AUTO_START) return;
|
|
|
|
|
|
|
|
TRACE("changing service start type to SERVICE_AUTO_START\n");
|
|
|
|
|
|
|
|
scm = OpenSCManagerW(NULL, NULL, 0);
|
|
|
|
if (!scm)
|
|
|
|
{
|
|
|
|
WARN("failed to open SCM (%u)\n", GetLastError());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
service = OpenServiceW(scm, scheduleW, SERVICE_QUERY_CONFIG | SERVICE_CHANGE_CONFIG);
|
|
|
|
if (service)
|
|
|
|
{
|
|
|
|
if (!QueryServiceConfigW(service, NULL, 0, &cfg_size) && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
|
|
|
|
{
|
|
|
|
cfg = HeapAlloc(GetProcessHeap(), 0, cfg_size);
|
|
|
|
if (cfg)
|
|
|
|
{
|
|
|
|
if (QueryServiceConfigW(service, cfg, cfg_size, &cfg_size))
|
|
|
|
{
|
|
|
|
start_type = cfg->dwStartType;
|
|
|
|
if (start_type != SERVICE_AUTO_START)
|
|
|
|
{
|
|
|
|
if (ChangeServiceConfigW(service, SERVICE_NO_CHANGE, SERVICE_AUTO_START, SERVICE_NO_CHANGE,
|
|
|
|
NULL, NULL, NULL, NULL, NULL, NULL, NULL))
|
|
|
|
start_type = SERVICE_AUTO_START;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
HeapFree(GetProcessHeap(), 0, cfg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
WARN("failed to query service config (%u)\n", GetLastError());
|
|
|
|
|
|
|
|
CloseServiceHandle(service);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
WARN("failed to open service (%u)\n", GetLastError());
|
|
|
|
|
|
|
|
CloseServiceHandle(scm);
|
|
|
|
}
|
|
|
|
|
2014-03-07 04:10:28 +01:00
|
|
|
static void schedsvc_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(schedsvc_handle, &status);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void WINAPI schedsvc_handler(DWORD control)
|
|
|
|
{
|
2014-03-18 09:42:52 +01:00
|
|
|
TRACE("%#x\n", control);
|
2014-03-07 04:10:28 +01:00
|
|
|
|
|
|
|
switch (control)
|
|
|
|
{
|
|
|
|
case SERVICE_CONTROL_STOP:
|
|
|
|
case SERVICE_CONTROL_SHUTDOWN:
|
|
|
|
schedsvc_update_status(SERVICE_STOP_PENDING);
|
|
|
|
SetEvent(done_event);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
schedsvc_update_status(SERVICE_RUNNING);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static RPC_BINDING_VECTOR *sched_bindings;
|
|
|
|
|
|
|
|
static RPC_STATUS RPC_init(void)
|
|
|
|
{
|
2018-04-05 09:55:39 +02:00
|
|
|
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 };
|
2014-03-07 04:10:28 +01:00
|
|
|
RPC_STATUS status;
|
|
|
|
|
2018-04-05 09:55:39 +02:00
|
|
|
status = RpcServerRegisterIf(ITaskSchedulerService_v1_0_s_ifspec, NULL, NULL);
|
|
|
|
if (status != RPC_S_OK)
|
|
|
|
{
|
|
|
|
ERR("RpcServerRegisterIf error %#x\n", status);
|
|
|
|
return status;
|
|
|
|
}
|
2014-03-07 04:10:28 +01:00
|
|
|
|
2018-04-05 09:55:39 +02:00
|
|
|
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);
|
2014-03-07 04:10:28 +01:00
|
|
|
if (status != RPC_S_OK)
|
|
|
|
{
|
2015-03-24 10:05:49 +01:00
|
|
|
ERR("RpcServerUseProtseqEp error %#x\n", status);
|
2014-03-07 04:10:28 +01:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2018-04-05 09:55:39 +02:00
|
|
|
status = RpcServerUseProtseqEpW(ncalrpcW, RPC_C_PROTSEQ_MAX_REQS_DEFAULT, endpoint_lrpcW, NULL);
|
2014-03-07 04:10:28 +01:00
|
|
|
if (status != RPC_S_OK)
|
|
|
|
{
|
2018-04-05 09:55:39 +02:00
|
|
|
ERR("RpcServerUseProtseqEp error %#x\n", status);
|
2014-03-07 04:10:28 +01:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
status = RpcServerInqBindings(&sched_bindings);
|
|
|
|
if (status != RPC_S_OK)
|
|
|
|
{
|
2015-03-24 10:05:49 +01:00
|
|
|
ERR("RpcServerInqBindings error %#x\n", status);
|
2014-03-07 04:10:28 +01:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
status = RpcEpRegisterW(ITaskSchedulerService_v1_0_s_ifspec, sched_bindings, NULL, NULL);
|
|
|
|
if (status != RPC_S_OK)
|
|
|
|
{
|
2015-03-24 10:05:49 +01:00
|
|
|
ERR("RpcEpRegister error %#x\n", status);
|
2014-03-07 04:10:28 +01:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2018-04-05 09:55:39 +02:00
|
|
|
status = RpcEpRegisterW(atsvc_v1_0_s_ifspec, sched_bindings, NULL, NULL);
|
|
|
|
if (status != RPC_S_OK)
|
|
|
|
{
|
|
|
|
ERR("RpcEpRegister error %#x\n", status);
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2014-03-07 04:10:28 +01:00
|
|
|
status = RpcServerListen(1, RPC_C_LISTEN_MAX_CALLS_DEFAULT, TRUE);
|
|
|
|
if (status != RPC_S_OK)
|
|
|
|
{
|
2015-03-24 10:05:49 +01:00
|
|
|
ERR("RpcServerListen error %#x\n", status);
|
2014-03-07 04:10:28 +01:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
return RPC_S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void RPC_finish(void)
|
|
|
|
{
|
|
|
|
RpcMgmtStopServerListening(NULL);
|
|
|
|
RpcEpUnregister(ITaskSchedulerService_v1_0_s_ifspec, sched_bindings, NULL);
|
2018-04-05 09:55:39 +02:00
|
|
|
RpcEpUnregister(atsvc_v1_0_s_ifspec, sched_bindings, NULL);
|
2014-03-07 04:10:28 +01:00
|
|
|
RpcBindingVectorFree(&sched_bindings);
|
2018-04-05 09:55:39 +02:00
|
|
|
RpcServerUnregisterIf(ITaskSchedulerService_v1_0_s_ifspec, NULL, FALSE);
|
|
|
|
RpcServerUnregisterIf(atsvc_v1_0_s_ifspec, NULL, FALSE);
|
2014-03-07 04:10:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void WINAPI ServiceMain(DWORD argc, LPWSTR *argv)
|
|
|
|
{
|
2018-04-17 09:12:03 +02:00
|
|
|
HANDLE thread;
|
|
|
|
DWORD tid;
|
|
|
|
|
2014-03-18 09:42:52 +01:00
|
|
|
TRACE("starting Task Scheduler Service\n");
|
2014-03-07 04:10:28 +01:00
|
|
|
|
|
|
|
schedsvc_handle = RegisterServiceCtrlHandlerW(scheduleW, schedsvc_handler);
|
|
|
|
if (!schedsvc_handle)
|
|
|
|
{
|
2015-03-24 10:05:49 +01:00
|
|
|
ERR("RegisterServiceCtrlHandler error %d\n", GetLastError());
|
2014-03-07 04:10:28 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-09-01 21:44:24 +02:00
|
|
|
schedsvc_update_status(SERVICE_START_PENDING);
|
2014-03-07 04:10:28 +01:00
|
|
|
|
2018-04-17 09:12:03 +02:00
|
|
|
done_event = CreateEventW(NULL, TRUE, FALSE, NULL);
|
|
|
|
thread = CreateThread(NULL, 0, tasks_monitor_thread, NULL, 0, &tid);
|
|
|
|
|
|
|
|
if (thread && RPC_init() == RPC_S_OK)
|
2016-09-01 21:44:24 +02:00
|
|
|
{
|
|
|
|
schedsvc_update_status(SERVICE_RUNNING);
|
2018-04-17 09:12:03 +02:00
|
|
|
WaitForSingleObject(thread, INFINITE);
|
|
|
|
CloseHandle(thread);
|
2016-09-01 21:44:24 +02:00
|
|
|
RPC_finish();
|
|
|
|
}
|
2014-03-07 04:10:28 +01:00
|
|
|
|
|
|
|
schedsvc_update_status(SERVICE_STOPPED);
|
|
|
|
|
2014-03-18 09:42:52 +01:00
|
|
|
TRACE("exiting Task Scheduler Service\n");
|
2014-03-07 04:10:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void __RPC_FAR * __RPC_USER MIDL_user_allocate(SIZE_T len)
|
|
|
|
{
|
2017-03-09 16:12:10 +01:00
|
|
|
return heap_alloc(len);
|
2014-03-07 04:10:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void __RPC_USER MIDL_user_free(void __RPC_FAR * ptr)
|
|
|
|
{
|
2017-03-09 16:12:10 +01:00
|
|
|
heap_free(ptr);
|
2014-03-07 04:10:28 +01:00
|
|
|
}
|