1/**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the mingw-w64 runtime package.
4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5 */
6#ifndef _INC_RESTARTMANAGER
7#define _INC_RESTARTMANAGER
8
9#if (_WIN32_WINNT >= 0x0600)
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
15typedef enum _RM_APP_STATUS {
16  RmStatusUnknown          = 0x0,
17  RmStatusRunning          = 0x1,
18  RmStatusStopped          = 0x2,
19  RmStatusStoppedOther     = 0x4,
20  RmStatusRestarted        = 0x8,
21  RmStatusErrorOnStop      = 0x10,
22  RmStatusErrorOnRestart   = 0x20,
23  RmStatusShutdownMasked   = 0x40,
24  RmStatusRestartMasked    = 0x80
25} RM_APP_STATUS;
26
27typedef enum _RM_APP_TYPE {
28  RmUnknownApp    = 0,
29  RmMainWindow    = 1,
30  RmOtherWindow   = 2,
31  RmService       = 3,
32  RmExplorer      = 4,
33  RmConsole       = 5,
34  RmCritical      = 1000
35} RM_APP_TYPE;
36
37typedef enum _RM_FILTER_ACTION {
38  RmInvalidFilterAction   = 0,
39  RmNoRestart             = 1,
40  RmNoShutdown            = 2
41} RM_FILTER_ACTION;
42
43typedef enum _RM_FILTER_TRIGGER {
44  RmFilterTriggerInvalid   = 0,
45  RmFilterTriggerFile      = 1,
46  RmFilterTriggerProcess   = 2,
47  RmFilterTriggerService   = 3
48} RM_FILTER_TRIGGER;
49
50typedef enum _RM_REBOOT_REASON {
51  RmRebootReasonNone               = 0x0,
52  RmRebootReasonPermissionDenied   = 0x1,
53  RmRebootReasonSessionMismatch    = 0x2,
54  RmRebootReasonCriticalProcess    = 0x4,
55  RmRebootReasonCriticalService    = 0x8,
56  RmRebootReasonDetectedSelf       = 0x10
57} RM_REBOOT_REASON;
58
59typedef enum _RM_SHUTDOWN_TYPE {
60  RmForceShutdown            = 0x1,
61  RmShutdownOnlyRegistered   = 0x10
62} RM_SHUTDOWN_TYPE;
63
64typedef struct _RM_UNIQUE_PROCESS {
65  DWORD    dwProcessId;
66  FILETIME ProcessStartTime;
67} RM_UNIQUE_PROCESS, *PRM_UNIQUE_PROCESS;
68
69typedef struct _RM_FILTER_INFO {
70  RM_FILTER_ACTION  FilterAction;
71  RM_FILTER_TRIGGER FilterTrigger;
72  DWORD             cbNextOffset;
73  LPWSTR            strFilename;
74  RM_UNIQUE_PROCESS Process;
75  LPWSTR            strServiceShortName;
76} RM_FILTER_INFO, *PRM_FILTER_INFO;
77
78typedef struct _RM_PROCESS_INFO {
79  RM_UNIQUE_PROCESS Process;
80  WCHAR             strAppName[CCH_RM_MAX_APP_NAME+1];
81  WCHAR             strServiceShortName[CCH_RM_MAX_SVC_NAME+1];
82  RM_APP_TYPE       ApplicationType;
83  ULONG             AppStatus;
84  DWORD             TSSessionId;
85  WINBOOL           bRestartable;
86} RM_PROCESS_INFO;
87
88typedef void ( *RM_WRITE_STATUS_CALLBACK )(
89  UINT nPercentComplete
90);
91
92DWORD WINAPI RmAddFilter(
93  DWORD dwSessionHandle,
94  LPCWSTR strFilename,
95  RM_UNIQUE_PROCESS *Application,
96  LPCWSTR strShortServiceName,
97  RM_FILTER_ACTION ActionType
98);
99
100DWORD WINAPI RmCancelCurrentTask(
101  DWORD dwSessionHandle
102);
103
104DWORD WINAPI RmEndSession(
105  DWORD dwSessionHandle
106);
107
108DWORD WINAPI RmGetFilterList(
109  DWORD dwSessionHandle,
110  PBYTE pbFilterBuf,
111  DWORD cbFilterBuf,
112  LPDWORD cbFilterBufNeeded
113);
114
115DWORD WINAPI RmGetList(
116  DWORD dwSessionHandle,
117  UINT *pnProcInfoNeeded,
118  UINT *pnProcInfo,
119  RM_PROCESS_INFO rgAffectedApps[ ],
120  LPDWORD lpdwRebootReasons
121);
122
123DWORD WINAPI RmJoinSession(
124  DWORD *pSessionHandle,
125  const WCHAR strSessionKey[ ]
126);
127
128DWORD WINAPI RmRegisterResources(
129  DWORD dwSessionHandle,
130  UINT nFiles,
131  LPCWSTR rgsFilenames[ ],
132  UINT nApplications,
133  RM_UNIQUE_PROCESS rgApplications[ ],
134  UINT nServices,
135  LPCWSTR rgsServiceNames[ ]
136);
137
138DWORD WINAPI RmRemoveFilter(
139  DWORD dwSessionHandle,
140  LPCWSTR strFilename,
141  RM_UNIQUE_PROCESS *Application,
142  LPCWSTR strShortServiceName
143);
144
145DWORD WINAPI RmRestart(
146  DWORD dwSessionHandle,
147  DWORD dwRestartFlags,
148  RM_WRITE_STATUS_CALLBACK fnStatus
149);
150
151#define RmForceShutdown 0x1
152#define RmShutdownOnlyRegistered 0x10
153
154DWORD WINAPI RmShutdown(
155  DWORD dwSessionHandle,
156  ULONG lActionFlags,
157  RM_WRITE_STATUS_CALLBACK fnStatus
158);
159
160DWORD WINAPI RmStartSession(
161  DWORD *pSessionHandle,
162  DWORD dwSessionFlags,
163  WCHAR strSessionKey[]
164);
165
166#ifdef __cplusplus
167}
168#endif
169
170#endif /* (_WIN32_WINNT >= 0x0600) */
171
172#endif /*_INC_RESTARTMANAGER*/
173
174