class WinRM::PSRP::Fragment
PowerShell Remoting Protocol message fragment.
Attributes
Public Class Methods
Source
# File lib/winrm/psrp/fragment.rb, line 27 def initialize(object_id, blob, fragment_id = 0, start_fragment = true, end_fragment = true) @object_id = object_id @blob = blob @fragment_id = fragment_id @start_fragment = start_fragment @end_fragment = end_fragment end
Creates a new PSRP
message fragment @param object_id
[Integer] The id of the fragmented message. @param blob [Array] Array of fragmented bytes. @param fragment_id
[Integer] The id of this fragment @param start_fragment
[Boolean] If the fragment is the first fragment @param end_fragment
[Boolean] If the fragment is the last fragment
Public Instance Methods
Source
# File lib/winrm/psrp/fragment.rb, line 40 def bytes [ int64be(object_id), int64be(fragment_id), end_start_fragment, int16be(blob.length), blob ].flatten end
Returns the raw PSRP
message bytes ready for transfer to Windows inside a WinRM
message. @return [Array<Byte>] Unencoded raw byte array of the PSRP
message.
Private Instance Methods
Source
# File lib/winrm/psrp/fragment.rb, line 52 def end_start_fragment end_start = 0 end_start += 0b10 if end_fragment end_start += 0b1 if start_fragment [end_start] end
Source
# File lib/winrm/psrp/fragment.rb, line 63 def int16be(int16) [int16].pack('N').unpack('C4') end
Source
# File lib/winrm/psrp/fragment.rb, line 59 def int64be(int64) [int64 >> 32, int64 & 0x00000000ffffffff].pack('N2').unpack('C8') end