Пример #1
0
 internal SafeCryptoBlobIn(byte[] data)
     : base(ownsHandle: true)
 {
     m_bufferSize = data.Length;
     m_blob       = SafeLocalFree.LocalAlloc(Marshal.SizeOf(typeof(NativeMethods.DATA_BLOB)));
     handle       = m_blob.DangerousGetHandle();
     m_pbData     = SafeLocalFree.LocalAlloc(data.Length);
     Marshal.Copy(data, 0, m_pbData.DangerousGetHandle(), data.Length);
     Marshal.StructureToPtr(new NativeMethods.DATA_BLOB
     {
         cbData = data.Length,
         pbData = m_pbData.DangerousGetHandle()
     }, handle, fDeleteOld: true);
 }
Пример #2
0
 internal void ZeroBuffer()
 {
     if (!IsInvalid && m_bufferSize > 0 && m_pbData != null)
     {
         Marshal.Copy(new byte[m_bufferSize], 0, m_pbData.DangerousGetHandle(), m_bufferSize);
     }
 }
Пример #3
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();
            }
        }
 internal SafeCryptoBlobOut()
     : base(ownsHandle: true)
 {
     m_pBlob = SafeLocalFree.LocalAlloc(Marshal.SizeOf(typeof(NativeMethods.DATA_BLOB)));
     handle  = m_pBlob.DangerousGetHandle();
 }