Debian Codegraph @

Include/Win/RestartManager.nsh

raw
1 !ifndef __WIN_RESTARTMANAGER__INC
2 !define __WIN_RESTARTMANAGER__INC 1
3
4 /**************************************************
5 WinBase.h
6 **************************************************/
7 !define /IfNDef RESTART_MAX_CMD_LINE 1024
8
9 !define /IfNDef RESTART_NO_CRASH 1
10 !define /IfNDef RESTART_NO_HANG 2
11 !define /IfNDef RESTART_NO_PATCH 4
12 !define /IfNDef RESTART_NO_REBOOT 8 ; Do not restart the process when the system is rebooted due to patch installations
13
14 !define /IfNDef RECOVERY_DEFAULT_PING_INTERVAL 5000
15 !define /IfNDef /math RECOVERY_MAX_PING_INTERVAL 5000 * 60
16
17
18 /**************************************************
19 RestartManager.h
20 **************************************************/
21 !define RM_SESSION_KEY_LEN 16
22 !define CCH_RM_SESSION_KEY 32
23 !define CCH_RM_MAX_APP_NAME 255
24 !define CCH_RM_MAX_SVC_NAME 63
25 !define RM_INVALID_TS_SESSION -1
26 !define RM_INVALID_PROCESS -1
27
28 !define RmUnknownApp 0
29 !define RmMainWindow 1
30 !define RmOtherWindow 2
31 !define RmService 3
32 !define RmExplorer 4
33 !define RmConsole 5
34 !define RmCritical 1000 ; Application is critical system process where a reboot is required to restart
35
36 !define RmForceShutdown 0x1 ; Force unresponsive applications and services to shut down after the timeout period
37 !define RmShutdownOnlyRegistered 0x10 ; Only shutdown apps if all apps registered for restart (RegisterApplicationRestart)
38
39 !define RmStatusUnknown 0
40 !define RmStatusRunning 1
41 !define RmStatusStopped 2 ; Application stopped by Restart Manager
42 !define RmStatusStoppedOther 4
43 !define RmStatusRestarted 8
44 !define RmStatusErrorOnStop 0x10
45 !define RmStatusErrorOnRestart 0x20
46 !define RmStatusShutdownMasked 0x40
47 !define RmStatusRestartMasked 0x80
48
49 !define RmRebootReasonNone 0
50 !define RmRebootReasonPermissionDenied 1
51 !define RmRebootReasonSessionMismatch 2
52 !define RmRebootReasonCriticalProcess 4
53 !define RmRebootReasonCriticalService 8
54 !define RmRebootReasonDetectedSelf 0x10
55
56
57 !define SYSSIZEOF_RM_UNIQUE_PROCESS 12
58 !define SYSSTRUCT_RM_UNIQUE_PROCESS (i,l)
59
60
61 !include LogicLib.nsh
62 !include Util.nsh
63
64
65 !macro RestartManager_StartSession outvarhandle
66 System::Call 'RSTRTMGR::RmStartSession(*i-1s, i0, w)i.s'
67 Pop ${outvarhandle}
68 ${If} ${outvarhandle} <> 0
69 ${OrIf} ${outvarhandle} == error
70 Pop ${outvarhandle}
71 Push ""
72 ${EndIf}
73 Pop ${outvarhandle}
74 !macroend
75
76 !macro RestartManager_EndSession handle
77 System::Call 'RSTRTMGR::RmEndSession(i${handle})'
78 !macroend
79
80 !macro RestartManager_RegisterFile handle path
81 System::Call 'RSTRTMGR::RmRegisterResources(i${handle},i1,*ws,i0,p0,i0,p0)i.r0' "${path}"
82 !macroend
83
84 !macro RestartManager_Shutdown handle
85 System::Call 'RSTRTMGR::RmShutdown(i${handle}, i${RmForceShutdown}, p0)'
86 !macroend
87
88 !macro RestartManager_Restart handle
89 System::Call 'RSTRTMGR::RmRestart(i${handle}, i0, p0)'
90 !macroend
91
92
93 !macro RestartManager_ShutdownFile fullpath outvar_errcode
94 Push "${fullpath}"
95 !insertmacro CallArtificialFunction RestartManager_ShutdownFileImp
96 Pop ${outvar_errcode}
97 !macroend
98 !macro RestartManager_ShutdownFileImp
99 Exch $1
100 Push $0
101 System::Call 'RSTRTMGR::RmStartSession(*i-1s, i0, w)i.r0'
102 ${If} $0 == error
103 Pop $0
104 StrCpy $0 1150
105 ${Else}
106 System::Call 'RSTRTMGR::RmRegisterResources(isr1,i1,*wr1,i0,p0,i0,p0)i.r0'
107 ${If} $0 = 0
108 System::Call 'RSTRTMGR::RmShutdown(ir1, i${RmForceShutdown}, p0)i.r0'
109 ${EndIf}
110 System::Call 'RSTRTMGR::RmEndSession(ir1)'
111 ${EndIf}
112 Exch
113 Pop $1
114 Exch $0
115 !macroend
116
117 !endif ;~ Include guard