mirror of
https://github.com/TalAloni/SMBLibrary.git
synced 2025-08-13 18:59:18 +02:00
Improved exception messages
This commit is contained in:
parent
e287129571
commit
5e71f927a2
4 changed files with 14 additions and 14 deletions
|
@ -81,7 +81,7 @@ namespace SMBLibrary.NetBios
|
||||||
case SessionPacketTypeName.SessionKeepAlive:
|
case SessionPacketTypeName.SessionKeepAlive:
|
||||||
return new SessionKeepAlivePacket(buffer, offset);
|
return new SessionKeepAlivePacket(buffer, offset);
|
||||||
default:
|
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"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,7 +158,7 @@ namespace SMBLibrary.SMB1
|
||||||
case CommandName.SMB_COM_NT_CANCEL:
|
case CommandName.SMB_COM_NT_CANCEL:
|
||||||
return new NTCancelRequest(buffer, offset);
|
return new NTCancelRequest(buffer, offset);
|
||||||
default:
|
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:
|
default:
|
||||||
throw new NotImplementedException("SMB Command 0x" + commandName.ToString("X"));
|
throw new InvalidDataException("Invalid SMB command 0x" + commandName.ToString("X2"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,8 +64,8 @@ namespace SMBLibrary.SMB2
|
||||||
|
|
||||||
public static SMB2Command ReadRequest(byte[] buffer, int offset)
|
public static SMB2Command ReadRequest(byte[] buffer, int offset)
|
||||||
{
|
{
|
||||||
SMB2CommandName command = (SMB2CommandName)LittleEndianConverter.ToUInt16(buffer, offset + 12);
|
SMB2CommandName commandName = (SMB2CommandName)LittleEndianConverter.ToUInt16(buffer, offset + 12);
|
||||||
switch (command)
|
switch (commandName)
|
||||||
{
|
{
|
||||||
case SMB2CommandName.Negotiate:
|
case SMB2CommandName.Negotiate:
|
||||||
return new NegotiateRequest(buffer, offset);
|
return new NegotiateRequest(buffer, offset);
|
||||||
|
@ -104,7 +104,7 @@ namespace SMBLibrary.SMB2
|
||||||
case SMB2CommandName.SetInfo:
|
case SMB2CommandName.SetInfo:
|
||||||
return new SetInfoRequest(buffer, offset);
|
return new SetInfoRequest(buffer, offset);
|
||||||
default:
|
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)
|
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);
|
ushort structureSize = LittleEndianConverter.ToUInt16(buffer, offset + SMB2Header.Length + 0);
|
||||||
switch (command)
|
switch (commandName)
|
||||||
{
|
{
|
||||||
case SMB2CommandName.Negotiate:
|
case SMB2CommandName.Negotiate:
|
||||||
{
|
{
|
||||||
|
@ -471,7 +471,7 @@ namespace SMBLibrary.SMB2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
throw new InvalidDataException("Invalid SMB2 command in buffer");
|
throw new InvalidDataException("Invalid SMB2 command 0x" + commandName.ToString("X4"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -220,7 +220,7 @@ namespace SMBLibrary.Win32.Security
|
||||||
}
|
}
|
||||||
if (result != SEC_E_OK)
|
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;
|
return credential;
|
||||||
|
@ -253,7 +253,7 @@ namespace SMBLibrary.Win32.Security
|
||||||
}
|
}
|
||||||
else
|
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);
|
FreeCredentialsHandle(ref credentialsHandle);
|
||||||
|
@ -290,7 +290,7 @@ namespace SMBLibrary.Win32.Security
|
||||||
}
|
}
|
||||||
else
|
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);
|
byte[] messageBytes = output.GetBufferBytes(0);
|
||||||
|
@ -329,7 +329,7 @@ namespace SMBLibrary.Win32.Security
|
||||||
}
|
}
|
||||||
else
|
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);
|
FreeCredentialsHandle(ref credentialsHandle);
|
||||||
|
@ -394,7 +394,7 @@ namespace SMBLibrary.Win32.Security
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new Exception("AcceptSecurityContext failed, Error code 0x" + result.ToString("X"));
|
throw new Exception("AcceptSecurityContext failed, Error code 0x" + result.ToString("X8"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue