Skip to content

Commit

Permalink
Merge 'dev' branch into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
XVilka committed Aug 5, 2023
2 parents 1ed04d6 + f903624 commit dbddcf1
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 52 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ ghidra/flex/
.ccls-cache
.gdb_history
.cache/
.DS_Store
4 changes: 2 additions & 2 deletions src/CodeXMLParse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct ParseCodeXMLContext
static char *strdup_rz(const char *s)
{
size_t sz = strlen(s);
char *r = reinterpret_cast<char *>(rz_malloc(sz + 1));
char *r = reinterpret_cast<char *>(rz_mem_alloc(sz + 1));
if(!r)
return NULL;
memcpy(r, s, sz + 1);
Expand Down Expand Up @@ -350,7 +350,7 @@ RZ_API RzAnnotatedCode *ParseCodeXML(Funcdata *func, const char *xml)
ParseNode(doc.child("function"), &ctx, ss, code);

std::string str = ss.str();
code->code = reinterpret_cast<char *>(rz_malloc(str.length() + 1));
code->code = reinterpret_cast<char *>(rz_mem_alloc(str.length() + 1));
if(!code->code)
{
rz_annotated_code_free(code);
Expand Down
3 changes: 2 additions & 1 deletion src/RizinScope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ FunctionSymbol *RizinScope::registerFunction(RzAnalysisFunction *fcn) const
auto flag = reinterpret_cast<RzFlagItem *>(pos);
if(flag->space && flag->space->name && !strcmp(flag->space->name, RZ_FLAGS_FS_SECTIONS))
continue;
if (flag->realname && *flag->realname) {
if(!strcmp(flag->name, fcn->name) && flag->realname && *flag->realname)
{
fcn_name = flag->realname;
break;
}
Expand Down
4 changes: 1 addition & 3 deletions src/analysis_ghidra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2937,9 +2937,7 @@ static bool esil_peek_n(RzAnalysisEsil *esil, int bits)
ut64 bitmask = genmask(bits - 1);
ut8 a[sizeof(ut64)] = {0};
ret = !!rz_analysis_esil_mem_read(esil, addr, a, bytes);
ut64 b = rz_read_ble64(a, 0); // esil->analysis->big_endian);
if(esil->analysis->big_endian)
rz_mem_swapendian((ut8 *)&b, (const ut8 *)&b, bytes);
ut64 b = rz_read_ble64(a, esil->analysis->big_endian);

snprintf(res, sizeof(res), "0x%" PFMT64x, b & bitmask);
rz_analysis_esil_push(esil, res);
Expand Down
46 changes: 23 additions & 23 deletions test/db/extras/analysis_ghidra
Original file line number Diff line number Diff line change
Expand Up @@ -83,91 +83,91 @@ e asm.bits
wx 89e1
pdq 1
ao | grep type
?e ----
echo ----
wx a168a00408
pdq 1
ao | grep type
?e ----
echo ----
wx a368a00408
pdq 1
ao | grep type
?e ----
echo ----
wx 8945f0
pdq 1
ao | grep type
?e ----
echo ----
wx 8b4510
pdq 1
ao | grep type
?e ----
echo ----
wx 0f4c0d03000000
pdq 1
ao | grep type
?e ----
echo ----
wx cd80
pdq 1
ao | grep type
?e ----
echo ----
wx 55
pdq 1
ao | grep type
?e ----
echo ----
wx 6a00
pdq 1
ao | grep type
?e ----
echo ----
wx 5d
pdq 1
ao | grep type
?e ----
echo ----
wx 83f853
pdq 1
ao | grep type
?e ----
echo ----
wx 85c0
pdq 1
ao | grep type
?e ----
echo ----
wx 83c410
pdq 1
ao | grep type
?e ----
echo ----
wx 81ec88100000
pdq 1
ao | grep type
?e ----
echo ----
wx f7ea
pdq 1
ao | grep type
?e ----
echo ----
wx f7f2
pdq 1
ao | grep type
?e ----
echo ----
wx d1e8
pdq 1
ao | grep type
?e ----
echo ----
wx d1e0
pdq 1
ao | grep type
?e ----
echo ----
wx d1f8
pdq 1
ao | grep type
?e ----
echo ----
wx 0b25f0ff0000
pdq 1
ao | grep type
?e ----
echo ----
wx 2325f0ff0000
pdq 1
ao | grep type
?e ----
echo ----
wx 3325f0ff0000
pdq 1
ao | grep type
?e ----
echo ----
wx 8703
pdq 1
ao | grep type
Expand All @@ -189,7 +189,7 @@ e asm.arch=ghidra
wx 298947f9
pdq 1
ao | grep type
?e ----
echo ----
wx 690200f9 @ 0x200
pdq 1 @ 0x200
ao @ 0x200| grep type
Expand Down
72 changes: 49 additions & 23 deletions test/db/extras/ghidra
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ s sym.get_global_array_entry
af
e ghidra.rawptr=1
pdg
?e --
echo --
e ghidra.rawptr=0
pdg
EOF
Expand Down Expand Up @@ -275,7 +275,7 @@ s sym.get_global_var
af
e ghidra.rawptr=1
pdg
?e --
echo --
e ghidra.rawptr=0
pdg
EOF
Expand Down Expand Up @@ -309,21 +309,21 @@ uint32_t sym.get_global_array_entry(void)
}
EOF
CMDS=<<EOF
avga global_var obj.global_var uint32_t
avga global_array obj.global_array uint32_t[2]
avga global_var uint32_t @ obj.global_var
avga global_array uint32_t[2] @ obj.global_array
s sym.get_global_var
af
e ghidra.rawptr=1
pdg
?e --
echo --
e ghidra.rawptr=0
pdg
?e --
echo --
s sym.get_global_array_entry
af
e ghidra.rawptr=1
pdg
?e --
echo --
e ghidra.rawptr=0
pdg
EOF
Expand Down Expand Up @@ -2277,12 +2277,12 @@ afvs 4 bright BrightPtr
afvs 8 argc "Bright *"
afvs 12 argv "const char **"
pdg
?e --
echo --
afvs 4 bright "BrightTypedefd *"
afvs 8 argc int32_t
afvs 12 argv "const char **"
pdg
?e --
echo --
afvs 4 bright BrightTypedefdPtr
pdg
EOF
Expand Down Expand Up @@ -2740,18 +2740,18 @@ s main
af
e scr.color=0
pdg
?e --
echo --
pdgo
?e --
echo --
pdg*
?e --
echo --
pdgx~!id=,<addr
?e --
echo --
pdgd~!id=,protectedMode
?e --
echo --
e scr.color=3
pdg
?e --
echo --
pdgo
EOF
RUN
Expand Down Expand Up @@ -3076,7 +3076,7 @@ EOF
CMDS=<<EOF
s main
pi 8
?e -----
echo -----
pdgsd 8~!STORE
EOF
RUN
Expand Down Expand Up @@ -3232,9 +3232,6 @@ jstring sym.Java_JNIFoo_nativeFoo(JNIEnv *env, jobject obj)
int64_t iVar1;
jstring pvVar2;
int64_t var_30h;
void *var_18h;
void *ptr;
int64_t var_8h;

iVar1 = sym.imp.malloc(0x1e);
if (iVar1 == 0) {
Expand All @@ -3254,10 +3251,10 @@ FILE=rizin-testbins/mach0/hello-macos-arm64
CMDS=<<EOF
aaa
s main
?e ------------ with propagation
echo ------------ with propagation
e ghidra.ropropagate
pdg
?e ------------ without propagation
echo ------------ without propagation
e ghidra.ropropagate=0
pdg
EOF
Expand All @@ -3267,8 +3264,8 @@ true

// WARNING: Variable defined which should be unmapped: var_10h
// WARNING: Variable defined which should be unmapped: var_8h
// WARNING: [rz-ghidra] Detected overlap for variable var_2ch
// WARNING: [rz-ghidra] Detected overlap for variable var_14h
// WARNING: [rz-ghidra] Detected overlap for variable var_2ch

undefined8 entry0(int64_t arg1, int64_t arg2)
{
Expand Down Expand Up @@ -3300,8 +3297,8 @@ undefined8 entry0(int64_t arg1, int64_t arg2)

// WARNING: Variable defined which should be unmapped: var_10h
// WARNING: Variable defined which should be unmapped: var_8h
// WARNING: [rz-ghidra] Detected overlap for variable var_2ch
// WARNING: [rz-ghidra] Detected overlap for variable var_14h
// WARNING: [rz-ghidra] Detected overlap for variable var_2ch

undefined8 entry0(int64_t arg1, int64_t arg2)
{
Expand Down Expand Up @@ -3350,3 +3347,32 @@ undefined4 sym.ko_example_init(void)
}
EOF
RUN

NAME=realname and multiple flags at function
FILE=rizin-testbins/mach0/hello-macos-arm64-objc-stubs-stripped
CMDS=<<EOF
e asm.flags.real=1
aaa
pdg @ 0x100003ae8
EOF
EXPECT=<<EOF

// WARNING: Variable defined which should be unmapped: var_10h
// WARNING: [rz-ghidra] Detected overlap for variable var_2ch

void method.Test.methodWithTwoArgs:secondArg:(int64_t arg1, int64_t arg2, int64_t arg3, int64_t arg4)
{
int32_t var_2ch;
int64_t var_28h;
int64_t var_10h;

var_2ch = (int32_t)arg4;
if (var_2ch < (int32_t)arg3) {
var_2ch = (int32_t)arg3;
}
*(int32_t *)(arg1 + 8) = var_2ch;
NSLog(__CFConstantStringClassReference);
return;
}
EOF
RUN

0 comments on commit dbddcf1

Please sign in to comment.