Skip to content

Commit 2dd2668

Browse files
authored
Merge pull request #46 from sunnamed434/dev
Bump new version 0.4.2-alpha.11
2 parents 0801440 + c3bed3f commit 2dd2668

File tree

4 files changed

+30
-11
lines changed

4 files changed

+30
-11
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
| Versions: |
22
| - |
3+
| [v0.4.2-alpha](#v042-alpha11) |
34
| [v0.4.1-alpha](#v041-alpha10) |
45
| [v0.4.0-alpha](#v040-alpha9) |
56
| [v0.3.3-alpha](#v033-alpha8) |
@@ -13,6 +14,9 @@
1314
| [v0.1.0](#v010) |
1415

1516
---
17+
### v0.4.2-alpha.11:
18+
#### Fixed:
19+
* Assembly resolving information and exceptions handling
1620

1721
### v0.4.1-alpha.10:
1822
#### Changed:

src/BitMono.CLI/Program.cs

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,32 +34,43 @@ private static async Task Main(string[] args)
3434
var moduleFileName = await new CLIBitMonoModuleFileResolver(args).ResolveAsync();
3535
if (string.IsNullOrWhiteSpace(moduleFileName))
3636
{
37-
Console.WriteLine("File not specified, please specify path to the file here: ");
38-
moduleFileName = Console.ReadLine();
39-
40-
if (string.IsNullOrWhiteSpace(moduleFileName))
37+
while (string.IsNullOrWhiteSpace(moduleFileName))
4138
{
39+
Console.Clear();
4240
Console.WriteLine("Please, specify file or drag-and-drop in BitMono CLI");
43-
Console.ReadLine();
44-
return;
41+
Console.WriteLine("File not specified, please specify path to the file here: ");
42+
moduleFileName = Console.ReadLine();
4543
}
4644
}
45+
var moduleFileBaseDirectory = Path.GetDirectoryName(moduleFileName);
46+
var dependenciesDirectoryName = Path.Combine(moduleFileBaseDirectory, "libs");
47+
if (Directory.Exists(dependenciesDirectoryName) == false)
48+
{
49+
while (string.IsNullOrWhiteSpace(dependenciesDirectoryName))
50+
{
51+
Console.Clear();
52+
Console.WriteLine("Please, specify dependencies (libs) path: ");
53+
dependenciesDirectoryName = Console.ReadLine();
54+
}
55+
}
56+
else
57+
{
58+
Console.WriteLine("Dependencies (libs) directory was automatically found {0}!", dependenciesDirectoryName);
59+
}
4760

4861
var domainBaseDirectory = AppDomain.CurrentDomain.BaseDirectory;
4962
var protectionsFile = Path.Combine(domainBaseDirectory, Protections);
5063
var runtimeModuleDefMD = ModuleDefMD.Load(typeof(BitMono.Runtime.Hooking).Module);
5164
Assembly.LoadFrom(protectionsFile);
5265

53-
var moduleFileBaseDirectory = Path.GetDirectoryName(moduleFileName);
54-
var dependenciesDirectoryName = Path.Combine(moduleFileBaseDirectory, "libs");
5566
var outputDirectoryName = Path.Combine(moduleFileBaseDirectory, "output");
5667
Directory.CreateDirectory(dependenciesDirectoryName);
5768
Directory.CreateDirectory(outputDirectoryName);
5869

5970
var serviceProvider = new BitMonoApplication().RegisterModule(new BitMonoModule(configureLogger =>
6071
{
6172
configureLogger.WriteTo.Async(configure => configure.Console(
62-
outputTemplate: "[{Timestamp:yyyy-MM-dd HH:mm:ss} {Level:u3}][{SourceContext}] {Message:lj}{NewLine}{Exception}"));
73+
outputTemplate: "[{Timestamp:yyyy-MM-dd HH:mm:ss} {Level:u3}][{SourceContext}] {Message:lj}{NewLine}{Exception}"));
6374
})).Build();
6475

6576
var obfuscationConfiguration = serviceProvider.LifetimeScope.Resolve<IBitMonoObfuscationConfiguration>();

src/BitMono.Core/Protecting/Resolvers/BitMonoAssemblyResolver.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using BitMono.API.Protecting.Contexts;
22
using dnlib.DotNet;
3+
using System;
34
using System.Collections.Generic;
45
using System.Threading;
56
using System.Threading.Tasks;
@@ -36,12 +37,13 @@ public Task<bool> ResolveAsync(CancellationToken cancellationToken = default)
3637

3738
try
3839
{
40+
m_Logger.Information("Resolving assembly: " + assemblyRef.Name);
3941
m_ProtectionContext.ModuleCreationOptions.Context.AssemblyResolver.ResolveThrow(assemblyRef, m_ProtectionContext.ModuleDefMD);
4042
}
41-
catch (AssemblyResolveException)
43+
catch (Exception ex)
4244
{
4345
resolvingSucceed = false;
44-
m_Logger.Error("Failed to resolve dependency {0}", assemblyRef.FullName);
46+
m_Logger.Error("Failed to resolve dependency {0}, message: ", assemblyRef.FullName, ex.Message);
4547
}
4648
}
4749
return Task.FromResult(resolvingSucceed);

src/BitMono.Obfuscation/BitMonoEngine.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ public BitMonoEngine(
3939

4040
public async Task ObfuscateAsync(BitMonoContext context, ModuleDefMD runtimeModuleDefMD, List<IProtection> protections, List<ProtectionSettings> protectionSettings, CancellationToken cancellationToken = default)
4141
{
42+
cancellationToken.ThrowIfCancellationRequested();
43+
4244
var moduleDefMDCreationResult = m_ModuleDefMDCreator.Create();
4345
var protectionContext = new ProtectionContextCreator(moduleDefMDCreationResult, runtimeModuleDefMD, context).Create();
4446
m_Logger.Information("Loaded Module {0}", moduleDefMDCreationResult.ModuleDefMD.Name);

0 commit comments

Comments
 (0)