Thursday, July 11, 2013

Re: [android-developers] Re: Modifying an String of Android Resource File (*.arsc)

Thanks Yaron, but my requirement is parsing and modifying arsc file at runtime on the device.

So my next question is can apktool be ported on device. What I mean is since the source code is available are there any lib/frameworks (that apktool) which are only available for desktop and not for android.


On Thu, Jul 11, 2013 at 8:13 AM, Yaron Reinharts <yaron.reinharts@gmail.com> wrote:
No need to reinvent the wheel:
https://code.google.com/p/android-apktool/

Hope this helps
Yaron

On 07/11/2013 02:13 AM, giles ian wrote:
Hi Illyoung Choi,

Is it possible for you to share the code for the entire thing. i.e. 

1.Parsing
2. Modifying

On Tuesday, June 21, 2011 8:09:12 PM UTC-7, Illyoung Choi wrote:
Hi All.

Last day, I made a simple application for parsing an Android Resource
File (*.arsc) and modifying resource strings.

I think this thing might be a help for someone, so I'll share the
structure of *.arsc that I understood.

Since I could not spend many hours for this, my understanding is not
perfect and might be slightly wrong.


I patched string resource from *.apk.
Simply extracted *.apk with 7zip and got the resources.arsc file.

Below are the structure of *.arsc

struct ANDROID_RESOURCE_HEADER
{
int signature; // 0x000c0002, I assume this is a signature
int nImageLength; // total ARSC file size (bytes)
int nUnknown1[2]; // still unknown (not important for modifying
strings)
int nStringBlockLength; // total StringBlock(see below) size
int nStringCount; // total number of String Resources
int nUnknown2[4]; // still unknown  (not important for modifying
strings)
}

"struct ANDROID_RESOURCE_HEADER" is a header of ARSC file image.
So simply you can read this header information from file.

After this header, you will meet the StringBlock

StringBlock has 2Sections
{
[String Offset]
[String Data]
}

String Offset Section has Offset Values of Specific Strings from
StringBlock Start Address.

String Data Section has 2 Part

String Data
{
[Length]
[String]
}

Length part is 2byte. but, in AscII Mode, uses only 1byte.
Before reading String, you must check whether it is "Unicode" or
"AscII" format.

in Unicode format, Length part will be used with 2bytes.
normally it is "0x??, 0x00" (only if it is not longer than 256 bytes)

in AscII format, Length part will be used with 1bytes. but, they also
used second byte for mirroring.
if string length has a value 7, you will meet "0x07, 0x07"

So, I checked whether both bytes have same value to check string
format.


Lastly, actual string data will be after this length part with "Zero
Terminal"
in Unicode format, surely, Zero Terminal will be 2 byte of zero.



Whenever you change the string of this ARSC file, you should
recalculate these.
Length Part of String Data
String Offset of StringBlock
nImageLength of Header
nStringBlockLength of Header


After doing these all.
Simply, remove all JAR Signature (META-INF folder) from package.
Re-Archive with Zip and rename with *.apk.
Resign with your certificate by using "jarsigner" of JDK



Thanks.
--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 


--   Yaron Reinharts   Smart Drive Applications  http://www.poncho.co.il/gateaway.php  https://market.android.com/details?id=com.poncho.gsm.gate.activities      

--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate