我有一个内存地址,想检索它指向的值的1和0的数组。
我正在尝试在Ruby中执行此操作。我使用Ruby的object_id << 1
得到了一个内存地址。
也许有一种做LibC或FFI的方法,但是我还没有做任何事情。
if message =~ /\Amelt\Z/
# First step, assigning a variable
@melting_point = @melting_point_receivables.sample
def liqudify(raw_data_object)
# https://stackoverflow.com/a/24076936/4132642
i_ptr_int = raw_data_object.object_id << 1
# https://stackoverflow.com/questions/47757960/how-to-get-value-at-a-memory-address-in-linux-shell
end
liqudify(@melting_point)
# Next step, doing something intelligent with the data
# loosening it up somehow
# LIQUIDIFYING IT
# CONVERTING IT ALL TO BYTES
# PRESERVING VOLUME, just changing it's "Aggregatzustand"
end
预期(输入=内存地址)
=>
[0,1,0,0,0,1,0,1,0,1,0,1,1] for example