Class: WinRM::PSRP::Fragment

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

Overview

PowerShell Remoting Protocol message fragment.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Creates a new PSRP message fragment

Parameters:

  • psrp_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



30
31
32
33
34
35
36
# File 'lib/chef-winrm/psrp/fragment.rb', line 30

def initialize(psrp_object_id, blob, fragment_id = 0, start_fragment = true, end_fragment = true)
  @psrp_object_id = psrp_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.



22
23
24
# File 'lib/chef-winrm/psrp/fragment.rb', line 22

def blob
  @blob
end

#end_fragmentObject (readonly)

Returns the value of attribute end_fragment.



22
23
24
# File 'lib/chef-winrm/psrp/fragment.rb', line 22

def end_fragment
  @end_fragment
end

#fragment_idObject (readonly)

Returns the value of attribute fragment_id.



22
23
24
# File 'lib/chef-winrm/psrp/fragment.rb', line 22

def fragment_id
  @fragment_id
end

#psrp_object_idObject (readonly)

Returns the value of attribute psrp_object_id.



22
23
24
# File 'lib/chef-winrm/psrp/fragment.rb', line 22

def psrp_object_id
  @psrp_object_id
end

#start_fragmentObject (readonly)

Returns the value of attribute start_fragment.



22
23
24
# File 'lib/chef-winrm/psrp/fragment.rb', line 22

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.



41
42
43
44
45
46
47
48
49
# File 'lib/chef-winrm/psrp/fragment.rb', line 41

def bytes
  [
    int64be(psrp_object_id),
    int64be(fragment_id),
    end_start_fragment,
    int16be(blob.length),
    blob,
  ].flatten
end