Memory: Add LittleEndian16(), LittleEndian32() and LittleEndian64()

This commit is contained in:
Daiyuu Nobori authored and Davide Beatrici committed 2022-02-22 19:38:03 +01:00
1 parent 1e604407af
commit 56aedd6817
2 files changed
+45

No files matched your search

+42
View File
@@ -3373,6 +3373,48 @@ UINT64 Endian64(UINT64 src)
}
}
// Endian conversion 16bit
USHORT LittleEndian16(USHORT src)
{
int x = 0x01000000;
if (*((char *)&x))
{
return Swap16(src);
}
else
{
return src;
}
}
// Endian conversion 32bit
UINT LittleEndian32(UINT src)
{
int x = 0x01000000;
if (*((char *)&x))
{
return Swap32(src);
}
else
{
return src;
}
}
// Endian conversion 64bit
UINT64 LittleEndian64(UINT64 src)
{
int x = 0x01000000;
if (*((char *)&x))
{
return Swap64(src);
}
else
{
return src;
}
}
// 16bit swap
USHORT Swap16(USHORT value)
{
+3
View File
@@ -199,6 +199,9 @@ UINT64 Swap64(UINT64 value);
USHORT Endian16(USHORT src);
UINT Endian32(UINT src);
UINT64 Endian64(UINT64 src);
USHORT LittleEndian16(USHORT src);
UINT LittleEndian32(UINT src);
UINT64 LittleEndian64(UINT64 src);
void EndianUnicode(wchar_t *str);
BUF *NewBuf();