From fe0a87f356f0c9ac6b6fca7b9595cbcaf2a067ad Mon Sep 17 00:00:00 2001
From: Limiana <5073202+Limiana@users.noreply.github.com>
Date: Mon, 19 Sep 2022 17:41:20 +0300
Subject: [PATCH] update
---
Program/Program.cs | 136 +++++++++++++++++++++++++++
Program/Properties/AssemblyInfo.cs | 36 +++++++
Program/UnbanPluginsCN.csproj | 62 ++++++++++++
Program/app.manifest | 79 ++++++++++++++++
UnbanPluginsCN.sln | 10 +-
UnbanPluginsCN/UnbanPluginsCN.csproj | 13 +++
6 files changed, 331 insertions(+), 5 deletions(-)
create mode 100644 Program/Program.cs
create mode 100644 Program/Properties/AssemblyInfo.cs
create mode 100644 Program/UnbanPluginsCN.csproj
create mode 100644 Program/app.manifest
diff --git a/Program/Program.cs b/Program/Program.cs
new file mode 100644
index 0000000..33bbfb4
--- /dev/null
+++ b/Program/Program.cs
@@ -0,0 +1,136 @@
+// See https://aka.ms/new-console-template for more information
+using System;
+using System.Diagnostics;
+using System.Drawing;
+using System.IO;
+using System.Threading;
+using System.Windows.Forms;
+using static System.Net.Mime.MediaTypeNames;
+
+namespace UnbanPluginsCN;
+class Program
+{
+
+ private static string appGuid = "92f42221-51a5-4753-9e91-84aeea157d17";
+ static NotifyIcon n = null;
+ public static void Main(string[] args)
+ {
+ var mutex = new Mutex(true, appGuid, out var createdNew);
+
+ if (!createdNew)
+ {
+ MessageBox.Show("Another copy of UnbanPluginCN is already running");
+ return;
+ }
+
+ n = new NotifyIcon
+ {
+ Icon = SystemIcons.Application,
+ Visible = true,
+ Text = "UnbanPluginsCN",
+ ContextMenuStrip = new()
+ };
+ n.ContextMenuStrip.Items.Add("Exit", null, delegate { n.Dispose(); Environment.Exit(0); });
+
+ new Thread(() =>
+ {
+ Log("This is the beginning.");
+ while (true)
+ {
+ try
+ {
+ Thread.Sleep(500);
+ foreach (var x in Process.GetProcessesByName("Dalamud.Updater"))
+ {
+ if (!x.HasExited && x.MainModule != null)
+ {
+ Log($"Found process: {x.MainModule.FileName}");
+ var directory = Path.GetDirectoryName(x.MainModule.FileName);
+ if (directory != null)
+ {
+ Log($"Purging all bannedplugin.json files");
+ foreach (var f in Directory.GetFiles(directory, "bannedplugin.json", SearchOption.AllDirectories))
+ {
+ if (Path.GetFileName(f) == "bannedplugin.json")
+ {
+ Log($"File: {f}");
+ try
+ {
+ File.WriteAllText(f, "[]");
+ }
+ catch (Exception e)
+ {
+ Log(e.Message);
+ }
+ }
+ }
+ using var watcher = new FileSystemWatcher(directory);
+
+ watcher.NotifyFilter = NotifyFilters.Attributes
+ | NotifyFilters.CreationTime
+ | NotifyFilters.DirectoryName
+ | NotifyFilters.FileName
+ | NotifyFilters.LastWrite
+ | NotifyFilters.Security
+ | NotifyFilters.Size;
+
+ watcher.Changed += OnChanged;
+ watcher.Created += OnCreated;
+
+ watcher.Filter = "bannedplugin.json";
+ watcher.IncludeSubdirectories = true;
+ watcher.EnableRaisingEvents = true;
+ x.WaitForExit();
+ watcher.EnableRaisingEvents = false;
+ Log("Process terminated, awaiting next...");
+ }
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ Log(ex.Message);
+ }
+ }
+ }).Start();
+ System.Windows.Forms.Application.Run();
+ }
+
+ static void Log(string s)
+ {
+
+ Console.WriteLine(s);
+ File.AppendAllText("UnbanPluginsCN.log", s + "\n");
+ }
+
+ private static void OnChanged(object sender, FileSystemEventArgs e)
+ {
+ if (e.ChangeType != WatcherChangeTypes.Changed)
+ {
+ return;
+ }
+ Log($"Changed: {e.FullPath}");
+ try
+ {
+ File.WriteAllText(e.FullPath, "[]");
+ }
+ catch (Exception ex)
+ {
+ Log(ex.Message);
+ }
+ }
+
+ private static void OnCreated(object sender, FileSystemEventArgs e)
+ {
+ string value = $"Created: {e.FullPath}";
+ Log(value);
+ try
+ {
+ File.WriteAllText(e.FullPath, "[]");
+ }
+ catch (Exception ex)
+ {
+ Log(ex.Message);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Program/Properties/AssemblyInfo.cs b/Program/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..3b34739
--- /dev/null
+++ b/Program/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Program")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Program")]
+[assembly: AssemblyCopyright("Copyright © 2022")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("1384ca6f-5951-45c6-b080-27e64c5d5da9")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Program/UnbanPluginsCN.csproj b/Program/UnbanPluginsCN.csproj
new file mode 100644
index 0000000..be47050
--- /dev/null
+++ b/Program/UnbanPluginsCN.csproj
@@ -0,0 +1,62 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {1384CA6F-5951-45C6-B080-27E64C5D5DA9}
+ WinExe
+ UnbanPluginsCN
+ UnbanPluginsCN
+ v4.7.2
+ 512
+ true
+ true
+ preview
+
+
+ x64
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ x64
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+ app.manifest
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Program/app.manifest b/Program/app.manifest
new file mode 100644
index 0000000..49c0149
--- /dev/null
+++ b/Program/app.manifest
@@ -0,0 +1,79 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/UnbanPluginsCN.sln b/UnbanPluginsCN.sln
index 4d3c9fd..61e594c 100644
--- a/UnbanPluginsCN.sln
+++ b/UnbanPluginsCN.sln
@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.32804.182
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnbanPluginsCN", "UnbanPluginsCN\UnbanPluginsCN.csproj", "{0D6CA012-06C1-4412-AB0A-AFFFC55B0834}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnbanPluginsCN", "Program\UnbanPluginsCN.csproj", "{1384CA6F-5951-45C6-B080-27E64C5D5DA9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -11,10 +11,10 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {0D6CA012-06C1-4412-AB0A-AFFFC55B0834}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {0D6CA012-06C1-4412-AB0A-AFFFC55B0834}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {0D6CA012-06C1-4412-AB0A-AFFFC55B0834}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {0D6CA012-06C1-4412-AB0A-AFFFC55B0834}.Release|Any CPU.Build.0 = Release|Any CPU
+ {1384CA6F-5951-45C6-B080-27E64C5D5DA9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1384CA6F-5951-45C6-B080-27E64C5D5DA9}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1384CA6F-5951-45C6-B080-27E64C5D5DA9}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1384CA6F-5951-45C6-B080-27E64C5D5DA9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/UnbanPluginsCN/UnbanPluginsCN.csproj b/UnbanPluginsCN/UnbanPluginsCN.csproj
index 2fa28f5..2b39e9f 100644
--- a/UnbanPluginsCN/UnbanPluginsCN.csproj
+++ b/UnbanPluginsCN/UnbanPluginsCN.csproj
@@ -6,6 +6,19 @@
enable
enable
true
+ <_SuppressWinFormsTrimError>true
+ true
+ true
+ win10-x64
+
+ true
+
+
+ embedded
+
+
+ embedded
+