Skip to content
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

memory: Optimize gum_memory_write for Linux/Android #989

Merged

Conversation

DoranekoSystems
Copy link
Contributor

Related to PR #988

Benchmark results

const memPtr = Memory.alloc(4096);

const module = new CModule(
  `
 #include <gum/gummemory.h>

 void zero_memory(gpointer address, gsize size) {
   guint8 zeros[4096] = {0};
   gum_memory_write(address, zeros, size);
 }
`,
  {}
);
const zero_memory = new NativeFunction(module.zero_memory, 'bool', ['pointer','int']);
let start = Date.now();
for (let i = 0; i < 1000; i++) {
  zero_memory(memPtr, 4096);
}
let end = Date.now();
console.log(`gum_memory_write => elapsedTime: ${end - start} ms`);

Device:Android Pixel3a

frida-server:16.6.5
gum_memory_write => elapsedTime: 4955 ms

this version
gum_memory_write => elapsedTime: 8 ms

oleavr and others added 2 commits January 27, 2025 20:46
By making use of process_vm_writev() if the kernel supports it.
@oleavr oleavr force-pushed the fix/linux-memory-write-optimization branch from ff4664e to 789abd1 Compare January 27, 2025 19:48
@oleavr oleavr merged commit 752bf40 into frida:main Jan 27, 2025
12 of 31 checks passed
@oleavr
Copy link
Member

oleavr commented Jan 27, 2025

Thanks! 🙌

@enovella
Copy link

Sweet! <3

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