diff --git a/SMBLibrary/NetBios/SessionPackets/SessionPacket.cs b/SMBLibrary/NetBios/SessionPackets/SessionPacket.cs index aabaad4..7b114b6 100644 --- a/SMBLibrary/NetBios/SessionPackets/SessionPacket.cs +++ b/SMBLibrary/NetBios/SessionPackets/SessionPacket.cs @@ -81,7 +81,7 @@ namespace SMBLibrary.NetBios case SessionPacketTypeName.SessionKeepAlive: return new SessionKeepAlivePacket(buffer, offset); default: - throw new InvalidDataException("Invalid NetBIOS session packet type: 0x" + type.ToString("X")); + throw new InvalidDataException("Invalid NetBIOS session packet type: 0x" + type.ToString("X2")); } } } diff --git a/SMBLibrary/SMB1/Commands/SMB1Command.cs b/SMBLibrary/SMB1/Commands/SMB1Command.cs index 03580b5..026381d 100644 --- a/SMBLibrary/SMB1/Commands/SMB1Command.cs +++ b/SMBLibrary/SMB1/Commands/SMB1Command.cs @@ -158,7 +158,7 @@ namespace SMBLibrary.SMB1 case CommandName.SMB_COM_NT_CANCEL: return new NTCancelRequest(buffer, offset); default: - throw new NotImplementedException("SMB Command 0x" + commandName.ToString("X")); + throw new InvalidDataException("Invalid SMB command 0x" + commandName.ToString("X2")); } } @@ -465,7 +465,7 @@ namespace SMBLibrary.SMB1 } } default: - throw new NotImplementedException("SMB Command 0x" + commandName.ToString("X")); + throw new InvalidDataException("Invalid SMB command 0x" + commandName.ToString("X2")); } } diff --git a/SMBLibrary/SMB2/Commands/SMB2Command.cs b/SMBLibrary/SMB2/Commands/SMB2Command.cs index a4383b1..3cad214 100644 --- a/SMBLibrary/SMB2/Commands/SMB2Command.cs +++ b/SMBLibrary/SMB2/Commands/SMB2Command.cs @@ -64,8 +64,8 @@ namespace SMBLibrary.SMB2 public static SMB2Command ReadRequest(byte[] buffer, int offset) { - SMB2CommandName command = (SMB2CommandName)LittleEndianConverter.ToUInt16(buffer, offset + 12); - switch (command) + SMB2CommandName commandName = (SMB2CommandName)LittleEndianConverter.ToUInt16(buffer, offset + 12); + switch (commandName) { case SMB2CommandName.Negotiate: return new NegotiateRequest(buffer, offset); @@ -104,7 +104,7 @@ namespace SMBLibrary.SMB2 case SMB2CommandName.SetInfo: return new SetInfoRequest(buffer, offset); default: - throw new InvalidDataException("Invalid SMB2 command in buffer"); + throw new InvalidDataException("Invalid SMB2 command 0x" + commandName.ToString("X4")); } } @@ -178,9 +178,9 @@ namespace SMBLibrary.SMB2 public static SMB2Command ReadResponse(byte[] buffer, int offset) { - SMB2CommandName command = (SMB2CommandName)LittleEndianConverter.ToUInt16(buffer, offset + 12); + SMB2CommandName commandName = (SMB2CommandName)LittleEndianConverter.ToUInt16(buffer, offset + 12); ushort structureSize = LittleEndianConverter.ToUInt16(buffer, offset + SMB2Header.Length + 0); - switch (command) + switch (commandName) { case SMB2CommandName.Negotiate: { @@ -471,7 +471,7 @@ namespace SMBLibrary.SMB2 } } default: - throw new InvalidDataException("Invalid SMB2 command in buffer"); + throw new InvalidDataException("Invalid SMB2 command 0x" + commandName.ToString("X4")); } } diff --git a/SMBLibrary/Win32/Security/SSPIHelper.cs b/SMBLibrary/Win32/Security/SSPIHelper.cs index ade98f8..87aa1b0 100644 --- a/SMBLibrary/Win32/Security/SSPIHelper.cs +++ b/SMBLibrary/Win32/Security/SSPIHelper.cs @@ -220,7 +220,7 @@ namespace SMBLibrary.Win32.Security } if (result != SEC_E_OK) { - throw new Exception("AcquireCredentialsHandle failed, Error code 0x" + result.ToString("X")); + throw new Exception("AcquireCredentialsHandle failed, Error code 0x" + result.ToString("X8")); } return credential; @@ -253,7 +253,7 @@ namespace SMBLibrary.Win32.Security } else { - throw new Exception("InitializeSecurityContext failed, Error code 0x" + result.ToString("X")); + throw new Exception("InitializeSecurityContext failed, Error code 0x" + result.ToString("X8")); } } FreeCredentialsHandle(ref credentialsHandle); @@ -290,7 +290,7 @@ namespace SMBLibrary.Win32.Security } else { - throw new Exception("InitializeSecurityContext failed, Error code 0x" + result.ToString("X")); + throw new Exception("InitializeSecurityContext failed, Error code 0x" + result.ToString("X8")); } } byte[] messageBytes = output.GetBufferBytes(0); @@ -329,7 +329,7 @@ namespace SMBLibrary.Win32.Security } else { - throw new Exception("AcceptSecurityContext failed, Error code 0x" + result.ToString("X")); + throw new Exception("AcceptSecurityContext failed, Error code 0x" + result.ToString("X8")); } } FreeCredentialsHandle(ref credentialsHandle); @@ -394,7 +394,7 @@ namespace SMBLibrary.Win32.Security } else { - throw new Exception("AcceptSecurityContext failed, Error code 0x" + result.ToString("X")); + throw new Exception("AcceptSecurityContext failed, Error code 0x" + result.ToString("X8")); } } }