Skip to content

Commit

Permalink
Fix for issue skylot#1739
Browse files Browse the repository at this point in the history
  • Loading branch information
jmlitfi committed Dec 14, 2022
1 parent bdda26d commit 3f8b3b5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import jadx.api.ICodeInfo;
import jadx.api.plugins.input.data.AccessFlags;
import jadx.api.plugins.input.data.AccessFlagsScope;
Expand Down Expand Up @@ -77,6 +80,7 @@ public class Smali {
private final boolean printBytecode = true;

private boolean isJavaBytecode;
private static final Logger LOG = LoggerFactory.getLogger(Smali.class);

private Smali() {
}
Expand Down Expand Up @@ -447,6 +451,8 @@ private void writeMethodDef(SmaliWriter smali, IMethodData mth, LineInfo lineInf
}

private boolean formatMthParamInfo(IMethodData mth, SmaliWriter smali, ICodeReader codeReader, LineInfo line) {
LOG.info("******* Reading Method *******");
LOG.info(mth.toString());
List<String> types = mth.getMethodRef().getArgTypes();
if (types.isEmpty()) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

import org.jetbrains.annotations.Nullable;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import jadx.api.plugins.input.data.ILocalVar;
import jadx.api.plugins.input.data.impl.DebugInfo;
import jadx.plugins.input.dex.sections.DexConsts;
Expand Down Expand Up @@ -45,6 +48,7 @@ public class DebugInfoParser {

private List<String> argTypes;
private int[] argRegs;
private static final Logger LOG = LoggerFactory.getLogger(DebugInfoParser.class);

public DebugInfoParser(SectionReader in, int regsCount, int codeSize) {
this.in = in;
Expand Down Expand Up @@ -87,20 +91,23 @@ public DebugInfo process(int debugOff) {
resultList = new ArrayList<>();
linesMap = new HashMap<>();

LOG.info("******* Reading debug_info_item *******");
int addr = 0;
int line = in.readUleb128();
int paramsCount = in.readUleb128();
int argsCount = argTypes.size();
int line = in.readUleb128(); //line_start
int paramsCount = in.readUleb128(); //parameters_size
int argsCount = argTypes.size(); //parameter_names

for (int i = 0; i < paramsCount; i++) {
int nameId = in.readUleb128p1();
String name = ext.getString(nameId);
LOG.info("Reading Param: " + name);
if (name != null && i < argsCount) {
int regNum = argRegs[i];
startVar(new DexLocalVar(regNum, name, argTypes.get(i)), -1);
startVar(new DexLocalVar(regNum, name, argTypes.get(i)), -1); //startVar(variable, start_offset)
varsInfoFound = true;
}
}
LOG.info("******* Reading DBG Vars *******");
while (true) {
int c = in.readUByte();
if (c == DBG_END_SEQUENCE) {
Expand All @@ -117,6 +124,9 @@ public DebugInfo process(int debugOff) {
break;
}
case DBG_START_LOCAL: {
LOG.info("Reading DBG_START_LOCAL");
LOG.info("startOffset: " + Integer.toString(addr));

int regNum = in.readUleb128();
int nameId = in.readUleb128() - 1;
int type = in.readUleb128() - 1;
Expand All @@ -126,6 +136,9 @@ public DebugInfo process(int debugOff) {
break;
}
case DBG_START_LOCAL_EXTENDED: {
LOG.info("Reading DBG_START_LOCAL_EXTENDED");
LOG.info("startOffset: " + Integer.toString(addr));

int regNum = in.readUleb128();
int nameId = in.readUleb128p1();
int type = in.readUleb128p1();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import jadx.api.plugins.utils.Utils;
import jadx.plugins.input.dex.sections.SectionReader;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class DexLocalVar implements ILocalVar {
private final int regNum;
private final String name;
Expand All @@ -16,6 +19,7 @@ public class DexLocalVar implements ILocalVar {
private boolean isEnd;
private int startOffset;
private int endOffset;
private static final Logger LOG = LoggerFactory.getLogger(DexLocalVar.class);

public DexLocalVar(SectionReader dex, int regNum, int nameId, int typeId, int signId) {
this(regNum, dex.getString(nameId), dex.getType(typeId), dex.getString(signId));
Expand All @@ -30,6 +34,7 @@ public DexLocalVar(int regNum, String name, String type, @Nullable String sign)
this.name = name;
this.type = type;
this.sign = sign;
LOG.info("regNum: " + Integer.toString(regNum) + ", name: " + name + ", argType: " + type + ", sign: " + sign);
}

public void start(int addr) {
Expand Down

0 comments on commit 3f8b3b5

Please sign in to comment.