Last active
July 13, 2020 21:55
-
-
Save mistydemeo/f253d4fa6f86e8d6927961e0dd9e7f66 to your computer and use it in GitHub Desktop.
This file contains hidden or 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' | |
require 'fiddle/import' | |
module Sysctl | |
extend Fiddle::Importer | |
dlload "/usr/lib/libSystem.dylib" | |
extern "int sysctlbyname(const char *name, void *oldp, size_t *oldlenp, void *newp, size_t newlen)" | |
end | |
ret = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INT) | |
ret_size = Fiddle::Pointer[[Fiddle::SIZEOF_INT].pack("L")] | |
puts Sysctl.sysctlbyname("sysctl.proc_translated", ret, ret_size, nil, 0).inspect | |
puts ret.to_s(Fiddle::SIZEOF_INT).unpack("L").first | |
puts ret_size.to_s(Fiddle::SIZEOF_INT).inspect |
Author
mistydemeo
commented
Jul 13, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment