private static ByteBuffer read() {
try
{
File
file
=
new
File
(
"C:\\Users\\Administrator\\Desktop\\1.dex"
);
if
(!
file
.exists()) {
return
null;
}
FileInputStream fileInputStream
=
new FileInputStream(
file
);
byte[] bArr
=
new byte[fileInputStream.available()];
fileInputStream.read(bArr);
ByteBuffer wrap
=
ByteBuffer.wrap(bArr);
fileInputStream.close();
return
wrap;
} catch (Exception unused) {
unused.printStackTrace();
return
null;
}
}
private static
File
fix(ByteBuffer byteBuffer,
int
i,
int
i2,
int
i3) throws Exception {
try
{
File
dir
=
new
File
(
"C:\\Users\\Administrator\\Desktop"
);
int
intValue
=
D.getClassDefData(byteBuffer, i).get(
"class_data_off"
).intValue();
HashMap<String,
int
[][]> classData
=
D.getClassData(byteBuffer, intValue);
classData.get(
"direct_methods"
)[i2][
2
]
=
i3;
byte[] encodeClassData
=
D.encodeClassData(classData);
byteBuffer.position(intValue);
byteBuffer.put(encodeClassData);
byteBuffer.position(
32
);
byte[] bArr
=
new byte[byteBuffer.capacity()
-
32
];
byteBuffer.get(bArr);
byte[] sha1
=
Utils.getSha1(bArr);
byteBuffer.position(
12
);
byteBuffer.put(sha1);
int
checksum
=
Utils.checksum(byteBuffer);
byteBuffer.position(
8
);
byteBuffer.putInt(Integer.reverseBytes(checksum));
byte[] array
=
byteBuffer.array();
File
file
=
new
File
(
dir
,
"2.dex"
);
FileOutputStream fileOutputStream
=
new FileOutputStream(
file
);
fileOutputStream.write(array);
fileOutputStream.close();
return
file
;
} catch (Exception e) {
e.printStackTrace();
return
null;
}
}
ByteBuffer read
=
read();
File
fix
=
fix(read,
0
,
3
,
7908
);