Skip to content

Commit d7c3e89

Browse files
committed
TargetFrameworks net35;net40
1 parent 3952e76 commit d7c3e89

File tree

7 files changed

+118
-11
lines changed

7 files changed

+118
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# unpack.libmonodroid_bundle_app.so
2-
Unpack *.apk\lib\{ABI}\libmonodroid_bundle_app.so
2+
Unpack *.apk\lib\\{ABI\}\libmonodroid_bundle_app.so

unpack.libmonodroid_bundle_app.so/Program.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,18 @@ void Main()
4242
// ReSharper disable PossibleNullReferenceException
4343
var entryAssembly = Assembly.GetEntryAssembly();
4444
var title = entryAssembly.FullName.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault();
45-
if (!string.IsNullOrWhiteSpace(title)) Console.Title = title;
45+
// ReSharper disable once AssignNullToNotNullAttribute
46+
if (!title.IsNullOrWhiteSpace()) Console.Title = title;
4647
var rootPath = Path.GetDirectoryName(entryAssembly.Location);
4748
if (rootPath == null) throw new ArgumentNullException(nameof(rootPath));
48-
var sofilepaths = Directory.GetFiles(rootPath).Where(x =>
49-
Path.GetExtension(x).Equals(GetSoFileExtension(), StringComparison.OrdinalIgnoreCase)).ToArray();
50-
var sofilepath =
51-
sofilepaths.FirstOrDefault(x => Path.GetFileName(x).Equals(GetSoDefaultFileName(), StringComparison.OrdinalIgnoreCase)) ??
52-
sofilepaths.FirstOrDefault();
49+
var sofilepath = args?.FirstOrDefault(x => x != null && File.Exists(x) && Path.GetExtension(x).Equals(GetSoFileExtension(), StringComparison.OrdinalIgnoreCase));
50+
if (sofilepath == null)
51+
{
52+
var sofilepaths = Directory.GetFiles(rootPath).Where(x => Path.GetExtension(x).Equals(GetSoFileExtension(), StringComparison.OrdinalIgnoreCase)).ToArray();
53+
sofilepath =
54+
sofilepaths.FirstOrDefault(x => Path.GetFileName(x).Equals(GetSoDefaultFileName(), StringComparison.OrdinalIgnoreCase)) ??
55+
sofilepaths.FirstOrDefault();
56+
}
5357
if (sofilepath == null) ReadLineAndExit("Can not find the .so file.");
5458
// ReSharper disable once AssignNullToNotNullAttribute
5559
var bytes = File.ReadAllBytes(sofilepath);
@@ -71,7 +75,7 @@ void Main()
7175
addr += i;
7276

7377
var name = GetString(bytes, addr);
74-
if (string.IsNullOrWhiteSpace(name))
78+
if (name.IsNullOrWhiteSpace())
7579
break;
7680

7781
//We only care about dlls
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1-
using System.Runtime.CompilerServices;
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
23

34
[assembly: SuppressIldasm]
5+
6+
[assembly: AssemblyTitle("unpack.libmonodroid_bundle_app.so " +
7+
#if NET35
8+
".NET Framework 3.5"
9+
#elif NET40
10+
".NET Framework 4.0"
11+
#else
12+
""
13+
#endif
14+
)]
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#if NET35
2+
3+
// ReSharper disable once CheckNamespace
4+
namespace System.IO
5+
{
6+
/// <summary>
7+
/// CopyTo .NET Framework 3.5
8+
/// </summary>
9+
public static class StreamExtension
10+
{
11+
public static void CopyTo(this Stream source, Stream destination) => CopyTo(source, destination, 81920);
12+
13+
public static void CopyTo(this Stream source, Stream destination, int bufferSize)
14+
{
15+
if (source == null)
16+
throw new ArgumentNullException(nameof(source));
17+
if (destination == null)
18+
throw new ArgumentNullException(nameof(destination));
19+
if (bufferSize <= 0)
20+
throw new ArgumentOutOfRangeException(nameof(bufferSize), "ArgumentOutOfRange_NeedPosNum");
21+
if (!source.CanRead && !source.CanWrite)
22+
throw new ObjectDisposedException(nameof(source), "ObjectDisposed_StreamClosed");
23+
if (!destination.CanRead && !destination.CanWrite)
24+
throw new ObjectDisposedException(nameof(destination), "ObjectDisposed_StreamClosed");
25+
if (!source.CanRead)
26+
throw new NotSupportedException(nameof(source) + "_NotSupported_UnreadableStream");
27+
if (!destination.CanWrite)
28+
throw new NotSupportedException(nameof(destination) + "_NotSupported_UnwritableStream");
29+
InternalCopyTo(source, destination, bufferSize);
30+
}
31+
32+
private static void InternalCopyTo(Stream source, Stream destination, int bufferSize)
33+
{
34+
byte[] buffer = new byte[bufferSize];
35+
int count;
36+
while ((count = source.Read(buffer, 0, buffer.Length)) != 0)
37+
destination.Write(buffer, 0, count);
38+
}
39+
}
40+
}
41+
42+
#endif
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// ReSharper disable once CheckNamespace
2+
namespace System
3+
{
4+
/// <summary>
5+
/// System.String Extension
6+
/// </summary>
7+
public static partial class StringExtension
8+
{
9+
#if NET35
10+
/// <summary>
11+
/// 指示指定的字符串是 <see langword="null" />、空还是仅由空白字符组成。
12+
/// </summary>
13+
/// <param name="value">要测试的字符串。</param>
14+
/// <returns>
15+
/// 如果 <see langword="true" /> 参数为 <paramref name="value" /> 或 <see langword="null" />,或者如果 <see cref="F:System.String.Empty" /> 仅由空白字符组成,则为 <paramref name="value" />。
16+
/// </returns>
17+
public static bool IsNullOrWhiteSpace(this string value)
18+
{
19+
if (value == null)
20+
return true;
21+
for (int index = 0; index < value.Length; ++index)
22+
{
23+
if (!char.IsWhiteSpace(value[index]))
24+
return false;
25+
}
26+
return true;
27+
}
28+
29+
#else
30+
31+
/// <summary>
32+
/// 指示指定的字符串是 <see langword="null" />、空还是仅由空白字符组成。
33+
/// </summary>
34+
/// <param name="value">要测试的字符串。</param>
35+
/// <returns>
36+
/// 如果 <see langword="true" /> 参数为 <paramref name="value" /> 或 <see langword="null" />,或者如果 <see cref="F:System.String.Empty" /> 仅由空白字符组成,则为 <paramref name="value" />。
37+
/// </returns>
38+
public static bool IsNullOrWhiteSpace(this string value) => string.IsNullOrWhiteSpace(value);
39+
40+
#endif
41+
42+
}
43+
}

unpack.libmonodroid_bundle_app.so/unpack.libmonodroid_bundle_app.so.csproj

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,22 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net45</TargetFramework>
6-
<SignAssembly>false</SignAssembly>
5+
<TargetFrameworks>net35;net40</TargetFrameworks>
6+
<SignAssembly>true</SignAssembly>
77
<LangVersion>latest</LangVersion>
88
<PlatformTarget>AnyCPU</PlatformTarget>
99
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
1010
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
1111
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
1212
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
1313
<GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
14+
<DelaySign>false</DelaySign>
15+
<AssemblyOriginatorKeyFile>unpack.libmonodroid_bundle_app.so.snk</AssemblyOriginatorKeyFile>
16+
</PropertyGroup>
17+
18+
<PropertyGroup Condition="'$(Configuration)'=='Release'">
19+
<DebugType>none</DebugType>
20+
<DebugSymbols>false</DebugSymbols>
1421
</PropertyGroup>
1522

1623
<ItemGroup>
Binary file not shown.

0 commit comments

Comments
 (0)