New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
abs_offset and adjust_offset not playing nicely #53
Comments
I banged away at my keyboard and eventually ended up with this: module BinData
class Base
def real_abs_offset
if @params[:adjust_offset].nil?
parent.real_abs_offset + parent.offset_of(self)
else
@lazy.lazy_eval @params[:adjust_offset]
end
end
end
end I can't really explain how/why it works (and I feel like a monkey at a typewriter) or it's terribly wrong, but it's allowed me to continue on with my current task. I thought it would be worth posting here to see your thoughts on it. |
Do be aware that |
Your example can be written as: class KeychainFile < BinData::Record
endian :big
string :magic, length: 4, asserted_value: 'kych'
string :padding, read_length: 8
uint32 :schema_offset # in this example, the value is 20
skip to_abs_offset: lambda { schema_offset + 4 }
uint32 :table_count
end |
Hi,
Love the library. I've been playing with the
:adjust_offset
option and ran into an issue. The issue may be with my understanding or the code. :) I'll demonstrate with an exampleIt appears that
abs_offset
does not take into account the value returned byadjust_offset
. The value ofkf.table_count
is located at offset 24 and my understanding ofabs_offset
is that it returns the location within the IO that houses the data. Is this a correct understanding? If so, I think there may be a bug but I am not clever enough to fix it :)The text was updated successfully, but these errors were encountered: