Skip to content

implement rust plugin command #6583

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

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open

Conversation

rbran
Copy link
Contributor

@rbran rbran commented Apr 7, 2025

No description provided.

},
BNGetValidPluginCommandsForLowLevelILFunction, BNRegisterPluginCommandForLowLevelILFunction, LowLevelILFunctionPluginCommand, CustomLowLevelILFunctionPluginCommand {
lowLevelILFunctionCommand::lowLevelILFunctionIsValid(
// TODO I don't know what Generics should be used here
Copy link
Member

Choose a reason for hiding this comment

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

RegularLowLevelILFunction

Need to document this more... but generally use that unless you are emitting LLIL or need SSA version

Copy link
Contributor Author

Choose a reason for hiding this comment

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

RegularLowLevelILFunction<CoreArchitecture> with BinaryView::default_arch?

Copy link
Member

Choose a reason for hiding this comment

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

Looks like the LLIL function in rust needs to stop trying to track the arch at construction, i.e. do what C++ does

Ref<Architecture> LowLevelILFunction::GetArchitecture() const
{
Ref<Function> func = GetFunction();
if (!func)
return nullptr;
return func->GetArchitecture();
}

IDK the implication of this, but otherwise we need to manually retrieve the underlying function object to get the architecture.

You might have ran into this with your PR #5318

Copy link
Member

Choose a reason for hiding this comment

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

This is likely so that we get the generic A in the arch signature here:

pub(crate) fn arch(&self) -> &A {
self.arch_handle.borrow()
}

So we don't have another layer of indirection though the core to get at our architecture from LLIL.

Copy link
Member

@emesare emesare Apr 7, 2025

Choose a reason for hiding this comment

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

Calling the default_arch obviously is not the correct move here, but you can leave it for now and add a TODO, the underlying issue is we need a way to construct the LLIL function with the function objects underlying core architecture, this is easy to "solve" with a new function that calls

pub fn function(&self) -> Ref<Function> {
unsafe {
let func = BNGetLowLevelILOwnerFunction(self.handle);
Function::ref_from_raw(func)
}
}
to get the function architecture

And then sets the arch handle for the LLIL function:

pub(crate) arch_handle: A::Handle,

Copy link
Member

@emesare emesare Apr 8, 2025

Choose a reason for hiding this comment

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

I think the right answer is a new new function that will lookup the CoreArchitecture. I think keeping that generic around is the right move.

EDIT: Didn't see the commit right below, ignore this message lol

@emesare emesare added this to the H milestone Apr 16, 2025
@emesare emesare added the Component: Rust API Issue needs changes to the Rust API label Apr 16, 2025
@emesare emesare linked an issue Apr 17, 2025 that may be closed by this pull request
@emesare emesare self-assigned this Apr 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Rust API Issue needs changes to the Rust API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add PluginCommand to Rust API
2 participants