[Android] note 亂亂寫
§How-to modify the content of .jar
Download smali and baksmali from smali.
Open the xxx.jar file with something such as winrar or 7zip or whatever you prefer.
Copy out the classes.dex file.
Run following from command line:
Open the file xxx.smali that you want to modify in something like notepad or context or any text editor.
Now back to the command line and run:
Open the services.jar file with your archiving tool again and replace the existing classes.dex file with our new classes.dex we just created.
§Reflection
有時你會需要突破存取限制來呼叫受護的或私有的方法,這時候您可以使用反射機制來達到目的,一個存取私有方法的例子如下:
即使宣告為私有方法或成員,仍可以透過反射機制存取私有方法,要突破權限仍是可以的。
Reference:
良葛格學習筆記 Java 學習筆記 (10) - Reflection
§RAM Disk in Ubuntu
Modify /etc/fstab Add the following code to the last line:
It would share a half of total memory as the disk space.
java -jar baksmali.jar -o classout/ classes.dex
java -Xmx512M -jar smali.jar classout/ -o new-classes.dex
§Reflection
有時你會需要突破存取限制來呼叫受護的或私有的方法,這時候您可以使用反射機制來達到目的,一個存取私有方法的例子如下:
Class c = Class.forName("com.jackal.private");
Method privateMethod = c.getDeclaredMethod("getPrivateMethod", arg0, arg1, ...);
//privateMethod.setAccessible(true);
privateMethod.invoke(instanceObj, arg0, arg1, ...);
即使宣告為私有方法或成員,仍可以透過反射機制存取私有方法,要突破權限仍是可以的。
Reference:
良葛格學習筆記 Java 學習筆記 (10) - Reflection
§RAM Disk in Ubuntu
Modify /etc/fstab Add the following code to the last line:
tmpfs /tmp tmpfs defaults 0 0
It would share a half of total memory as the disk space.
留言
tmpfs 可以加參數指定大小 (tmp 我都給它 300m)
# mount -t tmpfs tmpfs /where/the/mountpoint -o size=100m
用到一半發現大小不夠,也可以 remount
# mount tmpfs /where/the/mountpoing -o remount,size=120m