diff --git a/jadx-core/src/main/java/jadx/core/xmlgen/BinaryXMLParser.java b/jadx-core/src/main/java/jadx/core/xmlgen/BinaryXMLParser.java index c39dc4cbb..b043469e3 100644 --- a/jadx-core/src/main/java/jadx/core/xmlgen/BinaryXMLParser.java +++ b/jadx-core/src/main/java/jadx/core/xmlgen/BinaryXMLParser.java @@ -17,7 +17,17 @@ import java.util.HashMap; import java.util.Map; import android.R.style; -//import android.content.res.Resources; + +/* TODO: + Don't die when error occurs + Check error cases, maybe checked const values are not always the same + Better error messages + What to do, when Binary XML Manifest is > size(int)? + Check for missung chunk size types + Implement missing data types + Use linenumbers to recreate EXACT AndroidManifest + Check Element chunk size +*/ public class BinaryXMLParser { private byte[] bytes; @@ -28,10 +38,10 @@ public class BinaryXMLParser { private String currentTag="ERROR"; private int numtabs=-1; private boolean wasOneLiner=false; - PrintWriter writer; - Map styleMap = null; + private PrintWriter writer; + private Map styleMap = null; + public BinaryXMLParser(String xmlfilepath, String xmloutfilepath) { - //System.out.println(xmlfilepath); try { writer = new PrintWriter(xmloutfilepath,"UTF-8"); } catch(FileNotFoundException fnfe) { die("FNFE"); } @@ -83,10 +93,8 @@ public class BinaryXMLParser { else if(type==0x0103) parseElementEnd(); else if(type==0x0000) continue; // NullType is just doing nothing else die("Type: " + Integer.toHexString(type) + " not yet implemented"); - //System.out.println("COUNT: "+Integer.toHexString(count)); } writer.close(); - //die("Done"); } private void parseStringPool() { @@ -97,29 +105,18 @@ public class BinaryXMLParser { int flags = cInt32(bytes, count); int stringsStart = cInt32(bytes, count); int stylesStart = cInt32(bytes, count); -/* - System.out.println(hsize); - System.out.println(stringCount); - System.out.println(styleCount); - System.out.println(flags); - System.out.println(stringsStart); - System.out.println(stylesStart); -*/ int[] stringsOffsets = new int[stringCount]; for(int i=0; i"); } @@ -195,13 +172,9 @@ public class BinaryXMLParser { int attributeSize = cInt16(bytes, count); if(attributeSize != 0x14) die("startNS's attributeSize is not 0x14"); int attributeCount = cInt16(bytes, count); - //System.out.println("startNS: attributeCount: " + attributeCount); int idIndex = cInt16(bytes, count); - //System.out.println("startNS: idIndex: " + idIndex); int classIndex = cInt16(bytes, count); - //System.out.println("startNS: classIndex: " + classIndex); int styleIndex = cInt16(bytes, count); - if(styleIndex!=0) System.out.println("startNS: styleIndex: " + styleIndex); if("manifest".equals(strings[startNSName])) writer.print(" xmlns:\""+nsURI+"\""); if(attributeCount>0) writer.print(" "); for(int i=0; i"); - //System.out.println("ELEMENT BEG Line: " + elementBegLineNumber + " of " + strings[startNSName]); } private void parseElementEnd() { if(cInt16(bytes, count) != 0x0010) die("ELEMENT END header is not 0x0010"); if(cInt32(bytes, count) != 0x18) die("ELEMENT END header chunk is not 0x18 big"); int endLineNumber = cInt32(bytes, count); - //if(endLineNumber!=2) die("NAMESPACE beginning line number != 2 not supported yet"); int comment = cInt32(bytes, count); - //System.out.println("Comment: 0x" + Integer.toHexString(comment)); int elementNS = cInt32(bytes, count); int elementName = cInt32(bytes, count); if(currentTag==strings[elementName]) { @@ -291,8 +237,6 @@ public class BinaryXMLParser { writer.println(strings[elementName]+">"); } numtabs-=1; - //System.out.println("ELEMENT END Line: " + endLineNumber + " of " + strings[elementName]); - // TODO: Mind linenumbers for real original file ;) } private int cInt8(byte[] bytes, int offset) {