Class: Rex::Java::Serialization::Model::Reference
- Defined in:
- lib/rex/java/serialization/model/reference.rb
Overview
This class provides a Java Reference representation.
Instance Attribute Summary collapse
-
#contents ⇒ Fixnum
The stream handle being referenced.
-
#handle ⇒ Object
Returns the value of attribute handle.
Attributes inherited from Element
Instance Method Summary collapse
-
#decode(io) ⇒ self
Deserializes a Rex::Java::Serialization::Model::Reference.
-
#encode ⇒ String
Serializes the Rex::Java::Serialization::Model::Reference.
-
#initialize(stream = nil) ⇒ Reference
constructor
A new instance of Reference.
-
#to_s ⇒ String
Creates a print-friendly string representation.
Methods inherited from Element
Constructor Details
#initialize(stream = nil) ⇒ Reference
Returns a new instance of Reference.
15 16 17 18 |
# File 'lib/rex/java/serialization/model/reference.rb', line 15 def initialize(stream = nil) super(stream) self.handle = 0 end |
Instance Attribute Details
#contents ⇒ Fixnum
Returns The stream handle being referenced.
12 |
# File 'lib/rex/java/serialization/model/reference.rb', line 12 attr_accessor :handle |
#handle ⇒ Object
Returns the value of attribute handle.
12 13 14 |
# File 'lib/rex/java/serialization/model/reference.rb', line 12 def handle @handle end |
Instance Method Details
#decode(io) ⇒ self
Deserializes a Rex::Java::Serialization::Model::Reference
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rex/java/serialization/model/reference.rb', line 25 def decode(io) handle_raw = io.read(4) unless handle_raw && handle_raw.length == 4 raise ::RuntimeError, 'Failed to unserialize Reference' end self.handle = handle_raw.unpack('N')[0] self end |
#encode ⇒ String
Serializes the Rex::Java::Serialization::Model::Reference
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/rex/java/serialization/model/reference.rb', line 40 def encode if handle < BASE_WIRE_HANDLE raise ::RuntimeError, 'Failed to serialize Reference' end encoded = '' encoded << [handle].pack('N') encoded end |
#to_s ⇒ String
Creates a print-friendly string representation
54 55 56 |
# File 'lib/rex/java/serialization/model/reference.rb', line 54 def to_s "0x#{handle.to_s(16)}" end |