Groups
Sign in
Groups
ruby-ffi
Conversations
About
Send feedback
Help
How to (pointer).read_string given the offset in an ffi struct?
28 views
Skip to first unread message
cootcraig
unread,
Aug 21, 2015, 3:13:09 PM
8/21/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ruby-ffi
Suppose I have an ffi struct like this:
class RAW_BUF < FFI::Struct
layout :data, [:uchar, 576]
end
How would I construct a pointer to offset 124 (for example)
in the struct?
I was hoping to use pointer.read_string where the pointer
is constructed as above.
cootcraig
unread,
Aug 22, 2015, 1:47:06 AM
8/22/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ruby-ffi
I figured out a solution. See this function
def pointer_from_struct_offset(ffi_struct,offset)
FFI::Pointer.new(ffi_struct.to_ptr.address + offset)
end
Reply all
Reply to author
Forward
0 new messages