|
@@ -1,4 +1,4 @@
|
|
-/* Copyright (C) 2014 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
|
|
|
|
|
|
+/* Copyright (C) 2014-2017 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
|
|
*
|
|
*
|
|
* You can redistribute this program and/or modify it under the terms of
|
|
* 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,
|
|
* the GNU Lesser Public License as published by the Free Software Foundation,
|
|
@@ -24,7 +24,7 @@ namespace SMBLibrary.RPC
|
|
public PacketTypeName PacketType;
|
|
public PacketTypeName PacketType;
|
|
public PacketFlags Flags;
|
|
public PacketFlags Flags;
|
|
public DataRepresentationFormat DataRepresentation;
|
|
public DataRepresentationFormat DataRepresentation;
|
|
- public ushort FragmentLength;
|
|
|
|
|
|
+ public ushort FragmentLength; // The length of the entire PDU
|
|
public ushort AuthLength;
|
|
public ushort AuthLength;
|
|
public uint CallID;
|
|
public uint CallID;
|
|
|
|
|
|
@@ -34,16 +34,16 @@ namespace SMBLibrary.RPC
|
|
VersionMinor = 0;
|
|
VersionMinor = 0;
|
|
}
|
|
}
|
|
|
|
|
|
- public RPCPDU(byte[] buffer)
|
|
|
|
|
|
+ public RPCPDU(byte[] buffer, int offset)
|
|
{
|
|
{
|
|
- VersionMajor = ByteReader.ReadByte(buffer, 0);
|
|
|
|
- VersionMinor = ByteReader.ReadByte(buffer, 1);
|
|
|
|
- PacketType = (PacketTypeName)ByteReader.ReadByte(buffer, 2);
|
|
|
|
- Flags = (PacketFlags)ByteReader.ReadByte(buffer, 3);
|
|
|
|
- DataRepresentation = new DataRepresentationFormat(buffer, 4);
|
|
|
|
- FragmentLength = LittleEndianConverter.ToUInt16(buffer, 8);
|
|
|
|
- AuthLength = LittleEndianConverter.ToUInt16(buffer, 10);
|
|
|
|
- CallID = LittleEndianConverter.ToUInt32(buffer, 12);
|
|
|
|
|
|
+ VersionMajor = ByteReader.ReadByte(buffer, offset + 0);
|
|
|
|
+ VersionMinor = ByteReader.ReadByte(buffer, offset + 1);
|
|
|
|
+ PacketType = (PacketTypeName)ByteReader.ReadByte(buffer, offset + 2);
|
|
|
|
+ Flags = (PacketFlags)ByteReader.ReadByte(buffer, offset + 3);
|
|
|
|
+ DataRepresentation = new DataRepresentationFormat(buffer, offset + 4);
|
|
|
|
+ FragmentLength = LittleEndianConverter.ToUInt16(buffer, offset + 8);
|
|
|
|
+ AuthLength = LittleEndianConverter.ToUInt16(buffer, offset + 10);
|
|
|
|
+ CallID = LittleEndianConverter.ToUInt32(buffer, offset + 12);
|
|
}
|
|
}
|
|
|
|
|
|
public abstract byte[] GetBytes();
|
|
public abstract byte[] GetBytes();
|
|
@@ -60,21 +60,21 @@ namespace SMBLibrary.RPC
|
|
LittleEndianWriter.WriteUInt32(buffer, 12, CallID);
|
|
LittleEndianWriter.WriteUInt32(buffer, 12, CallID);
|
|
}
|
|
}
|
|
|
|
|
|
- public static RPCPDU GetPDU(byte[] buffer)
|
|
|
|
|
|
+ public static RPCPDU GetPDU(byte[] buffer, int offset)
|
|
{
|
|
{
|
|
PacketTypeName packetType = (PacketTypeName)ByteReader.ReadByte(buffer, 2);
|
|
PacketTypeName packetType = (PacketTypeName)ByteReader.ReadByte(buffer, 2);
|
|
switch (packetType)
|
|
switch (packetType)
|
|
{
|
|
{
|
|
case PacketTypeName.Request:
|
|
case PacketTypeName.Request:
|
|
- return new RequestPDU(buffer);
|
|
|
|
|
|
+ return new RequestPDU(buffer, offset);
|
|
case PacketTypeName.Response:
|
|
case PacketTypeName.Response:
|
|
- return new ResponsePDU(buffer);
|
|
|
|
|
|
+ return new ResponsePDU(buffer, offset);
|
|
case PacketTypeName.Fault:
|
|
case PacketTypeName.Fault:
|
|
- return new FaultPDU(buffer);
|
|
|
|
|
|
+ return new FaultPDU(buffer, offset);
|
|
case PacketTypeName.Bind:
|
|
case PacketTypeName.Bind:
|
|
- return new BindPDU(buffer);
|
|
|
|
|
|
+ return new BindPDU(buffer, offset);
|
|
case PacketTypeName.BindAck:
|
|
case PacketTypeName.BindAck:
|
|
- return new BindAckPDU(buffer);
|
|
|
|
|
|
+ return new BindAckPDU(buffer, offset);
|
|
default:
|
|
default:
|
|
throw new NotImplementedException();
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|