Class: TurboRex::MSRPC::MIDL::OifParamDesc

Inherits:
ParamDesc
  • Object
show all
Defined in:
lib/turborex/msrpc/midl.rb

Constant Summary collapse

FS_LENGTH =
6

Instance Attribute Summary collapse

Attributes inherited from ParamDesc

#stack_offset, #stream

Instance Method Summary collapse

Methods inherited from ParamDesc

#initialize

Constructor Details

This class inherits a constructor from TurboRex::MSRPC::MIDL::ParamDesc

Instance Attribute Details

#param_attrsObject (readonly)

Returns the value of attribute param_attrs.



296
297
298
# File 'lib/turborex/msrpc/midl.rb', line 296

def param_attrs
  @param_attrs
end

#typefsObject (readonly)

Returns the value of attribute typefs.



297
298
299
# File 'lib/turborex/msrpc/midl.rb', line 297

def typefs
  @typefs
end

Instance Method Details

#decompileObject

return Parameter object



300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
# File 'lib/turborex/msrpc/midl.rb', line 300

def decompile
  raw = @stream.read(FS_LENGTH)
  header = @cparser.decode_c_struct('Oif_ParamDesc_Header_t', raw)

  @param_attrs = header.ParamAttributes
  @stack_offset = header.StackOffset

  case @cparser.cpu.size
  when 32
    ptr_len = 4
  when 64
    ptr_len = 8
  end

  virtual_stack_index = @stack_offset / ptr_len 
  param_name = "arg_#{virtual_stack_index}"

  parameter = Parameter.new(param_name)

  if @param_attrs.IsBasetype == 1
    struct = @cparser.decode_c_struct('Oif_Param_Desc_BaseType_t', raw)
    _stream = @stream.dup
    _stream.base_drift(4)
    data_type = TypeFormatString::SimpleType.new(_stream, @cparser).decompile
  else
    struct = @cparser.decode_c_struct('Oif_Param_Desc_Other_t', raw)
    typefs_offset = struct.TypeOffset
    _typefs_stream = @typefs_stream.dup
    _typefs_stream.base_drift(typefs_offset)
    @typefs = TypeFormatString.new(_typefs_stream, @cparser)

    begin
      data_type = @typefs.decompile
    rescue TurboRex::Exception::MSRPC::InvalidTypeFormatString
      raise TurboRex::Exception::MSRPC::InvalidParamDescriptor
    end
  end

  if @param_attrs.IsSimpleRef == 1 # First-level refenrence pointer
    data_type = DataType::Pointer.new(data_type, :ref)
  end

  parameter.set_data_type(data_type)

  if @param_attrs.IsReturn == 1
    parameter.type_return
    parameter.name = nil
  else
    if @param_attrs.IsIn == 1
      parameter.attributes << :in
    end
  
    if @param_attrs.IsOut == 1
      parameter.attributes << :out
    end
  end


  parameter
end

#fs_lengthObject



361
362
363
# File 'lib/turborex/msrpc/midl.rb', line 361

def fs_length
  FS_LENGTH
end