mirror of
https://github.com/TalAloni/SMBLibrary.git
synced 2025-05-16 09:27:10 +02:00
BigEndianReader / Writer: Added ReadUInt24 / WriteUInt24 methods
This commit is contained in:
parent
366c4d61d1
commit
fb7d6d4bc8
2 changed files with 36 additions and 0 deletions
|
@ -18,6 +18,17 @@ namespace Utilities
|
|||
return BigEndianConverter.ToUInt16(buffer, offset - 2);
|
||||
}
|
||||
|
||||
public static uint ReadUInt24(byte[] buffer, int offset)
|
||||
{
|
||||
return (uint)((buffer[offset + 0] << 16) | (buffer[offset + 1] << 8) | (buffer[offset + 2] << 0));
|
||||
}
|
||||
|
||||
public static uint ReadUInt24(byte[] buffer, ref int offset)
|
||||
{
|
||||
offset += 3;
|
||||
return ReadUInt24(buffer, offset - 3);
|
||||
}
|
||||
|
||||
public static int ReadInt32(byte[] buffer, ref int offset)
|
||||
{
|
||||
offset += 4;
|
||||
|
@ -62,6 +73,13 @@ namespace Utilities
|
|||
return BigEndianConverter.ToUInt16(buffer, 0);
|
||||
}
|
||||
|
||||
public static uint ReadUInt24(Stream stream)
|
||||
{
|
||||
byte[] buffer = new byte[4];
|
||||
stream.Read(buffer, 1, 3);
|
||||
return BigEndianConverter.ToUInt32(buffer, 0);
|
||||
}
|
||||
|
||||
public static int ReadInt32(Stream stream)
|
||||
{
|
||||
byte[] buffer = new byte[4];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue