Skip to content

Add FridaScript.post(message, data) for sending messages to scripts #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jpovixwm
Copy link

Not sure about the purpose of batchId, it seems to work OK with a hardcoded zero.
The zero length buffer is needed, because if you pass null, it fails somewhere further down due to the marshaller expecting an array:

C:\github\httptoolkit\frida-js\node_modules\@httptoolkit\dbus-native\lib\marshall.js:58
      for (var i = 0; i < data.length; ++i)
                               ^

TypeError: Cannot read properties of null (reading 'length')
    at write (C:\github\httptoolkit\frida-js\node_modules\@httptoolkit\dbus-native\lib\marshall.js:58:32)
    at writeStruct (C:\github\httptoolkit\frida-js\node_modules\@httptoolkit\dbus-native\lib\marshall.js:32:5)
    at write (C:\github\httptoolkit\frida-js\node_modules\@httptoolkit\dbus-native\lib\marshall.js:42:7)
    at write (C:\github\httptoolkit\frida-js\node_modules\@httptoolkit\dbus-native\lib\marshall.js:59:9)
    at writeStruct (C:\github\httptoolkit\frida-js\node_modules\@httptoolkit\dbus-native\lib\marshall.js:32:5)
    at marshall (C:\github\httptoolkit\frida-js\node_modules\@httptoolkit\dbus-native\lib\marshall.js:18:13)
    at Object.marshallMessage [as marshall] (C:\github\httptoolkit\frida-js\node_modules\@httptoolkit\dbus-native\lib\message.js:86:16)
    at self.message (C:\github\httptoolkit\frida-js\node_modules\@httptoolkit\dbus-native\index.js:68:28)
    at bus.<anonymous> (C:\github\httptoolkit\frida-js\node_modules\@httptoolkit\dbus-native\lib\bus.js:43:21)
    at bus.invoke (C:\github\httptoolkit\frida-js\node_modules\@httptoolkit\dbus-native\lib\promisify.js:12:16)

Lastly, the test suite is going to fail for this PR because it will fetch Frida v17, but frida-js only works with v16.

@CLAassistant
Copy link

CLAassistant commented May 27, 2025

CLA assistant check
All committers have signed the CLA.

@pimterry
Copy link
Member

Thanks, this looks great! Nicely done.

Lastly, the test suite is going to fail for this PR because it will fetch Frida v17, but frida-js only works with v16.

Indeed they have failed. Have you already looked at this yourself already? If you have a fix for it, I'd love to merge that first rather than merging this with the tests failing. Or if not or you don't have time, don't worry, I can take a look myself and then merge this on top.

@jpovixwm
Copy link
Author

@pimterry Locally, I made these changes to get the tests to work:

diff --git a/test/download-frida.spec.ts b/test/download-frida.spec.ts
index 9a56ede..ef4c0b1 100644
--- a/test/download-frida.spec.ts
+++ b/test/download-frida.spec.ts
@@ -26,8 +26,8 @@ if (isNode) {
             );
 
             await new Promise((resolve, reject) => {
-                writeStream.on('finish', resolve);
-                writeStream.on('error', reject);
+                writeStream.on('finish', () => {resolve(undefined)});
+                writeStream.on('error', () => {reject(undefined)});
             });
 
             const fileStat = await fs.promises.stat(tmpFile.path);
@@ -88,8 +88,8 @@ if (isNode) {
 
             const streamResult: any = await new Promise((resolve, reject) => {
                 fridaServerStream.on('error', reject);
-                writeStream.on('error', reject);
-                writeStream.on('finish', resolve);
+                writeStream.on('error', () => {reject(undefined)});
+                writeStream.on('finish', () => {resolve(undefined)});
             });
 
             // Stream should complete without errors:
diff --git a/test/download-test-frida.ts b/test/download-test-frida.ts
index b959392..fed2f01 100644
--- a/test/download-test-frida.ts
+++ b/test/download-test-frida.ts
@@ -26,7 +26,7 @@ async function setUpLocalEnv() {
         : null;
 
     try {
-        const latestServerDetails = await getFridaReleaseDetails('latest', process.env.GITHUB_TOKEN);
+        const latestServerDetails = await getFridaReleaseDetails('16.7.19', process.env.GITHUB_TOKEN);
         const latestServerVersion: string = latestServerDetails.tag_name;
 
         if (!serverExists || semver.gt(latestServerVersion, currentServerVersion)) {

If you think that's acceptable, I can make another PR. (Or you could just commit that on your own, as it's not all that much changes).
Though ideally, I think the tests should grab the most recent 16.x release rather than hardcoding a specific release like that. On the other hand, I took a brief look at Frida's past releases, and it looks like they don't really make new releases for previous major versions.

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.

3 participants