Class Analyzer Not Initialized in Auto Analysis
Closed this issue · 3 comments
OS: Windows 64bit
Ghidra Version: 9.2_DEV (3c683ae770cf495deb32588202b00b88e125a4a4)
CPP_Class-Analyzer Version: 9.2_DEV (50e375d)
Describe the bug
Building the most recent version of Ghidra and this extension (50e375d) and running Auto Analysis doesn't produce any results in the ClassInfoType Tree - not even a DataType category to populate. This was tested with a random ELF binary, as well as several of the tests from https://github.com/astrelsky/InheritanceTests including some x86 files and mingw32-w64 files. I've got a script I use to build Ghidra and this extension attached below - this is run using the Git for Windows SDK. Flex and Bison are included with the SDK, and Gradle 5.6.3 was added manually.
To Reproduce
Steps to reproduce behavior:
- Build Ghidra
- Build Extension
- Install Extension
- Restart Ghidra
- Configure extension in Code Browser
- Restart Code Browser
- Try to decompile any executable (as far as I'm aware). Easy test is to try libstdc++.so.6.
- Check the ClassInfoType Tree Window - there isn't any category or anything
Expected Behavior
Using the 2.0-alpha.3 release of this extension with the most recent build of Ghidra, running the auto-analysis even with default settings results in a Data Type category with the name matching the name of the file being examined, and as the analysis continues it populates with class information. This doesn't happen in the most recent build.
Additional Information
Looking through the commits since the 2.0-alpha.3 it looks like there was quite a bit of refractoring with the extension classes. I'm going to create an actual dev environment with Eclipse to see if I can step through any of this to try and figure it out. I'm pretty bad at programming (as I'm sure will be evidenced by the batch script), and I honestly wouldn't be surprised to find out I'm building this wrong. Also running the "ClassReferences.java" script results in a Null Pointer error, and "ClassReferences.java" and "DynamicCaster.java" are the only scripts available in the CppClassAnalyzer folder.
#!/usr/bin/env bash
#various variables varying verily
echo -e "\e[1;42m Setting paths\e[0m"
GIT_PATH=/c/git-sdk-64
GRADLE_PATH=$GIT_PATH/gradle/bin
BISON_PATH=$HOME/Downloads/win_flex_bison-latest
FLEX_PATH=$HOME/Downloads/win_flex_bison-latest
export GHIDRA_INSTALL_DIR="$HOME/downloads/ghidra_9.2_DEV"
if ! hash gradle 2>/dev/null; then
echo -e "\e[1;42m Adding gradle to PATH\e[0m"
export PATH=$PATH:$GRADLE_PATH;
fi
if ! hash bison 2>/dev/null; then
echo -e "\e[1;42m Adding bison to PATH\e[0m"
export PATH=$PATH:$BISON_PATH;
fi
if ! hash flex 2>/dev/null; then
echo -e "\e[1;42m Adding flex to PATH\e[0m"
export PATH=$PATH:$FLEX_PATH;
fi
#remove directories for clean install
echo -e "\e[1;42m removing directories\e[0m"
rm -rf $HOME/.ghidra
rm -rf $GHIDRA_INSTALL_DIR
rm -rf $GIT_PATH/ghidra/.gradle
rm -rf $GIT_PATH/ghidra/ghidra
rm -rf $GIT_PATH/ghidra/Ghidra-Cpp-Class-Analyzer
rm -rf $LOCALAPPDATA/ghidra
#clone github repositories
echo -e "\e[1;42m cloning repositories\e[0m"
git clone https://github.com/NationalSecurityAgency/ghidra.git
git clone https://github.com/astrelsky/Ghidra-Cpp-Class-Analyzer.git
#build ghidra
cd ghidra
echo -e "\e[1;42m gradle build init\e[0m"
gradle --init-script gradle/support/fetchDependencies.gradle init
echo -e "\e[1;42m gradle build natives\e[0m"
gradle buildNatives_win64
echo "gradle sleigh compile"
gradle sleighCompile
echo -e "\e[1;42m gradle build ghidra\e[0m"
gradle buildGhidra
#unzip to downloads
#unfortunately this creates an annoying top level directory, so some weird cd and mv is needed
mkdir $GHIDRA_INSTALL_DIR
echo -e "\e[1;42m unzipping ghidra to downloads\e[0m"
unzip $GIT_PATH/ghidra/ghidra/build/dist/ghidra*.zip -d $GHIDRA_INSTALL_DIR
cd $GHIDRA_INSTALL_DIR
cd ghidra*
mv ./* ..
cd ../
rm -rf *_DEV
cd $GIT_PATH/ghidra
#build class analyzer
echo -e "\e[1;42m begin with CPP class analyzer project\e[0m"
cd Ghidra-Cpp-Class-Analyzer
echo -e "\e[1;42m build extension\e[0m"
gradle buildExtension
#copy extension to ghidra directory
echo -e "\e[1;42m copy extension to directory\e[0m"
cp dist/ghidra*.zip $GHIDRA_INSTALL_DIR/extensions/Ghidra/
I haven't updated the class references script in a while. I'm using vscode to develop and the ghidra scripts aren't on the classpath so I don't get any errors or warnings until it is built.
I did recently refactor out a bunch of synchronization issues but don't remember if I put out a pre release of it yet. I will take a good look into this tomorrow to see what is going on. You definitely should be seeing results running analysis on the inheritance tests though. I may have forgotten something when I implemented the extension points.
@astrelsky that works! I'm even getting more classes populated by the auto analysis than before. Thanks for all your work making this extension too, it's been a real help.