Module: PWN::FFI

Defined in:
lib/pwn/ffi.rb,
lib/pwn/ffi/fftw.rb,
lib/pwn/ffi/volk.rb,
lib/pwn/ffi/stdio.rb,
lib/pwn/ffi/liquid.rb,
lib/pwn/ffi/hack_rf.rb,
lib/pwn/ffi/rtl_sdr.rb,
lib/pwn/ffi/soapy_sdr.rb,
lib/pwn/ffi/dsp_native.rb,
lib/pwn/ffi/adalm_pluto.rb

Overview

This file, using the autoload directive loads FFI modules into memory only when they're needed. For more information, see: http://www.rubyinside.com/ruby-techniques-revealed-autoload-1652.html

Bindings under this namespace are thin — they attach functions from already-installed system shared objects (libliquid, libvolk, libfftw3f, librtlsdr, libhackrf, libSoapySDR) so PWN::SDR::Decoder::* can run MHz-rate DSP inner loops in native/SIMD code while Ruby stays in charge of orchestration. Nothing here shells out; nothing here compiles at gem install time. If a .so is missing the module still loads and .available? returns false so callers can fall back to pure Ruby.

Defined Under Namespace

Modules: AdalmPluto, DSPNative, FFTW, HackRF, Liquid, RTLSdr, SoapySDR, Stdio, Volk

Class Method Summary collapse

Class Method Details

.authorsObject

Author(s)

0day Inc. [email protected]



56
57
58
# File 'lib/pwn/ffi.rb', line 56

public_class_method def self.authors
  "AUTHOR(S):\n  0day Inc. <[email protected]>\n"
end

.available?(opts = {}) ⇒ Boolean

Supported Method Parameters

ok = PWN::FFI.available?( mod: 'required - Symbol or Module (e.g. :Liquid or PWN::FFI::Liquid)' )

Returns:

  • (Boolean)


38
39
40
41
42
43
44
# File 'lib/pwn/ffi.rb', line 38

public_class_method def self.available?(opts = {})
  mod = opts[:mod]
  mod = const_get(mod) if mod.is_a?(Symbol) || mod.is_a?(String)
  mod.respond_to?(:available?) && mod.available?
rescue NameError, LoadError
  false
end

.backendsObject

Supported Method Parameters

PWN::FFI.backends Returns { ModuleName => true|false } for every registered binding.



50
51
52
# File 'lib/pwn/ffi.rb', line 50

public_class_method def self.backends
  (constants - [:Stdio]).sort.to_h { |c| [c, available?(mod: c)] }
end

.helpObject

Display a List of Every PWN::FFI Module



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/pwn/ffi.rb', line 62

public_class_method def self.help
  puts "USAGE:
    # Run available and return its result
    #{self}.available?(
      mod: 'required - Symbol or Module (e.g. :Liquid or PWN::FFI::Liquid)'
    )

    # Returns { ModuleName => true|false } for every registered binding
    #{self}.backends

    # Print the AUTHOR(S) string for this module.
    #{self}.authors
  "
  constants.sort
end