How to deodex the firmware using jbart ODEX and DEODEX, what is this and what is needed? Unpacking and analysis of the original file

Your Android tablet But the phone was devastated by those who have firmware odexedі deodexed. And few people understand what goes into these concepts, and what advantages and disadvantages come with a different type of firmware.

I'll try it today in simple words Explain what odex and deodex are, and what is needed.

If you look at the folder with system programs on a tablet or phone with stock (factory) firmware, you will notice that the add-on is in addition to the apk file, its twin, odex file. For example, the applikatoin.apk file is similar to the applikatoin.odex file.

How do you need this odex file? In a nutshell (and simplified), a skin program consists of a set of instructions, which it does, and additional data, such as pictures, that are displayed on the screen. So, the odex file saves the program code itself.

All programs in Android system written (encoded) in my Java And in order to be able to install your processor with all the Java code, it is transferred to my processor-friendly Java virtual machine “Dalvik”.

For deodexed firmware, the code is located in the middle of the apk file. Apk files are packaged just like they were originally zip files that's why the firmware is deodexed smaller size.

You may have already realized why the odexed firmware is superior. Our system programs are already optimized for operation on a specific installation.

The same code that fits into the deodexed add-on can be run on any Android device and such programs can be easily modified. For example, to replace the image in a new one, you just need to unzip the apk file as the original one zip archives, replace the images and repackage the supplement. With odexed programs, such a number will not work - after such changes, the program may stop launching forever.

The Android system is about to start up system add-ons deodexed firmware, extracts the code from them, recompiles it and saves it in a special place: the dalvik-cache folder and then takes the ready-made code for the required apk file from this folder. Therefore, when flashing a tablet or phone, it is recommended to use the dalvik-cache (clear dalvik-cache) - program new firmware can change, and the system will vikorize the old code when it starts. And that’s why deodexed firmwares are launched for a long time first after they are installed on the device and the dalvik-cache is cleared.

In addition, it is important that odexed firmwares work much faster than those similar to those that are deodexed.

It’s too early to shut up about such concepts as Odex and Deodex. It is especially important to know about them at the moment when you decide to change the firmware. Not everyone can correctly explain Odex and Deodex – what is it? It is also important to select and install the correct security software on your mobile device. The result of the work of a smartphone or tablet does not really result in the acquisition of a professional accountant. On the right is that all selfish people can be mentally divided into two categories. Persha prices are stable, Swedish prices are stable I hope I work. Such developers rarely install custom firmware on devices. Another category, however, requires more detailed customization of the gadget based on individual needs. Such traders often use custom firmware, remove root rights and do not be afraid at your own risk of changing important parameters that affect your work operating system tablet or smartphone. At any time, information about the differences between Deodex and Odex will be useful for all categories of buyers, regardless of their needs for various mobile gadgets and installations Mini important instructions.

The difference between Odex and Deodex firmware, as well as their advantages and disadvantages

What is Odex and Deodex?

Odex – tse I understand What's on the radar factory firmware a mobile gadget that operates on the Android operating system. Sometimes they are called dexed. Deodex is a custom version of the firmware or, as it seems, it is deodexed.

The skin program is in the final section. In a custom operating system, Android is located in the classes.DEX file, in which the original version is located in the last section virtual machine Dalvik Virtual Machine, which is the operating system. Odex stands for "Optimized Dalvik Executable File". The operating principle of the Odex file lies in the fact that it allows you to extract data from the operating system without any interference, and unzipping information from files. apk extensions.

What is Deodex firmware? This software option, for each section of the program that is being compiled, repacks the classes.dex file, and then moves the apk file again. This allows you to save all the elements of the program in one section, which reduces the risk of introducing errors in the robot’s program when changing the user’s settings.

Find out about those Odex or Deodex firmware installed on your mobile device, really simple. For whom is it necessary to vikorist? file manager. Koristuvach needs to go to the /system/app folder. In addition to the extension of the files that will be stored in the folder, you can determine the type of system. Expanded odex to talk about the odex option. If you don't know the file system dad, this means that the mobile device has deodexed firmware installed.

Advantages and disadvantages

It’s impossible to say unequivocally which is better – Odex or Deodex? Both options have their advantages and shortcomings. The advantages of the deluxe version are that launching the program is much faster. This makes it possible for the system to acquire information in advance. Therefore, for files with extended apk, less memory is required for the device.

The advantages of deodexing systems lie in the fact that it is much easier to uninstall unnecessary supplement. To do this, you just need to delete the apk file, which is responsible for running the program. It is also important to note that it is much easier to modify the operating system if the data is placed in one.

Oxidized shell is more difficult to “break”, the fragments are taken from two different sections. Please be aware of the specific nature of this particular program, we recommend that you carefully proceed with this process. You can also delete files with odex extensions. A lot of work is done to the few deodexed shells through automatic cache cleaning, which saves the most required programs.

How to get the Deodex version?

There is a simple way in which you can get Deodex firmware with coded version. For this you need to download and install the xUltimate utility. Then a bunch of simple actions will follow.

If you actively use Android, install custom firmware and various mods, then, you know, you’ve already heard about those who have Odex and Deodex firmware, what does that mean? Find out from this article!

What does Odex, Deodex mean?

What do you need Deodex for?

Let’s get a bit ahead of ourselves to put everything in its place: Deodex add-ons in the firmware are necessary for those who want to install different mods - which can be radically changed external look Android (change icons, change notification row, add or select menu). Now let's take a look at what odex and deodex have become.

What is Odex?

In any program, this is the name of the final part, as it is the last part of the program when you enter the data of the correspondent. In OS Android given Some of it is added to the class file. DEX

However, as a rule, in official firmware this part of the program is named, to speed up the launch of the system and processing in a virtual machine Dalvik Virtual Machine(Up to Android 4.4). Since the Vikon’s part has been named, then It's called ODEX. With the arrival of the new middle age, Android add-ons called ART(h Android Lollipop 5.0), great changes have been made to robotic add-ons, but the need for deodex for mod lovers has been saved.

Pros and cons of Odex and Deodex firmware

Odex

  • - Odex, it’s more important to modify the firmware
  • + Odex, pratsyuє trokhi shvidshe
  • + Odex, takes less space to install add-ons

Deodex

  • - Deodex - if something went wrong at the time of deodexation, then come and reflash Android
  • + Deodex - easy customization of firmware
  • - Deodex - takes up more memory for installing programs

How to remove Deodex firmware?

Below will be presented programs, for additional help you can check Deodex firmware. But for this you need to prepare a little.

  1. You need to download and install Java JDK on your computer
  2. Install the file manager Root Browser and for help, go to the /system section and copy the following folders to internal memory or memory card:
    • /priv-app
    • /framework

Deodex firmware for additional help JoelDroid Batch Deodexer

Android versions: Lollipop 5.x.x
Necessary for work: NET Framework 4.5 ta Java JDK
entice: JoelDroid Batch Deodexer

Yak koristuvatisya JoelDroid Batch Deodexer

  1. Copy Android folders (app, priv-app, framework) to one on your computer (for example, MyRom)
  2. Run the JoelDroid Batch Deodexer program and select Roztashuvannya by clicking on “Browse”, folders are located (app, priv-app, framework)
  3. Press "Start Process"

Deodex firmware for additional help Deodexer for Android Runtime

Android versions: Lollipop 5.x.x, Marshmallow 6.x.x
Necessary for work: Java JDK
entice: Deodexer for Android Runtime

Yak koristuvatisya Deodexer for Android Runtime

  1. Unzip the archives containing the program folder
  2. Copy the Android folders (app, priv-app, framework) to one on your computer (for example, system)
  3. Run the Deodexer for Android Runtime program and select the folders to be installed (app, priv-app, framework)
  4. Meaning for deodex: app, priv-app, framework
  5. Click the Execute button

Deodex firmware for additional help Jbart

Android versions: Ginerbread 2.3.x - Marshmallow 6.x.x
Necessary for work: Java JDK
entice: Jbart

Yak koristuvatisya Jbart

  1. Unzip the archives containing the program folder
  2. Launch Jbart
  3. entice the entire folder s/system from Android, move to a computer and pack in ZIP archives or you will need the firmware packaged in ZIP
  4. Enter ZIP archives
  5. Select Android version (Rom API)
  6. At the bottom right click on "D - (Deodex)"

That's all! Read more articles and instructions in the section Android statistics and hacks. Get rid of the site at once Android +1, It will be even better!

Hello Habré!

Almost certainly, when I first became familiar with Android, I felt from my colleague at work that Android offers the ability to install modified or custom firmware. You know, then I will be far away from him. And then again, similar speeches were made. Deep in my soul, I say: those who break the virobnik are already intended for normal vikorstan.

How disappointed would I be if I received the phone from the Middle Kingdom, where factory adjustments were blocked Google wiki, Skype, Facebook and other add-ons. In principle, in the course of speech it would be possible to flatten your eyes, but if my phone does not allow the vicor of the eye Google entry- I, having taken the furnishings from myself, obligingly rose from me so that I would be gone.

It's been a while and my custom firmware is being popularized all over the world with great success.

This series of articles covers how to work reverse programming for Android, implement patches, tweaks and mods.

Preamble

Yes! Let's first take a look at the concepts that will be discussed with given statti. Your first understanding may be very different.

Patch- Change or replacement of something else program code By modifying the program algorithm.
Maud- as a rule, adding additional functionality to the original program code without changing the algorithm.
Tweak- improving the functionality of the program by making it easier to access system parameters.

I also want to respect that all butts will be taken for HTC phone ale does not mean that information given You cannot vikorize on other phones.

Preparing the middle

I'll do without reporting instructions how to profit from this and others software security. As you have read this article and you have read this far, then I am sure that you are already convinced that you would like to experiment in this field. Instructions, articles and test results are constantly in private access, In this case, as in Khabr. I will also do without a description of some terms, otherwise the article will seem even great and tedious. We write less at the right. I sing that your center has been standing for a long time. If you don’t, then I’ll suggest you to enchant and install.

1 . Android SDK. This is the middle of developing add-ons for Android. In order to make modifications, we will definitely have to check our program code. The middle of rozrobka is the most beautiful thing that we can vikorize.
2 . Android Kitchen. This utility allows you to work with images of system batches of official or unofficial firmware.
3 . JD-GUI. Java code decompiler. I will immediately point out that this is the shortest decompiler for the ease of use of a vikoristan.
4 . DJ Java Decompiler. Another decompiler, or disassembler, as you like to call it, Java program code. It's not a good idea to use the script, but it parses code that JD-GUI doesn't understand.
5 . smali. Another disassembler, but also a long way to code. smali is required for disassembly, and backsmali is required for code assembly.
6 . dex2jar. Utility for converting formatted files to Dalvik code.

Firmware redesign

Obviously, the firmware that you have on your phone is optimized to reduce energy consumption. Before the firmware can be changed, it must be converted to a format that allows the code to be changed. Why should I use Android Kitchen? You can do it with your hands, as I did before, until you know the “kitchen” itself. How to repair the system area of ​​the phone, install the middle part, run DEODEX firmware, you can read on the Internet. Since you don’t understand anything anymore, I think you should check this article until you get enough evidence.

After the firmware from the optimized view (ODEX - optimizing Dalvik compilation code, since it does not change the memory) has become DEODEX (that is, NOT optimized), all files that are compiled are ready before modification.

Without middle modifications

Creation of patches
As I have already confirmed, my phone is now on the fence with Google. Well, even if I’m sorry, I can’t go to Playstore, oblikovy record don’t fake it, phone book It doesn't synchronize to the fret. What kind of Android do you need? Having been digging around the logs of the site for a long time, I knew the records that they said about those that Google’s wiki was blocked. Most importantly, in Android, you read the log, but you don’t know which system add-on is violating it. To know where to grow my legs, I had to strip all the system programs down to disassembled Java code. It took quite an hour, but I’m still working on my computer while analyzing and searching for the required code. The steps for removing such tools are as follows:
1 . Get DEODEX all firmware
2 . Your new DEODEX firmware will need to be downloaded and flashed onto your phone. How to be careful is the topic of another article.
3 . For each file located in /system/framework, extract the classes.dex file and convert it to JAR using dex2jar.
4 . Open the JAR in JD-GUI and save the output code
5 . Extract the output code from the archive.

As a result, I ended up with as many folders as there were JAR file ov in /system/framework, and this folder contains a small structure of Java output codes.
Through a series of awkward manipulations, I know very well how to generate entries in logcat.

We can’t see the whole logic of the defense, which is why for a skin attack there is no history. I had to spend a couple of years, first I knew how to carry out verifications, get a block diagram of the algorithm in my head and figure out where to go in order to “populate” the algorithm a little.

Everything turned out to be simple. And the subprogram, based on the setting of constants in advance, accurately predicted whether the phone should be installed in China or not.

The code is in the file HTCExtension.jar, and the class, which took revenge on this subprogram, being in

Unpacking and analysis of the original file
1 . First, we need to take the original DEODEX JAR file, which provides the required part of the code. To our vipadka HTCExtension.jar.
2 . Open up as an archiver and pull out classes.dex there
3 . Using the dex2jar converter, convert it to a JAR file. Command: dex2jar.bat classes.dex
4 . Open the classes_dex2jar.jar file in JD-GUI.
5 . So, most often JD-GUI decompiles the code without looking at the original, but understandably, but can be read in its entirety. At the end of the day, it is important that the subprogram checks the parameters of the project and the current firmware code. Our sum pad displays the value TRUE.
public static boolean isChina() ( if ((HtcBuildFlag.Htc_PROJECT_flag == 216) || (HtcBuildFlag.Htc_PROJECT_flag == 218) || (HtcBuildFlag.Htc_PROJECT_flag == 23 g == 1) && (2 == HtcBuildFlag.Htc_LANGUAGE_flag) ) || (HtcBuildFlag.Htc_PROJECT_flag == 27)) return true;
6 . To create a patch, we need to disassemble the Dalvik code itself. For whom the vikorist is baksmali. The easiest way is to create a folder and place three files there at once: HTCExtension.jar, smali.jarі baksmali.jar. Give the command java -Xmx512m -jar baksmali.jar -a -d -o HTCExtension -x HTCExtension.jar

This is your API Android versions. For JB - ce 16
- folder where all firmware frameworks are located.

I have a special team
java -Xmx512m -jar baksmali.jar -a 16 -d S:\dev\Android\Android-Kitchen\WORKING_JB_15\system\framework -o HTCExtension -x HTCExtension.jar
7 . Our new dad now has an HTCExtension folder, and in it our files with the Dalvik code.
8 . Find the file by dosage \com\htc\util\contacts\BuildUtils$Customization.java and amazing code:
.method public static isChina()Z .registers 3 .prologue const/4 v0, 0x1 .line 276 sget-short v1, Lcom/htc/htcjavaflag/HtcBuildFlag;->Htc_PROJECT_flag:S const/16 v2, , v2, :cond_13 sget-short v1, Lcom/htc/htcjavaflag/HtcBuildFlag;->Htc_PROJECT_flag:S const/16 v2, 0xda if-eq v1, v2, :cond_13 sget-short v1,Fc/ ;->Htc_PROJECT_flag:S const/16 v2 , 0x17 box v1, v2, :cond_14 .line 297:cond_13:goto_13 return v0 .line 283:cond_14 sget-short v1, Lcom/tc/ Htc_PROJECT_flag:S if-ne v1, v0, :cond_1d .line 285 const/4 v1, 0x2 sget-short v2, Lcom/htc/htcjavaflag/HtcBuildFlag;->Htc_LANGUAGE_flag:S if-eq. 291:cond_1d sget-short v1, Lcom/htc/htcjavaflag/HtcBuildFlag;->Htc_PROJECT_flag:S const/16 v2, 0x1b if-eq v1, v2, :cond_13 .line 297 const/4 method
9 . It's scary, isn't it? Nothing made sense. Ale, you can correct it on the right. Having created a bunch of your patches and filled your hand with this, you can easily modify the code without third-party costs. In our opinion, in whose code
.prologue const/4 v0, 0x1 is set to 1, which means TRUE. Further verification will follow, and if the phone is not Chinese, then the value will change:
.line 297 const/4 v0, 0x0 goto:goto_13
10 . The simplest way to restore the father of Russian democracy is to change the offensive code:
.prologue const/4 v0, 0x0 , then change the value of the variable from 1 to 0. Otherwise, the value FALSE will be returned and the JD-GUI code will look like public static boolean isChina() ( if (( HtcBuildFlag.Htc_PROJECT_flag == 216) || (HtcBuildFlag.Htc_PROJECT_flag == 218) || Flag.Htc_LANGUAGE_flag)) || (HtcBuildFlag.Htc_PROJECT_flag == 27)) return false;
11 . So, method, practice. Well, we don’t look for easy paths - all the time. In other words, it’s not very beautiful. I would like to see the code
public static boolean isChina() ( return false; )
12 . How can we find the Dalvik code? exit code? For beginners we have a little trick to learn.

Created by Dalvik code
1 . Vidkryvaemo Android SDK.
2 . We create a new project and write the new code into our single test class
package ru.habrahabr.test; public class test (public static boolean isChina() (return false;))
3 . Let's compile our project and then take the assembled program from the workspace.
4 . We put together a collection of additions to the folder where we gutted the JAR file.
5 . Give the command java -Xmx512m -jar baksmali.jar -a -d -o test -x test .apk
6 . We disassembled extensively collected additions from the Dalvik code.
7 . We open our file test.smali and the code there
.method public static isChina()Z .registers 1 .prologue .line 7 const/4 v0, 0x0 return v0 .end method
8 . That's it, the code for patching is ready.
Patch development
1 . Dalvik code is marked with markers that indicate the row of code in the original output file. This is required when displaying errors such as those found in your program. Without insertions of rows, the code also works miraculously.
2 . We delete the rows with row numbering, copy and replace the method (subprogram) in our \com\htc\util\contacts\BuildUtils$Customization.java file.
.method public static isChina()Z .registers 1 .prologue const/4 v0, 0x0 return v0 .end method
3 . We save the file. So, forgetting to say, a normal editor is required, for example, Notepad++ or EditPlus. Who deserves it?
Compilation and folding of a patched JAR file
1 . For help backsmali, we have stolen our JAR file, and now we need to get it back.
2 . Give the command java -Xmx512m -jar smali.jar -a 16 HTCExtension -o classes.dex
3 . Our teacher has a classes.dex file
4 . Once again we open it up HTCExtension.jar the file is replaced by the archiver and replaced with a new one classes.dex on our beautiful creations.
5 . That's it, ours HTCExtension.jar modify the program code.
Replacing the original file with patches
Please note, for ordinary users, special scripts are created that can be replaced via recovery. Alas, we don’t care. First, long and boring, different confirmed by koristuvach And we can afford to do some subtle things.

1 . You can replace the current working file with the following commands, if you already have DEODEX firmware and root access:

Adb push HTCExtension.jar /sdcard/HTCExtension.jar adb shell su mount -o remount -rw /system dd if=/system/framework/HTCExtension.jar of=/system/framework/HTCExtension.jar.back dd if=/sdcard /HTCExtension.jar of=/system/framework/HTCExtension.jar chmod 644 /system/framework/HTCExtension.jar rm /data/dalvik-cache/system@ [email protected]@classes.dex reboot

The first team uploads the patch file to the flash drive
Another command opens the shell
The third command gives root access
The fourth command sets the system to read/write mode
Hey, the command is to stop backup copy file
The 6th command overwrites the existing file with the new patch.
Team 7 gives permission
The 8th command clears the cache
9th command to re-engage the annex.

2 . Thank you for reading to this point, I missed a lot.
3 . After re-uploading, your new patch code will remain in order.
4 . If the code does not work or the error appears, you can use some simple combinations to restore the backup copy.
adb shell su mount -o remount -rw /system dd if=/system/framework/HTCExtension.jar.back of=/system/framework/HTCExtension.jar rm /data/dalvik-cache/system@ [email protected]@classes.dex reboot

Epilogue

So, some people thought this article was very specific, some thought it was a bit incomprehensible, and some thought it was boring. I specifically avoided too much detail and illustration of how everything looks alive in practice. First of all, this process will be wasteful and will only generate even more nutrition. In other words, I don’t want to antagonize the army of koristuvachs on the forums to say that they jammed the phone.

Until the next day, I will find out how Twiki works. Will the butt be vikoristannya automatic recording telephone calls by telephone. Thank you for your respect.

P.S. If you don’t understand why you’re betting, put on food - I’ll be happy to inform you and explain in the future.

A lot of people's phones and tablets on Android, who have installed their firmware, have expressed respect for those who have firmware. odexedі deodexed. However, not a lot of people understand what goes behind these concepts, and what are the pros and cons that come with a different type of firmware.

Today you find out what it is odexі deodex, and this is what is needed.

If you look in the system programs folder system/app on your tablet or phone with stock (factory) firmware, then be sure to note that all add-ons are locked apk file, yogo double, odex file. For example, the applikatoin.apk file is similar to the applikatoin.odex file.

What is this used for? odex file? To keep it short and simple, the application consists of a set of instructions and other instructions for how it works, and additional data, such as pictures, that are displayed on the screen. The axis itself, at the file odex The program code itself is saved.
All programs in the Android system are written (coded) in Java and in order for the processor to be installed - its brain, summing up the Java code, is transferred to my processor-friendly Java virtual machine "Dalvik".

For deodexed firmware, the code is located in the middle of the apk. Apk files are packaged the same as the original ones zip files Therefore, the deodexed firmware is now smaller in size. Ale code, which is located in the file odex optimized for specific outbuilding, and the code that is saved in the apk file can be downloaded on any device. You, who have seen it all, have realized what the advantages are odexed firmware. Our system programs are already optimized for operation on a specific installation.
The actual code contained in the deodexed appendix can be run on any Android device and can be easily modified by the program. For example, to add images to a new one, you just need to unzip the apk file as the original zip archive, replace the images and repack the add-on. Z odexed Programs will not be able to do this trick - after such changes, the program will stop starting immediately.

The Android system, when starting the system add-ons of the deodexed firmware, extracts the code from them, recompiles it and saves it in a special place: in the dalvik-cache folder and then takes the ready-made code for the required apk file from this folders. This is why it is recommended that when flashing a phone or tablet, clearing dalvik-cache (clear dalvik-cache) - the program in the new firmware can change, and the system will correct the old code when it starts. It takes so long to start up deodexed firmware first after they are installed on Android device that dalvik-cache cleanup.
In addition, it is important that odexed The firmware is performed in the following manner, below similar, or deodexed.

Odex: To quickly download Dalvik VM, the code that is compiled (classes.dex) can be added from programs (files.apk) in addition to files with extensions .odex. As a rule, this type has factory (official) firmware installed. The downside of this solution is the impossibility of customizing the interface.
Deodex: redesigned the code that links from .odex files back to program files (.apk). To install Deodex"ed firmware is usually required