Skip to content

Instantly share code, notes, and snippets.

@gr33n7007h
Created October 5, 2019 14:59
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 gr33n7007h/c2f67a652af289d100a236d14aeba33e to your computer and use it in GitHub Desktop.
Save gr33n7007h/c2f67a652af289d100a236d14aeba33e to your computer and use it in GitHub Desktop.
require 'fiddle/import'
class Object
extend Fiddle::Importer
RUBY_FL_SINGLETON = 1 << 12
RBasic = struct ['uintptr_t flags', 'uintptr_t klass']
private_constant :RUBY_FL_SINGLETON, :RBasic
def ghost
basic.flags |= RUBY_FL_SINGLETON
true
end
def unghost
basic.flags &= ~RUBY_FL_SINGLETON
true
end
private
def ptr
__id__ * 2
end
def basic
RBasic.new ptr
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment