Comments (4)
I use the following code for plain dexlib2 to write the classes to a new dex file:
public static void writeToDexFile(String filePath, List<ClassDef> classes, int opCode) throws IOException {
DexFileFactory.writeDexFile(filePath, new DexFile() {
@Nonnull
@Override
public Set<? extends ClassDef> getClasses() {
return new AbstractSet<ClassDef>() {
@Nonnull
@Override
public Iterator<ClassDef> iterator() {
return classes.iterator();
}
@Override
public int size() {
return classes.size();
}
};
}
@Nonnull
@Override
public Opcodes getOpcodes() {
return Opcodes.forApi(opCode);
}
});
}
And the following code to create/modify an existing class:
List<Method> instrumentedMethods = Lists.newArrayList(classDef.getMethods()).parallelStream()
.map(method -> instrumentMethod(dexFile, classDef, method))
.collect(Collectors.toList());
return new ImmutableClassDef(
classDef.getType(),
classDef.getAccessFlags(),
classDef.getSuperclass(),
classDef.getInterfaces(),
classDef.getSourceFile(),
classDef.getAnnotations(),
classDef.getFields(),
instrumentedMethods);
from smali.
@auermich93 thinks.
then,
how to get a class all import class.
i want to write a class and all depends import class to a dex file.
from smali.
@yujack008 There are no explicit imports like in a .java
file. You have to iterate over all fields and instructions and collect this information on your own.
from smali.
i want to move the useless classes to a new dex ,how to?
from smali.
Related Issues (20)
- New official version published? HOT 4
- added support for 4rcc in MutableMethodImplementation
- Ive been Hacked please help me HOT 6
- Parsing smali methode HOT 1
- The Fields do not keep their initial values if they're default value
- odex error
- Error while writing instruction at code offset 0x8
- How to calculate the contribution of each class to the dex HOT 2
- Dex file size increases by ~50% without making changes (DexFileFactory.loadDexFile then DexFileFactory.writeDexFile) HOT 7
- missing EOF at '.class'
- any method to replace one String with modifiedString in StringIds section of dex file using dexlib2? HOT 3
- How to create a new method using dexlib2 HOT 2
- Try to run examples/BracketedMemberNames HOT 1
- Smali patcher does not support Dex version 039 HOT 1
- java.lang.NoSuchMethodError when calling DexPool.internClass
- smali report error
- how to move the useless classes to a new dex using dexlib2? HOT 1
- [Feature Request] Could we support dex v41? HOT 3
- Won't build under Debian WSL
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from smali.