Compare commits

...

2 Commits

Author SHA1 Message Date
~lucidiot e938a28c5f Do not decode file contents as text
This adds support for extracting binaries, even
if they are completely invalid UTF-16LE text.
2022-06-02 22:32:30 +02:00
~lucidiot 7e413eb87b Handle UnauthorizedAccessException 2022-06-02 22:31:21 +02:00
4 changed files with 10 additions and 5 deletions

View File

@ -106,6 +106,12 @@ If any of the files do not exist or if any error occurs while parsing one of the
path,
destination,
e.Message);
} catch (UnauthorizedAccessException e) {
Console.WriteLine(
"Failed unpacking APK file at {0} to {1}: {2}",
path,
destination,
e.Message);
}
}

View File

@ -104,7 +104,7 @@ namespace TSUnpack {
string dir = Path.GetDirectoryName(path);
if (!Directory.Exists(dir))
Directory.CreateDirectory(dir);
File.WriteAllBytes(path, Encoding.Unicode.GetBytes(apkFile.Content));
File.WriteAllBytes(path, apkFile.Content);
}
}
}

View File

@ -87,16 +87,16 @@ namespace Kaitai
{
_fileLen = m_io.ReadU4le();
_name = new ApkString(m_io, this, m_root);
_content = System.Text.Encoding.GetEncoding("utf-16").GetString(m_io.ReadBytes(FileLen));
_content = m_io.ReadBytes(FileLen);
}
private uint _fileLen;
private ApkString _name;
private string _content;
private byte[] _content;
private MstsApk m_root;
private MstsApk m_parent;
public uint FileLen { get { return _fileLen; } }
public ApkString Name { get { return _name; } }
public string Content { get { return _content; } }
public byte[] Content { get { return _content; } }
public MstsApk M_Root { get { return m_root; } }
public MstsApk M_Parent { get { return m_parent; } }
}

View File

@ -25,7 +25,6 @@ types:
- id: name
type: apk_string
- id: content
type: str
size: file_len
seq:
- id: route_display_name