[System.Security.SecuritySafeCritical] // auto-generated public void Dispose() { lock (_methodLock) { if (_encryptedBuffer != null && !_encryptedBuffer.IsInvalid) { _encryptedBuffer.Dispose(); _encryptedBuffer = null; } } }
[System.Security.SecurityCritical] // auto-generated private void ProtectMemory(SafeBSTRHandle decryptedBuffer) { Debug.Assert(!decryptedBuffer.IsInvalid, "Invalid buffer!"); if (_decryptedLength == 0) { return; } try { SafeBSTRHandle newEncryptedBuffer = null; if (Interop.Crypt32.CryptProtectData(decryptedBuffer, out newEncryptedBuffer)) { _encryptedBuffer.Dispose(); _encryptedBuffer = newEncryptedBuffer; } else { throw new CryptographicException(Marshal.GetLastWin32Error()); } } finally { decryptedBuffer.ClearBuffer(); } }
[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 > MaxLength) { throw new ArgumentOutOfRangeException(nameof(capacity), SR.ArgumentOutOfRange_Capacity); } Debug.Assert(_buffer != null); if (((uint)capacity * sizeof(char)) <= _buffer.ByteLength) { return; } SafeBSTRHandle 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 ProtectMemory(SafeBSTRHandle decryptedBuffer) { Debug.Assert(!decryptedBuffer.IsInvalid, "Invalid buffer!"); if (_decryptedLength == 0) { return; } try { SafeBSTRHandle newEncryptedBuffer = null; if (Interop.Crypt32.CryptProtectData(decryptedBuffer, out newEncryptedBuffer)) { _encryptedBuffer.Dispose(); _encryptedBuffer = newEncryptedBuffer; } else { throw new CryptographicException(Marshal.GetLastWin32Error()); } } finally { decryptedBuffer.ClearBuffer(); decryptedBuffer.Dispose(); } }