Skip to content

About

Extract COM interface information and generate Rust code in windows-rs format

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

com-interface-gen

A command-line tool that extracts COM object type information and generates Rust code in windows-rs interface macro format.

Features

  • Extract COM interface information using IProvideClassInfo
  • Multiple output formats:
    • Rust: Generate code in windows-rs interface macro format
    • JSON: Structured JSON output
  • Search by GUID or ProgID
  • Output to stdout or file

Usage

Basic Examples

# Generate Rust code from GUID (stdout)
com-interface-gen --guid "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"

# Generate from ProgID
com-interface-gen --progid "Shell.Application"

# Output as JSON
com-interface-gen --guid "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" --format json

# Output to file
com-interface-gen --guid "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" --output output.rs

Command-Line Options

Options:
  -g, --guid <GUID>        GUID of the COM class (format: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX)
  -p, --progid <PROGID>    ProgID of the COM class (alternative to GUID)
  -f, --format <FORMAT>    Output format [default: rust] [possible values: json, rust]
  -o, --output <FILE>      Output file path (stdout if not specified)
  -h, --help               Print help

Output Examples

Rust Format

use windows::{
    Win32::System::{Com::{IDispatch, IDispatch_Impl, IDispatch_Vtbl}, Variant::VARIANT},
    core::{BSTR, HRESULT, OutRef, interface},
};

/// version: 1.0
/// IShellDispatch Interface
// DUAL|DISPATCHABLE
// DISPATCH
#[interface("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")]
pub unsafe trait IShellDispatch: IDispatch {
    // ...
}

JSON Format

{
  "guid": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
  "name": "IShellDispatch",
  "doc": "IShellDispatch Interface",
  "kind": "DISPATCH",
  "flags": "DUAL|DISPATCHABLE",
  "functions": [...]
}

Technical Details

This tool uses the following Windows COM APIs:

  • IProvideClassInfo::GetClassInfo() - Retrieve COM class type information
  • ITypeInfo - Read interface metadata
  • CLSIDFromProgID() - Convert ProgID to CLSID

⚠️ Limitations

This is an experimental prototype with the following limitations:

  • Pointer and array return types are not supported (causes todo!() panic)
  • Limited VARIANT type support (VT_BSTR, VT_I4, VT_VARIANT, VT_INT, VT_UI4, VT_UI2, VT_UINT, VT_BOOL, VT_I1)
  • Unsupported types will cause todo!() panic
  • Tested only with specific COM components

Intended use: Prototyping, investigation, and learning purposes only. Not recommended for production use.

Requirements

  • Windows OS
  • Target COM object must be registered on the system

About

Extract COM interface information and generate Rust code in windows-rs format

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages