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

WIP branch supporting latest ghidra-native-0.5.0 #149

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile.acr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include config.mk
DESTDIR?=

GHIDRA_NATIVE_COMMIT=0.4.5
GHIDRA_NATIVE_COMMIT=0.5.0

PUGIXML=third-party/pugixml/Makefile

Expand Down
7 changes: 7 additions & 0 deletions ghidra/deps.mk
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# hardcoded for now
USE_BISON=0


LDFLAGS+=-lz

# GHIDRA_HOME=../ghidra/ghidra/
# GHIDRA_DECOMPILER=$(GHIDRA_HOME)/Ghidra/Features/Decompiler/src/decompile/cpp
GHIDRA_HOME=../ghidra-native
Expand All @@ -20,6 +23,10 @@ G_DECOMPILER+=merge.cc double.cc coreaction.cc condexe.cc override.cc
G_DECOMPILER+=dynamic.cc crc32.cc prettyprint.cc printlanguage.cc
G_DECOMPILER+=printc.cc printjava.cc memstate.cc opbehavior.cc
G_DECOMPILER+=paramid.cc transform.cc string_ghidra.cc stringmanage.cc
G_DECOMPILER+=slaformat.cc
G_DECOMPILER+=compression.cc
G_DECOMPILER+=multiprecision.cc
G_DECOMPILER+=modelrules.cc

G_DECOMPILER+=ghidra_arch.cc
G_DECOMPILER+=loadimage_ghidra.cc
Expand Down
2 changes: 1 addition & 1 deletion preconfigure.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set PATH=%CD%\radare2\bin;%PATH%
set VSARCH=x64

git submodule update --init
set GNV=0.4.5
set GNV=0.5.0

python -m wget https://github.com/radareorg/ghidra-native/releases/download/%GNV%/ghidra-native-%GNV%.zip

Expand Down
13 changes: 11 additions & 2 deletions src/R2PrintC.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* r2ghidra - LGPL - Copyright 2019-2023 - thestr4ng3r, pancake */
/* r2ghidra - LGPL - Copyright 2019-2024 - thestr4ng3r, pancake */

#include "R2PrintC.h"
#include "RCoreMutex.h"
Expand Down Expand Up @@ -55,8 +55,17 @@ void R2PrintC::pushUnnamedLocation(const Address &addr, const Varnode *vn, const
if (space->getType() == IPTR_PROCESSOR) {
pushOp (&dereference, op);
auto type = glb->types->getTypePointer (space->getAddrSize (), vn->getType (), space->getWordSize ());
pushConstant (addr.getOffset (), type, vn, op);
// pushConstant (addr.getOffset (), type, vn, op);
pushConstant(addr.getOffset(),type,casetoken,vn, op);
} else {
PrintC::pushUnnamedLocation (addr,vn, op);
}
}

/*
void R2PrintC::push_integer(uintb val,int4 sz,bool sign,tagtype tag, const Varnode *vn,const PcodeOp *op) {
}

void R2PrintC::pushConstant(uintb val,const Datatype *ct,tagtype tag, const Varnode *vn, const PcodeOp *op) {
}
*/
2 changes: 1 addition & 1 deletion src/R2PrintC.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* r2ghidra - LGPL - Copyright 2019-2023 - thestr4ng3r, pancake */
/* r2ghidra - LGPL - Copyright 2019-2024 - pancake */

#ifndef R2GHIDRA_R2PRINTC_H
#define R2GHIDRA_R2PRINTC_H
Expand Down
5 changes: 4 additions & 1 deletion src/R2TypeFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Datatype *R2TypeFactory::queryR2Struct(const string &n, std::set<std::string> &s
arch->addWarning ("Struct " + n + " has no fields.");
return nullptr;
}
setFields (fields, r, 0, 0);
// setFields (fields, r, 0, 0);
return r;
} catch (std::invalid_argument &e) {
arch->addWarning ("Failed to load struct " + n + " from sdb.");
Expand Down Expand Up @@ -168,10 +168,13 @@ Datatype *R2TypeFactory::queryR2Typedef(const string &n, std::set<std::string> &
if (!resolved) {
return nullptr;
}
#if 0
Datatype *typedefd = resolved->clone ();
setName (typedefd, n); // this removes the old name from the nametree
setName (resolved, resolved->getName()); // add the old name back
return typedefd;
#endif
return nullptr;
}

Datatype *R2TypeFactory::queryR2(const string &n, std::set<std::string> &stackTypes) {
Expand Down
Loading