From eda6f4c2ddca4aa59948df32b3a33147acc884d8 Mon Sep 17 00:00:00 2001 From: TalAloni Date: Mon, 11 Jan 2021 23:06:31 +0200 Subject: [PATCH] NDRParser / NDRWriter: Added ability to read/write arbitrary number of bytes --- SMBLibrary/RPC/NDR/NDRParser.cs | 7 ++++++- SMBLibrary/RPC/NDR/NDRWriter.cs | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/SMBLibrary/RPC/NDR/NDRParser.cs b/SMBLibrary/RPC/NDR/NDRParser.cs index 4dd67f5..9170461 100644 --- a/SMBLibrary/RPC/NDR/NDRParser.cs +++ b/SMBLibrary/RPC/NDR/NDRParser.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 Tal Aloni . All rights reserved. +/* Copyright (C) 2014-2020 Tal Aloni . All rights reserved. * * You can redistribute this program and/or modify it under the terms of * the GNU Lesser Public License as published by the Free Software Foundation, @@ -135,5 +135,10 @@ namespace SMBLibrary.RPC m_offset += (4 - (m_offset % 4)) % 4; return LittleEndianReader.ReadUInt32(m_buffer, ref m_offset); } + + public byte[] ReadBytes(int count) + { + return ByteReader.ReadBytes(m_buffer, ref m_offset, count); + } } } diff --git a/SMBLibrary/RPC/NDR/NDRWriter.cs b/SMBLibrary/RPC/NDR/NDRWriter.cs index 8fd5982..3d22040 100644 --- a/SMBLibrary/RPC/NDR/NDRWriter.cs +++ b/SMBLibrary/RPC/NDR/NDRWriter.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 Tal Aloni . All rights reserved. +/* Copyright (C) 2014-2020 Tal Aloni . All rights reserved. * * You can redistribute this program and/or modify it under the terms of * the GNU Lesser Public License as published by the Free Software Foundation, @@ -121,6 +121,11 @@ namespace SMBLibrary.RPC LittleEndianWriter.WriteUInt32(m_stream, value); } + public void WriteBytes(byte[] value) + { + ByteWriter.WriteBytes(m_stream, value); + } + public byte[] GetBytes() { byte[] buffer = new byte[m_stream.Length];