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

Windows: Add support for missing callback types #1110

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

dgmcdona
Copy link
Contributor

@dgmcdona dgmcdona commented Mar 5, 2024

This PR updates the windows.callbacks.Callbacks plugin to support callback types that were present in the original volatility framework but have not yet been added to volatility3. These callback types include:

  • IoRegisterShutdownNotification
  • IoRegisterFsRegistrationChange
  • GenericKernelCallback
  • EventCategoryHardwareProfileChange
  • EventCategoryDeviceInterfaceChange
  • EventCategoryTargetDeviceChange
  • DbgSetDebugPrintCallback

This required updates to the callbacks JSON symbol files, the creation of a _SHUTDOWN_PACKET extension, and updates to the plugin itself. Because it introduces three new requirements (handles, driverirp, and poolscanner), I have incremented the major version number for the callbacks plugin. No other plugins depend on the callbacks plugin at this time, so it was not necessary to increase version numbers in other plugins.

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.

Thanks, there's a lot to go through here but it generally looks pretty good. It's quite a significant chunk of functionality though so I'd quite like to defer to @iMHLv2 's opinion to ensure it does what it's supposed and there's no gotchas that I've missed...

volatility3/framework/plugins/windows/callbacks.py Outdated Show resolved Hide resolved
volatility3/framework/plugins/windows/callbacks.py Outdated Show resolved Hide resolved
volatility3/framework/plugins/windows/callbacks.py Outdated Show resolved Hide resolved
volatility3/framework/plugins/windows/callbacks.py Outdated Show resolved Hide resolved
volatility3/framework/plugins/windows/callbacks.py Outdated Show resolved Hide resolved
volatility3/framework/plugins/windows/callbacks.py Outdated Show resolved Hide resolved
volatility3/framework/plugins/windows/callbacks.py Outdated Show resolved Hide resolved
volatility3/framework/plugins/windows/callbacks.py Outdated Show resolved Hide resolved
@ikelos ikelos requested a review from iMHLv2 March 5, 2024 22:07
@dgmcdona dgmcdona force-pushed the dgmcdona/windows-callbacks branch 3 times, most recently from 186c814 to 84f8997 Compare March 12, 2024 03:12
Updates the windows callbacks symbol files to include structures that
were missing from the original volatility plugin.
Fixes a bad format string inside of a raised exception
Updates the Windows callbacks plugin to support several types of
callbacks that were present in the original volatility framework, but
were missing in volatility3. Adds an extension for `_SHUTDOWN_PACKET`
structures for determining validity of structure.
This plugin class was missing a `_version` attribute, so I added one and
set it to (1, 0, 0).
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, pretty happy with this, just a few more comments. 5:)

from volatility3.framework.configuration import requirements
from volatility3.framework.interfaces.objects import ObjectInterface
Copy link
Member

Choose a reason for hiding this comment

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

Please try not to import classes directly, but only ever modules. Importing ObjectInterface like this may allow someone to one day write from callbacks import ObjectInterface and it then won't be clear that it actually belongs to another module.

The list containing the built constraints.
"""

PNP9_SIZE = 0x30
Copy link
Member

Choose a reason for hiding this comment

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

I'm generally a fan of having fixed values pulled out and tagged with a comment or put in a variable, but it doesn't feel like these will get used anywhere else, so I'd be tempted to just embed them in the code below? The code below already kinda hard codes the binary tag values so I'm not sure it's much different?

context, layer_name, nt_symbol_table, constraints
):
try:
if hasattr(mem_object, "is_valid") and not mem_object.is_valid():
Copy link
Member

Choose a reason for hiding this comment

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

What objects don't have an is_valid method? Feels like this could be changed to just check pointers?


return (
callback_type,
cast(int, callback_address),
Copy link
Member

Choose a reason for hiding this comment

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

Yeah, probably a little overboard with the casting... 5;) I mean, it's good and I approve of well typed systems, but... a lot of these things should already be the type they're cast to, and hopefully mypy will one day be able to figure that out, but I'm not sure littering our code with hints will help all that much?

@ikelos
Copy link
Member

ikelos commented Mar 13, 2024

@iMHLv2 could you give this a scan over to check there's nothing subtle I've missed please?

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

3 participants