-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
331 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} | ||
} |
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,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")] |
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,62 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{1384CA6F-5951-45C6-B080-27E64C5D5DA9}</ProjectGuid> | ||
<OutputType>WinExe</OutputType> | ||
<RootNamespace>UnbanPluginsCN</RootNamespace> | ||
<AssemblyName>UnbanPluginsCN</AssemblyName> | ||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | ||
<Deterministic>true</Deterministic> | ||
<LangVersion>preview</LangVersion> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>x64</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>x64</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<StartupObject /> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<ApplicationManifest>app.manifest</ApplicationManifest> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Drawing" /> | ||
<Reference Include="System.Windows.Forms" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="app.manifest" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
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,79 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/> | ||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> | ||
<security> | ||
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3"> | ||
<!-- UAC Manifest Options | ||
If you want to change the Windows User Account Control level replace the | ||
requestedExecutionLevel node with one of the following. | ||
<requestedExecutionLevel level="asInvoker" uiAccess="false" /> | ||
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> | ||
<requestedExecutionLevel level="highestAvailable" uiAccess="false" /> | ||
Specifying requestedExecutionLevel element will disable file and registry virtualization. | ||
Remove this element if your application requires this virtualization for backwards | ||
compatibility. | ||
--> | ||
<requestedExecutionLevel level="highestAvailable" uiAccess="false" /> | ||
</requestedPrivileges> | ||
</security> | ||
</trustInfo> | ||
|
||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> | ||
<application> | ||
<!-- A list of the Windows versions that this application has been tested on | ||
and is designed to work with. Uncomment the appropriate elements | ||
and Windows will automatically select the most compatible environment. --> | ||
|
||
<!-- Windows Vista --> | ||
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />--> | ||
|
||
<!-- Windows 7 --> | ||
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />--> | ||
|
||
<!-- Windows 8 --> | ||
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />--> | ||
|
||
<!-- Windows 8.1 --> | ||
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />--> | ||
|
||
<!-- Windows 10 --> | ||
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />--> | ||
|
||
</application> | ||
</compatibility> | ||
|
||
<!-- Indicates that the application is DPI-aware and will not be automatically scaled by Windows at higher | ||
DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need | ||
to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should | ||
also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config. | ||
Makes the application long-path aware. See https://docs.microsoft.com/windows/win32/fileio/maximum-file-path-limitation --> | ||
<!-- | ||
<application xmlns="urn:schemas-microsoft-com:asm.v3"> | ||
<windowsSettings> | ||
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware> | ||
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware> | ||
</windowsSettings> | ||
</application> | ||
--> | ||
|
||
<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) --> | ||
<!-- | ||
<dependency> | ||
<dependentAssembly> | ||
<assemblyIdentity | ||
type="win32" | ||
name="Microsoft.Windows.Common-Controls" | ||
version="6.0.0.0" | ||
processorArchitecture="*" | ||
publicKeyToken="6595b64144ccf1df" | ||
language="*" | ||
/> | ||
</dependentAssembly> | ||
</dependency> | ||
--> | ||
|
||
</assembly> |
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