title: How to hook dynamically loaded dex and libs by packer with frida?
body: <p>i'm trying to hook java class that is being loaded dynamically by the packer.</p>
  <p>i used frida-DexDump to get the original dex but how can i hook its functions ? the function i am trying to hook it's call is a native function( declared this way &quot;public static native void Init(String str, String str2);</p>
  <p>&quot;).</p>
  <p>here is the way i tried but nothing come out</p>
  <pre><code>Java.perform(function() {
  Java.openClassFile('/data/data/com.malware.android/6644448.dex').load();
  // Printing all available classes 
  var iterator = Java.openClassFile('/data/data/com.malware.android/6984300.dex').getClassNames();
  
  // Here all the elements of the array is being printed. 
  for (var j = 0; j &lt; iterator.length; j++) {
      console.log(iterator[j]);
  }
  
  var my_class = Java.use(&quot;com.lib.connect&quot;);
  //replace the original implmenetation of the function `Init` with our custom function 
  //Init is a native function that it's being affected to Integer variable
  
  my_class.Init.implementation = function(x, y) {
      //print the original arguments
      console.log(&quot;original call: Init(&quot; + x + &quot;, &quot; + y + &quot;)&quot;);
      //call the original implementation of `Init` with args (2,5)
      this.Init(&quot;2&quot;, &quot;5&quot;);
  }
  </code></pre>
  <p>});</p>
  <p>Question 2 :
  by loading the dumped dex into Jadx i can see that the app is loading Native libs from assets folder but the folder or files physically aren't stored in assets folder.
  so where can i find those files ? what can i do ? tried dumping the app with gameguardian but nothing shows up
  created a script that tried pulling the files from the desired folder once created but i can't see any file there (tried this method because one lib is loaded into app it is being deleted)
  here is how it is being called</p>
  <pre><code>private void Config(Context context) {
      AssetManager assets = context.getAssets();
      new File(context.getFilesDir().getPath() + &quot;/vseh&quot;).mkdirs();
      new File(context.getFilesDir().getPath() + &quot;/vseh/mtx&quot;).mkdirs();
      String str = context.getFilesDir().getPath() + &quot;/vseh/mtx/global-mtx.dat&quot;;
      String str2 = context.getFilesDir().getPath() + &quot;/vseh/mtx/base.apk&quot;;
      if (!new File(str2).exists()) {
          try {
              copyFile(assets.open(&quot;__ainfo.tsa&quot;), new FileOutputStream(str2));
          } catch (IOException e) {
              e.printStackTrace();
          }
          try {
              Runtime.getRuntime().exec(&quot;chmod -R 644 &quot; + str2);
          } catch (IOException e2) {
              e2.printStackTrace();
          }
      }
      try {
          copyFile(assets.open(&quot;__info.tsa&quot;), new FileOutputStream(str));
          System.load(str);
          FuckLeecher();
          new File(str).delete();
      } catch (IOException e3) {
          e3.printStackTrace();
      }
  }
  </code></pre>