Class: Omnizip::Formats::Msi::TableParser

Inherits:
Object
  • Object
show all
Includes:
Constants
Defined in:
lib/omnizip/formats/msi/table_parser.rb

Overview

MSI Table Parser

Parses MSI database tables from OLE streams. MSI uses a column-major storage format where each column's data is stored contiguously.

Key tables for file extraction:

  • File: File entries with name, size, component, sequence
  • Component: Links files to directories
  • Directory: Directory hierarchy
  • Media: Cabinet file references

Constant Summary

Constants included from Constants

Constants::BINARY_TYPE, Constants::CATEGORY_BINARY, Constants::CATEGORY_CABINET, Constants::CATEGORY_CONDITION, Constants::CATEGORY_DEFAULT, Constants::CATEGORY_DOUBLE, Constants::CATEGORY_FILENAME, Constants::CATEGORY_GUID, Constants::CATEGORY_IDENTIFIER, Constants::CATEGORY_LANGUAGE, Constants::CATEGORY_LOWERCASE, Constants::CATEGORY_PATH, Constants::CATEGORY_SHORTCUT, Constants::CATEGORY_TEMPLATE, Constants::CATEGORY_TEXT, Constants::CATEGORY_UPPERCASE, Constants::CATEGORY_VERSION, Constants::COLUMNS_STREAM, Constants::COMPONENT_TABLE, Constants::COMP_ATTR_64BIT, Constants::COMP_ATTR_DISABLE_REGISTRY, Constants::COMP_ATTR_LOCAL_ONLY, Constants::COMP_ATTR_NEVER_OVERWRITE, Constants::COMP_ATTR_ODBC, Constants::COMP_ATTR_OPTIONAL, Constants::COMP_ATTR_PERMANENT, Constants::COMP_ATTR_REGISTRY_KEY_PATH, Constants::COMP_ATTR_SHARED, Constants::COMP_ATTR_SHARED_DLL, Constants::COMP_ATTR_SOURCE_ONLY, Constants::COMP_ATTR_TRANSITIVE, Constants::COMP_ATTR_UNINSTALL_ON_SUPERSEDE, Constants::DIRECTORY_TABLE, Constants::EMBEDDED_CAB_PREFIX, Constants::FILE_ATTR_CHECKSUM, Constants::FILE_ATTR_COMPRESSED, Constants::FILE_ATTR_HIDDEN, Constants::FILE_ATTR_NONCOMPRESSED, Constants::FILE_ATTR_PATCHADDED, Constants::FILE_ATTR_READONLY, Constants::FILE_ATTR_SYSTEM, Constants::FILE_ATTR_VITAL, Constants::FILE_TABLE, Constants::INT16_TYPE, Constants::INT32_TYPE, Constants::MEDIA_TABLE, Constants::OBJECT_TYPE, Constants::PROGRAM_FILES, Constants::PROGRAM_FILES_X64, Constants::SOURCE_DIR, Constants::STREAMS_TABLE, Constants::STRING_DATA_STREAM, Constants::STRING_POOL_STREAM, Constants::STRING_TYPE, Constants::SYSTEM_FOLDER, Constants::SYSTEM_X64_FOLDER, Constants::TABLES_STREAM, Constants::TARGET_DIR, Constants::WINDOWS_FOLDER

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Constants

decode_stream_name

Constructor Details

#initialize(string_pool, stream_reader) ⇒ TableParser

Initialize table parser

Parameters:

  • string_pool (StringPool)

    String pool for lookups

  • stream_reader (Proc)

    Method to read streams



38
39
40
41
42
43
44
45
46
# File 'lib/omnizip/formats/msi/table_parser.rb', line 38

def initialize(string_pool, stream_reader)
  @string_pool = string_pool
  @read_stream = stream_reader
  @tables = {}
  @columns = {}
  @table_names = []
  load_table_list
  load_column_defs
end

Instance Attribute Details

#columnsHash (readonly)

Returns Column definitions (table_name => columns).

Returns:

  • (Hash)

    Column definitions (table_name => columns)



26
27
28
# File 'lib/omnizip/formats/msi/table_parser.rb', line 26

def columns
  @columns
end

#read_streamProc (readonly)

Returns Stream reader method.

Returns:

  • (Proc)

    Stream reader method



32
33
34
# File 'lib/omnizip/formats/msi/table_parser.rb', line 32

def read_stream
  @read_stream
end

#string_poolStringPool (readonly)

Returns String pool for string lookups.

Returns:



20
21
22
# File 'lib/omnizip/formats/msi/table_parser.rb', line 20

def string_pool
  @string_pool
end

#table_namesArray<String> (readonly)

Returns Table names.

Returns:

  • (Array<String>)

    Table names



29
30
31
# File 'lib/omnizip/formats/msi/table_parser.rb', line 29

def table_names
  @table_names
end

#tablesHash (readonly)

Returns Parsed tables (table_name => rows).

Returns:

  • (Hash)

    Parsed tables (table_name => rows)



23
24
25
# File 'lib/omnizip/formats/msi/table_parser.rb', line 23

def tables
  @tables
end

Instance Method Details

#column_defs(table_name) ⇒ Array<Hash>

Get column definitions for table

Parameters:

  • table_name (String)

    Table name

Returns:

  • (Array<Hash>)

    Column definitions



62
63
64
# File 'lib/omnizip/formats/msi/table_parser.rb', line 62

def column_defs(table_name)
  @columns[table_name] || []
end

#table(table_name) ⇒ Array<Hash>

Get table rows

Parameters:

  • table_name (String)

    Table name

Returns:

  • (Array<Hash>)

    Table rows (each row is a hash of column => value)



52
53
54
55
56
# File 'lib/omnizip/formats/msi/table_parser.rb', line 52

def table(table_name)
  return @tables[table_name] if @tables.key?(table_name)

  @tables[table_name] = parse_table(table_name)
end

#table_exists?(table_name) ⇒ Boolean

Check if table exists

Parameters:

  • table_name (String)

    Table name

Returns:

  • (Boolean)


70
71
72
# File 'lib/omnizip/formats/msi/table_parser.rb', line 70

def table_exists?(table_name)
  @table_names.include?(table_name)
end