File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -135,7 +135,7 @@ More detailed tutorial about specific features is in development. Completed chap
135135
136136* [ Emulator] ( https://msm-code.github.io/ghidralib/emulator/ )
137137
138- If you prefer to learn by example, tou can also browse the [ examples] ( ./examples/ ) directory.
138+ If you prefer to learn by example, you can also browse the [ examples] ( ./examples/ ) directory.
139139
140140A fair warning: ghidralib is still actively developed and the API may change
141141slightly in the future. But this doesn't matter for your one-off scripts, does it?
Original file line number Diff line number Diff line change @@ -32,7 +32,9 @@ void check(int value) {
3232}
3333
3434int main(int argc, char * argv[ ] ) {
35+ if (argc != 2) { return 1; }
3536 check(atoi(argv[ 1] ));
37+ return 0;
3638}
3739```
3840
@@ -274,6 +276,10 @@ emu.add_hook(Symbol("hash").address, hash_hook)
274276emu.emulate(Symbol(" check" ).address)
275277```
276278
279+ ** Exercise** : Create a hook for ` atoi ` function that will simulate the libc function -
280+ it should parse the string from the parameter and return it in RAX. Test it by emulating
281+ the "call atoi" instruction with a string parameter.
282+
277283### State inspection
278284
279285Of course, after emulation we are interested in the final state of the emulator.
@@ -319,6 +325,10 @@ It doesn't get any easier than that. The `simple` in the name refers to the retu
319325in many cases you will want to use ` Function.emulate ` to get the whole context of the
320326emulator after execution.
321327
328+ ** Exercise** : Complete the ` atoi ` hook from the previous exercise first. Then create an emulator,
329+ add ` printf ` and ` atoi ` hooks, and execute a ` main ` function with the correct parameters.
330+ This will require you to pass correct ` argc ` and ` argv ` parameters.
331+
322332### Misc features
323333
324334** maxsteps**
You can’t perform that action at this time.
0 commit comments