VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Platform
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2024-06-12 12:30:04 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2024-06-12 12:30:04 +0200
commit455a4f2176a5cfbe325e1e40cea20dd3e466b64c (patch)
tree7a84d0f768ee375ea9f648bbbdeac7a4906f13fb /src/Platform
parentbf9f3ec4f0a987ae1591ab5466f6eee599203c85 (diff)
downloadVeraCrypt-455a4f2176a5cfbe325e1e40cea20dd3e466b64c.tar.gz
VeraCrypt-455a4f2176a5cfbe325e1e40cea20dd3e466b64c.zip
Avoid conflict with C++17 features std::byte by using uint8 type instead of byte
Diffstat (limited to 'src/Platform')
-rw-r--r--src/Platform/Buffer.cpp2
-rw-r--r--src/Platform/Buffer.h26
-rw-r--r--src/Platform/FileStream.h2
-rw-r--r--src/Platform/Memory.h28
-rw-r--r--src/Platform/MemoryStream.cpp2
-rw-r--r--src/Platform/MemoryStream.h2
-rw-r--r--src/Platform/PlatformBase.h4
-rw-r--r--src/Platform/PlatformTest.cpp6
-rw-r--r--src/Platform/Serializer.cpp26
-rw-r--r--src/Platform/Serializer.h4
-rw-r--r--src/Platform/StringConverter.cpp4
-rw-r--r--src/Platform/TextReader.cpp2
-rw-r--r--src/Platform/Unix/Process.cpp2
13 files changed, 55 insertions, 55 deletions
diff --git a/src/Platform/Buffer.cpp b/src/Platform/Buffer.cpp
index 82c2a3f1..5829b1d9 100644
--- a/src/Platform/Buffer.cpp
+++ b/src/Platform/Buffer.cpp
@@ -44,7 +44,7 @@ namespace VeraCrypt
try
{
- DataPtr = static_cast<byte *> ((alignment > 0)? Memory::AllocateAligned (size, alignment) : Memory::Allocate (size));
+ DataPtr = static_cast<uint8 *> ((alignment > 0)? Memory::AllocateAligned (size, alignment) : Memory::Allocate (size));
DataSize = size;
DataAlignment = alignment;
}
diff --git a/src/Platform/Buffer.h b/src/Platform/Buffer.h
index 1150fcf5..a1eb0918 100644
--- a/src/Platform/Buffer.h
+++ b/src/Platform/Buffer.h
@@ -24,20 +24,20 @@ namespace VeraCrypt
public:
ConstBufferPtr ()
: DataPtr (nullptr), DataSize (0) { }
- ConstBufferPtr (const byte *data, size_t size)
+ ConstBufferPtr (const uint8 *data, size_t size)
: DataPtr (data), DataSize (size) { }
virtual ~ConstBufferPtr () { }
- operator const byte * () const { return DataPtr; }
+ operator const uint8 * () const { return DataPtr; }
bool IsDataEqual (const ConstBufferPtr &other) const { return Memory::Compare (DataPtr, DataSize, other.DataPtr, other.DataSize) == 0; }
- const byte *Get () const { return DataPtr; }
+ const uint8 *Get () const { return DataPtr; }
ConstBufferPtr GetRange (size_t offset, size_t size) const;
- void Set (const byte *data, size_t size) { DataPtr = data; DataSize = size; }
+ void Set (const uint8 *data, size_t size) { DataPtr = data; DataSize = size; }
size_t Size () const { return DataSize; }
protected:
- const byte *DataPtr;
+ const uint8 *DataPtr;
size_t DataSize;
};
@@ -47,23 +47,23 @@ namespace VeraCrypt
public:
BufferPtr ()
: DataPtr (nullptr), DataSize (0) { }
- BufferPtr (byte *data, size_t size)
+ BufferPtr (uint8 *data, size_t size)
: DataPtr (data), DataSize (size) { }
virtual ~BufferPtr () { }
- operator byte * () const { return DataPtr; }
+ operator uint8 * () const { return DataPtr; }
void CopyFrom (const ConstBufferPtr &bufferPtr) const;
void Erase () const { Zero(); }
- byte *Get () const { return DataPtr; }
+ uint8 *Get () const { return DataPtr; }
BufferPtr GetRange (size_t offset, size_t size) const;
- void Set (byte *data, size_t size) { DataPtr = data; DataSize = size; }
+ void Set (uint8 *data, size_t size) { DataPtr = data; DataSize = size; }
size_t Size () const { return DataSize; }
void Zero () const { Memory::Zero (DataPtr, DataSize); }
operator ConstBufferPtr () const { return ConstBufferPtr (DataPtr, DataSize); }
protected:
- byte *DataPtr;
+ uint8 *DataPtr;
size_t DataSize;
};
@@ -77,7 +77,7 @@ namespace VeraCrypt
virtual void Allocate (size_t size, size_t alignment = 0);
virtual void CopyFrom (const ConstBufferPtr &bufferPtr, size_t alignment = 0);
- virtual byte *Ptr () const { return DataPtr; }
+ virtual uint8 *Ptr () const { return DataPtr; }
virtual void Erase ();
virtual void Free ();
virtual BufferPtr GetRange (size_t offset, size_t size) const;
@@ -86,12 +86,12 @@ namespace VeraCrypt
virtual bool IsAllocated () const { return DataSize != 0; }
virtual void Zero ();
- virtual operator byte * () const { return DataPtr; }
+ virtual operator uint8 * () const { return DataPtr; }
virtual operator BufferPtr () const { return BufferPtr (DataPtr, DataSize); }
virtual operator ConstBufferPtr () const { return ConstBufferPtr (DataPtr, DataSize); }
protected:
- byte *DataPtr;
+ uint8 *DataPtr;
size_t DataSize;
size_t DataAlignment;
diff --git a/src/Platform/FileStream.h b/src/Platform/FileStream.h
index 0ef40862..66df1999 100644
--- a/src/Platform/FileStream.h
+++ b/src/Platform/FileStream.h
@@ -43,7 +43,7 @@ namespace VeraCrypt
vector <char> buffer (4096);
uint64 len;
- while ((len = DataFile->Read (BufferPtr (reinterpret_cast <byte *> (&buffer[0]), buffer.size()))) > 0)
+ while ((len = DataFile->Read (BufferPtr (reinterpret_cast <uint8 *> (&buffer[0]), buffer.size()))) > 0)
str.insert (str.end(), buffer.begin(), buffer.begin() + static_cast <int> (len));
return str;
diff --git a/src/Platform/Memory.h b/src/Platform/Memory.h
index e0d4bfe3..b124022f 100644
--- a/src/Platform/Memory.h
+++ b/src/Platform/Memory.h
@@ -85,7 +85,7 @@ namespace VeraCrypt
class Endian
{
public:
- static byte Big (const byte &x)
+ static uint8 Big (const uint8 &x)
{
return x;
}
@@ -117,7 +117,7 @@ namespace VeraCrypt
#endif
}
- static byte Little (const byte &x)
+ static uint8 Little (const uint8 &x)
{
return x;
}
@@ -157,22 +157,22 @@ namespace VeraCrypt
static uint32 MirrorBytes (const uint32 &x)
{
- uint32 n = (byte) x;
- n <<= 8; n |= (byte) (x >> 8);
- n <<= 8; n |= (byte) (x >> 16);
- return (n << 8) | (byte) (x >> 24);
+ uint32 n = (uint8) x;
+ n <<= 8; n |= (uint8) (x >> 8);
+ n <<= 8; n |= (uint8) (x >> 16);
+ return (n << 8) | (uint8) (x >> 24);
}
static uint64 MirrorBytes (const uint64 &x)
{
- uint64 n = (byte) x;
- n <<= 8; n |= (byte) (x >> 8);
- n <<= 8; n |= (byte) (x >> 16);
- n <<= 8; n |= (byte) (x >> 24);
- n <<= 8; n |= (byte) (x >> 32);
- n <<= 8; n |= (byte) (x >> 40);
- n <<= 8; n |= (byte) (x >> 48);
- return (n << 8) | (byte) (x >> 56);
+ uint64 n = (uint8) x;
+ n <<= 8; n |= (uint8) (x >> 8);
+ n <<= 8; n |= (uint8) (x >> 16);
+ n <<= 8; n |= (uint8) (x >> 24);
+ n <<= 8; n |= (uint8) (x >> 32);
+ n <<= 8; n |= (uint8) (x >> 40);
+ n <<= 8; n |= (uint8) (x >> 48);
+ return (n << 8) | (uint8) (x >> 56);
}
};
}
diff --git a/src/Platform/MemoryStream.cpp b/src/Platform/MemoryStream.cpp
index 8bf229fe..1bd090b9 100644
--- a/src/Platform/MemoryStream.cpp
+++ b/src/Platform/MemoryStream.cpp
@@ -18,7 +18,7 @@ namespace VeraCrypt
MemoryStream::MemoryStream (const ConstBufferPtr &data) :
ReadPosition (0)
{
- Data = vector <byte> (data.Size());
+ Data = vector <uint8> (data.Size());
BufferPtr (&Data[0], Data.size()).CopyFrom (data);
}
diff --git a/src/Platform/MemoryStream.h b/src/Platform/MemoryStream.h
index 3df0bd13..068e6d6e 100644
--- a/src/Platform/MemoryStream.h
+++ b/src/Platform/MemoryStream.h
@@ -32,7 +32,7 @@ namespace VeraCrypt
virtual void Write (const ConstBufferPtr &data);
protected:
- vector <byte> Data;
+ vector <uint8> Data;
size_t ReadPosition;
};
}
diff --git a/src/Platform/PlatformBase.h b/src/Platform/PlatformBase.h
index 22022dc7..e378704c 100644
--- a/src/Platform/PlatformBase.h
+++ b/src/Platform/PlatformBase.h
@@ -43,7 +43,7 @@ namespace VeraCrypt
typedef __int16 int16;
typedef __int32 int32;
typedef __int64 int64;
- typedef unsigned __int8 byte;
+ typedef unsigned __int8 uint8;
typedef unsigned __int16 uint16;
typedef unsigned __int32 uint32;
typedef unsigned __int64 uint64;
@@ -53,7 +53,7 @@ namespace VeraCrypt
typedef int16_t int16;
typedef int32_t int32;
typedef int64_t int64;
- typedef uint8_t byte;
+ typedef uint8_t uint8;
typedef uint16_t uint16;
typedef uint32_t uint32;
typedef uint64_t uint64;
diff --git a/src/Platform/PlatformTest.cpp b/src/Platform/PlatformTest.cpp
index 7362d6bf..9a3faae2 100644
--- a/src/Platform/PlatformTest.cpp
+++ b/src/Platform/PlatformTest.cpp
@@ -76,7 +76,7 @@ namespace VeraCrypt
Buffer buffer (10);
for (size_t i = 0; i < buffer.Size(); i++)
- buffer[i] = (byte) i;
+ buffer[i] = (uint8) i;
ser.Serialize ("int32", i32);
ser.Serialize ("int64", i64);
@@ -141,7 +141,7 @@ namespace VeraCrypt
Buffer dbuffer (10);
ser.Deserialize ("buffer", buffer);
for (size_t i = 0; i < buffer.Size(); i++)
- if (buffer[i] != (byte) i)
+ if (buffer[i] != (uint8) i)
throw TestFailed (SRC_POS);
shared_ptr <ExecutedProcessFailed> dex = Serializable::DeserializeNew <ExecutedProcessFailed> (stream);
@@ -238,7 +238,7 @@ namespace VeraCrypt
bool PlatformTest::TestAll ()
{
// Integer types
- if (sizeof (byte) != 1 || sizeof (int8) != 1 || sizeof (__int8) != 1) throw TestFailed (SRC_POS);
+ if (sizeof (uint8) != 1 || sizeof (int8) != 1 || sizeof (__int8) != 1) throw TestFailed (SRC_POS);
if (sizeof (uint16) != 2 || sizeof (int16) != 2 || sizeof (__int16) != 2) throw TestFailed (SRC_POS);
if (sizeof (uint32) != 4 || sizeof (int32) != 4 || sizeof (__int32) != 4) throw TestFailed (SRC_POS);
if (sizeof (uint64) != 8 || sizeof (int64) != 8) throw TestFailed (SRC_POS);
diff --git a/src/Platform/Serializer.cpp b/src/Platform/Serializer.cpp
index b69fe891..6f428b15 100644
--- a/src/Platform/Serializer.cpp
+++ b/src/Platform/Serializer.cpp
@@ -21,13 +21,13 @@ namespace VeraCrypt
T Serializer::Deserialize ()
{
uint64 size;
- DataStream->ReadCompleteBuffer (BufferPtr ((byte *) &size, sizeof (size)));
+ DataStream->ReadCompleteBuffer (BufferPtr ((uint8 *) &size, sizeof (size)));
if (Endian::Big (size) != sizeof (T))
throw ParameterIncorrect (SRC_POS);
T data;
- DataStream->ReadCompleteBuffer (BufferPtr ((byte *) &data, sizeof (data)));
+ DataStream->ReadCompleteBuffer (BufferPtr ((uint8 *) &data, sizeof (data)));
return Endian::Big (data);
}
@@ -35,13 +35,13 @@ namespace VeraCrypt
void Serializer::Deserialize (const string &name, bool &data)
{
ValidateName (name);
- data = Deserialize <byte> () == 1;
+ data = Deserialize <uint8> () == 1;
}
- void Serializer::Deserialize (const string &name, byte &data)
+ void Serializer::Deserialize (const string &name, uint8 &data)
{
ValidateName (name);
- data = Deserialize <byte> ();
+ data = Deserialize <uint8> ();
}
void Serializer::Deserialize (const string &name, int32 &data)
@@ -127,7 +127,7 @@ namespace VeraCrypt
uint64 size = Deserialize <uint64> ();
vector <char> data ((size_t) size);
- DataStream->ReadCompleteBuffer (BufferPtr ((byte *) &data[0], (size_t) size));
+ DataStream->ReadCompleteBuffer (BufferPtr ((uint8 *) &data[0], (size_t) size));
return string (&data[0]);
}
@@ -155,7 +155,7 @@ namespace VeraCrypt
uint64 size = Deserialize <uint64> ();
vector <wchar_t> data ((size_t) size / sizeof (wchar_t));
- DataStream->ReadCompleteBuffer (BufferPtr ((byte *) &data[0], (size_t) size));
+ DataStream->ReadCompleteBuffer (BufferPtr ((uint8 *) &data[0], (size_t) size));
return wstring (&data[0]);
}
@@ -182,20 +182,20 @@ namespace VeraCrypt
void Serializer::Serialize (T data)
{
uint64 size = Endian::Big (uint64 (sizeof (data)));
- DataStream->Write (ConstBufferPtr ((byte *) &size, sizeof (size)));
+ DataStream->Write (ConstBufferPtr ((uint8 *) &size, sizeof (size)));
data = Endian::Big (data);
- DataStream->Write (ConstBufferPtr ((byte *) &data, sizeof (data)));
+ DataStream->Write (ConstBufferPtr ((uint8 *) &data, sizeof (data)));
}
void Serializer::Serialize (const string &name, bool data)
{
SerializeString (name);
- byte d = data ? 1 : 0;
+ uint8 d = data ? 1 : 0;
Serialize (d);
}
- void Serializer::Serialize (const string &name, byte data)
+ void Serializer::Serialize (const string &name, uint8 data)
{
SerializeString (name);
Serialize (data);
@@ -282,14 +282,14 @@ namespace VeraCrypt
void Serializer::SerializeString (const string &data)
{
Serialize ((uint64) data.size() + 1);
- DataStream->Write (ConstBufferPtr ((byte *) (data.data() ? data.data() : data.c_str()), data.size() + 1));
+ DataStream->Write (ConstBufferPtr ((uint8 *) (data.data() ? data.data() : data.c_str()), data.size() + 1));
}
void Serializer::SerializeWString (const wstring &data)
{
uint64 size = (data.size() + 1) * sizeof (wchar_t);
Serialize (size);
- DataStream->Write (ConstBufferPtr ((byte *) (data.data() ? data.data() : data.c_str()), (size_t) size));
+ DataStream->Write (ConstBufferPtr ((uint8 *) (data.data() ? data.data() : data.c_str()), (size_t) size));
}
void Serializer::ValidateName (const string &name)
diff --git a/src/Platform/Serializer.h b/src/Platform/Serializer.h
index c2dac324..3617a83b 100644
--- a/src/Platform/Serializer.h
+++ b/src/Platform/Serializer.h
@@ -27,7 +27,7 @@ namespace VeraCrypt
virtual ~Serializer () { }
void Deserialize (const string &name, bool &data);
- void Deserialize (const string &name, byte &data);
+ void Deserialize (const string &name, uint8 &data);
void Deserialize (const string &name, int32 &data);
void Deserialize (const string &name, int64 &data);
void Deserialize (const string &name, uint32 &data);
@@ -45,7 +45,7 @@ namespace VeraCrypt
wstring DeserializeWString (const string &name);
list <wstring> DeserializeWStringList (const string &name);
void Serialize (const string &name, bool data);
- void Serialize (const string &name, byte data);
+ void Serialize (const string &name, uint8 data);
void Serialize (const string &name, const char *data);
void Serialize (const string &name, int32 data);
void Serialize (const string &name, int64 data);
diff --git a/src/Platform/StringConverter.cpp b/src/Platform/StringConverter.cpp
index e1a6df98..7b3134ee 100644
--- a/src/Platform/StringConverter.cpp
+++ b/src/Platform/StringConverter.cpp
@@ -385,9 +385,9 @@ namespace VeraCrypt
}
BufferPtr (
- (byte *) buffer,
+ (uint8 *) buffer,
bufferSize).CopyFrom (
- ConstBufferPtr ((byte *) (wstring (str).c_str()),
+ ConstBufferPtr ((uint8 *) (wstring (str).c_str()),
(str.length() + 1) * sizeof (wchar_t)
)
);
diff --git a/src/Platform/TextReader.cpp b/src/Platform/TextReader.cpp
index 7d6a0c64..bdaf19c2 100644
--- a/src/Platform/TextReader.cpp
+++ b/src/Platform/TextReader.cpp
@@ -26,7 +26,7 @@ namespace VeraCrypt
outputString.erase();
char c;
- while (InputStream->Read (BufferPtr ((byte *) &c, sizeof (c))) == sizeof (c))
+ while (InputStream->Read (BufferPtr ((uint8 *) &c, sizeof (c))) == sizeof (c))
{
if (c == '\r')
continue;
diff --git a/src/Platform/Unix/Process.cpp b/src/Platform/Unix/Process.cpp
index 36b01e6b..46b14a1e 100644
--- a/src/Platform/Unix/Process.cpp
+++ b/src/Platform/Unix/Process.cpp
@@ -174,7 +174,7 @@ namespace VeraCrypt
try
{
- shared_ptr <Stream> stream (new MemoryStream (ConstBufferPtr ((byte *) &exOutput[0], exOutput.size())));
+ shared_ptr <Stream> stream (new MemoryStream (ConstBufferPtr ((uint8 *) &exOutput[0], exOutput.size())));
deserializedObject.reset (Serializable::DeserializeNew (stream));
deserializedException = dynamic_cast <Exception*> (deserializedObject.get());
}