ReactOS  0.4.12-dev-43-g63b00d8
precomp.h File Reference
#include <limits.h>
#include <stdarg.h>
#include <stdio.h>
#include <windef.h>
#include <winbase.h>
#include <winreg.h>
#include <winsvc.h>
#include <winuser.h>
#include <undocuser.h>
#include <ndk/rtlfuncs.h>
#include <atsvc_s.h>
#include <wine/debug.h>
Include dependency graph for precomp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _JOB
 

Macros

#define WIN32_NO_STATUS
 
#define _INC_WINDOWS
 
#define COM_NO_WINDOWS_H
 
#define JOB_NAME_LENGTH   9
 

Typedefs

typedef struct _JOB JOB
 
typedef struct _JOBPJOB
 

Functions

NTSYSAPI ULONG NTAPI RtlRandomEx (PULONG Seed)
 
DWORD GetNextJobTimeout (VOID)
 
VOID RunNextJob (VOID)
 
LONG SaveJob (PJOB pJob)
 
LONG DeleteJob (PJOB pJob)
 
LONG LoadJobs (VOID)
 
VOID CalculateNextStartTime (_In_ PJOB pJob)
 
VOID InsertJobIntoStartList (_In_ PLIST_ENTRY StartListHead, _In_ PJOB pJob)
 
VOID DumpStartList (_In_ PLIST_ENTRY StartListHead)
 
DWORD WINAPI RpcThreadRoutine (LPVOID lpParameter)
 

Variables

DWORD dwNextJobId
 
DWORD dwJobCount
 
LIST_ENTRY JobListHead
 
RTL_RESOURCE JobListLock
 
LIST_ENTRY StartListHead
 
RTL_RESOURCE StartListLock
 
HANDLE Events [2]
 

Macro Definition Documentation

◆ _INC_WINDOWS

#define _INC_WINDOWS

Definition at line 5 of file precomp.h.

◆ COM_NO_WINDOWS_H

#define COM_NO_WINDOWS_H

Definition at line 6 of file precomp.h.

◆ JOB_NAME_LENGTH

#define JOB_NAME_LENGTH   9

Definition at line 23 of file precomp.h.

Referenced by GetJobName(), and LoadJobs().

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 4 of file precomp.h.

Typedef Documentation

◆ JOB

typedef struct _JOB JOB

◆ PJOB

typedef struct _JOB * PJOB

Function Documentation

◆ CalculateNextStartTime()

VOID CalculateNextStartTime ( _In_ PJOB  pJob)

Definition at line 468 of file job.c.

Referenced by LoadJobs(), NetrJobAdd(), and ReScheduleJob().

470 {
472  FILETIME FileTime;
473  DWORD_PTR Now;
474 
475  TRACE("CalculateNextStartTime(%p)\n", pJob);
476 
477  GetLocalTime(&StartTime);
478 
479  Now = (DWORD_PTR)StartTime.wHour * 3600000 +
480  (DWORD_PTR)StartTime.wMinute * 60000;
481 
482  StartTime.wMilliseconds = 0;
483  StartTime.wSecond = 0;
484  StartTime.wHour = (WORD)(pJob->JobTime / 3600000);
485  StartTime.wMinute = (WORD)((pJob->JobTime % 3600000) / 60000);
486 
487  if (pJob->DaysOfMonth != 0)
488  {
489  FIXME("Support DaysOfMonth!\n");
490  }
491  else if (pJob->DaysOfWeek != 0)
492  {
493  FIXME("Support DaysOfWeek!\n");
494  }
495  else
496  {
497  /* Start the job tomorrow */
498  if (Now > pJob->JobTime)
499  {
500  if (StartTime.wDay + 1 > DaysOfMonth(StartTime.wMonth, StartTime.wYear))
501  {
502  if (StartTime.wMonth == 12)
503  {
504  StartTime.wDay = 1;
505  StartTime.wMonth = 1;
506  StartTime.wYear++;
507  }
508  else
509  {
510  StartTime.wDay = 1;
511  StartTime.wMonth++;
512  }
513  }
514  else
515  {
516  StartTime.wDay++;
517  }
518  }
519  }
520 
521  TRACE("Next start: %02hu:%02hu %02hu.%02hu.%hu\n", StartTime.wHour,
522  StartTime.wMinute, StartTime.wDay, StartTime.wMonth, StartTime.wYear);
523 
524  SystemTimeToFileTime(&StartTime, &FileTime);
525  pJob->StartTime.u.LowPart = FileTime.dwLowDateTime;
526  pJob->StartTime.u.HighPart = FileTime.dwHighDateTime;
527 }
#define DWORD_PTR
Definition: treelist.c:76
WORD wMonth
Definition: winbase.h:871
static LARGE_INTEGER StartTime
Definition: sys_arch.c:18
DWORD dwHighDateTime
Definition: mapidefs.h:66
WORD wYear
Definition: winbase.h:870
#define FIXME(fmt,...)
Definition: debug.h:110
WORD wMinute
Definition: winbase.h:875
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:276
#define TRACE(s)
Definition: solgame.cpp:4
unsigned short WORD
Definition: ntddk_ex.h:93
WORD wSecond
Definition: winbase.h:876
WORD wMilliseconds
Definition: winbase.h:877
struct tm * Now
Definition: output.c:19
uint32_t DWORD_PTR
Definition: typedefs.h:63
WORD wDay
Definition: winbase.h:873
BOOL WINAPI SystemTimeToFileTime(IN CONST SYSTEMTIME *lpSystemTime, OUT LPFILETIME lpFileTime)
Definition: time.c:148
WORD wHour
Definition: winbase.h:874
static WORD DaysOfMonth(WORD wMonth, WORD wYear)
Definition: job.c:454
DWORD dwLowDateTime
Definition: mapidefs.h:65

◆ DeleteJob()

LONG DeleteJob ( PJOB  pJob)

◆ DumpStartList()

VOID DumpStartList ( _In_ PLIST_ENTRY  StartListHead)

Definition at line 582 of file job.c.

Referenced by LoadJobs(), NetrJobAdd(), NetrJobDel(), and ReScheduleJob().

584 {
585  PLIST_ENTRY CurrentEntry;
586  PJOB CurrentJob;
587 
588  CurrentEntry = StartListHead->Flink;
589  while (CurrentEntry != StartListHead)
590  {
591  CurrentJob = CONTAINING_RECORD(CurrentEntry, JOB, StartEntry);
592 
593  TRACE("%3lu: %016I64x\n", CurrentJob->JobId, CurrentJob->StartTime.QuadPart);
594 
595  CurrentEntry = CurrentEntry->Flink;
596  }
597 }
DWORD JobId
Definition: precomp.h:39
ULARGE_INTEGER StartTime
Definition: precomp.h:36
LIST_ENTRY StartListHead
Definition: job.c:32
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define TRACE(s)
Definition: solgame.cpp:4
Definition: typedefs.h:117
Definition: precomp.h:31

◆ GetNextJobTimeout()

DWORD GetNextJobTimeout ( VOID  )

Definition at line 39 of file job.c.

Referenced by SchedServiceMain().

40 {
41  FILETIME FileTime;
42  SYSTEMTIME SystemTime;
43  ULARGE_INTEGER CurrentTime, Timeout;
44  PJOB pNextJob;
45 
47  {
48  TRACE("No job in list! Wait until next update.\n");
49  return INFINITE;
50  }
51 
52  pNextJob = CONTAINING_RECORD((&StartListHead)->Flink, JOB, StartEntry);
53 
54  FileTime.dwLowDateTime = pNextJob->StartTime.u.LowPart;
55  FileTime.dwHighDateTime = pNextJob->StartTime.u.HighPart;
56  FileTimeToSystemTime(&FileTime, &SystemTime);
57 
58  TRACE("Start next job (%lu) at %02hu:%02hu %02hu.%02hu.%hu\n",
59  pNextJob->JobId, SystemTime.wHour, SystemTime.wMinute,
60  SystemTime.wDay, SystemTime.wMonth, SystemTime.wYear);
61 
62  GetLocalTime(&SystemTime);
63  SystemTimeToFileTime(&SystemTime, &FileTime);
64 
65  CurrentTime.u.LowPart = FileTime.dwLowDateTime;
66  CurrentTime.u.HighPart = FileTime.dwHighDateTime;
67 
68  if (CurrentTime.QuadPart >= pNextJob->StartTime.QuadPart)
69  {
70  TRACE("Next event has already gone by!\n");
71  return 0;
72  }
73 
74  Timeout.QuadPart = (pNextJob->StartTime.QuadPart - CurrentTime.QuadPart) / 10000;
75  if (Timeout.u.HighPart != 0)
76  {
77  TRACE("Event happens too far in the future!\n");
78  return INFINITE;
79  }
80 
81  TRACE("Timeout: %lu\n", Timeout.u.LowPart);
82  return Timeout.u.LowPart;
83 }
DWORD JobId
Definition: precomp.h:39
ULARGE_INTEGER StartTime
Definition: precomp.h:36
WORD wMonth
Definition: winbase.h:871
LIST_ENTRY StartListHead
Definition: job.c:32
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
DWORD dwHighDateTime
Definition: mapidefs.h:66
WORD wYear
Definition: winbase.h:870
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
WORD wMinute
Definition: winbase.h:875
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:276
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _ULARGE_INTEGER::@3737 u
#define TRACE(s)
Definition: solgame.cpp:4
BOOL WINAPI FileTimeToSystemTime(IN CONST FILETIME *lpFileTime, OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:178
WORD wDay
Definition: winbase.h:873
BOOL WINAPI SystemTimeToFileTime(IN CONST SYSTEMTIME *lpSystemTime, OUT LPFILETIME lpFileTime)
Definition: time.c:148
static ULONG Timeout
Definition: ping.c:61
WORD wHour
Definition: winbase.h:874
#define INFINITE
Definition: serial.h:102
Definition: precomp.h:31
DWORD dwLowDateTime
Definition: mapidefs.h:65

◆ InsertJobIntoStartList()

VOID InsertJobIntoStartList ( _In_ PLIST_ENTRY  StartListHead,
_In_ PJOB  pJob 
)

Definition at line 531 of file job.c.

Referenced by LoadJobs(), NetrJobAdd(), and ReScheduleJob().

534 {
535  PLIST_ENTRY CurrentEntry, PreviousEntry;
536  PJOB CurrentJob;
537 
539  {
540  InsertHeadList(StartListHead, &pJob->StartEntry);
541  return;
542  }
543 
544  CurrentEntry = StartListHead->Flink;
545  while (CurrentEntry != StartListHead)
546  {
547  CurrentJob = CONTAINING_RECORD(CurrentEntry, JOB, StartEntry);
548 
549  if ((CurrentEntry == StartListHead->Flink) &&
550  (pJob->StartTime.QuadPart < CurrentJob->StartTime.QuadPart))
551  {
552  /* Insert before the first entry */
553  InsertHeadList(StartListHead, &pJob->StartEntry);
554  return;
555  }
556 
557  if (pJob->StartTime.QuadPart < CurrentJob->StartTime.QuadPart)
558  {
559  /* Insert between the previous and the current entry */
560  PreviousEntry = CurrentEntry->Blink;
561  pJob->StartEntry.Blink = PreviousEntry;
562  pJob->StartEntry.Flink = CurrentEntry;
563  PreviousEntry->Flink = &pJob->StartEntry;
564  CurrentEntry->Blink = &pJob->StartEntry;
565  return;
566  }
567 
568  if ((CurrentEntry->Flink == StartListHead) &&
569  (pJob->StartTime.QuadPart >= CurrentJob->StartTime.QuadPart))
570  {
571  /* Insert after the last entry */
572  InsertTailList(StartListHead, &pJob->StartEntry);
573  return;
574  }
575 
576  CurrentEntry = CurrentEntry->Flink;
577  }
578 }
ULARGE_INTEGER StartTime
Definition: precomp.h:36
struct _LIST_ENTRY * Blink
Definition: typedefs.h:120
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
#define InsertTailList(ListHead, Entry)
LIST_ENTRY StartListHead
Definition: job.c:32
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
Definition: typedefs.h:117
Definition: precomp.h:31

◆ LoadJobs()

LONG LoadJobs ( VOID  )

Definition at line 315 of file job.c.

Referenced by ServiceInit().

316 {
317  SCHEDULE Schedule;
318  WCHAR szNameBuffer[JOB_NAME_LENGTH];
319  DWORD dwNameLength, dwIndex, dwSize;
320  HKEY hJobsKey = NULL, hJobKey = NULL;
321  PJOB pJob = NULL;
322  LONG lError;
323 
324  TRACE("LoadJobs()\n");
325 
327  L"System\\CurrentControlSet\\Services\\Schedule\\Jobs",
328  0,
329  NULL,
331  KEY_READ,
332  NULL,
333  &hJobsKey,
334  NULL);
335  if (lError != ERROR_SUCCESS)
336  goto done;
337 
338  for (dwIndex = 0; dwIndex < 1000; dwIndex++)
339  {
340  dwNameLength = JOB_NAME_LENGTH;
341  lError = RegEnumKeyEx(hJobsKey,
342  dwIndex,
343  szNameBuffer,
344  &dwNameLength,
345  NULL,
346  NULL,
347  NULL,
348  NULL);
349  if (lError != ERROR_SUCCESS)
350  {
351  lError = ERROR_SUCCESS;
352  break;
353  }
354 
355  TRACE("KeyName: %S\n", szNameBuffer);
356 
357  lError = RegOpenKeyEx(hJobsKey,
358  szNameBuffer,
359  0,
360  KEY_READ,
361  &hJobKey);
362  if (lError != ERROR_SUCCESS)
363  break;
364 
365  dwSize = sizeof(SCHEDULE);
366  lError = RegQueryValueEx(hJobKey,
367  L"Schedule",
368  NULL,
369  NULL,
370  (PBYTE)&Schedule,
371  &dwSize);
372  if (lError == ERROR_SUCCESS)
373  {
374  dwSize = 0;
375  RegQueryValueEx(hJobKey,
376  L"Command",
377  NULL,
378  NULL,
379  NULL,
380  &dwSize);
381  if (dwSize != 0)
382  {
383  /* Allocate a new job object */
384  pJob = HeapAlloc(GetProcessHeap(),
386  sizeof(JOB) + dwSize - sizeof(WCHAR));
387  if (pJob == NULL)
388  {
389  lError = ERROR_OUTOFMEMORY;
390  break;
391  }
392 
393  lError = RegQueryValueEx(hJobKey,
394  L"Command",
395  NULL,
396  NULL,
397  (PBYTE)pJob->Command,
398  &dwSize);
399  if (lError != ERROR_SUCCESS)
400  break;
401 
402  wcscpy(pJob->Name, szNameBuffer);
403  pJob->JobTime = Schedule.JobTime;
404  pJob->DaysOfMonth = Schedule.DaysOfMonth;
405  pJob->DaysOfWeek = Schedule.DaysOfWeek;
406  pJob->Flags = Schedule.Flags;
407 
408  /* Acquire the job list lock exclusively */
410 
411  /* Assign a new job ID */
412  pJob->JobId = dwNextJobId++;
413  dwJobCount++;
414 
415  /* Append the new job to the job list */
417 
418  /* Calculate the next start time */
420 
421  /* Insert the job into the start list */
423 #if 0
425 #endif
426 
427  /* Release the job list lock */
429 
430  pJob = NULL;
431  }
432  }
433 
434  RegCloseKey(hJobKey);
435  hJobKey = NULL;
436  }
437 
438 done:
439  if (pJob != NULL)
440  HeapFree(GetProcessHeap(), 0, pJob);
441 
442  if (hJobKey != NULL)
443  RegCloseKey(hJobKey);
444 
445  if (hJobsKey != NULL)
446  RegCloseKey(hJobsKey);
447 
448  return lError;
449 }
#define RegQueryValueEx
Definition: winreg.h:524
LIST_ENTRY JobEntry
Definition: precomp.h:33
RTL_RESOURCE JobListLock
Definition: job.c:30
DWORD JobId
Definition: precomp.h:39
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
VOID InsertJobIntoStartList(_In_ PLIST_ENTRY StartListHead, _In_ PJOB pJob)
Definition: job.c:531
#define KEY_READ
Definition: nt_native.h:1023
__wchar_t WCHAR
Definition: xmlstorage.h:180
UCHAR DaysOfWeek
Definition: job.c:22
WCHAR Name[JOB_NAME_LENGTH]
Definition: precomp.h:37
#define InsertTailList(ListHead, Entry)
LIST_ENTRY StartListHead
Definition: job.c:32
WCHAR Command[1]
Definition: precomp.h:44
NTSYSAPI VOID NTAPI RtlReleaseResource(_In_ PRTL_RESOURCE Resource)
LIST_ENTRY JobListHead
Definition: job.c:29
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1094
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
UCHAR Flags
Definition: precomp.h:43
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
DWORD_PTR JobTime
Definition: precomp.h:40
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
UCHAR DaysOfWeek
Definition: precomp.h:42
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
struct _SCHEDULE SCHEDULE
unsigned long DWORD
Definition: ntddk_ex.h:95
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1087
#define RegEnumKeyEx
Definition: winreg.h:510
UCHAR Flags
Definition: job.c:23
#define RegOpenKeyEx
Definition: winreg.h:520
DWORD JobTime
Definition: job.c:20
#define JOB_NAME_LENGTH
Definition: precomp.h:23
DWORD dwJobCount
Definition: job.c:28
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
Definition: job.c:18
VOID DumpStartList(_In_ PLIST_ENTRY StartListHead)
Definition: job.c:582
DWORD DaysOfMonth
Definition: precomp.h:41
DWORD dwNextJobId
Definition: job.c:27
VOID CalculateNextStartTime(_In_ PJOB pJob)
Definition: job.c:468
DWORD DaysOfMonth
Definition: job.c:21
BYTE * PBYTE
Definition: pedump.c:66
Definition: precomp.h:31
#define HeapFree(x, y, z)
Definition: compat.h:394
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
NTSYSAPI BOOLEAN NTAPI RtlAcquireResourceExclusive(_In_ PRTL_RESOURCE Resource, _In_ BOOLEAN Wait)

◆ RpcThreadRoutine()

DWORD WINAPI RpcThreadRoutine ( LPVOID  lpParameter)

Definition at line 26 of file rpc.c.

27 {
29 
32 
33  Status = RpcServerUseProtseqEpW(L"ncacn_np", 20, L"\\pipe\\EventLog", NULL);
34  if (Status != RPC_S_OK)
35  {
36  DPRINT("RpcServerUseProtseqEpW() failed (Status %lx)\n", Status);
37  goto Quit;
38  }
39 
40  Status = RpcServerRegisterIf(eventlog_v0_0_s_ifspec, NULL, NULL);
41  if (Status != RPC_S_OK)
42  {
43  DPRINT("RpcServerRegisterIf() failed (Status %lx)\n", Status);
44  goto Quit;
45  }
46 
48  if (Status != RPC_S_OK)
49  {
50  DPRINT("RpcServerListen() failed (Status %lx)\n", Status);
51  }
52 
55  {
57  ElfDeleteEventLogHandle(&LogHandle);
58  }
60 
61 Quit:
63 
64  return 0;
65 }
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
long RPC_STATUS
Definition: rpc.h:52
static LIST_ENTRY LogHandleListHead
Definition: rpc.c:18
RPC_STATUS WINAPI RpcServerListen(UINT MinimumCallThreads, UINT MaxCalls, UINT DontWait)
Definition: rpc_server.c:1527
#define RPC_C_LISTEN_MAX_CALLS_DEFAULT
Definition: rpcdce.h:122
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:697
smooth NULL
Definition: ftsmooth.c:416
static NTSTATUS ElfDeleteEventLogHandle(PIELF_HANDLE LogHandle)
Definition: rpc.c:264
static CRITICAL_SECTION LogHandleListCs
Definition: rpc.c:19
void DPRINT(...)
Definition: polytest.cpp:61
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
RPC_STATUS WINAPI RpcServerRegisterIf(RPC_IF_HANDLE IfSpec, UUID *MgrTypeUuid, RPC_MGR_EPV *MgrEpv)
Definition: rpc_server.c:1123
static const WCHAR L[]
Definition: oid.c:1087
PVOID IELF_HANDLE
Definition: eventlogrpc.idl:22
Status
Definition: gdiplustypes.h:24
RPC_STATUS WINAPI RpcServerUseProtseqEpW(RPC_WSTR Protseq, UINT MaxCalls, RPC_WSTR Endpoint, LPVOID SecurityDescriptor)
Definition: rpc_server.c:934
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
_In_ UINT _Out_ PNDIS_HANDLE LogHandle
Definition: ndis.h:5363
#define RPC_S_OK
Definition: rpcnterr.h:22

◆ RtlRandomEx()

NTSYSAPI ULONG NTAPI RtlRandomEx ( PULONG  Seed)

Referenced by get_uuid(), and GetJobName().

◆ RunNextJob()

VOID RunNextJob ( VOID  )

Definition at line 121 of file job.c.

Referenced by SchedServiceMain().

122 {
123  PROCESS_INFORMATION ProcessInformation;
124  STARTUPINFOW StartupInfo;
125  BOOL bRet;
126  PJOB pNextJob;
127 
129  {
130  ERR("No job in list!\n");
131  return;
132  }
133 
134  pNextJob = CONTAINING_RECORD((&StartListHead)->Flink, JOB, StartEntry);
135 
136  TRACE("Run job %ld: %S\n", pNextJob->JobId, pNextJob->Command);
137 
138  ZeroMemory(&StartupInfo, sizeof(StartupInfo));
139  StartupInfo.cb = sizeof(StartupInfo);
140  StartupInfo.lpTitle = pNextJob->Command;
141  StartupInfo.dwFlags = STARTF_USESHOWWINDOW;
142  StartupInfo.wShowWindow = SW_SHOWDEFAULT;
143 
144  if ((pNextJob->Flags & JOB_NONINTERACTIVE) == 0)
145  {
146  StartupInfo.dwFlags |= STARTF_INHERITDESKTOP;
147  StartupInfo.lpDesktop = L"WinSta0\\Default";
148  }
149 
150  bRet = CreateProcessW(NULL,
151  pNextJob->Command,
152  NULL,
153  NULL,
154  FALSE,
156  NULL,
157  NULL,
158  &StartupInfo,
159  &ProcessInformation);
160  if (bRet == FALSE)
161  {
162  ERR("CreateProcessW() failed (Error %lu)\n", GetLastError());
163  }
164  else
165  {
166  CloseHandle(ProcessInformation.hThread);
167  CloseHandle(ProcessInformation.hProcess);
168  }
169 
170  ReScheduleJob(pNextJob);
171 }
DWORD JobId
Definition: precomp.h:39
#define SW_SHOWDEFAULT
Definition: winuser.h:774
#define CloseHandle
Definition: compat.h:398
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define ZeroMemory
Definition: winbase.h:1635
LIST_ENTRY StartListHead
Definition: job.c:32
WCHAR Command[1]
Definition: precomp.h:44
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
UCHAR Flags
Definition: precomp.h:43
LPWSTR lpDesktop
Definition: winbase.h:819
#define STARTF_INHERITDESKTOP
Definition: undocuser.h:162
smooth NULL
Definition: ftsmooth.c:416
LPWSTR lpTitle
Definition: winbase.h:820
#define STARTF_USESHOWWINDOW
Definition: winbase.h:472
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessW(LPCWSTR lpApplicationName, LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
Definition: proc.c:4623
#define TRACE(s)
Definition: solgame.cpp:4
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CREATE_NEW_CONSOLE
Definition: winbase.h:180
DWORD cb
Definition: winbase.h:817
#define JOB_NONINTERACTIVE
Definition: lmat.h:11
static VOID ReScheduleJob(PJOB pJob)
Definition: job.c:88
static const WCHAR L[]
Definition: oid.c:1087
WORD wShowWindow
Definition: winbase.h:829
#define ERR(fmt,...)
Definition: debug.h:109
DWORD dwFlags
Definition: winbase.h:828
Definition: precomp.h:31

◆ SaveJob()

LONG SaveJob ( PJOB  pJob)

Variable Documentation

◆ dwJobCount

DWORD dwJobCount

Definition at line 28 of file job.c.

Referenced by LoadJobs(), NetrJobAdd(), NetrJobDel(), NetrJobEnum(), and ReScheduleJob().

◆ dwNextJobId

DWORD dwNextJobId

Definition at line 27 of file job.c.

Referenced by LoadJobs(), and NetrJobAdd().

◆ Events

HANDLE Events[2]

◆ JobListHead

LIST_ENTRY JobListHead

Definition at line 29 of file job.c.

Referenced by NetrJobAdd(), NetrJobDel(), NetrJobEnum(), NetrJobGetInfo(), and ServiceInit().

◆ JobListLock

RTL_RESOURCE JobListLock

Definition at line 30 of file job.c.

Referenced by NetrJobAdd(), NetrJobDel(), NetrJobEnum(), NetrJobGetInfo(), SchedServiceMain(), and ServiceInit().

◆ StartListHead

LIST_ENTRY StartListHead

Definition at line 32 of file job.c.

Referenced by NetrJobAdd(), NetrJobDel(), and ServiceInit().

◆ StartListLock

RTL_RESOURCE StartListLock

Definition at line 33 of file job.c.

Referenced by ServiceInit().