124 {
126 byte[] array2 = null;
127 byte[] array3 = null;
128 byte[] array4 = null;
129 Privilege privilege = null;
130 if (owner != null)
131 {
133 array =
new byte[binaryLength];
135 }
136 if (group != null)
137 {
139 array2 = new byte[binaryLength];
141 }
142 if (dacl != null)
143 {
144 int binaryLength = dacl.BinaryLength;
145 array4 = new byte[binaryLength];
146 dacl.GetBinaryForm(array4, 0);
147 }
148 if (sacl != null)
149 {
150 int binaryLength = sacl.BinaryLength;
151 array3 = new byte[binaryLength];
152 sacl.GetBinaryForm(array3, 0);
153 }
155 {
156 privilege = new Privilege("SeSecurityPrivilege");
157 }
158 int num;
159 try
160 {
161 if (privilege != null)
162 {
163 try
164 {
165 privilege.Enable();
166 }
167 catch (PrivilegeNotHeldException)
168 {
169 }
170 }
171 if (name != null)
172 {
173 num = (int)global::Interop.Advapi32.SetSecurityInfoByName(name, (uint)
type, (uint)securityInformation,
array, array2, array4, array3);
174 }
175 else
176 {
178 {
180 }
182 {
184 }
185 num = (int)global::Interop.Advapi32.SetSecurityInfoByHandle(
handle, (uint)
type, (uint)securityInformation,
array, array2, array4, array3);
186 }
187 switch (num)
188 {
189 case 1300:
190 case 1314:
191 throw new PrivilegeNotHeldException("SeSecurityPrivilege");
192 case 5:
193 case 1347:
194 throw new UnauthorizedAccessException();
195 case 0:
196 break;
197 default:
198 goto IL_0145;
199 }
200 }
201 catch
202 {
203 privilege?.Revert();
204 throw;
205 }
206 finally
207 {
208 privilege?.Revert();
209 }
210 return 0;
211 IL_0145:
212 if (num == 8)
213 {
214 throw new OutOfMemoryException();
215 }
216 return num;
217 }
static string Argument_InvalidSafeHandle
void GetBinaryForm(byte[] binaryForm, int offset)