Module: Pwnlib::Shellcraft::Generators::Helper
- Included in:
- Amd64::Common, Amd64::Linux, I386::Common, I386::Linux, X86::Common, X86::Linux
- Defined in:
- lib/pwnlib/shellcraft/generators/helper.rb
Overview
Define methods for generator modules.
This module must and can only be extended by Common or Linux module under Pwnlib::Shellcraft::Generators.
Defined Under Namespace
Classes: Runner
Class Method Summary collapse
-
.extended(mod) ⇒ Object
Define a corresponding singleton method whenever an instance method is defined.
Class Method Details
.extended(mod) ⇒ Object
Define a corresponding singleton method whenever an instance method is defined.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/pwnlib/shellcraft/generators/helper.rb', line 91 def extended(mod) class << mod define_method(:method_added) do |m| # Define singleton methods, so we can invoke +Generators::X86::Common.pushstr_array+. # Each method runs in an independent 'runner', so methods would not effect each other. runner = Runner.new method = instance_method(m).bind(runner) define_singleton_method(m) do |*args, **kwargs| runner.clear # TODO(david942j): remove the check when we drop Ruby 2.6 support if kwargs.empty? method.call(*args) else method.call(*args, **kwargs) end runner.typesetting end end end end |