Skip to content
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

Fix on 'end_bit' computation #133

Merged

Conversation

xabiugarte
Copy link
Contributor

Hi, I was looking at the code for managing symbols and found this line:
https://github.com/volatilityfoundation/volatility3/blob/master/volatility/framework/symbols/intermed.py#L372

I think there might be a semantic inconsistency there: the ‘end_bit’ keyword is populated with the bit_length of the field, instead of the end_bit.

I have looked at the symbol json file, and it seems that bitfields contain ‘start_bit’ and ‘bit_length’. On the contrary, volatility2 vtypes seem to represent bitfields with their ‘start_bit’ and ‘end_bit’. (E.g.: https://github.com/volatilityfoundation/volatility/blob/aa6b960c1077e447bda9d64df507ec02f8fcc958/volatility/plugins/overlays/windows/win2003_sp0_x86_vtypes.py#L1814)

Given that the BitField class on framework/objects/_ _ init _ .py stores start_bit and end_bit, I’d lean towards updating https://github.com/volatilityfoundation/volatility3/blob/master/volatility/framework/symbols/intermed.py#L372
That would be consistent with volatility2 and how the BitField class is defined in volatility3.

Thanks,

@ikelos ikelos self-requested a review November 11, 2019 16:59
@ikelos ikelos self-assigned this Nov 11, 2019
Copy link
Member

@ikelos ikelos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, looks good to me. 5:)

@@ -369,7 +369,7 @@ def _interdict_to_template(self, dictionary: Dict[str, Any]) -> interfaces.objec
elif type_name == 'enum':
update = self._lookup_enum(dictionary['name'])
elif type_name == 'bitfield':
update = {'start_bit': dictionary['bit_position'], 'end_bit': dictionary['bit_length']}
update = {'start_bit': dictionary['bit_position'], 'end_bit': dictionary['bit_position'] + dictionary['bit_length']}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great spot! 5:)
It looks like the only place we use end_bit, we use it as the actual end rather than the length, so this makes sense.

@ikelos ikelos merged commit 5b04492 into volatilityfoundation:master Nov 11, 2019
ikelos added a commit that referenced this pull request Nov 13, 2019
Turns out that #133 exposed a mistake in how we were using the end_bit
field (and it should have been picked up in review, my bad).
Essentially we were masking based on the length of the end_bit after
*already* shifting by the start_bit.  We should mask then shift, not the
other way around.

May well fix issue #135 (pdb generation will have been affected by
this).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants