[SCHEDSVC]
authorEric Kohl <eric.kohl@reactos.org>
Sun, 22 Mar 2015 21:57:55 +0000 (21:57 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Sun, 22 Mar 2015 21:57:55 +0000 (21:57 +0000)
Start work on the seceduler service.

[NETAPI32]
Implement the scheduler service client functions.

svn path=/trunk/; revision=66862

15 files changed:
reactos/base/services/CMakeLists.txt
reactos/base/services/schedsvc/CMakeLists.txt [new file with mode: 0644]
reactos/base/services/schedsvc/precomp.h [new file with mode: 0644]
reactos/base/services/schedsvc/rpcserver.c [new file with mode: 0644]
reactos/base/services/schedsvc/schedsvc.c [new file with mode: 0644]
reactos/base/services/schedsvc/schedsvc.rc [new file with mode: 0644]
reactos/base/services/schedsvc/schedsvc.spec [new file with mode: 0644]
reactos/boot/bootdata/hivesft.inf
reactos/boot/bootdata/hivesys.inf
reactos/dll/win32/netapi32/CMakeLists.txt
reactos/dll/win32/netapi32/netapi32.c
reactos/dll/win32/netapi32/netapi32.spec
reactos/dll/win32/netapi32/schedule.c [new file with mode: 0644]
reactos/include/reactos/idl/atsvc.acf [new file with mode: 0644]
reactos/include/reactos/idl/atsvc.idl [new file with mode: 0644]

index 535e851..108dc5c 100644 (file)
@@ -2,6 +2,7 @@
 add_subdirectory(audiosrv)
 add_subdirectory(eventlog)
 add_subdirectory(rpcss)
+add_subdirectory(schedsvc)
 add_subdirectory(spoolsv)
 add_subdirectory(svchost)
 add_subdirectory(tcpsvcs)
diff --git a/reactos/base/services/schedsvc/CMakeLists.txt b/reactos/base/services/schedsvc/CMakeLists.txt
new file mode 100644 (file)
index 0000000..c3210c8
--- /dev/null
@@ -0,0 +1,16 @@
+
+include_directories(${REACTOS_SOURCE_DIR}/include/reactos/idl)
+add_rpc_files(server ${REACTOS_SOURCE_DIR}/include/reactos/idl/atsvc.idl)
+spec2def(schedsvc.dll schedsvc.spec ADD_IMPORTLIB)
+
+add_library(schedsvc SHARED
+    rpcserver.c
+    schedsvc.c
+    schedsvc.rc
+    ${CMAKE_CURRENT_BINARY_DIR}/atsvc_s.c
+    ${CMAKE_CURRENT_BINARY_DIR}/schedsvc.def)
+
+set_module_type(schedsvc win32dll UNICODE)
+target_link_libraries(schedsvc wine)
+add_importlibs(schedsvc advapi32 rpcrt4 msvcrt kernel32 ntdll)
+add_cd_file(TARGET schedsvc DESTINATION reactos/system32 FOR all)
diff --git a/reactos/base/services/schedsvc/precomp.h b/reactos/base/services/schedsvc/precomp.h
new file mode 100644 (file)
index 0000000..3fc6975
--- /dev/null
@@ -0,0 +1,22 @@
+#ifndef _SCHEDSVC_PCH_
+#define _SCHEDSVC_PCH_
+
+#define WIN32_NO_STATUS
+#define _INC_WINDOWS
+#define COM_NO_WINDOWS_H
+#include <stdarg.h>
+#include <windef.h>
+#include <winbase.h>
+#include <winreg.h>
+#include <winsvc.h>
+
+#include <atsvc_s.h>
+
+#include <wine/debug.h>
+
+DWORD
+WINAPI
+RpcThreadRoutine(
+    LPVOID lpParameter);
+
+#endif /* _SCHEDSVC_PCH_ */
diff --git a/reactos/base/services/schedsvc/rpcserver.c b/reactos/base/services/schedsvc/rpcserver.c
new file mode 100644 (file)
index 0000000..6797ce1
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+ *  ReactOS Services
+ *  Copyright (C) 2015 ReactOS Team
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program 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 General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+/*
+ * COPYRIGHT:        See COPYING in the top level directory
+ * PROJECT:          ReactOS Services
+ * FILE:             base/services/schedsvc/rpcserver.c
+ * PURPOSE:          Scheduler service
+ * PROGRAMMER:       Eric Kohl
+ */
+
+/* INCLUDES *****************************************************************/
+
+#include "precomp.h"
+
+#include "lmerr.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(schedsvc);
+
+/* FUNCTIONS *****************************************************************/
+
+DWORD
+WINAPI
+RpcThreadRoutine(
+    LPVOID lpParameter)
+{
+    RPC_STATUS Status;
+
+    Status = RpcServerUseProtseqEpW(L"ncacn_np", 20, L"\\pipe\\atsvc", NULL);
+    if (Status != RPC_S_OK)
+    {
+        ERR("RpcServerUseProtseqEpW() failed (Status %lx)\n", Status);
+        return 0;
+    }
+
+    Status = RpcServerRegisterIf(atsvc_v1_0_s_ifspec, NULL, NULL);
+    if (Status != RPC_S_OK)
+    {
+        ERR("RpcServerRegisterIf() failed (Status %lx)\n", Status);
+        return 0;
+    }
+
+    Status = RpcServerListen(1, RPC_C_LISTEN_MAX_CALLS_DEFAULT, FALSE);
+    if (Status != RPC_S_OK)
+    {
+        ERR("RpcServerListen() failed (Status %lx)\n", Status);
+    }
+
+    return 0;
+}
+
+
+void __RPC_FAR * __RPC_USER midl_user_allocate(SIZE_T len)
+{
+    return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
+}
+
+
+void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
+{
+    HeapFree(GetProcessHeap(), 0, ptr);
+}
+
+
+/* Function 0 */
+NET_API_STATUS
+WINAPI
+NetrJobAdd(
+    ATSVC_HANDLE ServerName,
+    LPAT_INFO pAtInfo,
+    LPDWORD pJobId)
+{
+    return ERROR_SUCCESS;
+}
+
+
+/* Function 1 */
+NET_API_STATUS
+WINAPI
+NetrJobDel(
+    ATSVC_HANDLE ServerName,
+    DWORD MinJobId,
+    DWORD MaxJobId)
+{
+    return ERROR_SUCCESS;
+}
+
+
+/* Function 2 */
+NET_API_STATUS
+__stdcall
+NetrJobEnum(
+    ATSVC_HANDLE ServerName,
+    LPAT_ENUM_CONTAINER pEnumContainer,
+    DWORD PreferedMaximumLength,
+    LPDWORD pTotalEntries,
+    LPDWORD pResumeHandle)
+{
+    return ERROR_SUCCESS;
+}
+
+
+/* Function 3 */
+NET_API_STATUS
+WINAPI
+NetrJobGetInfo(
+    ATSVC_HANDLE ServerName,
+    DWORD JobId,
+    LPAT_INFO *ppAtInfo)
+{
+    return ERROR_SUCCESS;
+}
+
+/* EOF */
diff --git a/reactos/base/services/schedsvc/schedsvc.c b/reactos/base/services/schedsvc/schedsvc.c
new file mode 100644 (file)
index 0000000..8b0c683
--- /dev/null
@@ -0,0 +1,183 @@
+/*
+ *  ReactOS Services
+ *  Copyright (C) 2015 ReactOS Team
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program 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 General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+/*
+ * COPYRIGHT:        See COPYING in the top level directory
+ * PROJECT:          ReactOS Services
+ * FILE:             base/services/schedsvc/schedsvc.c
+ * PURPOSE:          Scheduling service
+ * PROGRAMMER:       Eric Kohl
+ */
+
+/* INCLUDES *****************************************************************/
+
+#include "precomp.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(schedsvc);
+
+/* GLOBALS ******************************************************************/
+
+static WCHAR ServiceName[] = L"Schedule";
+
+static SERVICE_STATUS_HANDLE ServiceStatusHandle;
+static SERVICE_STATUS ServiceStatus;
+
+/* FUNCTIONS *****************************************************************/
+
+static VOID
+UpdateServiceStatus(DWORD dwState)
+{
+    ServiceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
+    ServiceStatus.dwCurrentState = dwState;
+    ServiceStatus.dwControlsAccepted = 0;
+    ServiceStatus.dwWin32ExitCode = 0;
+    ServiceStatus.dwServiceSpecificExitCode = 0;
+    ServiceStatus.dwCheckPoint = 0;
+
+    if (dwState == SERVICE_START_PENDING ||
+        dwState == SERVICE_STOP_PENDING ||
+        dwState == SERVICE_PAUSE_PENDING ||
+        dwState == SERVICE_CONTINUE_PENDING)
+        ServiceStatus.dwWaitHint = 10000;
+    else
+        ServiceStatus.dwWaitHint = 0;
+
+    SetServiceStatus(ServiceStatusHandle,
+                     &ServiceStatus);
+}
+
+static DWORD WINAPI
+ServiceControlHandler(DWORD dwControl,
+                      DWORD dwEventType,
+                      LPVOID lpEventData,
+                      LPVOID lpContext)
+{
+    TRACE("ServiceControlHandler() called\n");
+
+    switch (dwControl)
+    {
+        case SERVICE_CONTROL_STOP:
+            TRACE("  SERVICE_CONTROL_STOP received\n");
+            /* Stop listening to incoming RPC messages */
+            RpcMgmtStopServerListening(NULL);
+            UpdateServiceStatus(SERVICE_STOPPED);
+            return ERROR_SUCCESS;
+
+        case SERVICE_CONTROL_PAUSE:
+            TRACE("  SERVICE_CONTROL_PAUSE received\n");
+            UpdateServiceStatus(SERVICE_PAUSED);
+            return ERROR_SUCCESS;
+
+        case SERVICE_CONTROL_CONTINUE:
+            TRACE("  SERVICE_CONTROL_CONTINUE received\n");
+            UpdateServiceStatus(SERVICE_RUNNING);
+            return ERROR_SUCCESS;
+
+        case SERVICE_CONTROL_INTERROGATE:
+            TRACE("  SERVICE_CONTROL_INTERROGATE received\n");
+            SetServiceStatus(ServiceStatusHandle,
+                             &ServiceStatus);
+            return ERROR_SUCCESS;
+
+        case SERVICE_CONTROL_SHUTDOWN:
+            TRACE("  SERVICE_CONTROL_SHUTDOWN received\n");
+            UpdateServiceStatus(SERVICE_STOPPED);
+            return ERROR_SUCCESS;
+
+        default :
+            TRACE("  Control %lu received\n", dwControl);
+            return ERROR_CALL_NOT_IMPLEMENTED;
+    }
+}
+
+
+static
+DWORD
+ServiceInit(VOID)
+{
+    HANDLE hThread;
+
+    hThread = CreateThread(NULL,
+                           0,
+                           (LPTHREAD_START_ROUTINE)RpcThreadRoutine,
+                           NULL,
+                           0,
+                           NULL);
+
+    if (!hThread)
+    {
+        ERR("Can't create PortThread\n");
+        return GetLastError();
+    }
+    else
+        CloseHandle(hThread);
+
+    return ERROR_SUCCESS;
+}
+
+
+VOID WINAPI
+SchedServiceMain(DWORD argc, LPTSTR *argv)
+{
+    DWORD dwError;
+
+    UNREFERENCED_PARAMETER(argc);
+    UNREFERENCED_PARAMETER(argv);
+
+    TRACE("SchedServiceMain() called\n");
+
+    ServiceStatusHandle = RegisterServiceCtrlHandlerExW(ServiceName,
+                                                        ServiceControlHandler,
+                                                        NULL);
+    if (!ServiceStatusHandle)
+    {
+        ERR("RegisterServiceCtrlHandlerExW() failed! (Error %lu)\n", GetLastError());
+        return;
+    }
+
+    UpdateServiceStatus(SERVICE_START_PENDING);
+
+    dwError = ServiceInit();
+    if (dwError != ERROR_SUCCESS)
+    {
+        ERR("Service stopped (dwError: %lu\n", dwError);
+        UpdateServiceStatus(SERVICE_STOPPED);
+        return;
+    }
+
+    UpdateServiceStatus(SERVICE_RUNNING);
+}
+
+
+BOOL WINAPI
+DllMain(HINSTANCE hinstDLL,
+        DWORD fdwReason,
+        LPVOID lpvReserved)
+{
+    switch (fdwReason)
+    {
+        case DLL_PROCESS_ATTACH:
+            DisableThreadLibraryCalls(hinstDLL);
+            break;
+
+        case DLL_PROCESS_DETACH:
+            break;
+    }
+
+    return TRUE;
+}
diff --git a/reactos/base/services/schedsvc/schedsvc.rc b/reactos/base/services/schedsvc/schedsvc.rc
new file mode 100644 (file)
index 0000000..037bb5d
--- /dev/null
@@ -0,0 +1,5 @@
+#define REACTOS_VERSION_DLL
+#define REACTOS_STR_FILE_DESCRIPTION  "Scheduler Service"
+#define REACTOS_STR_INTERNAL_NAME     "schedsvc"
+#define REACTOS_STR_ORIGINAL_FILENAME "schedsvc.dll"
+#include <reactos/version.rc>
diff --git a/reactos/base/services/schedsvc/schedsvc.spec b/reactos/base/services/schedsvc/schedsvc.spec
new file mode 100644 (file)
index 0000000..006f8f3
--- /dev/null
@@ -0,0 +1 @@
+@ stdcall SchedServiceMain(long ptr)
index 8f79863..33193c5 100644 (file)
@@ -1609,7 +1609,7 @@ HKLM,"SOFTWARE\Microsoft\Ole","EnableRemoteConnect",0x00000000,"N"
 ; SvcHost services
 HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\SvcHost",,0x00000012
 HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\SvcHost","DcomLaunch",0x00010000,"PlugPlay"
-HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\SvcHost","netsvcs",0x00010000,"DHCP","BITS","lanmanworkstation","winmgmt"
+HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\SvcHost","netsvcs",0x00010000,"DHCP","BITS","lanmanworkstation","Schedule","winmgmt"
 
 ; Win32 config
 HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows",,0x00000012
index 729420c..3e4c54f 100644 (file)
@@ -1252,6 +1252,7 @@ HKLM,"SYSTEM\CurrentControlSet\Control\ServiceGroupOrder","List",0x00010000, \
  "PNP_TDI", \
  "TDI", \
  "PlugPlay", \
+ "SchedulerGroup", \
  "SpoolerGroup", \
  "UIGroup", \
  "Extended Base"
@@ -1897,6 +1898,18 @@ HKLM,"SYSTEM\CurrentControlSet\Services\Rpcss","ObjectName",0x00000000,"LocalSys
 HKLM,"SYSTEM\CurrentControlSet\Services\Rpcss","Start",0x00010001,0x00000002
 HKLM,"SYSTEM\CurrentControlSet\Services\Rpcss","Type",0x00010001,0x00000010
 
+; Scheduler service
+HKLM,"SYSTEM\CurrentControlSet\Services\Schedule","DependOnService",0x00010000,"RPCSS"
+HKLM,"SYSTEM\CurrentControlSet\Services\Schedule","DisplayName",0x00000000,"Scheduler service"
+HKLM,"SYSTEM\CurrentControlSet\Services\Schedule","ErrorControl",0x00010001,0x00000001
+HKLM,"SYSTEM\CurrentControlSet\Services\Schedule","Group",0x00000000,"SchedulerGroup"
+HKLM,"SYSTEM\CurrentControlSet\Services\Schedule","ImagePath",0x00020000,"%SystemRoot%\system32\svchost.exe -k netsvcs"
+HKLM,"SYSTEM\CurrentControlSet\Services\Schedule","ObjectName",0x00000000,"LocalSystem"
+HKLM,"SYSTEM\CurrentControlSet\Services\Schedule","Start",0x00010001,0x00000002
+HKLM,"SYSTEM\CurrentControlSet\Services\Schedule","Type",0x00010001,0x00000020
+HKLM,"SYSTEM\CurrentControlSet\Services\Schedule\Parameters","ServiceDll",0x00020000,"%SystemRoot%\system32\schedsvc.dll"
+HKLM,"SYSTEM\CurrentControlSet\Services\Schedule\Parameters","ServiceMain",0x00000000,"SchedServiceMain"
+
 ; Spooler service
 HKLM,"SYSTEM\CurrentControlSet\Services\Spooler","DependOnService",0x00010000,"RPCSS"
 HKLM,"SYSTEM\CurrentControlSet\Services\Spooler","DisplayName",0x00000000,"Printer Spooler"
index 33208c7..f283ad6 100644 (file)
@@ -6,6 +6,7 @@ include_directories(
 add_definitions(-D__WINESRC__)
 spec2def(netapi32.dll netapi32.spec ADD_IMPORTLIB)
 add_rpc_files(client
+    ${REACTOS_SOURCE_DIR}/include/reactos/idl/atsvc.idl
     ${REACTOS_SOURCE_DIR}/include/reactos/idl/dssetup.idl
     ${REACTOS_SOURCE_DIR}/include/reactos/idl/wkssvc.idl)
 
@@ -23,11 +24,13 @@ list(APPEND SOURCE
     nbt.c
     netapi32.c
     netbios.c
+    schedule.c
     share.c
     user.c
     wksta.c
     wksta_new.c
     netapi32.h
+    ${CMAKE_CURRENT_BINARY_DIR}/atsvc_c.c
     ${CMAKE_CURRENT_BINARY_DIR}/dssetup_c.c
     ${CMAKE_CURRENT_BINARY_DIR}/wkssvc_c.c)
 
index ecc66e2..c58308c 100644 (file)
@@ -201,25 +201,3 @@ NetpNtStatusToApiStatus(NTSTATUS Status)
 
     return ApiStatus;
 }
-
-NET_API_STATUS WINAPI NetScheduleJobAdd(LPCWSTR server, LPBYTE bufptr, LPDWORD jobid)
-{
-    FIXME("stub (%s, %p, %p)\n", debugstr_w(server), bufptr, jobid);
-    return NERR_Success;
-}
-
-NET_API_STATUS WINAPI NetScheduleJobDel(LPCWSTR server, DWORD minjobid, DWORD maxjobid)
-{
-    FIXME("stub (%s, %d, %d)\n", debugstr_w(server), minjobid, maxjobid);
-    return NERR_Success;
-}
-
-NET_API_STATUS WINAPI NetScheduleJobEnum(LPCWSTR server, LPBYTE* bufptr, DWORD prefmaxsize, LPDWORD entriesread,
-                                         LPDWORD totalentries, LPDWORD resumehandle)
-{
-    FIXME("stub (%s, %p, %d, %p, %p, %p)\n", debugstr_w(server), bufptr, prefmaxsize, entriesread, totalentries, resumehandle);
-    *entriesread = 0;
-    *totalentries = 0;
-    return NERR_Success;
-}
-
index c7c8de3..18e2f79 100644 (file)
 @ stdcall NetScheduleJobAdd(wstr ptr ptr)
 @ stdcall NetScheduleJobDel(wstr long long)
 @ stdcall NetScheduleJobEnum(wstr ptr long ptr ptr ptr)
-@ stub NetScheduleJobGetInfo
+@ stdcall NetScheduleJobGetInfo(wstr long ptr)
 @ stub NetServerComputerNameAdd
 @ stub NetServerComputerNameDel
 @ stdcall NetServerDiskEnum(wstr long ptr long ptr ptr ptr)
diff --git a/reactos/dll/win32/netapi32/schedule.c b/reactos/dll/win32/netapi32/schedule.c
new file mode 100644 (file)
index 0000000..c6dea47
--- /dev/null
@@ -0,0 +1,199 @@
+/*
+ * COPYRIGHT:       See COPYING in the top level directory
+ * PROJECT:         NetAPI DLL
+ * FILE:            reactos/dll/win32/netapi32/schedule.c
+ * PURPOSE:         Scheduler service interface code
+ *
+ * PROGRAMMERS:     Eric Kohl
+ */
+
+/* INCLUDES ******************************************************************/
+
+#include "netapi32.h"
+#include "atsvc_c.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(netapi32);
+
+/* FUNCTIONS *****************************************************************/
+
+handle_t __RPC_USER
+ATSVC_HANDLE_bind(ATSVC_HANDLE pszSystemName)
+{
+    handle_t hBinding = NULL;
+    LPWSTR pszStringBinding;
+    RPC_STATUS status;
+
+    TRACE("ATSVC_HANDLE_bind() called\n");
+
+    status = RpcStringBindingComposeW(NULL,
+                                      L"ncacn_np",
+                                      (RPC_WSTR)pszSystemName,
+                                      L"\\pipe\\atsvc",
+                                      NULL,
+                                      &pszStringBinding);
+    if (status)
+    {
+        TRACE("RpcStringBindingCompose returned 0x%x\n", status);
+        return NULL;
+    }
+
+    /* Set the binding handle that will be used to bind to the server. */
+    status = RpcBindingFromStringBindingW(pszStringBinding,
+                                          &hBinding);
+    if (status)
+    {
+        TRACE("RpcBindingFromStringBinding returned 0x%x\n", status);
+    }
+
+    status = RpcStringFreeW(&pszStringBinding);
+    if (status)
+    {
+//        TRACE("RpcStringFree returned 0x%x\n", status);
+    }
+
+    return hBinding;
+}
+
+
+void __RPC_USER
+ATSVC_HANDLE_unbind(ATSVC_HANDLE pszSystemName,
+                    handle_t hBinding)
+{
+    RPC_STATUS status;
+
+    TRACE("ATSVC_HANDLE_unbind() called\n");
+
+    status = RpcBindingFree(&hBinding);
+    if (status)
+    {
+        TRACE("RpcBindingFree returned 0x%x\n", status);
+    }
+}
+
+
+NET_API_STATUS
+WINAPI
+NetScheduleJobAdd(
+    LPCWSTR ServerName,
+    LPBYTE Buffer,
+    LPDWORD JobId)
+{
+    NET_API_STATUS status;
+
+    TRACE("NetScheduleJobAdd(%s, %p, %p)\n", debugstr_w(ServerName),
+          Buffer, JobId);
+
+    RpcTryExcept
+    {
+        status = NetrJobAdd(ServerName,
+                            (LPAT_INFO)Buffer,
+                            JobId);
+    }
+    RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+    {
+        status = I_RpcMapWin32Status(RpcExceptionCode());
+    }
+    RpcEndExcept;
+
+    return status;
+}
+
+
+NET_API_STATUS
+WINAPI
+NetScheduleJobDel(
+    LPCWSTR ServerName,
+    DWORD MinJobId,
+    DWORD MaxJobId)
+{
+    NET_API_STATUS status;
+
+    TRACE("NetScheduleJobDel(%s, %d, %d)\n", debugstr_w(ServerName),
+          MinJobId, MaxJobId);
+
+    RpcTryExcept
+    {
+        status = NetrJobDel(ServerName,
+                            MinJobId,
+                            MaxJobId);
+    }
+    RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+    {
+        status = I_RpcMapWin32Status(RpcExceptionCode());
+    }
+    RpcEndExcept;
+
+    return status;
+}
+
+
+NET_API_STATUS
+WINAPI
+NetScheduleJobEnum(
+    LPCWSTR ServerName,
+    LPBYTE *PointerToBuffer,
+    DWORD PreferredMaximumLength,
+    LPDWORD EntriesRead,
+    LPDWORD TotalEntries,
+    LPDWORD ResumeHandle)
+{
+    AT_ENUM_CONTAINER EnumContainer;
+    NET_API_STATUS status;
+
+    TRACE("NetScheduleJobEnum(%s, %p, %d, %p, %p, %p)\n", debugstr_w(ServerName),
+          PointerToBuffer, PreferredMaximumLength, EntriesRead, TotalEntries, ResumeHandle);
+
+    EnumContainer.EntriesRead = 0;
+    EnumContainer.Buffer = NULL;
+
+    RpcTryExcept
+    {
+        status = NetrJobEnum(ServerName,
+                             &EnumContainer,
+                             PreferredMaximumLength,
+                             TotalEntries,
+                             ResumeHandle);
+        if (status == NERR_Success || status == ERROR_MORE_DATA)
+        {
+            *PointerToBuffer = (LPBYTE)EnumContainer.Buffer;
+            *EntriesRead = EnumContainer.EntriesRead;
+        }
+    }
+    RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+    {
+        status = I_RpcMapWin32Status(RpcExceptionCode());
+    }
+    RpcEndExcept;
+
+    return status;
+}
+
+
+NET_API_STATUS
+WINAPI
+NetScheduleJobGetInfo(
+    LPCWSTR ServerName,
+    DWORD JobId,
+    LPBYTE *PointerToBuffer)
+{
+    NET_API_STATUS status;
+
+    TRACE("NetScheduleJobGetInfo(%s, %d, %p)\n", debugstr_w(ServerName),
+          JobId, PointerToBuffer);
+
+    RpcTryExcept
+    {
+        status = NetrJobGetInfo(ServerName,
+                                JobId,
+                                (LPAT_INFO *)PointerToBuffer);
+    }
+    RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+    {
+        status = I_RpcMapWin32Status(RpcExceptionCode());
+    }
+    RpcEndExcept;
+
+    return status;
+}
+
+/* EOF */
diff --git a/reactos/include/reactos/idl/atsvc.acf b/reactos/include/reactos/idl/atsvc.acf
new file mode 100644 (file)
index 0000000..ffd5fcf
--- /dev/null
@@ -0,0 +1,6 @@
+[
+    explicit_handle
+]
+interface atsvc
+{
+}
\ No newline at end of file
diff --git a/reactos/include/reactos/idl/atsvc.idl b/reactos/include/reactos/idl/atsvc.idl
new file mode 100644 (file)
index 0000000..f7e7cb1
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Scheduler Service interface definition
+ */
+
+#include <ms-dtyp.idl>
+
+typedef [handle] const wchar_t *ATSVC_HANDLE;
+
+typedef struct _AT_ENUM
+{
+    DWORD JobId;
+    DWORD_PTR JobTime;
+    DWORD DaysOfMonth;
+    unsigned char DaysOfWeek;
+    unsigned char Flags;
+    wchar_t *Command;
+} AT_ENUM, *PAT_ENUM, *LPAT_ENUM;
+
+typedef struct _AT_INFO
+{
+    DWORD_PTR JobTime;
+    DWORD DaysOfMonth;
+    unsigned char DaysOfWeek;
+    unsigned char Flags;
+    [string] wchar_t *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;
+
+[
+    uuid(1FF70682-0A51-30E8-076D-740BE8CEE98B),
+    version(1.0),
+#ifdef __midl
+    ms_union,
+#endif
+    pointer_default(unique),
+    endpoint("ncacn_np:[\\pipe\\atsvc]")
+#ifndef __midl
+    ,explicit_handle
+#endif
+]
+interface atsvc
+{
+    /* Function 0 */
+    NET_API_STATUS
+    __stdcall
+    NetrJobAdd(
+        [in, string, unique] ATSVC_HANDLE ServerName,
+        [in] LPAT_INFO pAtInfo,
+        [out] LPDWORD pJobId);
+
+    /* Function 1 */
+    NET_API_STATUS
+    __stdcall
+    NetrJobDel(
+        [in, string, unique] ATSVC_HANDLE ServerName,
+        [in] DWORD MinJobId,
+        [in] DWORD MaxJobId);
+
+    /* Function 2 */
+    NET_API_STATUS
+    __stdcall
+    NetrJobEnum(
+        [in, string, unique] ATSVC_HANDLE ServerName,
+        [in,out] LPAT_ENUM_CONTAINER pEnumContainer,
+        [in] DWORD PreferedMaximumLength,
+        [out] LPDWORD pTotalEntries,
+        [in, out, unique] LPDWORD pResumeHandle);
+
+    /* Function 3 */
+    NET_API_STATUS
+    __stdcall
+    NetrJobGetInfo(
+        [in, string, unique] ATSVC_HANDLE ServerName,
+        [in] DWORD JobId,
+        [out] LPAT_INFO *ppAtInfo);
+}