Are static members in XPosed hook classes shared between processes?

738 Views Asked by At

I'm newer to Java, here's what I think XPosed works:

  1. Before zygote_init, hook all apis and insert xposed_before_xxx and xposed_after_xxx method (where xxx is the name of the api).
  2. Load modules. Load hook class, realize it and keep it in memory of zygote. For each injecting method, add it to the private list of xposed_before/after_xxx.
  3. When an new app loads (forks from zygote), it also forked the hook class and the hooked method.
  4. When an app calls xxx, it actually runs xposed_before_xxx first, and the latter calls every inject method in its private list. Then the original api is called. Then xposed_after_xxx is called, and deals with itself's list.

So for each app, hook class is individual after forking from zygote. So, static members are not shared. Cause each hook class has only one instance in an app, static members act the same as non-static members. Am I right?

Thanks for reading my long & poor English...

1

There are 1 best solutions below

0
On BEST ANSWER

No, static members are not shared across processes. They act as static members within the app, not across apps.

Each application runs on its own VM so nothing is shared across processes.

Same applies for Xposed hooks, you can have a static method hooked for one application and not for others.

Even if you set your module to apply hooks on all applications, these hooks will be different instances in separate VMs.