Created
October 5, 2019 14:59
-
-
Save gr33n7007h/c2f67a652af289d100a236d14aeba33e 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/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