Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
J
jadx
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
jadx
Commits
b87d1a7f
Commit
b87d1a7f
authored
Dec 21, 2014
by
YASME-Tim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed XML oneLiners. Added another attribute value data type
parent
c242a62b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
12 deletions
+31
-12
BinaryXMLParser.java
...-core/src/main/java/jadx/core/xmlgen/BinaryXMLParser.java
+31
-12
No files found.
jadx-core/src/main/java/jadx/core/xmlgen/BinaryXMLParser.java
View file @
b87d1a7f
...
...
@@ -16,7 +16,10 @@ public class BinaryXMLParser {
private
String
[]
strings
;
private
int
count
;
private
String
nsPrefix
=
"ERROR"
;
private
String
nsURI
=
"ERROR"
;
private
String
currentTag
=
"ERROR"
;
private
int
numtabs
=-
1
;
private
boolean
wasOneLiner
=
false
;
PrintWriter
writer
;
public
BinaryXMLParser
(
String
xmlfilepath
,
String
xmloutfilepath
)
{
//System.out.println(xmlfilepath);
...
...
@@ -126,6 +129,7 @@ public class BinaryXMLParser {
nsPrefix
=
strings
[
beginPrefix
];
int
beginURI
=
cInt32
(
bytes
,
count
);
//System.out.println("URI: " + strings[beginURI]);
nsURI
=
strings
[
beginURI
];
//System.out.println("COUNT: "+Integer.toHexString(count));
}
...
...
@@ -141,6 +145,7 @@ public class BinaryXMLParser {
//System.out.println("Prefix: " + strings[endPrefix]);
nsPrefix
=
strings
[
endPrefix
];
int
endURI
=
cInt32
(
bytes
,
count
);
nsURI
=
strings
[
endURI
];
//System.out.println("URI: " + strings[endURI]);
}
...
...
@@ -149,15 +154,20 @@ public class BinaryXMLParser {
if
(
cInt16
(
bytes
,
count
)
!=
0x0010
)
die
(
"ELEMENT HEADER SIZE is not 0x10"
);
//if(cInt32(bytes, count) != 0x0060) die("ELEMENT CHUNK SIZE is not 0x60");
count
+=
4
;
int
elementLineNumber
=
cInt32
(
bytes
,
count
);
//System.out.println("
elementLineNumber: " + elementLineNumber
);
int
element
Beg
LineNumber
=
cInt32
(
bytes
,
count
);
//System.out.println("
ELEMENT BEG Line: " + elementBegLineNumber + " of " + strings[startNSName]
);
int
comment
=
cInt32
(
bytes
,
count
);
//System.out.println("Comment: 0x" + Integer.toHexString(comment));
//System.out.println("COUNT: "+Integer.toHexString(count));
int
startNS
=
cInt32
(
bytes
,
count
);
//System.out.println("Namespace: 0x" + Integer.toHexString(startNS));
int
startNSName
=
cInt32
(
bytes
,
count
);
//
what to do with this id?
int
startNSName
=
cInt32
(
bytes
,
count
);
//
actually is elementName...
//System.out.println("Namespace name: " + strings[startNSName]);
if
(!
wasOneLiner
&&
!
"ERROR"
.
equals
(
currentTag
)
&&
!
currentTag
.
equals
(
strings
[
startNSName
]))
{
writer
.
println
(
">"
);
}
wasOneLiner
=
false
;
currentTag
=
strings
[
startNSName
];
for
(
int
i
=
0
;
i
<
numtabs
;
i
++)
writer
.
print
(
"\t"
);
writer
.
print
(
"<"
+
strings
[
startNSName
]);
int
attributeStart
=
cInt16
(
bytes
,
count
);
...
...
@@ -172,6 +182,7 @@ public class BinaryXMLParser {
//System.out.println("startNS: classIndex: " + classIndex);
int
styleIndex
=
cInt16
(
bytes
,
count
);
//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
<
attributeCount
;
i
++)
{
int
attributeNS
=
cInt32
(
bytes
,
count
);
...
...
@@ -183,7 +194,7 @@ public class BinaryXMLParser {
if
(
cInt8
(
bytes
,
count
)
!=
0
)
die
(
"res0 is not 0"
);
int
attrValDataType
=
cInt8
(
bytes
,
count
);
int
attrValData
=
cInt32
(
bytes
,
count
);
/*
/*
(
System.out.println("ai["+i+"] ns: " + attributeNS);
//if(attributeNS!=-1) System.out.println("ai["+i+"] Sns: " + strings[attributeNS]);
System.out.println("ai["+i+"] name: " + attributeName);
...
...
@@ -193,6 +204,7 @@ public class BinaryXMLParser {
System.out.println("ai["+i+"] d: " + attrValData);
*/
if
(
attributeNS
!=
-
1
)
writer
.
print
(
nsPrefix
+
":"
);
//writer.print(strings[attributeName] + "=\"");
if
(
attrValDataType
==
0x3
)
writer
.
print
(
strings
[
attributeName
]
+
"=\""
+
strings
[
attrValData
]+
"\""
);
else
if
(
attrValDataType
==
0x10
)
writer
.
print
(
strings
[
attributeName
]
+
"=\""
+
attrValData
+
"\""
);
else
if
(
attrValDataType
==
0x12
)
{
...
...
@@ -200,11 +212,12 @@ public class BinaryXMLParser {
if
(
attrValData
==
0
)
writer
.
print
(
strings
[
attributeName
]
+
"=\"false\""
);
else
if
(
attrValData
==
1
||
attrValData
==-
1
)
writer
.
print
(
strings
[
attributeName
]
+
"=\"true\""
);
else
writer
.
print
(
strings
[
attributeName
]
+
"=\"UNKNOWN\""
);
}
}
else
if
(
attrValDataType
==
0x1
)
writer
.
print
(
strings
[
attributeName
]
+
"=\"0x"
+
Integer
.
toHexString
(
attrValData
)
+
"\""
);
else
writer
.
print
(
strings
[
attributeName
]
+
" = UNKNOWN DATA TYPE: "
+
attrValDataType
);
writer
.
print
(
" "
);
if
((
i
+
1
)<
attributeCount
)
writer
.
print
(
" "
);
}
writer
.
println
(
">"
);
//writer.println(">");
//System.out.println("ELEMENT BEG Line: " + elementBegLineNumber + " of " + strings[startNSName]);
}
private
void
parseElementEnd
()
{
...
...
@@ -212,16 +225,22 @@ public class BinaryXMLParser {
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");
//System.out.println("ELEMENT END Line:" + endLineNumber);
int
comment
=
cInt32
(
bytes
,
count
);
//System.out.println("Comment: 0x" + Integer.toHexString(comment));
int
elementNS
=
cInt32
(
bytes
,
count
);
int
elementName
=
cInt32
(
bytes
,
count
);
for
(
int
i
=
0
;
i
<
numtabs
;
i
++)
writer
.
print
(
"\t"
);
writer
.
print
(
"</"
);
if
(
elementNS
!=
-
1
)
writer
.
print
(
strings
[
elementNS
]+
":"
);
writer
.
println
(
strings
[
elementName
]+
">"
);
if
(
currentTag
==
strings
[
elementName
])
{
writer
.
println
(
"/>"
);
wasOneLiner
=
true
;
}
else
{
for
(
int
i
=
0
;
i
<
numtabs
;
i
++)
writer
.
print
(
"\t"
);
writer
.
print
(
"</"
);
if
(
elementNS
!=
-
1
)
writer
.
print
(
strings
[
elementNS
]+
":"
);
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
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment