Last active
December 30, 2020 02:12
-
-
Save ytnk531/fa7cc3de1e7e6b874941717dcab81922 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'fiddle' | |
libc = Fiddle.dlopen('libc.so.6') | |
printf = Fiddle::Function.new(libc['printf'], | |
[Fiddle::TYPE_VOIDP], | |
Fiddle::TYPE_INT | |
) | |
printf.call "Hello with Fiddle::Function\n" | |
require 'fiddle/import' | |
module Stdio | |
extend Fiddle::Importer | |
dlload "libc.so.6" | |
extern "int printf(char*)" | |
end | |
Stdio.printf "Hello with Fiddle::Importer\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment