-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from BUTR/dev
v1.0.3
- Loading branch information
Showing
22 changed files
with
159 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
MessageBox | ||
DeleteFile | ||
GetConsoleWindow | ||
ShowWindow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 10 additions & 12 deletions
22
...annerlord.BLSE.Shared/MessageBoxDialog.cs → ...ord.BLSE.Shared/Utils/MessageBoxDialog.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
|
||
using Windows.Win32; | ||
|
||
namespace Bannerlord.BLSE.Shared.Utils | ||
{ | ||
internal static class NtfsUnblocker | ||
{ | ||
public static void UnblockDirectory(string path, string wildcard = "*") => Parallel.ForEach(Directory.EnumerateFiles(path, wildcard, SearchOption.AllDirectories), UnblockFile); | ||
|
||
public static void UnblockFile(string fileName) => PInvoke.DeleteFile($"{fileName}:Zone.Identifier"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using Bannerlord.BUTR.Shared.Helpers; | ||
|
||
using HarmonyLib; | ||
using HarmonyLib.BUTR.Extensions; | ||
|
||
using System; | ||
using System.IO; | ||
using System.Reflection; | ||
using System.Threading; | ||
|
||
namespace Bannerlord.BLSE.Shared.Utils; | ||
|
||
public static class Unblocker | ||
{ | ||
private static readonly Harmony _harmony = new("Bannerlord.BLSE.Shared.Patches.Unblocker"); | ||
private static Thread? _currentUnblockingThread; | ||
|
||
|
||
public static void Unblock() | ||
{ | ||
if (_currentUnblockingThread is not null) | ||
return; | ||
|
||
Assembly.Load(new AssemblyName("TaleWorlds.Starter.Library")); | ||
|
||
var result = _harmony.TryPatch( | ||
AccessTools2.DeclaredMethod("TaleWorlds.Starter.Library.Program:Main"), | ||
prefix: AccessTools2.Method(typeof(Unblocker), nameof(MainPrefix))); | ||
|
||
if (result) | ||
{ | ||
_currentUnblockingThread = new Thread(UnblockFiles); | ||
_currentUnblockingThread.Start(); | ||
} | ||
} | ||
|
||
private static void MainPrefix() | ||
{ | ||
// We prevent the game from being started if we didn't finish with unblocking | ||
try | ||
{ | ||
_currentUnblockingThread?.Join(); | ||
} | ||
catch (Exception) { /* ignore */ } | ||
|
||
_harmony.Unpatch(AccessTools2.DeclaredMethod("TaleWorlds.Starter.Library.Program:Main"), AccessTools2.Method(typeof(Unblocker), nameof(MainPrefix))); | ||
} | ||
|
||
private static void UnblockFiles() | ||
{ | ||
var modulesPath = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), "../", "../", ModuleInfoHelper.ModulesFolder)); | ||
if (Directory.Exists(modulesPath)) | ||
{ | ||
try | ||
{ | ||
NtfsUnblocker.UnblockDirectory(modulesPath, "*.dll"); | ||
} | ||
catch { /* ignore */ } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 9 additions & 11 deletions
20
src/Bannerlord.LauncherEx/Helpers/Input/MessageBoxDialog.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.