Skip to content

Conversation

@ILOVEPIE
Copy link
Contributor

This is a PR for class reconstruction support. It's still a work in progress, but it's working. We need to clean it up probably.

@ILOVEPIE
Copy link
Contributor Author

@cyberkaida let me know what improvements you want me to make to this rough version.

@ILOVEPIE ILOVEPIE force-pushed the ClassDefinitionTools branch from 0528da1 to 2109fc2 Compare June 23, 2025 02:44
@ILOVEPIE
Copy link
Contributor Author

I did some cleanup on how the errors were being handled and stuff, this doesn't include code cleanup just yet, just fixing some of the issues with how it was handling errors.

@cyberkaida cyberkaida requested review from Copilot and cyberkaida June 23, 2025 06:46
@cyberkaida cyberkaida self-assigned this Jun 23, 2025
Copilot

This comment was marked as outdated.

@cyberkaida cyberkaida assigned ILOVEPIE and unassigned cyberkaida Jun 23, 2025
@cyberkaida cyberkaida added the enhancement New feature or request label Jun 23, 2025
@ILOVEPIE ILOVEPIE force-pushed the ClassDefinitionTools branch from 2109fc2 to 73ca9e6 Compare June 24, 2025 08:28
/**
* Find a function by name or address
*/
private Function findFunction(Program program, String functionName, String functionAddress) {

Check notice

Code scanning / CodeQL

Useless parameter Note

The parameter 'functionAddress' is never used.
@ILOVEPIE ILOVEPIE force-pushed the ClassDefinitionTools branch from 73ca9e6 to e40efb1 Compare June 24, 2025 08:45
}

Symbol functionSymbol = function.getSymbol();
Namespace parentNamespace = functionSymbol.getParentNamespace();

Check warning

Code scanning / CodeQL

Dereferenced variable may be null Warning

Variable
functionSymbol
may be null at this access as suggested by
this
null guard.
@ILOVEPIE ILOVEPIE requested a review from Copilot June 25, 2025 02:00
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds class reconstruction support by implementing a new tool provider for RTTI-based class reconstruction and integrating it into the MCP server.

  • Introduces ClassToolProvider with multiple tool registrations for listing, creating, and reconstructing classes via RTTI data.
  • Updates integration tests with ClassToolProviderIntegrationTest and registers the new provider in the MCP server.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/test.slow/java/reva/tools/classes/ClassToolProviderIntegrationTest.java Integration tests for the new class reconstruction functionality
src/main/java/reva/tools/classes/ClassToolProvider.java New tool provider implementation with several tools for class operations, including RTTI reconstruction
src/main/java/reva/tools/AbstractToolProvider.java Added a generic helper method to retrieve optional list parameters
src/main/java/reva/server/McpServerManager.java Updated to register the new ClassToolProvider

// Execute the RTTI script
String scriptName = "RecoverClassesFromRTTIScript.java";

try {
Copy link

Copilot AI Jun 25, 2025

Choose a reason for hiding this comment

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

The executeRttiReconstruction method contains deeply nested try-catch blocks. Consider refactoring this logic (e.g., by extracting helper methods) to improve readability and maintainability.

Copilot uses AI. Check for mistakes.
Comment on lines 302 to 304
try {
// Create the class namespace
Namespace classNamespace = symbolTable.createClass(parentNamespace, className, ghidra.program.model.symbol.SourceType.USER_DEFINED);

program.endTransaction(txId, true);

Map<String, Object> result = createBasicClassInfo(classNamespace, 0);
result.put("message", "Successfully created class namespace: " + className);
return createJsonResult(result);

} catch (Exception e) {
program.endTransaction(txId, false);
throw e;
Copy link

Copilot AI Jun 25, 2025

Choose a reason for hiding this comment

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

Consider using a try-finally block when managing transactions to ensure that program.endTransaction is always executed, even if an exception is thrown.

Suggested change
try {
// Create the class namespace
Namespace classNamespace = symbolTable.createClass(parentNamespace, className, ghidra.program.model.symbol.SourceType.USER_DEFINED);
program.endTransaction(txId, true);
Map<String, Object> result = createBasicClassInfo(classNamespace, 0);
result.put("message", "Successfully created class namespace: " + className);
return createJsonResult(result);
} catch (Exception e) {
program.endTransaction(txId, false);
throw e;
boolean success = false;
try {
// Create the class namespace
Namespace classNamespace = symbolTable.createClass(parentNamespace, className, ghidra.program.model.symbol.SourceType.USER_DEFINED);
success = true;
Map<String, Object> result = createBasicClassInfo(classNamespace, 0);
result.put("message", "Successfully created class namespace: " + className);
return createJsonResult(result);
} catch (Exception e) {
throw e;
} finally {
program.endTransaction(txId, success);

Copilot uses AI. Check for mistakes.
@ILOVEPIE ILOVEPIE force-pushed the ClassDefinitionTools branch from e40efb1 to 19b7aaf Compare July 10, 2025 05:13
ILOVEPIE and others added 2 commits August 9, 2025 10:08
- Use McpSchema.Tool.builder() pattern instead of constructor
- Add title fields to all 8 class tools for better UX
- Fix address formatting to use AddressUtil.formatAddress()
- Update error message to match integration test expectations
- Remove unused imports and add missing AddressUtil import

This aligns the ClassToolProvider with the new MCP SDK patterns
introduced in the main branch rebase.
@cyberkaida cyberkaida force-pushed the ClassDefinitionTools branch from 19b7aaf to 79fb394 Compare August 9, 2025 01:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants