Skip to content

Instantly share code, notes, and snippets.

@ytnk531
Last active December 30, 2020 02:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ytnk531/fa7cc3de1e7e6b874941717dcab81922 to your computer and use it in GitHub Desktop.
Save ytnk531/fa7cc3de1e7e6b874941717dcab81922 to your computer and use it in GitHub Desktop.
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