protected override bool ReleaseHandle() { if (m_pBlob != null) { NativeMemoryMethods.LocalFree(Blob.pbData); m_pBlob.Close(); } return(true); }
internal static SafeLocalFree LocalAlloc(int flags, int cb) { SafeLocalFree safeLocalFree = NativeMemoryMethods.LocalAlloc(flags, (UIntPtr)(ulong)cb); if (safeLocalFree.IsInvalid) { safeLocalFree.SetHandleAsInvalid(); throw new Win32Exception(Marshal.GetLastWin32Error()); } return(safeLocalFree); }
internal SafeCoTaskMem Alloc(int cb) { SafeCoTaskMem safeCoTaskMem = NativeMemoryMethods.CoTaskMemAlloc(cb); if (safeCoTaskMem.IsInvalid) { safeCoTaskMem.SetHandleAsInvalid(); throw new OutOfMemoryException(); } return(safeCoTaskMem); }
internal static bool AllocateAndInitializeSid(byte nSubAuthorityCount, uint nSubAuthority0, uint nSubAuthority1, uint nSubAuthority2, uint nSubAuthority3, uint nSubAuthority4, uint nSubAuthority5, uint nSubAuthority6, uint nSubAuthority7, out SafeSidPtr pSid) { SafeLocalFree safeLocalFree = null; try { SID_IDENTIFIER_AUTHORITY structure = default(SID_IDENTIFIER_AUTHORITY); structure.m_Value0 = SECURITY_NT_AUTHORITY[0]; structure.m_Value1 = SECURITY_NT_AUTHORITY[1]; structure.m_Value2 = SECURITY_NT_AUTHORITY[2]; structure.m_Value3 = SECURITY_NT_AUTHORITY[3]; structure.m_Value4 = SECURITY_NT_AUTHORITY[4]; structure.m_Value5 = SECURITY_NT_AUTHORITY[5]; safeLocalFree = SafeLocalFree.LocalAlloc(Marshal.SizeOf(structure)); Marshal.StructureToPtr(structure, safeLocalFree.DangerousGetHandle(), fDeleteOld: true); return(NativeMemoryMethods.AllocateAndInitializeSid(safeLocalFree, nSubAuthorityCount, nSubAuthority0, nSubAuthority1, nSubAuthority2, nSubAuthority3, nSubAuthority4, nSubAuthority5, nSubAuthority6, nSubAuthority7, out pSid)); } finally { safeLocalFree?.Close(); } }
protected override bool ReleaseHandle() { return(NativeMemoryMethods.LocalFree(handle) == IntPtr.Zero); }
protected override bool ReleaseHandle() { NativeMemoryMethods.CoTaskMemFree(handle); return(true); }