Class: WinRM::PSRP::Fragment

Inherits:
Object
  • Object
show all
Defined in:
lib/winrm/psrp/fragment.rb

Overview

PowerShell Remoting Protocol message fragment.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object_id, blob, fragment_id = 0, start_fragment = true, end_fragment = true) ⇒ Fragment

Creates a new PSRP message fragment

Parameters:

  • object_id (Integer)

    The id of the fragmented message.

  • blob (Array)

    Array of fragmented bytes.

  • fragment_id (Integer) (defaults to: 0)

    The id of this fragment

  • start_fragment (Boolean) (defaults to: true)

    If the fragment is the first fragment

  • end_fragment (Boolean) (defaults to: true)

    If the fragment is the last fragment



27
28
29
30
31
32
33
# 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

Instance Attribute Details

#blobObject (readonly)

Returns the value of attribute blob.



35
36
37
# File 'lib/winrm/psrp/fragment.rb', line 35

def blob
  @blob
end

#end_fragmentObject (readonly)

Returns the value of attribute end_fragment.



35
36
37
# File 'lib/winrm/psrp/fragment.rb', line 35

def end_fragment
  @end_fragment
end

#fragment_idObject (readonly)

Returns the value of attribute fragment_id.



35
36
37
# File 'lib/winrm/psrp/fragment.rb', line 35

def fragment_id
  @fragment_id
end

#object_idObject (readonly)

Returns the value of attribute object_id.



35
36
37
# File 'lib/winrm/psrp/fragment.rb', line 35

def object_id
  @object_id
end

#start_fragmentObject (readonly)

Returns the value of attribute start_fragment.



35
36
37
# File 'lib/winrm/psrp/fragment.rb', line 35

def start_fragment
  @start_fragment
end

Instance Method Details

#bytesArray<Byte>

Returns the raw PSRP message bytes ready for transfer to Windows inside a WinRM message.

Returns:

  • (Array<Byte>)

    Unencoded raw byte array of the PSRP message.



40
41
42
43
44
45
46
47
48
# 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