[System.Security.SecurityCritical] // auto-generated private unsafe void InitializeSecureString(char *value, int length) { if (length == 0) { AllocateBuffer(0); _decryptedLength = 0; return; } _encryptedBuffer = SafeBSTRHandle.Allocate(null, 0); SafeBSTRHandle decryptedBuffer = SafeBSTRHandle.Allocate(null, (uint)length); _decryptedLength = length; byte *bufferPtr = null; try { decryptedBuffer.AcquirePointer(ref bufferPtr); Buffer.MemoryCopy((byte *)value, bufferPtr, decryptedBuffer.Length * sizeof(char), length * sizeof(char)); } finally { if (bufferPtr != null) { decryptedBuffer.ReleasePointer(); } } ProtectMemory(decryptedBuffer); }
[System.Security.SecurityCritical] // auto-generated private void AllocateBuffer(uint size) { _encryptedBuffer = SafeBSTRHandle.Allocate(null, size); if (_encryptedBuffer.IsInvalid) { throw new OutOfMemoryException(); } }
private void AllocateBuffer(int size) { uint alignedSize = GetAlignedSize(size); m_buffer = SafeBSTRHandle.Allocate(null, alignedSize); if (m_buffer.IsInvalid) { throw new OutOfMemoryException(); } }
private void AllocateBuffer(int size) { this.m_buffer = SafeBSTRHandle.Allocate((string)null, SecureString.GetAlignedSize(size)); if (this.m_buffer.IsInvalid) { throw new OutOfMemoryException(); } }
[System.Security.SecurityCritical] // auto-generated unsafe static bool EncryptionSupported() { // check if the enrypt/decrypt function is supported on current OS bool supported = true; try { Win32Native.SystemFunction041( SafeBSTRHandle.Allocate(null , (int)Win32Native.CRYPTPROTECTMEMORY_BLOCK_SIZE), Win32Native.CRYPTPROTECTMEMORY_BLOCK_SIZE, Win32Native.CRYPTPROTECTMEMORY_SAME_PROCESS); } catch (EntryPointNotFoundException) { supported = false; } return supported; }
private static bool EncryptionSupported() { bool result = true; try { Win32Native.SystemFunction041(SafeBSTRHandle.Allocate(null, 16U), 16U, 0U); } catch (EntryPointNotFoundException) { result = false; } return(result); }
private static bool EncryptionSupported() { bool flag = true; try { Win32Native.SystemFunction041(SafeBSTRHandle.Allocate(null, 0x10), 0x10, 0); } catch (EntryPointNotFoundException) { flag = false; } return(flag); }
private static bool EncryptionSupported() { bool flag = true; try { Win32Native.SystemFunction041(SafeBSTRHandle.Allocate((string)null, 16U), 16U, 0U); } catch (EntryPointNotFoundException ex) { flag = false; } return(flag); }
[System.Security.SecurityCritical] // auto-generated private void EnsureCapacity(ref SafeBSTRHandle decryptedBuffer, int capacity) { if (capacity > MaxLength) { throw new ArgumentOutOfRangeException("capacity", SR.ArgumentOutOfRange_Capacity); } if (capacity <= _decryptedLength) { return; } SafeBSTRHandle newBuffer = SafeBSTRHandle.Allocate(null, (uint)capacity); SafeBSTRHandle.Copy(decryptedBuffer, newBuffer, (uint)_decryptedLength * sizeof(char)); decryptedBuffer.Dispose(); decryptedBuffer = newBuffer; }
private void EnsureCapacity(int capacity) { if (capacity > 0x10000) { throw new ArgumentOutOfRangeException("capacity", Environment.GetResourceString("ArgumentOutOfRange_Capacity")); } if (capacity > this.m_buffer.Length) { SafeBSTRHandle target = SafeBSTRHandle.Allocate(null, GetAlignedSize(capacity)); if (target.IsInvalid) { throw new OutOfMemoryException(); } SafeBSTRHandle.Copy(this.m_buffer, target); this.m_buffer.Close(); this.m_buffer = target; } }
private void EnsureCapacity(int capacity) { if (capacity > MaxLength) { throw new ArgumentOutOfRangeException(nameof(capacity), SR.ArgumentOutOfRange_Capacity); } if (((uint)capacity * sizeof(char)) <= _buffer.ByteLength) { return; } var oldBuffer = _buffer; SafeBSTRHandle newBuffer = SafeBSTRHandle.Allocate(GetAlignedSize((uint)capacity)); SafeBSTRHandle.Copy(oldBuffer, newBuffer, (uint)_decryptedLength * sizeof(char)); _buffer = newBuffer; oldBuffer.Dispose(); }
[System.Security.SecurityCritical] // auto-generated private void EnsureCapacity(int capacity) { if( capacity > MaxLength) { throw new ArgumentOutOfRangeException("capacity", Environment.GetResourceString("ArgumentOutOfRange_Capacity")); } Contract.EndContractBlock(); if( capacity <= m_buffer.Length) { return; } SafeBSTRHandle newBuffer = SafeBSTRHandle.Allocate(null, GetAlignedSize(capacity)); if (newBuffer.IsInvalid) { throw new OutOfMemoryException(); } SafeBSTRHandle.Copy(m_buffer, newBuffer); m_buffer.Close(); m_buffer = newBuffer; }
private void AllocateBuffer(uint size) { _buffer = SafeBSTRHandle.Allocate(GetAlignedSize(size)); }
[System.Security.SecurityCritical] // auto-generated private void AllocateBuffer(uint size) { _encryptedBuffer = SafeBSTRHandle.Allocate(null, size); }