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/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, FFTW, HackRF, Liquid, RTLSdr, SoapySDR, Stdio, Volk

Class Method Summary collapse

Class Method Details

.authorsObject

Author(s)

0day Inc. support@0dayinc.com



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

public_class_method def self.authors
  "AUTHOR(S):\n  0day Inc. <support@0dayinc.com>\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)


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

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.



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

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



61
62
63
# File 'lib/pwn/ffi.rb', line 61

public_class_method def self.help
  constants.sort
end