internal static int ConvertSdToSddl(byte[] binaryForm, int requestedRevision, SecurityInfos si, out string resultSddl) { uint resultStringLength = 0; IntPtr resultString; if (1 != Win32Native.ConvertSdToStringSd(binaryForm, (uint)requestedRevision, (uint)si, out resultString, ref resultStringLength)) { int lastWin32Error = Marshal.GetLastWin32Error(); resultSddl = (string)null; if (lastWin32Error == 8) { throw new OutOfMemoryException(); } return(lastWin32Error); } resultSddl = Marshal.PtrToStringUni(resultString); Win32Native.LocalFree(resultString); return(0); }
internal static int ConvertSdToSddl(byte[] binaryForm, int requestedRevision, SecurityInfos si, out string resultSddl) { uint num = 0U; IntPtr intPtr; if (1 == Win32Native.ConvertSdToStringSd(binaryForm, (uint)requestedRevision, (uint)si, out intPtr, ref num)) { resultSddl = Marshal.PtrToStringUni(intPtr); Win32Native.LocalFree(intPtr); return(0); } int lastWin32Error = Marshal.GetLastWin32Error(); resultSddl = null; if (lastWin32Error == 8) { throw new OutOfMemoryException(); } return(lastWin32Error); }
internal static int ConvertSdToSddl( byte[] binaryForm, int requestedRevision, SecurityInfos si, out string resultSddl) { int errorCode; IntPtr ByteArray; uint ByteArraySize = 0; if (TRUE != Win32Native.ConvertSdToStringSd(binaryForm, ( uint )requestedRevision, ( uint )si, out ByteArray, ref ByteArraySize)) { errorCode = Marshal.GetLastWin32Error(); goto Error; } // // Extract data from the returned pointer // resultSddl = Marshal.PtrToStringUni(ByteArray); // // Now is a good time to get rid of the returned pointer // Win32Native.LocalFree(ByteArray); return(0); Error: resultSddl = null; if (errorCode == Win32Native.ERROR_NOT_ENOUGH_MEMORY) { throw new OutOfMemoryException(); } return(errorCode); }
internal static int ConvertSdToSddl(byte[] binaryForm, int requestedRevision, SecurityInfos si, out string resultSddl) { int num; IntPtr ptr; uint resultStringLength = 0; if (1 != Win32Native.ConvertSdToStringSd(binaryForm, (uint)requestedRevision, (uint)si, out ptr, ref resultStringLength)) { num = Marshal.GetLastWin32Error(); } else { resultSddl = Marshal.PtrToStringUni(ptr); Win32Native.LocalFree(ptr); return(0); } resultSddl = null; if (num == 8) { throw new OutOfMemoryException(); } return(num); }