Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ BinaryFormFromSddlForm()

static byte[] System.Security.AccessControl.RawSecurityDescriptor.BinaryFormFromSddlForm ( string sddlForm)
inlinestaticprivate

Definition at line 145 of file RawSecurityDescriptor.cs.

146 {
147 if (sddlForm == null)
148 {
149 throw new ArgumentNullException("sddlForm");
150 }
151 IntPtr resultSd = IntPtr.Zero;
152 uint resultSdLength = 0u;
153 byte[] array = null;
154 try
155 {
156 if (!global::Interop.Advapi32.ConvertStringSdToSd(sddlForm, GenericSecurityDescriptor.Revision, out resultSd, ref resultSdLength))
157 {
158 int lastWin32Error = Marshal.GetLastWin32Error();
159 switch (lastWin32Error)
160 {
161 case 87:
162 case 1305:
163 case 1336:
164 case 1338:
166 case 8:
167 throw new OutOfMemoryException();
168 case 1337:
170 default:
171 throw new Win32Exception(lastWin32Error, System.SR.Format(System.SR.AccessControl_UnexpectedError, lastWin32Error));
172 case 0:
173 break;
174 }
175 }
176 array = new byte[resultSdLength];
177 Marshal.Copy(resultSd, array, 0, (int)resultSdLength);
178 return array;
179 }
180 finally
181 {
182 if (resultSd != IntPtr.Zero)
183 {
184 Marshal.FreeHGlobal(resultSd);
185 }
186 }
187 }
static void FreeHGlobal(IntPtr hglobal)
Definition Marshal.cs:1680
static void Copy(int[] source, int startIndex, IntPtr destination, int length)
Definition Marshal.cs:800
static string AccessControl_UnexpectedError
Definition SR.cs:42
static string AccessControl_InvalidSidInSDDLString
Definition SR.cs:30
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string ArgumentException_InvalidSDSddlForm
Definition SR.cs:68
Definition SR.cs:7

References System.SR.AccessControl_InvalidSidInSDDLString, System.SR.AccessControl_UnexpectedError, System.SR.ArgumentException_InvalidSDSddlForm, System.array, System.Runtime.InteropServices.Marshal.Copy(), System.SR.Format(), System.Runtime.InteropServices.Marshal.FreeHGlobal(), System.Runtime.InteropServices.Marshal.GetLastWin32Error(), System.Security.AccessControl.GenericSecurityDescriptor.Revision, and System.IntPtr.Zero.