nahidupa / smali

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

Error Decompiling #138

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What seems to be the problem?
Error occured while disassembling class Lcom.zynga.hanging.aux; - skipping class

java.io.IOException: The system cannot find the file specified
        at java.io.WinNTFileSystem.createFileExclusively(Native Method)
        at java.io.File.createNewFile(Unknown Source)
        at org.jf.baksmali.baksmali.disassembleDexFile(baksmali.java:181)
        at org.jf.baksmali.main.main(main.java:278)

What is the exact smali/baksmali command that you ran?
C:\smali>java -jar baksmali.jar "c:\apps\hwf\456\classes.dex" -o 
c:\apps\hwf\456\dump"

What version of smali/baksmali are you using? What rom are you working
from?
baksmali-1.3.3

What is the airspeed velocity of an unladen swallow?

Please provide any additional information below: error messages, symptoms,
etc.
I'm an app themer (strictly for personal use), and I was ready to theme a 
particular app. Unfortunately, for the aspects of this app that I've always 
themed, it requires 1 or two code changes, but baksmali will not decompile the 
dex file correctly. It has never been a problem in the past, but a quick glance 
at the file structure, it seems as though the code in this apk is now 
obfuscated, where in the past, it was not.

If I ignore the problem, smali doesn't throw any errors after I've made the 
necessary changes, but the app crashes. Checking the logcat after installing 
and running the newly smali'd apk, I see this:

E/AndroidRuntime( 4537): FATAL EXCEPTION: main
E/AndroidRuntime( 4537): java.lang.NoClassDefFoundError: com.zynga.hanging.aux

This leads me to believe that the problem lies with the decompilation performed 
by baksmali. Any insight into this error would be very highly appreciated. For 
reference, I've attached the problem classes.dex file. I would attach the 
entire APK, but it's a bit over the attachment limitation.

Original issue reported on code.google.com by putterpl...@gmail.com on 26 Aug 2012 at 7:28

Attachments:

GoogleCodeExporter commented 9 years ago
I am unable to reproduce, on linux at least.

It seems to be some sort of IO issue on windows, but I have no idea what might 
cause that. Did you try disassembling it again? Does the same error 
consistently happen on the same class?

Original comment by jesusfreke@jesusfreke.com on 26 Aug 2012 at 8:11

GoogleCodeExporter commented 9 years ago
Yes...it's the same class every time. Out of curiosity, I attempted to use a 
copy of Dedexer from April of this year, and it bugs on that same class as 
well. As you said you weren't able to reproduce in linux, I decided I'd try 
baksmali on a couple of my machines to see what's going on. Here are my results:

Win7 x64: Error, com.zynga.hanging.aux IS NOT present in dump
WinXP Pro x86: No error, com.zynga.hanging.aux IS NOT present in dump
Ubuntu x86: No error, com.zynga.hanging.aux IS present in dump

With that being said, since I'm able to decompile it without problems under 
linux, I think it would be safe to say that it's a windows problem.

Original comment by putterpl...@gmail.com on 27 Aug 2012 at 12:42

GoogleCodeExporter commented 9 years ago
Oh! I know what the problem is.

aux is a "special" filename on windows - you can't create a file named aux. 
Apparently, you can't even create it with an extension (like aux.smali).

Original comment by jesusfreke@jesusfreke.com on 27 Aug 2012 at 12:46

GoogleCodeExporter commented 9 years ago
That's definitely some useful information, and interesting as well. Just did 
some reading about it after reading your reply. Funny that I've never known 
that before. In that case, there's probably nothing that can be done about that 
for windows short of renaming the class. Even then, it would probably be near 
impossible to implement in the case that such a class is accessed via 
reflection.

Nonetheless, thanks a TON for pointing me in the right direction with that. For 
such things, I'll just use Linux. It will definitely save me from a headache if 
I ever run into it again in the future. :)

Original comment by putterpl...@gmail.com on 27 Aug 2012 at 7:15

GoogleCodeExporter commented 9 years ago
I'm actually not sure why this is happening. baksmali has logic that *should* 
rename this file to aux#.smali.

Can you try and create the following files, and let me know if they fail or 
not? (i.e. just create a blank file with the given name, in your favorite text 
editor, or whatever)

aux.smali  (pretty sure this one fails :))
con.smali  (this one should fail)
aux#.smali (this one *shouldn't* fail)

Original comment by jesusfreke@jesusfreke.com on 4 Sep 2012 at 12:11

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I have the same error.

Unable to create file smali\coN.smali - skipping class
Unable to create file smali\CoN.2.smali - skipping class
Unable to create file smali\aUX.smali - skipping class
Unable to create file smali\cOn.3.smali - skipping class
Unable to create file smali\Con.4.smali - skipping class
Unable to create file smali\AuX.2.smali - skipping class
Unable to create file smali\cON.5.smali - skipping class
Unable to create file smali\Aux.3.smali - skipping class
Unable to create file smali\AUX.4.smali - skipping class
Unable to create file smali\con.6.smali - skipping class
Unable to create file smali\COn.7.smali - skipping class
Unable to create file smali\aUx.5.smali - skipping class
Unable to create file smali\aux.6.smali - skipping class
Unable to create file smali\auX.7.smali - skipping class
Unable to create file smali\AUx.8.smali - skipping class
Unable to create file smali\CON.8.smali - skipping class

That`s due to windows fs restrictions. Maybe be can rename such files like this:
aux.1.smali > aux1.smali(we can create file with this name). If we use 
aux.1.smali windows thinks that 1.smali is extension and file name is aux(we 
can`t create file with such name). 

Wiki says that we can`t use such names:
CON, PRN, AUX, CLOCK$, NUL
COM0, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9
LPT0, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9

So we can`t rename com.1.smali to com1.smali

As result maybe the best solution is to rename files like this:
aux.1.smali > aux_1.smali
com1.smali > com1_.smali
com.smali > com_.smali

Original comment by furn...@gmail.com on 4 Sep 2012 at 6:12

GoogleCodeExporter commented 9 years ago
There already is logic to rename these reserved files. I don't understand why 
it's not getting triggered though.

Can either one of you test whether modifyWindowsReselvedFilenames is getting 
set to true or false, in 
util/src/main/java/org/jf/util/ClassFileNameHandler.java. You can just add a 
System.out.println after it gets set, on line 51.

Original comment by jesusfreke@jesusfreke.com on 4 Sep 2012 at 7:00

GoogleCodeExporter commented 9 years ago
It returns false. But how baksmali manages to create aux.smali and con.smali? - 
thats strange.

By the way. Can you fix one more windows issue. On windows baksmali shows 
"test" message during disassembling. It makes me crazy. On my linux desktop 
console stays clean. If you don`t want remove this message maybe you can say 
how can i remove it myself?

If you need more tests to fix this issue i`ll help you.

Original comment by furn...@gmail.com on 4 Sep 2012 at 9:24

GoogleCodeExporter commented 9 years ago
I made more tests - tried to set modifyWindowsReselvedFilenames = true

Now baksmali decompiles con.smali(renames to con#.smali) and aux smali(renames 
to aux#.smali) but still can`t decompile all other files. Baksmali don`t 
renames CoN.2.smali to CoN#.2.smali and so on.

Unable to create file out\CoN.2.smali - skipping class
Unable to create file out\cOn.3.smali - skipping class
Unable to create file out\Con.4.smali - skipping class
Unable to create file out\AuX.2.smali - skipping class
Unable to create file out\cON.5.smali - skipping class
Unable to create file out\Aux.3.smali - skipping class
Unable to create file out\AUX.4.smali - skipping class
Unable to create file out\con.6.smali - skipping class
Unable to create file out\COn.7.smali - skipping class
Unable to create file out\aUx.5.smali - skipping class
Unable to create file out\aux.6.smali - skipping class
Unable to create file out\auX.7.smali - skipping class
Unable to create file out\AUx.8.smali - skipping class
Unable to create file out\CON.8.smali - skipping class

PS: maybe it`s better don`t check if we can create files, but detect OS.
Example: 
http://www.mkyong.com/java/how-to-detect-os-in-java-systemgetpropertyosname/

Original comment by furn...@gmail.com on 4 Sep 2012 at 3:13

GoogleCodeExporter commented 9 years ago
Ok, I've fixed the Con.2.smali issue.

Now, I just need to figure out why modifyWindowsReselvedFilenames isn't working 
properly. Can you try the attached baksmali.jar, and respond back with it's 
output? I sprinkled in some Here<N> messages in strategic locations in 
modifyWindowsResolvedFilenames

Original comment by jesusfreke@jesusfreke.com on 5 Sep 2012 at 4:10

Attachments:

GoogleCodeExporter commented 9 years ago
here3
testhere5

Then skipping all classes as before. And as i said - it shows test in windows.

Original comment by furn...@gmail.com on 5 Sep 2012 at 5:39

GoogleCodeExporter commented 9 years ago
Ha! I know what it's doing. When I open and try to write con.smali - it is 
succeeding - but it doesn't open/create con.smali. It opens con (i.e. stdout), 
and writes to it!

Original comment by jesusfreke@jesusfreke.com on 5 Sep 2012 at 6:18

GoogleCodeExporter commented 9 years ago
Can you confirm the attached version works now?

Original comment by jesusfreke@jesusfreke.com on 5 Sep 2012 at 6:37

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks. In my case everything works now. Baksmali renames all aux and con files 
and no "test" message :). Hope in Putterplace case everything will work too.

Original comment by furn...@gmail.com on 5 Sep 2012 at 7:41

GoogleCodeExporter commented 9 years ago
Great! The fix is committed. Thanks for the help tracking this one down.

Original comment by jesusfreke@jesusfreke.com on 5 Sep 2012 at 7:45