protected override bool ReleaseHandle()
 {
     if (m_pBlob != null)
     {
         NativeMemoryMethods.LocalFree(Blob.pbData);
         m_pBlob.Close();
     }
     return(true);
 }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        internal SafeCoTaskMem Alloc(int cb)
        {
            SafeCoTaskMem safeCoTaskMem = NativeMemoryMethods.CoTaskMemAlloc(cb);

            if (safeCoTaskMem.IsInvalid)
            {
                safeCoTaskMem.SetHandleAsInvalid();
                throw new OutOfMemoryException();
            }
            return(safeCoTaskMem);
        }
Ejemplo n.º 4
0
        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();
            }
        }
Ejemplo n.º 5
0
 protected override bool ReleaseHandle()
 {
     return(NativeMemoryMethods.LocalFree(handle) == IntPtr.Zero);
 }
Ejemplo n.º 6
0
 protected override bool ReleaseHandle()
 {
     NativeMemoryMethods.CoTaskMemFree(handle);
     return(true);
 }