VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Platform/MemoryStream.cpp
blob: 38c7bf107e08de1c49a49caf64e1af62004bc835 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; backgrou
/*
 Derived from source code of TrueCrypt 7.1a, which is
 Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
 by the TrueCrypt License 3.0.

 Modifications and additions to the original source code (contained in this file) 
 and all other portions of this file are Copyright (c) 2013-2015 IDRIX
 and are governed by the Apache License 2.0 the full text of which is
 contained in the file License.txt included in VeraCrypt binary and source
 code distribution packages.
*/

#include "Exception.h"
#include "MemoryStream.h"

namespace VeraCrypt
{
	MemoryStream::MemoryStream (const ConstBufferPtr &data) :
		ReadPosition (0)
	{
		Data = vector <byte> (data.Size());
		BufferPtr (&Data[0], Data.size()).CopyFrom (data);
	}

	uint64 MemoryStream::Read (const BufferPtr &buffer)
	{
		if (Data.size() == 0)
			throw ParameterIncorrect (SRC_POS);

		ConstBufferPtr streamBuf (*this);
		size_t len = buffer.Size();
		if (streamBuf.Size() - ReadPosition < len)
			len = streamBuf.Size() - ReadPosition;

		BufferPtr(buffer).CopyFrom (streamBuf.GetRange (ReadPosition, len));
		ReadPosition += len;
		return len;
	}

	void MemoryStream::ReadCompleteBuffer (const BufferPtr &buffer)
	{
		if (Read (buffer) != buffer.Size())
			throw InsufficientData (SRC_POS);
	}

	void MemoryStream::Write (const ConstBufferPtr &data)
	{
		for (uint64 i = 0; i < data.Size(); i++)
			Data.push_back (data[i]);
	}
}
lass="p">> <a href="Documentation.html">Documentation</a> <img src="arrow_right.gif" alt=">>" style="margin-top: 5px"> <a href="Security%20Requirements%20and%20Precautions.html">Security Requirements and Precautions</a> <img src="arrow_right.gif" alt=">>" style="margin-top: 5px"> <a href="Multi-User%20Environment.html">Multi-User Environment</a> </p></div> <div class="wikidoc"> <div> <h1>Multi-User Environment</h1> <p>Keep in mind, that the content of a mounted VeraCrypt volume is visible (accessible) to all logged on users. NTFS file/folder permissions can be set to prevent this, unless the volume is mounted as removable medium (see section <a href="Removable%20Medium%20Volume.html"> <em>Volume Mounted as Removable Medium</em></a>) under a desktop edition of Windows Vista or later (sectors of a volume mounted as removable medium may be accessible at the volume level to users without administrator privileges, regardless of whether it is accessible to them at the file-system level).<br> <br> Moreover, on Windows, the password cache is shared by all logged on users (for more information, please see the section <em>Settings -&gt; Preferences</em>, subsection <em>Cache passwords in driver memory</em>).<br> <br> Also note that switching users in Windows XP or later (<em>Fast User Switching</em> functionality) does <em>not</em> dismount a successfully mounted VeraCrypt volume (unlike system restart, which dismounts all mounted VeraCrypt volumes).<br> <br> On Windows 2000, the container file permissions are ignored when a file-hosted VeraCrypt volume is to be mounted. On all supported versions of Windows, users without administrator privileges can mount any partition/device-hosted VeraCrypt volume (provided that they supply the correct password and/or keyfiles). A user without administrator privileges can dismount only volumes that he or she mounted. However, this does not apply to system favorite volumes unless you enable the option (disabled by default) <em>Settings</em> &gt; &lsquo;<em>System Favorite Volumes</em>&rsquo; &gt; &lsquo;<em>Allow only administrators to view and dismount system favorite volumes in VeraCrypt</em>&rsquo;.</p> </div> </div><div class="ClearBoth"></div></body></html>