lugurt / smali

Automatically exported from code.google.com/p/smali
0 stars 0 forks source link

Cannot Deodex Settings.odex #61

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What seems to be the problem?
I cannot Deodex the settings app on my Droid X running the new leaked 
Gingerbread

What is the exact smali/baksmali command that you ran?
Originally: java -jar baksmali.jar -x Settings.odex
I then ran it to include all the jar files in my framework (still no success)

What version of smali/baksmali are you using? What rom are you working
from?
1.2.6 Android 2.3.3 Motoblur

What is the airspeed velocity of an unladen swallow?
It depends on whether you are talking about an African or European swallow.

Please provide any additional information below: error messages, symptoms,
etc.

Error while disassembling method 
Lcom/android/settings/HDMIHelper$MirrorServiceConnection;->onServiceConnected(La
ndroid/content/ComponentName;Landroid/os/IBinder;)V. Continuing.
org.jf.dexlib.Code.Analysis.ValidationException: class 
Lcom/motorola/android/mirrorservice/IMirrorService; cannot be resolved.
    at org.jf.dexlib.Code.Analysis.ClassPath$UnresolvedClassDef.unresolvedValidationException(ClassPath.java:535)
    at org.jf.dexlib.Code.Analysis.ClassPath$UnresolvedClassDef.getClassDepth(ClassPath.java:543)
    at org.jf.dexlib.Code.Analysis.ClassPath.getCommonSuperclass(ClassPath.java:383)
    at org.jf.dexlib.Code.Analysis.RegisterType.merge(RegisterType.java:275)
    at org.jf.dexlib.Code.Analysis.AnalyzedInstruction.mergeRegister(AnalyzedInstruction.java:185)
    at org.jf.dexlib.Code.Analysis.MethodAnalyzer.propagateRegisterToSuccessors(MethodAnalyzer.java:444)
    at org.jf.dexlib.Code.Analysis.MethodAnalyzer.setPostRegisterTypeAndPropagateChanges(MethodAnalyzer.java:424)
    at org.jf.dexlib.Code.Analysis.MethodAnalyzer.setDestinationRegisterTypeAndPropagateChanges(MethodAnalyzer.java:396)
    at org.jf.dexlib.Code.Analysis.MethodAnalyzer.analyzeConstString(MethodAnalyzer.java:1801)
    at org.jf.dexlib.Code.Analysis.MethodAnalyzer.analyzeInstruction(MethodAnalyzer.java:673)
    at org.jf.dexlib.Code.Analysis.MethodAnalyzer.analyze(MethodAnalyzer.java:208)
    at org.jf.baksmali.Adaptors.MethodDefinition.addAnalyzedInstructionMethodItems(MethodDefinition.java:353)
    at org.jf.baksmali.Adaptors.MethodDefinition.getMethodItems(MethodDefinition.java:290)
    at org.jf.baksmali.Adaptors.MethodDefinition.writeTo(MethodDefinition.java:130)
    at org.jf.baksmali.Adaptors.ClassDefinition.writeMethods(ClassDefinition.java:322)
    at org.jf.baksmali.Adaptors.ClassDefinition.writeVirtualMethods(ClassDefinition.java:307)
    at org.jf.baksmali.Adaptors.ClassDefinition.writeTo(ClassDefinition.java:136)
    at org.jf.baksmali.baksmali.disassembleDexFile(baksmali.java:191)
    at org.jf.baksmali.main.main(main.java:278)
opcode: const-string
CodeAddress: 28
Method: 
Lcom/android/settings/HDMIHelper$MirrorServiceConnection;->onServiceConnected(La
ndroid/content/ComponentName;Landroid/os/IBinder;)V

***I then ran it to include all jars in framework (shot in the dark). 

java -jar baksmali.jar -c 
:am.jar:android.policy.jar:android.test.runner.jar:bmgr.jar:bouncycastle.jar:com
.android.location.provider.jar:com.blockbuster.moto.lib.jar:com.cequint.platform
.jar:com.google.android.maps.jar:com.motorola.android.camera.jar:com.motorola.an
droid.customization.jar:com.motorola.android.datamanager.base.jar:com.motorola.a
ndroid.dlna.jar:com.motorola.android.drm1.jar:com.motorola.android.Firewall.jar:
com.motorola.android.frameworks.jar:com.motorola.android.iextdispservice.jar:com
.motorola.android.mediasync.jar:com.motorola.android.mime.jar:com.motorola.andro
id.mobad.jar:com.motorola.android.nativehdmiapis_v1.jar:com.motorola.android.tel
ephony.jar:com.motorola.android.widget.jar:com.motorola.android.wmdrm.jar:com.mo
torola.app.admin.jar:com.motorola.atcmd.base.jar:com.motorola.atcmd.pluginMgr.ja
r:com.motorola.blur.library.friendfeed.jar:com.motorola.blur.library.home.jar:co
m.motorola.blur.library.image.jar:com.motorola.blur.library.messaging.jar:com.mo
torola.blur.library.service.jar:com.motorola.blur.library.utilities.jar:com.scal
ado.android.photoeditor.jar:com.scalado.caps.jar:core.jar:core-junit.jar:dmt.jar
:ext.jar:framework.jar:guava.jar:ime.jar:input.jar:javax.obex.jar:jcifs-krb5-1.3
.12.jar:monkey.jar:pm.jar:services.jar:sqlite-jdbc.jar:svc.jar -x Settings.odex
Error while disassembling method 
Lcom/android/settings/HDMIHelper$MirrorServiceConnection;->onServiceConnected(La
ndroid/content/ComponentName;Landroid/os/IBinder;)V. Continuing.
org.jf.dexlib.Code.Analysis.ValidationException: class 
Lcom/motorola/android/mirrorservice/IMirrorService; cannot be resolved.
    at org.jf.dexlib.Code.Analysis.ClassPath$UnresolvedClassDef.unresolvedValidationException(ClassPath.java:535)
    at org.jf.dexlib.Code.Analysis.ClassPath$UnresolvedClassDef.getClassDepth(ClassPath.java:543)
    at org.jf.dexlib.Code.Analysis.ClassPath.getCommonSuperclass(ClassPath.java:383)
    at org.jf.dexlib.Code.Analysis.RegisterType.merge(RegisterType.java:275)
    at org.jf.dexlib.Code.Analysis.AnalyzedInstruction.mergeRegister(AnalyzedInstruction.java:185)
    at org.jf.dexlib.Code.Analysis.MethodAnalyzer.propagateRegisterToSuccessors(MethodAnalyzer.java:444)
    at org.jf.dexlib.Code.Analysis.MethodAnalyzer.setPostRegisterTypeAndPropagateChanges(MethodAnalyzer.java:424)
    at org.jf.dexlib.Code.Analysis.MethodAnalyzer.setDestinationRegisterTypeAndPropagateChanges(MethodAnalyzer.java:396)
    at org.jf.dexlib.Code.Analysis.MethodAnalyzer.analyzeConstString(MethodAnalyzer.java:1801)
    at org.jf.dexlib.Code.Analysis.MethodAnalyzer.analyzeInstruction(MethodAnalyzer.java:673)
    at org.jf.dexlib.Code.Analysis.MethodAnalyzer.analyze(MethodAnalyzer.java:208)
    at org.jf.baksmali.Adaptors.MethodDefinition.addAnalyzedInstructionMethodItems(MethodDefinition.java:353)
    at org.jf.baksmali.Adaptors.MethodDefinition.getMethodItems(MethodDefinition.java:290)
    at org.jf.baksmali.Adaptors.MethodDefinition.writeTo(MethodDefinition.java:130)
    at org.jf.baksmali.Adaptors.ClassDefinition.writeMethods(ClassDefinition.java:322)
    at org.jf.baksmali.Adaptors.ClassDefinition.writeVirtualMethods(ClassDefinition.java:307)
    at org.jf.baksmali.Adaptors.ClassDefinition.writeTo(ClassDefinition.java:136)
    at org.jf.baksmali.baksmali.disassembleDexFile(baksmali.java:191)
    at org.jf.baksmali.main.main(main.java:278)
opcode: const-string
CodeAddress: 28
Method: 
Lcom/android/settings/HDMIHelper$MirrorServiceConnection;->onServiceConnected(La
ndroid/content/ComponentName;Landroid/os/IBinder;)V

I went ahead to just try it and smali'd it back and got out.dex...renamed to 
classes.dex and stuck that bad boy into Settings.apk and pushed it to 
/system/app. chmod 644'd it. Rebooted and Settings is Force closing. 

Thanks for all your hard work doing this and also supporting it. This is why I 
love the android community

Original issue reported on code.google.com by MMWAg...@gmail.com on 30 Mar 2011 at 5:42

GoogleCodeExporter commented 9 years ago
Add all framework files via -c is *never* the correct solution. It can cause 
incorrect results in some cases.

It is doubly wrong to add all the framework files via the -c option using an 
initial ':' character. Using an initial ':' tells baksmali to append all those 
jars to the existing default bootclasspath that it uses (which matches the 
BOOTCLASSPATH on most "clean" google android devices). So you will actually end 
up with duplicate entries because the default bootclasspath has, for example, 
framework.jar, and you are adding an extra framework.jar.

And thirdly, the order of the bootclasspath list does matter. You should have 
the files in the same order as in your BOOTCLASSPATH environment variable, with 
any extra dependencies at the end. 

Now, to address your particular problem, you first need to specify the correct 
BOOTCLASSPATH to use via the -c option. Next, assuming that it still can't find 
the class, you need to find which jar or apk contains the class that it is 
complaining about, and then add it to the end of the classpath that baksmali 
searches.

To find which jar/apk the class is in, simply run baksmali without the -x 
option on every jar/apk in both /system/framework and /system/app (or on the 
associated odex files, as applicable - but still without the -x option). And 
then grep through the results for that class.

And finally, if that still doesn't resolve the issue, and you are 100% certain 
that the class doesn't exist at all on the device (which does happen on 
occasion), then you can use the -I option to ignore these "class not found" 
type errors. But if you use the -I option when the class does in fact exist 
somewhere on the device, it will likely cause a crash in the application - so 
be sure that the class really doesn't exist :)

Original comment by JesusFr...@gmail.com on 30 Mar 2011 at 6:12

GoogleCodeExporter commented 9 years ago
Wow. Thank you for the fast response!!

Thank you for clarifying for me the situation with the bootclasspaths.. Can you 
be more specific when you are explaining how to locate with BOOTCLASSPATHS I 
will need? 

When I run say for example:

java -jar baksmali.jar Settings.apk //I get the following:
UNEXPECTED TOP-LEVEL EXCEPTION:
org.jf.dexlib.DexFile$NoClassesDexException: zip file Settings.apk does not 
contain a classes.dex file
    at org.jf.dexlib.DexFile.<init>(DexFile.java:305)
    at org.jf.baksmali.main.main(main.java:250)

Does that look right? And is that what you want me to do but with all of them, 
correct? Definitely don't mind spending serious time on this one. 

Original comment by MMWAg...@gmail.com on 30 Mar 2011 at 6:27

GoogleCodeExporter commented 9 years ago
Right. That's because Settings.apk has no classes.dex file. You have to run it 
on the odex file, like I mentioned.

Also: you can run baksmali on every apk/jar manually if you want - but I would 
suggest some sort of automation - i.e. the gnu find utility, or a quick bash 
script or something. ;)

BOOTCLASSPATH is an environment variable on the device:

For example:

jesusfreke@knork:~$ adb shell
# echo $BOOTCLASSPATH
/system/framework/core.jar:/system/framework/bouncycastle.jar:/system/framework/
ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/sy
stem/framework/services.jar:/system/framework/core-junit.jar
# 

For that BOOTCLASSPATH, you would use the following option for baksmali:
-c 
core.jar:bouncycastle.jar:ext.jar:framework.jar:android.policy.jar:services.jar:
core-junit.jar

Original comment by JesusFr...@gmail.com on 30 Mar 2011 at 6:43

GoogleCodeExporter commented 9 years ago
Great! thank you. It makes a lot more sense now. And yeah. I have a lot of time 
but I'm not father time lol I'll try and get a bash script running. 

Thanks again for your help! You rock!

Original comment by MMWAg...@gmail.com on 30 Mar 2011 at 7:02

GoogleCodeExporter commented 9 years ago
You are maybe missing some jars, like in the case of the Cliq2 2.3 leak. See 
http://modmymobile.com/forums/654-motorola-cliq-2-development/563175-deodexing-t
utorial-3.html#post4103857 for the 2 missing jars :)

Original comment by adum...@gmail.com on 2 Sep 2011 at 2:07