Forever king's Guide
How to extract system.img or Data.img
Want to Extract your precious files from your Nandroid backup?
You can do this easily by following this guide.
How to unyaffs (extracting system.img/data.img)
1 Download and extract Unyaffs In any folder
2 Now place you system.img/data.img in the folder in which you extracted unyaffs files.
3 Now open your Command prompt and CD to that folder (if windows7 just press shift+right click on that folder having things )
4 For extracting system.img
Type unyaffs.exe system.img
For extracing data.img
Type unyaffs.exe data.img
5 Done.
When Done you will see 'end of the line'.
So it was easy! Press Thanks if it worked for you. Are you having any problems while following it? Please Reply to the thread, I'm here to help you.
Thanks...it helped me a lot
---------- Post added at 05:54 AM ---------- Previous post was at 05:46 AM ----------
Hi i get an error while dumping stack...any help?
This is what i am getting..
Code:
D:\\unyaffs>unyaffs.exe system.img
36 [main] unyaffs 668 _cygtls::handle_exceptions: Exception: STATUS_ACCESS_
VIOLATION
35983 [main] unyaffs 668 open_stackdumpfile: Dumping stack trace to unyaffs.ex
e.stackdump
1362463 [main] unyaffs 668 _cygtls::handle_exceptions: Exception: STATUS_ACCESS_
VIOLATION
1394073 [main] unyaffs 668 _cygtls::handle_exceptions: Error while dumping state
(probably corrupted stack)
D:\unyaffs>
Can you post some screenies of successful case.?
viijay4b7 said:
This is what i am getting..
Code:
D:\\unyaffs>unyaffs.exe system.img
36 [main] unyaffs 668 _cygtls::handle_exceptions: Exception: STATUS_ACCESS_
VIOLATION
35983 [main] unyaffs 668 open_stackdumpfile: Dumping stack trace to unyaffs.ex
e.stackdump
1362463 [main] unyaffs 668 _cygtls::handle_exceptions: Exception: STATUS_ACCESS_
VIOLATION
1394073 [main] unyaffs 668 _cygtls::handle_exceptions: Error while dumping state
(probably corrupted stack)
D:\unyaffs>
Can you post some screenies of successful case.?
Click to expand...
Click to collapse
dude! this comes only when your system.img/data.img's size is 150+ mb this is old version! i have done full decompiling! with no error!
forever king said:
dude! this comes only when your system.img/data.img's size is 150+ mb this is old version! i have done full decompiling! with no error!
Click to expand...
Click to collapse
Thanks for the info.
So, what is the solution for me? mine is about 400MB i guess. Also I hope it is ext4. Do you have a link to ext4 tools?
Exactly I need to extract my system.img so i can pull the fresh /system/build.prop from it. The file size is 500MB how do I extract it's contents?
thanks
Ext2Read its the solution for ext4 .img files on windows
Yep, it did the trick for me, thanks for the tips.
You can use Yaffe tool for extracting files sizing more than 150 MB.
http://forum.xda-developers.com/showthread.php?t=2294909
Check this topic
"The program can't start because cygwin1.dll is missing from your computer. Try reinstalling the program to fix this problem."
how to extract data.img ?
$ file data.img
data.img: data
Click to expand...
Click to collapse
I'll try
How do i extract the system.img straight from the phone? There is no available firmware for mine
Related
Starting with ababrekar's brilliant expose' on how to manually port an XIP from one device to another, there has been a great deal of attention paid to the process of getting the XIP.BIN isolated from the rest of the ROM.
I thought that I could try to contribute with the information others have shared with me. Ultimately, it may prove to be beneficial if there were a development thread dedicated to extracting the XIP.BIN.
credit to dcd, vetvito, ababrekar, gguruusa, lennysh. noonski and of course, all those who develop and update the various tools!
First off, you're best off if you start with a RUU/WWE from HTC/Sprint/Bell. etc.
1) The very first step in this process is to extract the NBH file that includes the OS. Do this by using WinRAR or WinZip to open the executable and look for the largest file with the extension NBH. In the case of our example, that file is VOGUIMG.nbh.
2) The next step is to break VOGUIMG.nbh into it's various pieces by executing the following:
Code:
nbhextract.exe VOGUIMG.nbh
The result is the following screen output:
Code:
=== NBHextract v1.0
=== Extract contents from HTC NBH files
=== (c)2007 xda-developers.com
=== by: pof & TheBlasphemer based on itsme perl scripts
Device: VOGU10000
CID: VZW__001
Version: 3.14.605.1
Language: USA
Extracting: 00_SPL.nb
Extracting: 01_MainSplash.nb
Encoding: 01_MainSplash.bmp
Extracting: 02_SubSplash.nb
Encoding: 02_SubSplash.bmp
Extracting: 03_Unknown.nb
Extracting: 04_OS.nb
We are after the XIP, which is contained within the file 04_OS.nb
3) The next step is to break 04_OS.nb into it's various pieces by executing the following:
Code:
nbsplit.exe –titan 04_OS.nb
The result is the following files:
Code:
04_OS.nb.extra
04_OS.nb.payload
We're still not there yet, as the XIP is contained inside 04_OS.nb.payload.
The address where the XIP.BIN ends can be found with imgfsfromnb:
Code:
rename 04_OS.nb.payload to OS.nb.payload
imgfsfromnb OS.nb.payload imgfs.bin
output:
Sector size is 0x800 bytes
ImgFs partition starts at 0x00680000 and ends at 0x05680000
Dumping IMGFS at offset 0x006c0000 (size 0x04fc0000)
Click to expand...
Click to collapse
In the next step, we use RomMaster and we feed it the start address and end address of the XIP.
Remember, these start and end addresses will vary from device to device and in the case of the same device but a custom rom, the address can vary from one custom rom to the other.
Ababrekar has suggested "the best way to find out the start address for each partition would be from the LBA in MBR region"
In the case of the Vogue, when dealing with non-custom ROMs, the XIP usually begins at 0x00320000.
So, the start address is 0x00320000 and you use imgfsfromnb.exe to get the end address 0x006c0000 and feed these two parameters as part of the input to RomMaster:
Code:
RomMaster.exe -x -w 5 -s 0x00320000 -e 0x006c0000 OS.nb.payload -o xip.bin
What this does is output a file (XIP.BIN) comprised of all the data between the two (-s START -e END) addresses (-s 0x00320000 -e 0x006c0000) fed into RomMaster.
XIP.BIN
None of this have I discovered myself. It is a compilation of instructions that I received from members credited above. What we could do with this thread is use it as a discussion point for others who have or are having problems getting the XIP out of the os.nb.payload.
Best regards,
-boggsie
bookmarked!
thank you very much for this information!
Awesome to see people like you getting such amazing info ot inthe open This is bound to help many Thanks and bookmarked to keep an eye on it
Do you know a way to get the XIP from a *.bin emulator image?
frauhottelmann said:
Do you know a way to get the XIP from a *.bin emulator image?
Click to expand...
Click to collapse
Anyone found answer for this?
Hi all,
I've been trying to create a simple update.zip signed folder for my HTC Hero.
I have read all different "how to" but still face the same error message "Syntax error in update script"
I have copy/paste the following into the update-script
show_progress 0.1 0
copy_dir PACKAGE:system SYSTEM:
set_perm_recursive 0 0 0755 0644 SYSTEM:app
show_progress 0.1 10
i have create 2 folders.
1. system/app (here i have placed my APK)
2. META-INF/com/google/android/update-script
Now, i have made a ZIP file including the 2 folders.
I am using the autosign.bat and i manually select the ZIP file i created.
Everything is going ok, but then i get the Syntax error in update script when i try to run this using Amon Ra's bootloader.
Any suggestion or ideas?
I did it!!!
The problem was the extra " " space i had on the last script line!
Now, it works!
Another question. Is there a way to sign zip files on OS X?
Can you point me on the right direction pls?
http://www.mediafire.com/?j0anq7kfe...ajlhunt3jras6,c92jlnxd3vdngn8,i6hqic38gc4h68d
system is ext4 image, can be mounted with mount -o loop in linux or by utilizing latest version of ext3 driver ( 0.51 ) for windows.
Can me give someone the WLAN widget with the GPS think in?
Gesendet von meinem R800i
is it the system dump from xperia s...?????
is it dump? real one?
Sent from my X10i using XDA App
works on xperia arc s ?
download, extract, sin2img, mount, get files
Sent from my X10i using XDA App
how you get this ...??????
can someone help me with this Im stuck on mounting the annoying img file
tatit1011 said:
can someone help me with this Im stuck on mounting the annoying img file
Click to expand...
Click to collapse
you can unpack it without mounting, by using unyaffs : http://code.google.com/p/unyaffs/
It says broken image file, can someone upload the xperia S system folder? Thanks
can you provide the binaries you are using to unpack this ?
1- extrating with 7zip : Ok, there are 3 .sin files
2- sin2img I already had : Crash
3- I tried an other version : Ok ... but the .img file size is exactly the same as the .sin ...
4- unyaffs : Crash !
So I think I don't have the good binaries ...
Thanks
sambastrakan said:
can you provide the binaries you are using to unpack this ?
1- extrating with 7zip : Ok, there are 3 .sin files
2- sin2img I already had : Crash
3- I tried an other version : Ok ... but the .img file size is exactly the same as the .sin ...
4- unyaffs : Crash !
So I think I don't have the good binaries ...
Thanks
Click to expand...
Click to collapse
THIS IS NOT YAFFS THIS IS EXT4
JUST MOUNT THE IMG IN LINUX AS EXT 4
(i hav not.done myself, I'm jus saying)
Sent from my X10i using XDA App
I also tried to mount the .img in DiskInternals Linux Reader without success. Until today it was working for any image available in xda-dev... so I think there is something special with these images ...
I will try directly in Linux to see ...
thx.
I can confirm it's not working.
Latest sin2img version gives a FileStream.Seek ArgumentException "Attempted seeking before the beginning of the stream.".
An older version creates an img file the same size as the sin, but unyaffs crashes with a segmentation fault / core dump and:
[email protected]:~$ dmesg | tail
[44637.019046] unyaffs[18031]: segfault at 1adb2b2c0 ip 0000000000400a08 sp 00007fffba023ca0 error 4 in unyaffs[400000+1000]
Click to expand...
Click to collapse
No mounting either, 'cause:
[email protected]:~$ sudo mount -t ext4 -o loop system.img /mnt/mountpoint/
mount: wrong fs type, bad option, bad superblock on /dev/loop0,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so
[email protected]:~$ dmesg | tail
[44678.194165] EXT4-fs (loop0): VFS: Can't find ext4 filesystem
Click to expand...
Click to collapse
So, wasted time, I guess...
zdzihu has some tool to extract the package try that one. I think it's called auip.exe
ShyamSasi said:
zdzihu has some tool to extract the package try that one. I think it's called auip.exe
Click to expand...
Click to collapse
Thanks, but no luck with that one either. It keeps telling me the page size is wrong (tried with all three options)
Code:
[email protected]:~$ ./aIUP
aZuZu - Direct SIN / YAFFS Image Unpacker, v1.03.5. (c) aZuZu. 2011.
usage adiup [System.Img OR System.Sin] [Page Size] [Directory]
page size is one of 2048, 4096, 8192. - Sorry to lazy to encode auto detect. ;)
Tip: Directory - directory will be created if doesn't exist.
Supported: SE System.SIN files & Android System.IMG files.
[email protected]:~$ ./aIUP system.sin 4096 test/
UnPacking system.sin to test/ ...
Error: Page size parameter is wrong.
done.
[email protected]:~$ ./aIUP system.sin 2048 test/
UnPacking system.sin to test/ ...
Error: Page size parameter is wrong.
done.
[email protected]:~$ ./aIUP system.sin 8192 test/
UnPacking system.sin to test/ ...
Error: Page size parameter is wrong.
done.
Same for the .img file.
crimilde said:
Thanks, but no luck with that one either. It keeps telling me the page size is wrong (tried with all three options)
Code:
[email protected]:~$ ./aIUP
aZuZu - Direct SIN / YAFFS Image Unpacker, v1.03.5. (c) aZuZu. 2011.
usage adiup [System.Img OR System.Sin] [Page Size] [Directory]
page size is one of 2048, 4096, 8192. - Sorry to lazy to encode auto detect. ;)
Tip: Directory - directory will be created if doesn't exist.
Supported: SE System.SIN files & Android System.IMG files.
[email protected]:~$ ./aIUP system.sin 4096 test/
UnPacking system.sin to test/ ...
Error: Page size parameter is wrong.
done.
[email protected]:~$ ./aIUP system.sin 2048 test/
UnPacking system.sin to test/ ...
Error: Page size parameter is wrong.
done.
[email protected]:~$ ./aIUP system.sin 8192 test/
UnPacking system.sin to test/ ...
Error: Page size parameter is wrong.
done.
Same for the .img file.
Click to expand...
Click to collapse
What is your page files size? Those 3 are just examples. You need to find the page file of your PC.
ShyamSasi said:
What is your page files size? Those 3 are just examples. You need to find the page file of your PC.
Click to expand...
Click to collapse
Ah ok, sorry.
It's :
[email protected]:~$ getconf PAGESIZE
4096
Click to expand...
Click to collapse
Which I had already tried.
crimilde said:
Ah ok, sorry.
It's :
Which I had already tried.
Click to expand...
Click to collapse
I'll download it and try it today.
ShyamSasi said:
I'll download it and try it today.
Click to expand...
Click to collapse
yap please sone one fine a way to unpack it .......... ????
i am waiting too for it
[DEV_TOOL] HTC ROM EXTRACTOR
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Tools for working with firmware HTC in LINUX
fit Kenny Millington Source kmdm
(HOW TO)
PUSH THE BUTTON
! Requirements (libunshield v0.7 or higher):
Code:
$ sudo apt-get install automake
$ git clone https://github.com/kmdm/unshield.git
$ cd unshield/
$ git checkout -t origin/v18\_wip
$ ./bootstrap
$ ./configure --prefix=/usr
$ make
$ sudo make install
1. Extract from the zip and put the RUUXXXXXXXXX.exe to a folder with the tool;
2. Run in Terminal rom-extractor file and select the option:
MAIN MENU
u - UNRUU EXE TO ZIP - extract from the file rom.zip RUU.exe
d - DECRYPT MENU > DECRYPT MENU ROM.ZIP > OUTPUT.ZIP
r - REPACK MENU > REPACK MENU
e - ENCRYPT MENU >
c - CLEAN TOOL - Unmount and remove temporary files
x - exit
> DECRYPT MENU ROM.ZIP > OUTPUT.ZIP
1 ... 24 - decode the file rom.zip output.zip (select the target device)
> REPACK MENU
e - EXTRACT ZIP ROM - to extract the firmware from the ROM folder output.zip
m - MOUNT SYSTEM (EXT4 ONLY) - mount the partition image system.img in the folder system (you can add \ remove the firmware files)
d - DESPARSE SYSTEM.IMG (EXT4 ONLY) - uncompress the sparse image system.img (depending on the device - some zhaty, some not (determined EXPERIMENTAL)) and mount the partition image system.img in the folder system (you can add \ remove the firmware files)
s - MAKE SPARSE SYSTEM.IMG (EXT4 ONLY) - the creation of a sparse image sistem.img (you must specify the size of the partition XXXXM (device) - for example ONE X = 1280M)
n - UNMOUNT SYSTEM - dismount and delete the folder system
z - ADD SYSTEM.IMG > OUTPUT.ZIP - add new edited system.img into output.zip
> ENCRYPT MENU OUTPUT.ZIP > ROM.ZIP
1 ... 24 - create encrypt new rom.zip from output.zip
Thanks
as i9000 said:
[DEV_TOOL] HTC ROM EXTRACTOR
Tools for working with firmware HTC in LINUX
fit Kenny Millington Source
(HOW TO)
PUSH THE BUTTON
! Requirements (libunshield v0.7 or higher):
Code:
$ git clone https://github.com/kmdm/unshield.git
$ cd unshield/
$ git checkout -t origin/v18\_wip
$ ./bootstrap
$ ./configure --prefix=/usr
$ make
$ sudo make install
1. Extract from the zip and put the firmware. Exe to a folder with the tool;
2. Run in Terminal rom-extractor file and select the option:
u - extract from the file rom.zip RUU.exe
1 ... 21 - decode the file rom.zip output.zip (select the target device)
e - to extract the firmware from the ROM folder output.zip
m - mount the partition image system.img in the folder system (you can add \ remove the firmware files)
n - dismount and delete the folder system
c - Clean all tools
x - exit
d - uncompress the sparse image system.img (depending on the device - some zhaty, some not (determined EXPERIMENTAL)) and mount the partition image system.img in the folder system (you can add \ remove the firmware files)
s - the creation of a sparse image sistem.img (you must specify the size of the partition XXXXM (device) - for example ONE X = 1280M)
Click to expand...
Click to collapse
i can not work and i can not runnig
R: [DEV_TOOL] HTC ROM EXTRACTOR extract RUU & repack system.img
lauri_ylonen said:
i can not work and i can not runnig
Click to expand...
Click to collapse
This is only for linux
Inviato dal mio GT-I9070 con Tapatalk 2
Are there plans to add the One S?
Nm. Just looked at the source.... Oops.
bedwa said:
Are there plans to add the One S?
Nm. Just looked at the source.... Oops.
Click to expand...
Click to collapse
INFO FOR ALL...
If your device is not supported and you would like it supported please open an issue in the tracker with the device name, codename and a link to the most recent hboot file for the device. (Not a link to the full RUU!)
Click to expand...
Click to collapse
Kenny Milington https://github.com/kmdm/ruuveal
anything more?..
I promise to add new binaries in my instrument as we update source
Not as all. The oops was cause I looked at the source and noticed the unpacker was One S supported. Lol.
Fixed a typo in paragraph 21
HTC One VX (tc2) > HTC One S (ville)
add
HTC_ROM-EXTRACTOR_v.0.0.3_x64
it seems that I'm doing something wrong.
[email protected]:~$ git clone https://github.com/kmdm/unshield.git
Cloning into 'unshield'...
remote: Counting objects: 569, done.
remote: Compressing objects: 100% (208/208), done.
remote: Total 569 (delta 370), reused 545 (delta 346)
Receiving objects: 100% (569/569), 116.31 KiB | 204 KiB/s, done.
Resolving deltas: 100% (370/370), done.
[email protected]:~$ cd unshield/
[email protected]:~/unshield$ git checkout -t origin/v18\_wip
Branch v18_wip set up to track remote branch v18_wip from origin.
Switched to a new branch 'v18_wip'
[email protected]:~/unshield$ ./bootstrap
Creating configure.ac...done.
+ aclocal -I m4
./bootstrap: 29: ./bootstrap: aclocal: not found
[email protected]:~/unshield$
Click to expand...
Click to collapse
can anyone help?
Maybe a more step-bystep guide,
Sorry for been noob
andrewschumi said:
it seems that I'm doing something wrong.
can anyone help?
Maybe a more step-bystep guide,
Sorry for been noob
Click to expand...
Click to collapse
sudo apt-get install automake
Added
v.o.o.4
22 - HTC One U (m7_u)
23 - HTC One UL (m7_ul)
24 - HTC Desire SV (magnids)
ADDED v.0.0.5
REBUILD TOOL
ADDED ENCRYPT MENU!!!
as i9000 said:
ADDED v.0.0.5
REBUILD TOOL
ADDED ENCRYPT MENU!!!
Click to expand...
Click to collapse
Could you please help? unruu never completes. It gives me this
Extracting temporary files...
Extracting rom zip files...
./unruu_exe: line 8: 4379 Aborted (core dumped) ./unruu ruu.exe
failed to open source zip: No such file or directory
That last line fails because decrypt is looking for a zip that was never made.
If i do ./unruu ruu.exe , I am given the following
[email protected]:~/Desktop/HTC_ROM-EXTRACTOR_v.0.0.5/tools$ ./unruu ruu.exe
Extracting temporary files...
Extracting rom zip files...
Aborted (core dumped)
Click to expand...
Click to collapse
this was done as root with the same result.
Perhaps I need to switch to all i386 binaries? Ill try that, but i was trying to avoid it, as it will break my current nvidia driver setup. ohwell
Tilde88 said:
Could you please help? unruu never completes. It gives me this
Extracting temporary files...
Extracting rom zip files...
./unruu_exe: line 8: 4379 Aborted (core dumped) ./unruu ruu.exe
failed to open source zip: No such file or directory
That last line fails because decrypt is looking for a zip that was never made.
If i do ./unruu ruu.exe , I am given the following
this was done as root with the same result.
Perhaps I need to switch to all i386 binaries? Ill try that, but i was trying to avoid it, as it will break my current nvidia driver setup. ohwell
Click to expand...
Click to collapse
Did you do this?
! Requirements (libunshield v0.7 or higher):
Code:
$ sudo apt-get install automake
$ git clone https://github.com/kmdm/unshield.git
$ cd unshield/
$ git checkout -t origin/v18\_wip
$ ./bootstrap
$ ./configure --prefix=/usr
$ make
$ sudo make install
Added version 0.0.6 x86-64
25 - HTC One WLS (m7_wls)
26 - HTC One SV (k2_u)
27 - HTC One SV (k2_plc_cl)
as i9000 said:
Did you do this?
! Requirements (libunshield v0.7 or higher):
Code:
$ sudo apt-get install automake
$ git clone https://github.com/kmdm/unshield.git
$ cd unshield/
$ git checkout -t origin/v18\_wip
$ ./bootstrap
$ ./configure --prefix=/usr
$ make
$ sudo make install
Click to expand...
Click to collapse
lol yes of course
Tilde88 said:
lol yes of course
Click to expand...
Click to collapse
OK, try to extract some different rom, may be you has problem from invalid ruu.exe..
and more, what size have your ruu.exe? - x32 systems, can't handle files largest 2GB...
as i9000 said:
OK, try to extract some different rom, may be you has problem from invalid ruu.exe..
and more, what size have your ruu.exe? - x32 systems, can't handle files largest 2GB...
Click to expand...
Click to collapse
im running x64, tried with x64 binaries, and i also tried using 32bit binaries. furthermore, my RUU is onlt 1.15GB. Also, x86 (there is not such thing as x32) can handle 3gb files.
thanks so much for the tool though, everything else workes, I juse used a script I found from another developer to get the .zip, then used your tool for all the other features.
Tilde88 said:
im running x64, tried with x64 binaries, and i also tried using 32bit binaries. furthermore, my RUU is onlt 1.15GB. Also, x86 (there is not such thing as x32) can handle 3gb files.
thanks so much for the tool though, everything else workes, I juse used a script I found from another developer to get the .zip, then used your tool for all the other features.
Click to expand...
Click to collapse
Well then stay one variant - you doesn't installed "Unshield", try run terminal and input 'unsield'
here the correct conclusion:
Code:
~$ unshield
No action provided on command line.
Syntax:
unshield [-c COMPONENT] [-d DIRECTORY] [-D LEVEL] [-g GROUP] [-i VERSION] [-GhlOrV] c|g|l|t|x CABFILE [FILENAME...]
Options:
-c COMPONENT Only list/extract this component
-d DIRECTORY Extract files to DIRECTORY
-D LEVEL Set debug log level
0 - No logging (default)
1 - Errors only
2 - Errors and warnings
3 - Errors, warnings and debug messages
-g GROUP Only list/extract this file group
-h Show this help message
-i VERSION Force InstallShield version number (don't autodetect)
-j Junk paths (do not make directories)
-L Make file and directory names lowercase
-O Use old compression
-r Save raw data (do not decompress)
-V Print copyright and version information
Commands:
c List components
g List file groups
l List files
t Test files
x Extract files
Other:
CABFILE The file to list or extract contents of
FILENAME... Optionally specify names of specific files to extract (wildcards are supported)
hi is there any chance to add the Desire HD. As i am trying to merge a Orange UK RUU for Desire DHD and they never released the last RUU with all the OTA's to make a New RUU with all the OTA's included.
I have made a Nandroid backup after all the OTA's was installed to the phone i even have all the OTA's just need a way to extract the rom.zip (easy from exe file not a issue) add the changed .img files such as radio, system, hboot recovery rcdata lib.img and make a new rom.zip and ruu.exe any way this can be done just tried with your tool and got invalid htc aes encrypted zip.
Thanks in advance
THIS GUIDE HAS BEEN TESTED ON KITKAT, MARSHMALLOW AND NOUGAT
When you have a system app with an odex file like bluetooth.apk and bluetooth.odex you can't use apktool for decompile and there is no need for deodex the whole ROM, follow this guide to decompile and mod one of these apps and nothing else.
REQUIREMENTS
- Be root
- platform-tools folder : lastest version download
- Java installed
- Files: baksmali.jar, smali.jar and zipalign.exe.
SET UP
- Make a folder named "Baksmali" and place these files: baksmali.jar, smali.jar, zipaling.exe, the apk and it's odex file
- Place the platform-tools folder in Baksmali folder and rename it to framework.
- Make sure the files are named baksmali.jar and smali.jar for simplicity , not baksmali-somenumber.jar. This is optional but keep in mind that in the commands i will assume these files are named like that so if you don't you'll have to replace with their real names like baksmali-2.0.0.jar
I i attached a zip with the complete Baksmali folder, but keep in mind this folder was created in feb 2016, you may need download manually the latest files to make sure if you got any errors it's not because of outdated versions
DECOMPILE
- Conect your device to the PC
- Go to Backsmali/framework
- Right click + SHIFT on an empty space of the folder and select "open command window here" and write:
adb pull /system/framework/arm/boot.oat boot.oat
For kitkat: adb pull /system/framework
- Go to Baksmali folder
- Right click + SHIFT on an empty space of the folder and select "open command window here" and write this command (replace NAME with the name of your odex file):
java -jar baksmali.jar -x -c boot.oat -d framework NAME.odex -o out
For Kitkat = java -jar baksmali.jar -d framework -x NAME.odex
- The files should be in the "out" folder now created
COMPILE
This way you can create a classes.dex so then you can place it in an apk so the apk is not more dependent of the odex file.
- Again in Baksmali folder Right click + SHIFT and select "open command window here":
java -jar smali.jar -o classes.dex out
Now open the APK file with 7zip/winrar and drag the file classes.dex, confirm and exit.
write this command:
zipalign -v 4 apk.apk new_apk.apk
apk: name of the apk we just added classes.dex file
new_apk: apk generated by zipaling, ready to use in the device
PLACE APP IN THE DEVICE
Rename the new_apk to the original name, and with a root explorer place it in system/app with permisions rw-r-r, remember deleting the odex file in that folder.
Update Marhsmallow: Delete the folder APKNAME in system/app and paste the apk in with permisions rw-r-r
If when you open the app crashes always try rebooting
Hello
Thank you for your guide.
I am trying to decompile the Settings.apk in order to solve some translations issues in a flash-able ROM.
In the priv-app/Settings folder there is a Settings.odex file, so i tried to follow your guide to decompile the whole thing.
The following command gives me an error, i think there is some version mismatch here:
java -jar baksmali-2.1.0.jar -d framework -x Settings.odex
Exception in thread "main" org.jf.dexlib2.DexFileFactory$UnsupportedOatVersionException: Unsupported oat version: 39
at org.jf.dexlib2.DexFileFactory.loadDexFile(DexFileFactory.java:147)
at org.jf.dexlib2.DexFileFactory.loadDexFile(DexFileFactory.java:78)
at org.jf.baksmali.main.main(main.java:266)
I am copying the needed files (framework, Settings.odex/apk) from the Zip ROM, not from the phone, i guess this isnt an issue right?
luismpc said:
Hello
Thank you for your guide.
I am trying to decompile the Settings.apk in order to solve some translations issues in a flash-able ROM.
In the priv-app/Settings folder there is a Settings.odex file, so i tried to follow your guide to decompile the whole thing.
The following command gives me an error, i think there is some version mismatch here:
java -jar baksmali-2.1.0.jar -d framework -x Settings.odex
Exception in thread "main" org.jf.dexlib2.DexFileFactory$UnsupportedOatVersionException: Unsupported oat version: 39
at org.jf.dexlib2.DexFileFactory.loadDexFile(DexFileFactory.java:147)
at org.jf.dexlib2.DexFileFactory.loadDexFile(DexFileFactory.java:78)
at org.jf.baksmali.main.main(main.java:266)
I am copying the needed files (framework, Settings.odex/apk) from the Zip ROM, not from the phone, i guess this isnt an issue right?
Click to expand...
Click to collapse
Idk maybe you should try adb pull to extract the framework from the phone, also the last versión of baksmali is 2.1.1 you got them all here.
The folder i share has the lastest versión of both.
Note Im not a dev, i made this step by step guide because i dind't find in google something clear about it and took me a long time to make it work.
I followed this guide here and i was able to decompile my file, thanks
luismpc said:
Hello
Thank you for your guide.
I am trying to decompile the Settings.apk in order to solve some translations issues in a flash-able ROM.
In the priv-app/Settings folder there is a Settings.odex file, so i tried to follow your guide to decompile the whole thing.
The following command gives me an error, i think there is some version mismatch here:
java -jar baksmali-2.1.0.jar -d framework -x Settings.odex
Exception in thread "main" org.jf.dexlib2.DexFileFactory$UnsupportedOatVersionException: Unsupported oat version: 39
at org.jf.dexlib2.DexFileFactory.loadDexFile(DexFileFactory.java:147)
at org.jf.dexlib2.DexFileFactory.loadDexFile(DexFileFactory.java:78)
at org.jf.baksmali.main.main(main.java:266)
I am copying the needed files (framework, Settings.odex/apk) from the Zip ROM, not from the phone, i guess this isnt an issue right?
Click to expand...
Click to collapse
The guide worked on KitKat, now is updated to work on Marhsmallow, you can use the new method maybe also works on Lollipop...
This guide worked wonderfully for me. I was able to decompile and recompile a system apk for Marshmallow. Thank you!
Is there a way to convert the smali files to java for Marshmallow apks (dex2jar)?
Everything worked great up until the compile part. I got an error saying "mismatched d input '' expecting END_METHOD_DIRECTIVE"
See photo attached. Anyone have any idea how to fix this so I can compile a classes.dex for my SystemUI?
Also, I just upgraded to Android N if that makes a difference...
I tried for a Marshmallow file and get this error, also I did update smali and baksmali to the latest files;
Code:
C:\Baksmali>java -jar baksmali.jar -x -c boot.oat -d framework LGSystemUI.odex -o out
Exception in thread "main" com.beust.jcommander.ParameterException: Unknown option: -x
at com.beust.jcommander.JCommander.parseValues(JCommander.java:742)
at com.beust.jcommander.JCommander.parse(JCommander.java:282)
at com.beust.jcommander.JCommander.parse(JCommander.java:265)
at org.jf.baksmali.Main.main(Main.java:90)
Thanks
Good guide. Also working in 7.1.1
neo4uo said:
I tried for a Marshmallow file and get this error, also I did update smali and baksmali to the latest files;
Code:
C:\Baksmali>java -jar baksmali.jar -x -c boot.oat -d framework LGSystemUI.odex -o out
Exception in thread "main" com.beust.jcommander.ParameterException: Unknown option: -x
at com.beust.jcommander.JCommander.parseValues(JCommander.java:742)
at com.beust.jcommander.JCommander.parse(JCommander.java:282)
at com.beust.jcommander.JCommander.parse(JCommander.java:265)
at org.jf.baksmali.Main.main(Main.java:90)
Thanks
Click to expand...
Click to collapse
you don't need the "-x" for baksmail, just "x"
Code:
java -jar baksmali.jar x -c boot.oat -d framework LGSystemUI.odex -o out
you don't need the "-x" for baksmail, just "x"
Click to expand...
Click to collapse
Thanks a lot, it worked for me. I am using version 2.2.0.
However, while executing "java -jar smali.jar -o classes.dex out" command I get following error. Please suggest the necessary correction.
C:\Users\Sandip\Desktop\New folder\Baksmali>java -jar smali.jar -o classes.dex out
Exception in thread "main" com.beust.jcommander.MissingCommandException: Expected a command, got -o
at com.beust.jcommander.JCommander.parseValues(JCommander.java:725)
at com.beust.jcommander.JCommander.parse(JCommander.java:304)
at com.beust.jcommander.JCommander.parse(JCommander.java:287)
at org.jf.smali.Main.main(Main.java:87)
C:\Users\Sandip\Desktop\New folder\Baksmali>
Figured it out from here..... https://github.com/JesusFreke/smali/wiki/SmaliBaksmali2.2
Ok. I did everything worked. However, when I try with my SystemUI, I notice additional file inside a folder (lib/arm/libNaturalEffect.so) which I assume system animation effect separated from the system (indication of modifiable).
So, do I need to keep the folder and place recompiled SystemUI.apk inside it, or else?
In case anyone has this same error...
San.Dip said:
Thanks a lot, it worked for me. I am using version 2.2.0.
However, while executing "java -jar smali.jar -o classes.dex out" command I get following error. Please suggest the necessary correction.
C:\Users\Sandip\Desktop\New folder\Baksmali>java -jar smali.jar -o classes.dex out
Exception in thread "main" com.beust.jcommander.MissingCommandException: Expected a command, got -o
at com.beust.jcommander.JCommander.parseValues(JCommander.java:725)
at com.beust.jcommander.JCommander.parse(JCommander.java:304)
at com.beust.jcommander.JCommander.parse(JCommander.java:287)
at org.jf.smali.Main.main(Main.java:87)
C:\Users\Sandip\Desktop\New folder\Baksmali>
Click to expand...
Click to collapse
I had this same error, and here is the solution I found that worked:
java -jar smali.jar assemble out -o classes.dex
I know that SanDip left the link on where he figured out how to fix it, but it wasn't immediately obvious to me what the fix was after I visited the link. Hope this helps someone!
dnnz said:
THIS GUIDE HAS BEEN TESTED ON KITKAT, MARSHMALLOW AND NOUGAT
Click to expand...
Click to collapse
I try to use this guide for Lollipop 5.1.1. boot.oat created succesfully:
Code:
d:\Baksmali\framework>adb pull /system/framework/arm/boot.oat boot.oat
/system/framework/arm/boot.oat: 1 file pulled. 4.8 MB/s (54336860 bytes in 10.858s)
and everything is ok until following command:
Code:
d:\Baksmali>java -jar baksmali.jar -x -c boot.oat -d framework DownloadProviderUi.odex -o out
Exception in thread "main" com.beust.jcommander.MissingCommandException: Expected a command, got -x
at com.beust.jcommander.JCommander.parseValues(JCommander.java:725)
at com.beust.jcommander.JCommander.parse(JCommander.java:304)
at com.beust.jcommander.JCommander.parse(JCommander.java:287)
at org.jf.baksmali.Main.main(Main.java:90)
I can't find new files. I even can't find "out" folder. Where should it be? I'm newbie, this guide noob friendly - I hope you can help me. I have 2 apps: each have apk and odex files. I need to deodex this apps.
Xperiarmus said:
Code:
d:\Baksmali>java -jar baksmali.jar -x -c boot.oat -d framework DownloadProviderUi.odex -o out
Exception in thread "main" com.beust.jcommander.MissingCommandException: Expected a command, got -x
at com.beust.jcommander.JCommander.parseValues(JCommander.java:725)
at com.beust.jcommander.JCommander.parse(JCommander.java:304)
at com.beust.jcommander.JCommander.parse(JCommander.java:287)
at org.jf.baksmali.Main.main(Main.java:90)
Click to expand...
Click to collapse
Try executing without the dash before the command, like this: java -jar baksmali.jar x -c boot.oat -d framework DownloadProviderUi.odex -o out
---------- Post added at 03:39 PM ---------- Previous post was at 03:32 PM ----------
I'm also trying to use baksmali (v2.2.2) to decode odex files, without success so far. I'm launching the command:
sudo java -jar baksmali.jar x -c framework/arm/boot.oat -d framework/ Messages.odex -o out/
and I get the error below:
Code:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1890058312
at org.jf.dexlib2.dexbacked.BaseDexBuffer.readSmallUint(BaseDexBuffer.java:53)
at org.jf.dexlib2.dexbacked.OatFile$DexEntryIterator.next(OatFile.java:579)
at org.jf.dexlib2.dexbacked.OatFile$DexEntryIterator.next(OatFile.java:570)
at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:48)
at org.jf.util.AbstractForwardSequentialList$1.next(AbstractForwardSequentialList.java:91)
at java.util.AbstractSequentialList.get(AbstractSequentialList.java:88)
at org.jf.dexlib2.DexFileFactory.loadDexFile(DexFileFactory.java:129)
at org.jf.baksmali.DexInputCommand.loadDexFile(DexInputCommand.java:144)
at org.jf.baksmali.DisassembleCommand.run(DisassembleCommand.java:161)
at org.jf.baksmali.Main.main(Main.java:102)
Anyone having this issue as well? Adding -Xmx5000m option to the java command does not work.
I have just reinstalled stk.apk into pixelized OS for SMT-23
dnnz said:
THIS GUIDE HAS BEEN TESTED ON KITKAT, MARSHMALLOW AND NOUGAT
When you have a system app with an odex file like bluetooth.apk and bluetooth.odex you can't use apktool for decompile and there is no need for deodex the whole ROM, follow this guide to decompile and mod one of these apps and nothing else.
thank you very much sir, i almost reverted back to my old OS since custom OS did not have a sim card menu. omst epople since dont know abou this since i really had to search for this/.
Click to expand...
Click to collapse
To I tried to test it on the HiddenMenu.apk but am getting errors of missing "embedded dex file"
(I am on Android 8.0.0)
Code:
java -jar baksmali.jar x -c boot.oat -d framework HiddenMenu.odex -o out
Exception in thread "main" org.jf.dexlib2.DexFileFactory$DexFileNotFoundException: Could not locate the embedded dex file /system/app/HiddenMenu/HiddenMenu.apk. Is the vdex file missing?
at org.jf.dexlib2.dexbacked.OatFile$OatDexEntry.getDexFile(OatFile.java:586)
at org.jf.dexlib2.dexbacked.OatFile$OatDexEntry.getDexFile(OatFile.java:567)
at org.jf.baksmali.DexInputCommand.loadDexFile(DexInputCommand.java:158)
at org.jf.baksmali.DisassembleCommand.run(DisassembleCommand.java:162)
at org.jf.baksmali.Main.main(Main.java:102)
Caused by: org.jf.dexlib2.dexbacked.DexBackedDexFile$NotADexFile: Not a valid dex magic value: 7f 45 4c 46 02 01 01 03
at org.jf.dexlib2.util.DexUtil.verifyDexHeader(DexUtil.java:93)
at org.jf.dexlib2.dexbacked.OatFile$OatDexEntry.getDexFile(OatFile.java:583)
... 4 more
To try to solve the above problem, I tried to reconstruct the path structure as on the device (I adb pulled the complete \system\framework dir from the device), without success:
Code:
java -jar baksmali.jar x -c boot.oat -d framework .\system\app\HiddenMenu\oat\arm64\HiddenMenu.odex -o out
Error occurred while loading class path files. Aborting.
org.jf.dexlib2.DexFileFactory$DexFileNotFoundException: Could not locate the embedded dex file /system/framework/core-oj.jar. Is the vdex file missing?
at org.jf.dexlib2.dexbacked.OatFile$OatDexEntry.getDexFile(OatFile.java:586)
at org.jf.dexlib2.dexbacked.OatFile$OatDexEntry.getDexFile(OatFile.java:567)
at org.jf.dexlib2.analysis.PathEntryLoader.loadEntry(PathEntryLoader.java:62)
at org.jf.dexlib2.analysis.ClassPathResolver.loadLocalOrDeviceBootClassPathEntry(ClassPathResolver.java:197)
at org.jf.dexlib2.analysis.ClassPathResolver.<init>(ClassPathResolver.java:89)
at org.jf.dexlib2.analysis.ClassPathResolver.<init>(ClassPathResolver.java:154)
at org.jf.baksmali.AnalysisArguments.loadClassPathForDexFile(AnalysisArguments.java:134)
at org.jf.baksmali.AnalysisArguments.loadClassPathForDexFile(AnalysisArguments.java:89)
at org.jf.baksmali.DisassembleCommand.getOptions(DisassembleCommand.java:209)
at org.jf.baksmali.DeodexCommand.getOptions(DeodexCommand.java:71)
at org.jf.baksmali.DisassembleCommand.run(DisassembleCommand.java:183)
at org.jf.baksmali.Main.main(Main.java:102)
Caused by: org.jf.dexlib2.dexbacked.DexBackedDexFile$NotADexFile: Not a valid dex magic value: 7f 45 4c 46 01 01 01 03
at org.jf.dexlib2.util.DexUtil.verifyDexHeader(DexUtil.java:93)
at org.jf.dexlib2.dexbacked.OatFile$OatDexEntry.getDexFile(OatFile.java:583)
... 11 more