Class: TurboRex::MSRPC::MIDL::TypeFormatString::FixedSizedArray

Inherits:
TurboRex::MSRPC::MIDL::TypeFormatString show all
Defined in:
lib/turborex/msrpc/midl.rb

Constant Summary

Constants inherited from TurboRex::MSRPC::MIDL::TypeFormatString

HANDLER_TABLE

Constants included from NDRType

NDRType::DECODE_IS_USED, NDRType::ENCODE_IS_USED, NDRType::FC_ADD_1, NDRType::FC_ALIGNM2, NDRType::FC_ALIGNM4, NDRType::FC_ALIGNM8, NDRType::FC_AUTO_HANDLE, NDRType::FC_BIND_CONTEXT, NDRType::FC_BIND_GENERIC, NDRType::FC_BIND_PRIMITIVE, NDRType::FC_BLKHOLE, NDRType::FC_BOGUS_ARRAY, NDRType::FC_BOGUS_STRUCT, NDRType::FC_BSTRING, NDRType::FC_BYTE, NDRType::FC_BYTE_COUNT_POINTER, NDRType::FC_CALLBACK, NDRType::FC_CALLBACK_HANDLE, NDRType::FC_CARRAY, NDRType::FC_CHAR, NDRType::FC_CONSTANT_IID, NDRType::FC_CPSTRUCT, NDRType::FC_CSTRING, NDRType::FC_CSTRUCT, NDRType::FC_CVARRAY, NDRType::FC_CVSTRUCT, NDRType::FC_C_BSTRING, NDRType::FC_C_CSTRING, NDRType::FC_C_SSTRING, NDRType::FC_C_WSTRING, NDRType::FC_DEREFERENCE, NDRType::FC_DIV_2, NDRType::FC_DOUBLE, NDRType::FC_EMBEDDED_COMPLEX, NDRType::FC_ENCAPSULATED_UNION, NDRType::FC_END, NDRType::FC_END_OF_UNIVERSE, NDRType::FC_ENUM16, NDRType::FC_ENUM32, NDRType::FC_ERROR_STATUS_T, NDRType::FC_EXPLICIT_HANDLE, NDRType::FC_EXPR, NDRType::FC_FIXED_OFFSET, NDRType::FC_FIXED_REPEAT, NDRType::FC_FLOAT, NDRType::FC_FP, NDRType::FC_HARD_STRUCT, NDRType::FC_HYPER, NDRType::FC_IGNORE, NDRType::FC_INT3264, NDRType::FC_IN_OUT_PARAM, NDRType::FC_IN_PARAM, NDRType::FC_IN_PARAM_BASETYPE, NDRType::FC_IN_PARAM_NO_FREE_INST, NDRType::FC_IP, NDRType::FC_LGFARRAY, NDRType::FC_LGVARRAY, NDRType::FC_LONG, NDRType::FC_MULT_2, NDRType::FC_NON_ENCAPSULATED_UNION, NDRType::FC_NO_REPEAT, NDRType::FC_OP, NDRType::FC_OUT_PARAM, NDRType::FC_PAD, NDRType::FC_PIPE, NDRType::FC_POINTER, NDRType::FC_PP, NDRType::FC_PSTRUCT, NDRType::FC_RANGE, NDRType::FC_REPRESENT_AS, NDRType::FC_REPRESENT_AS_PTR, NDRType::FC_RETURN_PARAM, NDRType::FC_RETURN_PARAM_BASETYPE, NDRType::FC_RP, NDRType::FC_SHORT, NDRType::FC_SMALL, NDRType::FC_SMFARRAY, NDRType::FC_SMVARRAY, NDRType::FC_SPLIT_ADD_1, NDRType::FC_SPLIT_CALLBACK, NDRType::FC_SPLIT_DEREFERENCE, NDRType::FC_SPLIT_DIV_2, NDRType::FC_SPLIT_MULT_2, NDRType::FC_SPLIT_SUB_1, NDRType::FC_SSTRING, NDRType::FC_STRING_SIZED, NDRType::FC_STRUCT, NDRType::FC_STRUCTPAD1, NDRType::FC_STRUCTPAD2, NDRType::FC_STRUCTPAD3, NDRType::FC_STRUCTPAD4, NDRType::FC_STRUCTPAD5, NDRType::FC_STRUCTPAD6, NDRType::FC_STRUCTPAD7, NDRType::FC_SUB_1, NDRType::FC_TRANSMIT_AS, NDRType::FC_TRANSMIT_AS_PTR, NDRType::FC_UINT3264, NDRType::FC_ULONG, NDRType::FC_UNUSED1, NDRType::FC_UNUSED2, NDRType::FC_UNUSED3, NDRType::FC_UNUSED4, NDRType::FC_UNUSED5, NDRType::FC_UP, NDRType::FC_USER_MARSHAL, NDRType::FC_USHORT, NDRType::FC_USMALL, NDRType::FC_VARIABLE_OFFSET, NDRType::FC_VARIABLE_REPEAT, NDRType::FC_WCHAR, NDRType::FC_WSTRING, NDRType::FC_ZERO, NDRType::Oi_FULL_PTR_USED, NDRType::Oi_HAS_COMM_OR_FAULT, NDRType::Oi_HAS_RPCFLAGS, NDRType::Oi_IGNORE_OBJECT_EXCEPTION_HANDLING, NDRType::Oi_OBJECT_PROC, NDRType::Oi_OBJ_USE_V2_INTERPRETER, NDRType::Oi_RPCSS_ALLOC_USED, NDRType::Oi_USE_NEW_INIT_ROUTINES, NDRType::Oi_Unused, NDRType::Oi_overloaded1, NDRType::Oi_overloaded2, NDRType::WIN2K_EXT64_SIZE, NDRType::WIN2K_EXT_SIZE

Instance Method Summary collapse

Methods inherited from TurboRex::MSRPC::MIDL::TypeFormatString

#fs_length, #initialize, #select_handler

Constructor Details

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

Instance Method Details

#decompileObject



573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
# File 'lib/turborex/msrpc/midl.rb', line 573

def decompile
  offset = 0
  type = @typefs_stream.read(1).unpack('C').first
  case type
  when FC_SMFARRAY
    size = @cparser.sizeof(@cparser.find_c_struct('SM_FArray_Header_t'))
    header = @cparser.decode_c_struct('SM_FArray_Header_t', @typefs_stream.read(size))
  when FC_LGFARRAY
    size = @cparser.sizeof(@cparser.find_c_struct('LG_FArray_Header_t'))
    header = @cparser.decode_c_struct('LG_FArray_Header_t', @typefs_stream.read(size))
  end

  total_size = header.TotalSize
  offset += size
  _stream = @typefs_stream.dup
  _stream.base_drift(offset)
  if @typefs_stream.read(1, offset).unpack('C').first == FC_PP # Pointer layout
    ptr_layout = PointerLayout.new(_stream, @cparser) # TODO: How to handle when the count of pointer instance greater than one?
    layout = ptr_layout.decompile.first
    offset += ptr_layout.fs_length
    _stream.base_drift(ptr_layout.fs_length)
    element = TypeFormatString.new(_stream, @cparser).decompile
    ary = ::Array.new(layout[:repeat], element)
    case layout[:type]
    when :fixed
      return DataType::Array.new(*ary)
    end
  end

  element = TypeFormatString.new(_stream, @cparser).decompile
  if (element_size = element.bytesize) == :variable
    case @cparser.cpu.size
    when 32
      element_size = 4
    when 64
      element_size = 8
    end
  end

  ary_len = total_size / element_size
  ary = ::Array.new(ary_len, element)
  DataType::Array.new(*ary) 
end