Skip to content

Commit

Permalink
add currentData and currentInstruction variables
Browse files Browse the repository at this point in the history
  • Loading branch information
goatshriek committed Jul 7, 2024
1 parent 6a3c7f3 commit 7f082bd
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 5 deletions.
5 changes: 2 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [4.0.0] - 2024-07-06
## [4.0.0] - 2024-07-07
### Added
- Current function interpreter variables with the function containing the
current address.
- Current function, data, and instruction interpreter variables.

### Changed
- Upgrade to JRuby 9.4.7.0 (Ruby 3.1.4)
Expand Down
4 changes: 3 additions & 1 deletion src/main/help/help/topics/Clojure/interpreter.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ <H2>Environment</H2>
environments are also available in the Clojure interpreter as global
variables, both for interactive sessions and scripts. There are also some
extra variables for commonly needed values such as the current function.
These are all added to the ghidra namespace:
These are all added to the ghidra namespace.
</P>

<PRE>
ghidra/current-address
ghidra/current-data
ghidra/current-function
ghidra/current-highlight
ghidra/current-instruction
ghidra/current-location
ghidra/current-program
ghidra/current-selection
Expand Down
2 changes: 2 additions & 0 deletions src/main/help/help/topics/Groovy/interpreter.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ <H2>Environment</H2>

<PRE>
currentAddress
currentData
currentFunction
currentHighlight
currentInstruction
currentLocation
currentProgram
currentSelection
Expand Down
2 changes: 2 additions & 0 deletions src/main/help/help/topics/JShell/interpreter.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ <H2>Environment</H2>

<PRE>
currentAddress
currentData
currentFunction
currentHighlight
currentInstruction
currentLocation
currentProgram
currentSelection
Expand Down
2 changes: 2 additions & 0 deletions src/main/help/help/topics/Kotlin/interpreter.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ <H2>Environment</H2>

<PRE>
currentAddress
currentData
currentFunction
currentHighlight
currentInstruction
currentLocation
currentProgram
currentSelection
Expand Down
2 changes: 2 additions & 0 deletions src/main/help/help/topics/Ruby/interpreter.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ <H2>Environment</H2>

<PRE>
$current_address
$current_data
$current_function
$current_highlight
$current_instruction
$current_location
$current_program
$current_selection
Expand Down
28 changes: 27 additions & 1 deletion src/main/java/com/goatshriek/rubydragon/GhidraInterpreter.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,17 @@ public String getCurrentAPIName() {
return "currentAPI";
}

/**
* The default name for the current data variable.
*
* @return The default name for the current data variable.
*
* @since 4.0.0
*/
public String getCurrentDataName() {
return "currentData";
}

/**
* The default name for the current function variable.
*
Expand All @@ -146,6 +157,17 @@ public String getCurrentHighlightName() {
return "currentHighlight";
}

/**
* The default name for the current instruction variable.
*
* @return The default name for the current instruction variable.
*
* @since 4.0.0
*/
public String getCurrentInstructionName() {
return "currentInstruction";
}

/**
* The default name for the current location variable.
*
Expand Down Expand Up @@ -306,7 +328,11 @@ public void setStreams(InterpreterConsole console) {
*/
public void updateAddress(Address address) {
setVariable(getCurrentAddressName(), address);
setVariable(getCurrentFunctionName(), api.getFunctionContaining(address));
if (api != null) {
setVariable(getCurrentDataName(), api.getDataContaining(address));
setVariable(getCurrentFunctionName(), api.getFunctionContaining(address));
setVariable(getCurrentInstructionName(), api.getInstructionContaining(address));
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,18 @@ public String getCurrentAPIName() {
return "current-api";
}

/**
* The name for the current data variable.
*
* @return The name for the current data variable.
*
* @since 4.0.0
*/
@Override
public String getCurrentDataName() {
return "current-data";
}

/**
* The name for the current function variable.
*
Expand All @@ -166,6 +178,18 @@ public String getCurrentHighlightName() {
return "current-highlight";
}

/**
* The name for the current instruction variable.
*
* @return The name for the current instruction variable.
*
* @since 4.0.0
*/
@Override
public String getCurrentInstructionName() {
return "current-instruction";
}

/**
* The name for the current location variable.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,18 @@ public String getCurrentAPIName() {
return "$current_api";
}

/**
* The name for the current data variable.
*
* @return The name for the current data variable.
*
* @since 4.0.0
*/
@Override
public String getCurrentDataName() {
return "$current_data";
}

/**
* The name for the current function variable.
*
Expand All @@ -191,6 +203,18 @@ public String getCurrentHighlightName() {
return "$current_highlight";
}

/**
* The name for the current data variable.
*
* @return The name for the current data variable.
*
* @since 4.0.0
*/
@Override
public String getCurrentInstructionName() {
return "$current_data";
}

/**
* The name for the current location variable.
*
Expand Down

0 comments on commit 7f082bd

Please sign in to comment.