frida / frida-node

Frida Node.js bindings
282 stars 66 forks source link

Rewritten examples with ES6 #16

Closed SuperPaintman closed 8 years ago

SuperPaintman commented 8 years ago

Hi! I rewrote the examples using the ES6, and format them.

oleavr commented 8 years ago

Awesome, thanks for doing this! Would you be interested in converting the last details also? Off the top of my head:

Cheers!

SomeoneWeird commented 8 years ago

Also, change the injected scripts to use backticks instead of doing "" + "" + etc :tada:

SuperPaintman commented 8 years ago

@oleavr, @SomeoneWeird Done :)

oleavr commented 8 years ago

Sweet! It would be great to also omit the space between onEnter and (, and perhaps also remove the vertical alignment (it was there already, but I just thought of it now), so the code layout is stable even if a variable is renamed later.

SuperPaintman commented 8 years ago

I removed the space

oleavr commented 8 years ago

Nice work! What do you think about getting rid of the last var occurences also?

SuperPaintman commented 8 years ago

@oleavr they can't be replaced by a const, because we replace placeholder '%addr%'.

oleavr commented 8 years ago

@SuperPaintman That's fine, const just means it's not possible to assign a new value to the variable, so in such cases we should use let (var is legacy). The '%addr%' placeholder is replaced when the script is generated, but before it is loaded, so even those variables should be const (as long as we never reassign, or need to declare the variable without assigning in order to assign it later).

SuperPaintman commented 8 years ago

@oleavr Oh, sorry, I do not fully understood the concept of the new variables in ES6. Now i replaced var to let

oleavr commented 8 years ago

@SuperPaintman No worries! I've added some more comments on the issues I noticed. By the way, maybe we also want to switch the examples to using co? That way we'd get rid of the callback chaining spaghetti that we have had so far (because we couldn't use co due to lack of ES6 support). Here's an example: https://gist.github.com/oleavr/a22d675b76e7509cd2c9#file-app-js

oleavr commented 8 years ago

And I also noticed that maybe we want to rename script to source, to distinguish the source-code from the resulting script object (it's also named source at the API level).

SuperPaintman commented 8 years ago

@oleavr thanks for suggested to learn the CO. This is probably my best experience of this week!

oleavr commented 8 years ago

Nice work! Thanks a lot, and sorry for the delay here.