Giter Club home page Giter Club logo

modhack's Introduction

modhack

What is modhack?

modhack is collection of utilities to manipulate wit Erlang modules.

Exported functions

  • alias(Target, Alias) --- make an alias for module Target (indeed it is proxy)
  • copy(Source, Destination) --- copy module at binary-level
  • overlay([Mod1, Mod2|...], ResultName) --- combine modules into one supermodule
  • patch(Module, Patch) or patch(Module, [Patch1|...]) --- modify Module so that functions existing in Patches take precedence.

Usage example

Eshell V5.9  (abort with ^G)
1> victim:module_info(exports).
[{fun4,0},{module_info,0},{module_info,1}]
2> modhack:overlay([mod1, mod2, mod3], victim).
{module,victim}
3> victim:module_info(exports).                
[{fun2,0},
 {fun3,0},
 {fun2,1},
 {fun1,0},
 {module_info,0},
 {module_info,1}]
4> victim:fun1().
mod1
5> victim:fun2(x).
{mod2,x}
6> victim:fun2(). 
mod3
7> l(victim), victim:module_info(exports).
[{fun4,0},{module_info,0},{module_info,1}]
8> modhack:patch(victim, mod1), victim:fun1().
mod1

mod1.erl

-module(mod1).
-compile(export_all).
fun1() -> ?MODULE.

mod2.erl

-module(mod2).
-compile(export_all).
fun1() -> ?MODULE.
fun2(Arg) -> {?MODULE, Arg}.

mod3.erl

-module(mod3).
-compile(export_all).
fun2() -> ?MODULE.
fun3() -> ?MODULE.

victim.erl

-module(victim).
-compile(export_all).
fun4() -> ?MODULE.

modhack's People

Contributors

stolen avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.