1 | /**
|
---|
2 | * This file is part of the mingw-w64 runtime package.
|
---|
3 | * No warranty is given; refer to the file DISCLAIMER within this package.
|
---|
4 | */
|
---|
5 |
|
---|
6 | #ifndef _INC_RESTARTMANAGER
|
---|
7 | #define _INC_RESTARTMANAGER
|
---|
8 |
|
---|
9 | #include <winapifamily.h>
|
---|
10 |
|
---|
11 | #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
---|
12 |
|
---|
13 | #ifdef __cplusplus
|
---|
14 | extern "C" {
|
---|
15 | #endif
|
---|
16 |
|
---|
17 | #define RM_SESSION_KEY_LEN sizeof (GUID)
|
---|
18 | #define CCH_RM_SESSION_KEY RM_SESSION_KEY_LEN * 2
|
---|
19 | #define CCH_RM_MAX_APP_NAME 255
|
---|
20 | #define CCH_RM_MAX_SVC_NAME 63
|
---|
21 | #define RM_INVALID_TS_SESSION -1
|
---|
22 | #define RM_INVALID_PROCESS -1
|
---|
23 |
|
---|
24 | typedef enum _RM_APP_STATUS {
|
---|
25 | RmStatusUnknown = 0x0,
|
---|
26 | RmStatusRunning = 0x1,
|
---|
27 | RmStatusStopped = 0x2,
|
---|
28 | RmStatusStoppedOther = 0x4,
|
---|
29 | RmStatusRestarted = 0x8,
|
---|
30 | RmStatusErrorOnStop = 0x10,
|
---|
31 | RmStatusErrorOnRestart = 0x20,
|
---|
32 | RmStatusShutdownMasked = 0x40,
|
---|
33 | RmStatusRestartMasked = 0x80
|
---|
34 | } RM_APP_STATUS;
|
---|
35 |
|
---|
36 | typedef enum _RM_SHUTDOWN_TYPE {
|
---|
37 | RmForceShutdown = 0x1,
|
---|
38 | RmShutdownOnlyRegistered = 0x10
|
---|
39 | } RM_SHUTDOWN_TYPE;
|
---|
40 |
|
---|
41 | typedef enum _RM_APP_TYPE {
|
---|
42 | RmUnknownApp = 0,
|
---|
43 | RmMainWindow,
|
---|
44 | RmOtherWindow,
|
---|
45 | RmService,
|
---|
46 | RmExplorer,
|
---|
47 | RmConsole,
|
---|
48 | RmCritical = 1000
|
---|
49 | } RM_APP_TYPE;
|
---|
50 |
|
---|
51 | typedef enum _RM_REBOOT_REASON {
|
---|
52 | RmRebootReasonNone = 0x0,
|
---|
53 | RmRebootReasonPermissionDenied = 0x1,
|
---|
54 | RmRebootReasonSessionMismatch = 0x2,
|
---|
55 | RmRebootReasonCriticalProcess = 0x4,
|
---|
56 | RmRebootReasonCriticalService = 0x8,
|
---|
57 | RmRebootReasonDetectedSelf = 0x10
|
---|
58 | } RM_REBOOT_REASON;
|
---|
59 |
|
---|
60 | typedef enum _RM_FILTER_TRIGGER {
|
---|
61 | RmFilterTriggerInvalid = 0,
|
---|
62 | RmFilterTriggerFile,
|
---|
63 | RmFilterTriggerProcess,
|
---|
64 | RmFilterTriggerService
|
---|
65 | } RM_FILTER_TRIGGER;
|
---|
66 |
|
---|
67 | typedef enum _RM_FILTER_ACTION {
|
---|
68 | RmInvalidFilterAction = 0,
|
---|
69 | RmNoRestart,
|
---|
70 | RmNoShutdown
|
---|
71 | } RM_FILTER_ACTION;
|
---|
72 |
|
---|
73 | typedef struct _RM_UNIQUE_PROCESS {
|
---|
74 | DWORD dwProcessId;
|
---|
75 | FILETIME ProcessStartTime;
|
---|
76 | } RM_UNIQUE_PROCESS, *PRM_UNIQUE_PROCESS;
|
---|
77 |
|
---|
78 | typedef 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 | BOOL bRestartable;
|
---|
86 | } RM_PROCESS_INFO, *PRM_PROCESS_INFO;
|
---|
87 |
|
---|
88 | typedef struct _RM_FILTER_INFO {
|
---|
89 | RM_FILTER_ACTION FilterAction;
|
---|
90 | RM_FILTER_TRIGGER FilterTrigger;
|
---|
91 | DWORD cbNextOffset;
|
---|
92 | __C89_NAMELESS union {
|
---|
93 | LPWSTR strFilename;
|
---|
94 | RM_UNIQUE_PROCESS Process;
|
---|
95 | LPWSTR strServiceShortName;
|
---|
96 | };
|
---|
97 | } RM_FILTER_INFO, *PRM_FILTER_INFO;
|
---|
98 |
|
---|
99 | typedef void (*RM_WRITE_STATUS_CALLBACK)(UINT nPercentComplete);
|
---|
100 |
|
---|
101 | DWORD WINAPI RmStartSession(DWORD *pSessionHandle, DWORD dwSessionFlags, WCHAR strSessionKey[]);
|
---|
102 | DWORD WINAPI RmJoinSession(DWORD *pSessionHandle, const WCHAR strSessionKey[]);
|
---|
103 | DWORD WINAPI RmEndSession(DWORD dwSessionHandle);
|
---|
104 | DWORD WINAPI RmRegisterResources(DWORD dwSessionHandle, UINT nFiles, LPCWSTR rgsFileNames[], UINT nApplications, RM_UNIQUE_PROCESS rgApplications[], UINT nServices, LPCWSTR rgsServiceNames[]);
|
---|
105 | DWORD WINAPI RmGetList(DWORD dwSessionHandle, UINT *pnProcInfoNeeded, UINT *pnProcInfo, RM_PROCESS_INFO rgAffectedApps[], LPDWORD lpdwRebootReasons);
|
---|
106 | DWORD WINAPI RmShutdown(DWORD dwSessionHandle, ULONG lActionFlags, RM_WRITE_STATUS_CALLBACK fnStatus);
|
---|
107 | DWORD WINAPI RmRestart(DWORD dwSessionHandle, DWORD dwRestartFlags, RM_WRITE_STATUS_CALLBACK fnStatus);
|
---|
108 | DWORD WINAPI RmCancelCurrentTask(DWORD dwSessionHandle);
|
---|
109 | DWORD WINAPI RmAddFilter(DWORD dwSessionHandle, LPCWSTR strModuleName, RM_UNIQUE_PROCESS *pProcess, LPCWSTR strServiceShortName, RM_FILTER_ACTION FilterAction);
|
---|
110 | DWORD WINAPI RmRemoveFilter(DWORD dwSessionHandle, LPCWSTR strModuleName, RM_UNIQUE_PROCESS *pProcess, LPCWSTR strServiceShortName);
|
---|
111 | DWORD WINAPI RmGetFilterList(DWORD dwSessionHandle, PBYTE pbFilterBuf, DWORD cbFilterBuf, LPDWORD cbFilterBufNeeded);
|
---|
112 |
|
---|
113 | #ifdef __cplusplus
|
---|
114 | }
|
---|
115 | #endif
|
---|
116 |
|
---|
117 | #endif
|
---|
118 |
|
---|
119 | #endif
|
---|