1
+ !ifndef UAC_HDR__INC
2
+ !verbose push
3
+ !verbose 3
4
+ !ifndef UAC_VERBOSE
5
+ !define UAC_VERBOSE 3
6
+ !endif
7
+ !verbose ${UAC_VERBOSE}
8
+
9
+ !define UAC_HDR__INC 0x00020100 ; MMmmbbrr
10
+
11
+ !include LogicLib.nsh
12
+
13
+ !macro _UAC_definemath def val1 op val2
14
+ !define /math _UAC_definemath " ${val1}" ${op} ${val2}
15
+ !ifdef ${def}
16
+ !undef ${def}
17
+ !endif
18
+ !define ${def} " ${_UAC_definemath}"
19
+ !undef _UAC_definemath
20
+ !macroend
21
+
22
+ !macro _UAC_ParseDefineFlags_orin parse outflags
23
+ !searchparse /noerrors ${${parse} } " " _UAC_ParseDefineFlags_orin_f1 " |" _UAC_ParseDefineFlags_orin_f2
24
+ !define _UAC_ParseDefineFlags_orin_this ${_UAC_ParseDefineFlags_orin_f1}
25
+ !undef ${parse}
26
+ !define ${parse} ${_UAC_ParseDefineFlags_orin_f2}
27
+ !define _UAC_ParseDefineFlags_orin_saveout ${${outflags} }
28
+ !undef ${outflags}
29
+ !define /math ${outflags} " ${_UAC_ParseDefineFlags_orin_saveout}" | " ${_UAC_ParseDefineFlags_orin_this}"
30
+ !undef _UAC_ParseDefineFlags_orin_saveout
31
+ !undef _UAC_ParseDefineFlags_orin_this
32
+ !ifdef _UAC_ParseDefineFlags_orin_f1
33
+ !undef _UAC_ParseDefineFlags_orin_f1
34
+ !undef _UAC_ParseDefineFlags_orin_f2
35
+ !endif
36
+ !macroend
37
+ !macro _UAC_ParseDefineFlags_Begin _outdef _in
38
+ !define _UAC_PDF${_outdef} _parse " ${_in}"
39
+ !define _UAC_PDF${_outdef} _flags " "
40
+ !define _UAC_PDF${_outdef} _r 0
41
+ !insertmacro _UAC_ParseDefineFlags_orin _UAC_PDF${_outdef} _parse _UAC_PDF${_outdef} _flags ; 0x1
42
+ !insertmacro _UAC_ParseDefineFlags_orin _UAC_PDF${_outdef} _parse _UAC_PDF${_outdef} _flags ; 0x2
43
+ !insertmacro _UAC_ParseDefineFlags_orin _UAC_PDF${_outdef} _parse _UAC_PDF${_outdef} _flags ; 0x4
44
+ !insertmacro _UAC_ParseDefineFlags_orin _UAC_PDF${_outdef} _parse _UAC_PDF${_outdef} _flags ; 0x8
45
+ !insertmacro _UAC_ParseDefineFlags_orin _UAC_PDF${_outdef} _parse _UAC_PDF${_outdef} _flags ; 0x10
46
+ !macroend
47
+ !macro _UAC_ParseDefineFlags_End _outdef
48
+ !define ${_outdef} ${_UAC_PDF${_outdef} _r}
49
+ !undef _UAC_PDF${_outdef} _r
50
+ !undef _UAC_PDF${_outdef} _flags
51
+ !undef _UAC_PDF${_outdef} _parse
52
+ !macroend
53
+ !macro _UAC_ParseDefineFlags_IncludeFlag _outdef flag
54
+ !if ${_UAC_PDF${_outdef} _flags} & ${flag}
55
+ !insertmacro _UAC_definemath _UAC_PDF${_outdef} _r ${_UAC_PDF${_outdef} _r} | ${flag}
56
+ !endif
57
+ !macroend
58
+ !macro _UAC_ParseDefineFlagsToInt _outdef _in
59
+ !insertmacro _UAC_ParseDefineFlags_Begin _UAC_ParseDefineFlagsToInt_tmp " ${_in}"
60
+ !define ${_outdef} ${_UAC_PDF_UAC_ParseDefineFlagsToInt_tmp_flags}
61
+ !insertmacro _UAC_ParseDefineFlags_End _UAC_ParseDefineFlagsToInt_tmp
62
+ !undef _UAC_ParseDefineFlagsToInt_tmp
63
+ !macroend
64
+
65
+ !macro _UAC_IncL
66
+ !insertmacro _UAC_definemath __UAC_L " ${__UAC_L}" + 1
67
+ !macroend
68
+
69
+
70
+ !macro _UAC_MakeLL_Cmp cmpop cmp pluginparams
71
+ !insertmacro _LOGICLIB_TEMP
72
+ UAC::_ ${pluginparams}
73
+ pop $_LOGICLIB_TEMP
74
+ !insertmacro ${cmpop} $_LOGICLIB_TEMP ${cmp} ` ${_t}` ` ${_f}`
75
+ !macroend
76
+
77
+
78
+
79
+ !macro UAC_RunElevated
80
+ UAC::_ 0
81
+ !macroend
82
+
83
+
84
+ !macro UAC_IsAdmin
85
+ UAC::_ 2
86
+ !macroend
87
+ !define UAC_IsAdmin ` "" UAC_IsAdmin ""`
88
+ !macro _UAC_IsAdmin _a _b _t _f
89
+ !insertmacro _UAC_MakeLL_Cmp _!= 0 2s
90
+ !macroend
91
+
92
+
93
+
94
+ !macro UAC_IsInnerInstance
95
+ UAC::_ 3
96
+ !macroend
97
+ !define UAC_IsInnerInstance ` "" UAC_IsInnerInstance ""`
98
+ !macro _UAC_IsInnerInstance _a _b _t _f
99
+ !insertmacro _UAC_MakeLL_Cmp _!= 0 3s
100
+ !macroend
101
+
102
+ !macro UAC_Notify_OnGuiInit
103
+ UAC::_ 4
104
+ !macroend
105
+ !macro UAC_PageElevation_OnGuiInit
106
+ !insertmacro UAC_Notify_OnGuiInit
107
+ !macroend
108
+ !macro UAC_PageElevation_OnInit
109
+ UAC::_ 5
110
+ ${IfThen} ${Errors} ${|} Quit ${|}
111
+ !macroend
112
+
113
+
114
+ !define UAC_SYNCREGISTERS 0x1
115
+ # !define UAC_SYNCSTACK 0x2
116
+ !define UAC_SYNCOUTDIR 0x4
117
+ !define UAC_SYNCINSTDIR 0x8
118
+ # !define UAC_CLEARERRFLAG 0x10
119
+ !macro UAC_AsUser_Call type name flags
120
+ push $0
121
+ Get${type} Address $0 ${name}
122
+ !verbose push
123
+ !verbose ${UAC_VERBOSE}
124
+ !insertmacro _UAC_ParseDefineFlagsToInt _UAC_AsUser_Call__flags ${flags}
125
+ !verbose pop
126
+ StrCpy $0 " 1$0:${_UAC_AsUser_Call__flags}"
127
+ !undef _UAC_AsUser_Call__flags
128
+ Exch $0
129
+ UAC::_
130
+ !macroend
131
+
132
+ !macro _UAC_AsUser_GenOp outvar op opparam1 opparam2
133
+ !define _UAC_AUGOGR_ID _UAC_AUGOGR_OP${outvar}${op}${opparam1}${opparam2}
134
+ !ifndef ${_UAC_AUGOGR_ID} ; Has this exact action been done before?
135
+ !if ${outvar} == $0
136
+ !define ${_UAC_AUGOGR_ID} $1
137
+ !else
138
+ !define ${_UAC_AUGOGR_ID} $0
139
+ !endif
140
+ !if " ${opparam1}" == " "
141
+ !define _UAC_AUGOGR_OPP1 ${${_UAC_AUGOGR_ID} }
142
+ !define _UAC_AUGOGR_OPP2 ${opparam2}
143
+ !else
144
+ !define _UAC_AUGOGR_OPP1 ${opparam1}
145
+ !define _UAC_AUGOGR_OPP2 ${${_UAC_AUGOGR_ID} }
146
+ !endif
147
+ goto ${_UAC_AUGOGR_ID} _C
148
+ ${_UAC_AUGOGR_ID} _F:
149
+ ${op} ${_UAC_AUGOGR_OPP1} ${_UAC_AUGOGR_OPP2}
150
+ return
151
+ ${_UAC_AUGOGR_ID} _C:
152
+ !undef _UAC_AUGOGR_OPP1
153
+ !undef _UAC_AUGOGR_OPP2
154
+ !endif
155
+ push ${${_UAC_AUGOGR_ID} }
156
+ !insertmacro UAC_AsUser_Call Label ${_UAC_AUGOGR_ID} _F ${UAC_SYNCREGISTERS}
157
+ StrCpy ${outvar} ${${_UAC_AUGOGR_ID} }
158
+ pop ${${_UAC_AUGOGR_ID} }
159
+ !undef _UAC_AUGOGR_ID
160
+ !macroend
161
+
162
+ !macro UAC_AsUser_GetSection datatype secidx outvar
163
+ !insertmacro _UAC_AsUser_GenOp ${outvar} SectionGet${datatype} ${secidx} " "
164
+ !macroend
165
+
166
+ !macro UAC_AsUser_GetGlobalVar var
167
+ !insertmacro _UAC_AsUser_GenOp ${var} StrCpy " " ${var}
168
+ !macroend
169
+ !macro UAC_AsUser_GetGlobal outvar srcvar
170
+ !insertmacro _UAC_AsUser_GenOp ${outvar} StrCpy " " ${srcvar}
171
+ !macroend
172
+
173
+
174
+ !macro UAC_AsUser_ExecShell verb command params workdir show
175
+ !insertmacro _UAC_IncL
176
+ # !warning "__UAC_L=${__UAC_L}"
177
+ goto _UAC_L_E_${__UAC_L}
178
+ _UAC_L_F_${__UAC_L} :
179
+ /* !if "${workdir}" != ""
180
+ SetOutPath "${workdir}"
181
+ !endif*/
182
+ # MessageBox mb_ok Outer1
183
+ # system::call 'kernel32::OutputDebugStringA(m "hello from UAC_AsUser_ExecShell >$temp|$instdir|$\n")'
184
+ ExecShell " ${verb}" " ${command}" ${params} ${show}
185
+ # MessageBox mb_ok Outer2
186
+ return
187
+ _UAC_L_E_${__UAC_L} :
188
+ !if " ${workdir}" != " "
189
+ push $outdir
190
+ SetOutPath " ${workdir}"
191
+ !endif
192
+ !insertmacro UAC_AsUser_Call Label _UAC_L_F_${__UAC_L} ${UAC_SYNCREGISTERS} |${UAC_SYNCOUTDIR} # |${UAC_CLEARERRFLAG}
193
+ !if " ${workdir}" != " "
194
+ pop $outdir
195
+ SetOutPath $outdir
196
+ !endif
197
+ !macroend
198
+
199
+ !verbose pop
200
+ !endif /* UAC_HDR__INC */
0 commit comments