Table of Contents
Content
1. A simple tutorial on a useful tool (Insight)
What can you learn?
2.Android optimization process analysis
3.Android DEX file analysis Analysis
4. Analysis of Android DEX class loading process
0x01 A simple tutorial on a useful tool (Insight)
#Create a new project
Android Optimization Process Analysis
1.extractAndProcessZip
2. Continue to optimize
.
PS: Tips
0x04 Android Dex class loading process
Home Operation and Maintenance Safety How to create a new project in Android

How to create a new project in Android

May 29, 2023 pm 11:37 PM
android

Content

1. A simple tutorial on a useful tool (Insight)

What can you learn?

A super powerful analysis assistant software.

2.Android optimization process analysis

What can you learn?

1. In-depth understanding of the Android optimization process
2. Close observation of the Android source code
2. You can see the functions in the lower part of the big boss’ shell

3.Android DEX file analysis Analysis

What can you learn?

1. Other functions that can be downloaded
2. The process of parsing dex files
3. A little knowledge about shelling and downloading

4. Analysis of Android DEX class loading process

What can you learn?

1. The complete process of class loading
2. Selection of shelling and reinforcement classes

0x01 A simple tutorial on a useful tool (Insight)

This software is very useful for Analysis of c/c and java source code has strong auxiliary functions, which will be used later, so a brief introduction is given.

Tools can be found in the attachment. Just upload and download separately.

SI3US-205035-36448

A registration code is provided here.

Install, next, next.

How to create a new project in Android

#Create a new project

Select new project.

How to create a new project in Android

Single machine OK
How to create a new project in Android

Select the first one


How to create a new project in Android

Select Add Tree, which means adding them all.
How to create a new project in Android

After loading is complete

How to create a new project in Android

we will use this software for analysis.

Android Optimization Process Analysis

I want to be verbose. At this time, I know the importance of English. Of course, my English is not good, but I can look it up in the dictionary.


How to create a new project in Android

1.extractAndProcessZip

Let’s not talk about this content first, let’s take a look at the name of this function. extract: Extract, and and, Process process Zip, compressed file format, we all know that apk is actually a zip compressed package.
Then the meaning of this function is the process of extracting zip.

Then let’s analyze it step by step.


How to create a new project in Android

Here is the intermediate variable definition of extractAndProcessZip. It is not the focus of our research.


How to create a new project in Android

DexClassVerifyMode verifyMode = VERIFY_MODE_ALL;
Copy after login

This sentence defines verifyMode, which is the verification module. The data initialized here is VERIFY_MODE_ALL, which means that everything is verified.

Thinking

If we make changes here, can we skip this verification.

Let’s look at other values.


How to create a new project in Android

If you have an idea, you can define this value yourself.

DexOptimizerMode dexOptMode = OPTIMIZE_MODE_VERIFIED;
Copy after login


How to create a new project in Android

Let’s continue looking down.
How to create a new project in Android

There is a function called dexOptCreateEmptyHeader which, as the name suggests, creates an empty header for dex optimization..


How to create a new project in Android

dexOffset, record the file position so we can get back here later, is actually the starting position of reading the dex file.

Let’s look at the next function.
How to create a new project in Android

Open the zip archive, find the DEX entry.
Obviously, what this part is doing is to find the dex file from the apk.

Then proceed with analysis.


How to create a new project in Android

Function to extract some offsets of dex.

How to create a new project in Android

Extract the DEX data into the cache file at the current offset. Record some offsets of the dex file.

The next thing to talk about is the process of dex odexing.


How to create a new project in Android

This is where verification is optimized.

You can modify the optimization process here, and even remove the optimization verification.

Think about
Where does the data here come from and where to compare it. ·
These data are compared in build.prop.

2. Continue to optimize

Let’s follow up on the dvmContinueOptimization function.

PS:
We are about to come into contact with a very important place that is very related to shelling

Open the dvmContinueOptimization function

How to create a new project in Android

The first is a judgment.


How to create a new project in Android

#Then there is a write to the dex file.

Then read on (the important point is coming)


How to create a new project in Android

##dvmDexFileOpenPartial. If you have seen other people’s shelling tutorials before, you must know it. Here is the frequently used endpoint. I only knew to download it before, but now I know that this function exists in the source code.

Let’s take a look at the call of the dvmDexFileOpenPartial function

How to create a new project in Android

It is called twice here, and once is its own definition.

Let’s take a look at the prototype of dvmDexFileOpenPartial first

int dvmDexFileOpenPartial(const void* addr, int len, DvmDex** ppDvmDex)

Parameter 1: The base of the loaded DEX file in memory Address. (That is, DEX.035)
Parameter 2: The file length of the loaded DEX file,
Parameter 3: Output parameter, the DEX file is converted into a DvmDex structure, which contains the classes, fields, and methods of the Dex file. String information. The object that Dalivk operates on the Dex file is the structure structure


How to create a new project in Android

Finally, the header information is written here.


How to create a new project in Android

0x03 Android DEX file parsing and analysis

dvmRawDexFileOpen() This function is the key function we need to understand. It is in RawDexFile .cpp function.


How to create a new project in Android

First define the basic variables.


How to create a new project in Android

#We all know that a very important thing in the file format is the magic number, so here is the first step to determine the magic number, verifyMagicAndGetAdler32. The magic here is the magic number.



How to create a new project in Android

Here is the verification of time and file size.


How to create a new project in Android

This function is a key function, and it is also a function that we need to focus on analyzing. Its main function is to generate the odex file corresponding to dex, also It is the so-called odexization. Let's follow up the function to see.


How to create a new project in Android

The following is part of the dexOptGenerateCacheFileName() function. Our main thing is to see where it is output.

How to create a new project in Android

Here you can see that it is generated in the data directory, ALOGV("Cache file for '%s' '%s' is '%s'" , fileName, subFileName, nameBuf);

Format like this.

That is to say, our odex file has been generated here.

The next thing to do is this function dvmDexFileOpenFromFd(), further optimize, complete the mapping, and set it as a readable file. Open this function. The location is in DvmDex.cpp.

How to create a new project in Android

#Let’s first look at where this function is called.

How to create a new project in Android

The place where this function is called is our key function dvmRawDexFileOpen. This function first calls dexOptGenerateCacheFileName to generate odex, and then calls dvmDexFileOpenFromFd for another optimization.

The last step in optimization is dexFileParse(), which is to parse DEX. This position is briefly summarized in DexFile

How to create a new project in Android

.

dvmRawDexFileOpen() main control function - dexOptGenerateCacheFileName() generates the corresponding odex - dvmDexFileOpenFromFd() further optimizes - dexFileParse() parses dex.

PS: Tips

When dexfileopenpartial is in the next section, you may find that there is no way to break it, then we can choose dexOptGenerateCacheFileNamePKcS0, dvmdexfileopenfromfd and other functions to proceed to the next section.

Generally speaking, dexfileopenpartial is better at handling things with shells.

0x04 Android Dex class loading process

Other source codes are guided by a main control function to guide other key functions to operate. The dex class loading process is also like this.

Its main control function is Dalvik_dalvik_system_DexFile_defineClassNative()


How to create a new project in Android

##There is also a function that needs attention Dalvik_dalvik_system_DexFile_openDexFileNative

What needs to be noted here is that there are two places where you can dump.


How to create a new project in Android

Let’s continue to look at our main control function.

There is such a call in the main control function.


How to create a new project in Android

This call is to verify the cookie, but this cookie is likely to be the decrypted dex cookie, so you can also dump this cookie here.

Then look down.


How to create a new project in Android

dvmDefineClass function, this function is a function that confirms class loading.

How to create a new project in Android

#The function makes a judgment on its own, but what is returned is indeed a big head. Let's follow up on this function to see.


How to create a new project in Android

How to create a new project in Android

The most important thing here is clazz, which is the dynamically loaded class.

His value is returned by the loadClassFromDex function, so we will take a further look.

How to create a new project in Android

#See such a structure here.


How to create a new project in Android

Let’s take a look at the details of this structure.


How to create a new project in Android

Whether this structure is exactly the same as the dex structure shows that this is what we need.

The above is the detailed content of How to create a new project in Android. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

New report delivers damning assessment of rumoured Samsung Galaxy S25, Galaxy S25 Plus and Galaxy S25 Ultra camera upgrades New report delivers damning assessment of rumoured Samsung Galaxy S25, Galaxy S25 Plus and Galaxy S25 Ultra camera upgrades Sep 12, 2024 pm 12:23 PM

In recent days, Ice Universe has been steadily revealing details about the Galaxy S25 Ultra, which is widely believed to be Samsung's next flagship smartphone. Among other things, the leaker claimed that Samsung only plans to bring one camera upgrade

Samsung Galaxy S25 Ultra leaks in first render images with rumoured design changes revealed Samsung Galaxy S25 Ultra leaks in first render images with rumoured design changes revealed Sep 11, 2024 am 06:37 AM

OnLeaks has now partnered with Android Headlines to provide a first look at the Galaxy S25 Ultra, a few days after a failed attempt to generate upwards of $4,000 from his X (formerly Twitter) followers. For context, the render images embedded below h

IFA 2024 | TCL\'s NXTPAPER 14 won\'t match the Galaxy Tab S10 Ultra in performance, but it nearly matches it in size IFA 2024 | TCL\'s NXTPAPER 14 won\'t match the Galaxy Tab S10 Ultra in performance, but it nearly matches it in size Sep 07, 2024 am 06:35 AM

Alongside announcing two new smartphones, TCL has also announced a new Android tablet called the NXTPAPER 14, and its massive screen size is one of its selling points. The NXTPAPER 14 features version 3.0 of TCL's signature brand of matte LCD panels

Vivo Y300 Pro packs 6,500 mAh battery in a slim 7.69 mm body Vivo Y300 Pro packs 6,500 mAh battery in a slim 7.69 mm body Sep 07, 2024 am 06:39 AM

The Vivo Y300 Pro just got fully revealed, and it's one of the slimmest mid-range Android phones with a large battery. To be exact, the smartphone is only 7.69 mm thick but features a 6,500 mAh battery. This is the same capacity as the recently launc

Samsung Galaxy S24 FE billed to launch for less than expected in four colours and two memory options Samsung Galaxy S24 FE billed to launch for less than expected in four colours and two memory options Sep 12, 2024 pm 09:21 PM

Samsung has not offered any hints yet about when it will update its Fan Edition (FE) smartphone series. As it stands, the Galaxy S23 FE remains the company's most recent edition, having been presented at the start of October 2023. However, plenty of

New report delivers damning assessment of rumoured Samsung Galaxy S25, Galaxy S25 Plus and Galaxy S25 Ultra camera upgrades New report delivers damning assessment of rumoured Samsung Galaxy S25, Galaxy S25 Plus and Galaxy S25 Ultra camera upgrades Sep 12, 2024 pm 12:22 PM

In recent days, Ice Universe has been steadily revealing details about the Galaxy S25 Ultra, which is widely believed to be Samsung's next flagship smartphone. Among other things, the leaker claimed that Samsung only plans to bring one camera upgrade

Xiaomi Redmi Note 14 Pro Plus arrives as first Qualcomm Snapdragon 7s Gen 3 smartphone with Light Hunter 800 camera Xiaomi Redmi Note 14 Pro Plus arrives as first Qualcomm Snapdragon 7s Gen 3 smartphone with Light Hunter 800 camera Sep 27, 2024 am 06:23 AM

The Redmi Note 14 Pro Plus is now official as a direct successor to last year'sRedmi Note 13 Pro Plus(curr. $375 on Amazon). As expected, the Redmi Note 14 Pro Plus heads up the Redmi Note 14 series alongside theRedmi Note 14and Redmi Note 14 Pro. Li

iQOO Z9 Turbo Plus: Reservations begin for the potentially beefed-up series flagship iQOO Z9 Turbo Plus: Reservations begin for the potentially beefed-up series flagship Sep 10, 2024 am 06:45 AM

OnePlus'sister brand iQOO has a 2023-4 product cycle that might be nearlyover; nevertheless, the brand has declared that it is not done with itsZ9series just yet. Its final, and possibly highest-end,Turbo+variant has just beenannouncedas predicted. T

See all articles