Skip to content

Commit 8488bfc

Browse files
committed
bug fixes and format fixes
1 parent fab4051 commit 8488bfc

File tree

9 files changed

+579
-560
lines changed

9 files changed

+579
-560
lines changed

.babelrc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"presets": [
3+
[
4+
"@babel/preset-env",
5+
{
6+
"loose": true
7+
}
8+
]
9+
],
10+
"plugins": [
11+
[
12+
"@babel/plugin-transform-runtime",
13+
{
14+
"corejs": 2
15+
}
16+
]
17+
]
18+
}

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# jnitrace Change Log
22

3+
## 2.2.1
4+
- Sorted the alignment of the backtraces so they are right justified
5+
- Fixed a bug when tracing Release<ArrayType>Elements where all types were assumed to be the size of a pointer
6+
- Upgraded eslint-package to patch security vulnerability
7+
- Stopped trying to kill Frida session if it was already dead
8+
39
## 2.2.0
410
- Changed backtrace output to include debug symbols, where possible
511

jnitrace/jnitrace.py

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def __init__(self, _config, _buffer_output):
7777
self._is_64b = False
7878

7979
def _print_thread_id(self, thread_id):
80-
print("{}{:15s}/* TID {:d} */{}".format(
80+
print("{}{:16s}/* TID {:d} */{}".format(
8181
Fore.WHITE,
8282
self._color_manager.get_current_color(),
8383
thread_id,
@@ -279,8 +279,8 @@ def _calculate_backtrace_lengths(self, backtrace):
279279

280280
if b_t_len > max_len:
281281
max_len = b_t_len
282-
if len(b_t["symbol"]["name"]) > max_name:
283-
max_name = len(b_t["symbol"]["name"])
282+
if len(symbol_name) > max_name:
283+
max_name = len(symbol_name)
284284

285285
return max_len, max_name, size
286286

@@ -488,6 +488,24 @@ def _parse_args():
488488

489489
return args
490490

491+
def _finish(args, device, pid, scripts):
492+
print('Stopping application (name={}, pid={})...'.format(
493+
args.target,
494+
pid
495+
), end="")
496+
try:
497+
if args.append:
498+
scripts["append"].unload()
499+
scripts["script"].unload()
500+
if args.prepend:
501+
scripts["prepend"].unload()
502+
503+
device.kill(pid)
504+
except frida.InvalidOperationError:
505+
pass
506+
finally:
507+
print("stopped.")
508+
491509
def main():
492510
"""
493511
Main function to process command arguments and to inject Frida.
@@ -516,16 +534,19 @@ def main():
516534
pid = device.get_process(args.target).pid
517535

518536
session = device.attach(pid)
537+
scripts = {}
519538

520539
if args.prepend:
521540
prepend = session.create_script(args.prepend.read(), runtime="v8")
522541
prepend.on("message", _custom_script_on_message)
523542
prepend.load()
524543
args.prepend.close()
544+
scripts["prepend"] = prepend
525545

526546
script = session.create_script(jscode, runtime="v8")
527547
script.on("message", formatter.on_message)
528548
script.load()
549+
scripts["script"] = script
529550

530551
script.post({
531552
"type": "config",
@@ -547,6 +568,7 @@ def main():
547568
append.on("message", _custom_script_on_message)
548569
append.load()
549570
args.append.close()
571+
scripts["append"] = append
550572

551573
if args.inject_method == "spawn":
552574
device.resume(pid)
@@ -564,18 +586,7 @@ def main():
564586
json.dump(formatter.get_output(), args.output, indent=4)
565587
args.output.close()
566588

567-
if args.append:
568-
append.unload()
569-
script.unload()
570-
if args.prepend:
571-
prepend.unload()
572-
573-
print('Stopping application (name={}, pid={})...'.format(
574-
args.target,
575-
pid
576-
), end="")
577-
device.kill(pid)
578-
print("stopped.")
589+
_finish(args, device, pid, scripts)
579590

580591
if __name__ == '__main__':
581592
main()

jnitrace/src/data/java_vm.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
{
33
"name": "reserved0",
44
"args": [],
5-
"ret": ""
5+
"ret": "void"
66
},
77
{
88
"name": "reserved1",
99
"args": [],
10-
"ret": ""
10+
"ret": "void"
1111
},
1212
{
1313
"name": "reserved2",
1414
"args": [],
15-
"ret": ""
15+
"ret": "void"
1616
},
1717
{
1818
"name": "DestroyJavaVM",

jnitrace/src/data/jni_env.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@
22
{
33
"name": "reserved0",
44
"args": [],
5-
"ret": ""
5+
"ret": "void"
66
},
77
{
88
"name": "reserved1",
99
"args": [],
10-
"ret": ""
10+
"ret": "void"
1111
},
1212
{
1313
"name": "reserved2",
1414
"args": [],
15-
"ret": ""
15+
"ret": "void"
1616
},
1717
{
1818
"name": "reserved3",
1919
"args": [],
20-
"ret": ""
20+
"ret": "void"
2121
},
2222
{
2323
"name": "GetVersion",

jnitrace/src/transport/data_transport.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ class DataTransport {
687687
const BUFFER_PTR_INDEX = 2;
688688
const SKIP_ENV_INDEX = 1;
689689

690-
const byteArrayArg = data.method.args[BYTE_ARRAY_INDEX];
690+
const byteArrayArg = data.method.args[BUFFER_PTR_INDEX];
691691
const type = byteArrayArg.slice(TYPE_NAME_START, TYPE_NAME_END);
692692
const nType = Types.convertNativeJTypeToFridaType(type);
693693
const size = Types.sizeOf(nType);

0 commit comments

Comments
 (0)