-
Notifications
You must be signed in to change notification settings - Fork 51
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 #191 from SubnauticaModding/dev
QModManager 4.0.2.3
- Loading branch information
Showing
24 changed files
with
120 additions
and
33 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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 |
---|---|---|
@@ -1 +1 @@ | ||
4.0.2.2 | ||
4.0.2.3 |
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,68 @@ | ||
using Mono.Cecil; | ||
using System; | ||
using System.IO; | ||
|
||
namespace QModManager | ||
{ | ||
internal static class CleanUp | ||
{ | ||
private static bool IsChildOf(this DirectoryInfo child, DirectoryInfo parent, bool recursive = false) | ||
{ | ||
if (child.Parent == null) | ||
return false; | ||
|
||
return child.Parent.FullName == parent.FullName || (recursive && child.Parent.IsChildOf(parent, recursive)); | ||
} | ||
|
||
private static bool IsChildOf(this FileInfo child, DirectoryInfo parent, bool recursive = true) | ||
{ | ||
if (child.Directory == null) | ||
return false; | ||
|
||
return child.Directory.FullName == parent.FullName || (recursive && child.Directory.IsChildOf(parent, recursive)); | ||
} | ||
private static bool IsChildOf(this FileInfo child, string parentPath, bool recursive = true) | ||
=> child.IsChildOf(new DirectoryInfo(parentPath), recursive); | ||
|
||
internal static void Initialize(string gameRootDirectory, string managedDirectory) | ||
{ | ||
string qmodsDirectory = Path.Combine(gameRootDirectory, "QMods"); | ||
string bepinexCoreDirectory = Path.Combine(gameRootDirectory, "BepInEx", "core"); | ||
|
||
string[] pathsToCheck = new[] { managedDirectory, qmodsDirectory }; | ||
|
||
foreach (var path in pathsToCheck) | ||
{ | ||
foreach (var file in Directory.GetFiles(path, "*.dll", SearchOption.AllDirectories)) | ||
{ | ||
var fileInfo = new FileInfo(file); | ||
if (fileInfo.FullName.Contains("system32") || fileInfo.FullName.Contains("Windows") || fileInfo.IsChildOf(bepinexCoreDirectory, true)) | ||
{ | ||
Console.WriteLine($"Path is unsafe! {path}"); | ||
continue; | ||
} | ||
|
||
try | ||
{ | ||
using (var stream = new MemoryStream(File.ReadAllBytes(file))) | ||
{ | ||
if (AssemblyDefinition.ReadAssembly(stream).MainModule.Name == "0Harmony" && File.Exists(file)) | ||
{ | ||
File.Delete(file); | ||
Console.WriteLine($"Deleted {new DirectoryInfo(file).FullName}..."); | ||
} | ||
} | ||
} | ||
catch (BadImageFormatException) | ||
{ | ||
if (Path.GetFileName(file).StartsWith("0Harmony") && File.Exists(file)) | ||
{ | ||
File.Delete(file); | ||
Console.WriteLine($"Deleted {new DirectoryInfo(file).FullName}..."); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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
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
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