Skip to content

Switch_to_typescript#1

Open
itayAnc wants to merge 6 commits into
mon231:mainfrom
itayAnc:switch_to_typescript
Open

Switch_to_typescript#1
itayAnc wants to merge 6 commits into
mon231:mainfrom
itayAnc:switch_to_typescript

Conversation

@itayAnc
Copy link
Copy Markdown

@itayAnc itayAnc commented Jun 14, 2024

No description provided.

@itayAnc itayAnc changed the title DRAFT: Switch_to_typescript Switch_to_typescript Jun 28, 2024
Comment thread src/deep_clone.ts

function serialize_parcelable(obj)
{
function serialize_parcelable(obj: Java.Wrapper) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't we know the ret-type of this func? (convertible to Uint8Array? convert it and return a known typescrict value)

Comment thread src/deep_clone.ts
clone_clonable,
clone_serializable,
clone_parcelable,
serialize_parcelable,
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd like this repo to be splitted to subpackages/namespaces (idk how simple will it be to do so), such that we have JavaUtils namespace, and it has a ParcelableUtils module and CloneUtils (and the CloneUtils' funcs that clones parcelables will use ParcelableUtils' funcs)

Comment thread src/deep_clone.ts
@@ -1,10 +1,8 @@
function clone_clonable(obj)
{
function clone_clonable(obj: Java.Wrapper) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd like it to be clear that the retval is same-typed as the param

Comment thread src/file_io.ts
@@ -1,28 +1,24 @@
function file_write_string(file_path, content)
{
function file_write_string(file_path: string, content: string | ArrayBuffer | number[]) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it really works with such params? cool!

Comment thread src/file_io.ts

function file_read_bytes(file_path)
{
function file_read_bytes(file_path: string) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make it return Uint8Array

@@ -0,0 +1,39 @@
function class_exists(class_name: string) {
return !!Java.classFactory.loader?.find(class_name);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sheeshh!!!!

}
}

throw "Error can't find class " + class_name;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't there any cool exception-types in typescript?
Just like those ValueError, OSError, ... from python..? 🥲🥲

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to JavaClassUtils module?

Comment thread src/get_object_address.ts
@@ -0,0 +1,7 @@
function get_object_address(obj: Java.Wrapper) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

retval type-scrict-ness here really matters! let's not give up on it

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

module ProcessUtils in OSUtils namespace?

Comment thread src/index.ts
@@ -0,0 +1,40 @@
import { write_int } from "./patch_memory"
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks very bad.. I expected from that lang to have import-all feature by default, and not expect devs to add everything to their __all__ export

Comment thread src/interactive.ts
@@ -0,0 +1,20 @@
function show_toast(message: string) {
Java.perform(() => {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder how correct is it to Java.perform here, but not anywhere else...

Comment thread src/interactive.ts
const context = Java.use("android.app.ActivityThread").currentApplication().getApplicationContext();
const JavaString = Java.use("java.lang.String");

ToastWidget.makeText(context, JavaString.$new(message), 1).show();
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add a typed (something similar to std::chrono::milliseconds) duration param to the show_toast func? (with default value 1sec)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ResearchUtils module in the JavaUtils namespace?

Comment thread src/print_stack_trace.ts
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ResearchUtils as above

Comment thread src/print_stack_trace.ts
let stackTrace = currentThread.getStackTrace();

stackTrace.forEach(function(stackTraceElement) {
// TODO: repalce this any
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unresolved TODO

Comment thread package.json
@@ -0,0 +1,17 @@
{
"name": "frida-agent-example",
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we got to have our own cool libname, let's talk about it together

Comment thread .gitignore
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

textfiles must end by a newline !!!

Comment thread .eslintrc.js
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this file? wouldn't we like it to be .gitignored?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants