Add files via upload

This commit is contained in:
Bluzume 2021-03-09 10:48:40 +13:00 committed by GitHub
parent 959b572d8e
commit de020c5e60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 10940 additions and 5 deletions

View File

@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30114.105
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlashPatcher", "DontTouchMyFlash\FlashPatcher.csproj", "{E986744D-FB17-40E9-83DC-6043995545D9}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlashPatcher", "FlashPatcher\FlashPatcher.csproj", "{E986744D-FB17-40E9-83DC-6043995545D9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

6
FlashPatcher/App.config Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup>
</configuration>

View File

@ -0,0 +1,99 @@
<?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>{E986744D-FB17-40E9-83DC-6043995545D9}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>FlashPatcher</RootNamespace>
<AssemblyName>Flash Pwner</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</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>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup />
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>icon0.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="FileUtil.cs" />
<Compile Include="FlashPwner.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FlashPwner.Designer.cs">
<DependentUpon>FlashPwner.cs</DependentUpon>
</Compile>
<Compile Include="Privileges.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="FlashPwner.resx">
<DependentUpon>FlashPwner.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="app.manifest" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Content Include="icon0.ico" />
</ItemGroup>
<ItemGroup>
<Folder Include="Resources\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

132
FlashPatcher/FileUtil.cs Normal file
View File

@ -0,0 +1,132 @@
using System.Runtime.InteropServices;
using System.Diagnostics;
using System;
using System.Collections.Generic;
static public class FileUtil
{
[StructLayout(LayoutKind.Sequential)]
struct RM_UNIQUE_PROCESS
{
public int dwProcessId;
public System.Runtime.InteropServices.ComTypes.FILETIME ProcessStartTime;
}
const int RmRebootReasonNone = 0;
const int CCH_RM_MAX_APP_NAME = 255;
const int CCH_RM_MAX_SVC_NAME = 63;
enum RM_APP_TYPE
{
RmUnknownApp = 0,
RmMainWindow = 1,
RmOtherWindow = 2,
RmService = 3,
RmExplorer = 4,
RmConsole = 5,
RmCritical = 1000
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
struct RM_PROCESS_INFO
{
public RM_UNIQUE_PROCESS Process;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = CCH_RM_MAX_APP_NAME + 1)]
public string strAppName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = CCH_RM_MAX_SVC_NAME + 1)]
public string strServiceShortName;
public RM_APP_TYPE ApplicationType;
public uint AppStatus;
public uint TSSessionId;
[MarshalAs(UnmanagedType.Bool)]
public bool bRestartable;
}
[DllImport("rstrtmgr.dll", CharSet = CharSet.Unicode)]
static extern int RmRegisterResources(uint pSessionHandle,
UInt32 nFiles,
string[] rgsFilenames,
UInt32 nApplications,
[In] RM_UNIQUE_PROCESS[] rgApplications,
UInt32 nServices,
string[] rgsServiceNames);
[DllImport("rstrtmgr.dll", CharSet = CharSet.Auto)]
static extern int RmStartSession(out uint pSessionHandle, int dwSessionFlags, string strSessionKey);
[DllImport("rstrtmgr.dll")]
static extern int RmEndSession(uint pSessionHandle);
[DllImport("rstrtmgr.dll")]
static extern int RmGetList(uint dwSessionHandle,
out uint pnProcInfoNeeded,
ref uint pnProcInfo,
[In, Out] RM_PROCESS_INFO[] rgAffectedApps,
ref uint lpdwRebootReasons);
static public List<Process> WhoIsLocking(string path)
{
uint handle;
string key = Guid.NewGuid().ToString();
List<Process> processes = new List<Process>();
int res = RmStartSession(out handle, 0, key);
if (res != 0) throw new Exception("Could not begin restart session. Unable to determine file locker.");
try
{
const int ERROR_MORE_DATA = 234;
uint pnProcInfoNeeded = 0,
pnProcInfo = 0,
lpdwRebootReasons = RmRebootReasonNone;
string[] resources = new string[] { path }; // Just checking on one resource.
res = RmRegisterResources(handle, (uint)resources.Length, resources, 0, null, 0, null);
if (res != 0) throw new Exception("Could not register resource.");
//Note: there's a race condition here -- the first call to RmGetList() returns
// the total number of process. However, when we call RmGetList() again to get
// the actual processes this number may have increased.
res = RmGetList(handle, out pnProcInfoNeeded, ref pnProcInfo, null, ref lpdwRebootReasons);
if (res == ERROR_MORE_DATA)
{
// Create an array to store the process results
RM_PROCESS_INFO[] processInfo = new RM_PROCESS_INFO[pnProcInfoNeeded];
pnProcInfo = pnProcInfoNeeded;
// Get the list
res = RmGetList(handle, out pnProcInfoNeeded, ref pnProcInfo, processInfo, ref lpdwRebootReasons);
if (res == 0)
{
processes = new List<Process>((int)pnProcInfo);
// Enumerate all of the results and add them to the
// list to be returned
for (int i = 0; i < pnProcInfo; i++)
{
try
{
processes.Add(Process.GetProcessById(processInfo[i].Process.dwProcessId));
}
// catch the error -- in case the process is no longer running
catch (ArgumentException) { }
}
}
else throw new Exception("Could not list processes locking resource.");
}
else if (res != 0) throw new Exception("Could not list processes locking resource. Failed to get size of result.");
}
finally
{
RmEndSession(handle);
}
return processes;
}
}

View File

@ -0,0 +1,101 @@
<?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>{E986744D-FB17-40E9-83DC-6043995545D9}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>FlashPatcher</RootNamespace>
<AssemblyName>Flash Patcher</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup />
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>icon0.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="FileUtil.cs" />
<Compile Include="FlashPatcherForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FlashPatcherForm.Designer.cs">
<DependentUpon>FlashPatcherForm.cs</DependentUpon>
</Compile>
<Compile Include="Privileges.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="FlashPatcherForm.resx">
<DependentUpon>FlashPatcherForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="app.manifest" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Content Include="icon0.ico" />
</ItemGroup>
<ItemGroup>
<Folder Include="Resources\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

175
FlashPatcher/FlashPatcherForm.Designer.cs generated Normal file
View File

@ -0,0 +1,175 @@
namespace FlashPatcher
{
partial class FlashPatcherForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FlashPatcherForm));
this.label1 = new System.Windows.Forms.Label();
this.addFile = new System.Windows.Forms.Button();
this.cringe = new System.Windows.Forms.Label();
this.defuseBomb = new System.Windows.Forms.Button();
this.console = new System.Windows.Forms.TextBox();
this.flashExes = new System.Windows.Forms.ListBox();
this.deleteFile = new System.Windows.Forms.Button();
this.progressBar = new System.Windows.Forms.ProgressBar();
this.projectorPatch = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(9, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(263, 13);
this.label1.TabIndex = 0;
this.label1.Text = "Flash Executables: (pepflash.dll, NPSWF64, flash.ocx)";
//
// addFile
//
this.addFile.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.addFile.Location = new System.Drawing.Point(434, 2);
this.addFile.Name = "addFile";
this.addFile.Size = new System.Drawing.Size(39, 20);
this.addFile.TabIndex = 1;
this.addFile.Text = "Add ";
this.addFile.UseVisualStyleBackColor = true;
this.addFile.Click += new System.EventHandler(this.addFile_Click);
//
// cringe
//
this.cringe.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.cringe.AutoSize = true;
this.cringe.Location = new System.Drawing.Point(2, 530);
this.cringe.Name = "cringe";
this.cringe.Size = new System.Drawing.Size(211, 13);
this.cringe.TabIndex = 4;
this.cringe.Text = "The quieter you becom, the moar u cn hear";
//
// defuseBomb
//
this.defuseBomb.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.defuseBomb.Location = new System.Drawing.Point(11, 468);
this.defuseBomb.Name = "defuseBomb";
this.defuseBomb.Size = new System.Drawing.Size(462, 23);
this.defuseBomb.TabIndex = 5;
this.defuseBomb.Text = "!!! DEFUSE THE BOMB !!!";
this.defuseBomb.UseVisualStyleBackColor = true;
this.defuseBomb.Click += new System.EventHandler(this.defuseBomb_Click);
//
// console
//
this.console.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.console.Location = new System.Drawing.Point(12, 178);
this.console.Multiline = true;
this.console.Name = "console";
this.console.Size = new System.Drawing.Size(462, 284);
this.console.TabIndex = 6;
//
// flashExes
//
this.flashExes.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.flashExes.FormattingEnabled = true;
this.flashExes.HorizontalScrollbar = true;
this.flashExes.Location = new System.Drawing.Point(12, 25);
this.flashExes.Name = "flashExes";
this.flashExes.Size = new System.Drawing.Size(462, 147);
this.flashExes.TabIndex = 7;
//
// deleteFile
//
this.deleteFile.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.deleteFile.Location = new System.Drawing.Point(386, 2);
this.deleteFile.Name = "deleteFile";
this.deleteFile.Size = new System.Drawing.Size(48, 20);
this.deleteFile.TabIndex = 8;
this.deleteFile.Text = "Delete";
this.deleteFile.UseVisualStyleBackColor = true;
this.deleteFile.Click += new System.EventHandler(this.deleteFile_Click);
//
// progressBar
//
this.progressBar.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.progressBar.Location = new System.Drawing.Point(14, 497);
this.progressBar.Name = "progressBar";
this.progressBar.Size = new System.Drawing.Size(459, 23);
this.progressBar.TabIndex = 9;
//
// projectorPatch
//
this.projectorPatch.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.projectorPatch.Location = new System.Drawing.Point(422, 532);
this.projectorPatch.Name = "projectorPatch";
this.projectorPatch.Size = new System.Drawing.Size(63, 19);
this.projectorPatch.TabIndex = 10;
this.projectorPatch.Text = "Projector+";
this.projectorPatch.UseVisualStyleBackColor = true;
this.projectorPatch.Click += new System.EventHandler(this.projectorPatch_Click);
//
// FlashPatcherForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(486, 552);
this.Controls.Add(this.projectorPatch);
this.Controls.Add(this.progressBar);
this.Controls.Add(this.deleteFile);
this.Controls.Add(this.flashExes);
this.Controls.Add(this.console);
this.Controls.Add(this.defuseBomb);
this.Controls.Add(this.cringe);
this.Controls.Add(this.addFile);
this.Controls.Add(this.label1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximumSize = new System.Drawing.Size(1920, 591);
this.MinimumSize = new System.Drawing.Size(502, 591);
this.Name = "FlashPatcherForm";
this.Text = "Flash Patcher";
this.Load += new System.EventHandler(this.FlashPwner_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button addFile;
private System.Windows.Forms.Label cringe;
private System.Windows.Forms.Button defuseBomb;
private System.Windows.Forms.TextBox console;
private System.Windows.Forms.ListBox flashExes;
private System.Windows.Forms.Button deleteFile;
private System.Windows.Forms.ProgressBar progressBar;
private System.Windows.Forms.Button projectorPatch;
}
}

View File

@ -0,0 +1,248 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using System.Security.AccessControl;
using System.Security.Principal;
using System.Windows.Forms;
namespace FlashPatcher
{
public partial class FlashPatcherForm : Form
{
public FlashPatcherForm()
{
InitializeComponent();
}
public byte[] Timestamp = new byte[] { 0x00, 0x00, 0x40, 0x46, 0x3E, 0x6F, 0x77, 0x42 };
public byte[] Infintiy = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x7F };
public Int64 GetPositionAfterMatch(byte[] data, byte[] pattern)
{
for (Int64 i = 0; i < data.LongLength - pattern.LongLength; i++)
{
bool match = true;
for (Int64 k = 0; k < pattern.LongLength; k++)
{
if (data[i + k] != pattern[k])
{
match = false;
break;
}
}
if (match)
{
return i;
}
}
return -1;
}
public void TakeOwn(string filepath)
{
FileSecurity fileS = File.GetAccessControl(filepath);
SecurityIdentifier cu = WindowsIdentity.GetCurrent().User;
SecurityIdentifier everyone = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
try
{
Privileges.EnablePrivilege(SecurityEntity.SE_TAKE_OWNERSHIP_NAME);
}
catch(Exception)
{
console.AppendText("Failed to get SeTakeOwnershipPrivledge\r\n");
}
fileS.SetOwner(cu);
File.SetAccessControl(filepath, fileS);
fileS.SetAccessRuleProtection(false, false);
fileS.RemoveAccessRuleAll(new FileSystemAccessRule(everyone, FileSystemRights.FullControl, AccessControlType.Deny));
fileS.RemoveAccessRuleAll(new FileSystemAccessRule(cu, FileSystemRights.FullControl, AccessControlType.Deny));
fileS.SetAccessRule(new FileSystemAccessRule(everyone, FileSystemRights.FullControl, AccessControlType.Allow));
fileS.SetAccessRule(new FileSystemAccessRule(cu, FileSystemRights.FullControl, AccessControlType.Allow));
File.SetAccessControl(filepath, fileS);
File.SetAttributes(filepath, FileAttributes.Normal);
}
public bool CheckFileAndAdd(string filepath)
{
try
{
byte[] fileData = File.ReadAllBytes(filepath);
Int64 timestampLocation = GetPositionAfterMatch(fileData, Timestamp);
if (timestampLocation != -1)
{
flashExes.Items.Add(filepath);
console.AppendText("Found killswitch timestamp in " + Path.GetFileName(filepath) + " @ 0x" + timestampLocation.ToString("X") + "\r\n");
return true;
}
return false;
}
catch(Exception)
{
return false;
}
}
public void ScanFolder(string path)
{
if(Directory.Exists(path))
{
String[] fileList = Directory.GetFiles(path, "*", SearchOption.AllDirectories);
foreach (string file in fileList)
{
if (file.ToLower().EndsWith(".ocx") || file.ToLower().EndsWith(".dll") || file.ToLower().EndsWith(".exe"))
{
CheckFileAndAdd(file);
}
}
}
}
public bool PatchExe(string filepath)
{
try
{
Process[] lockingProcesses = FileUtil.WhoIsLocking(filepath).ToArray();
foreach(Process proc in lockingProcesses)
{
DialogResult res = MessageBox.Show("Flash is currently in use by (" + proc.Id.ToString() + ")" + proc.ProcessName + "\nEnd Process?", "File in use :/", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
if (res == DialogResult.Yes)
proc.Kill(); // DIE HHAHA
else
return true;
}
byte[] fileData = File.ReadAllBytes(filepath);
Int64 timestampLocation = GetPositionAfterMatch(fileData, Timestamp);
TakeOwn(filepath);
FileStream fs = File.OpenWrite(filepath);
fs.Seek(timestampLocation, SeekOrigin.Begin);
fs.Write(Infintiy, 0x00, Infintiy.Length);
fs.Close();
console.AppendText("Patched: " + Path.GetFileName(filepath) + ".\r\n");
flashExes.Items.Remove(filepath);
Application.DoEvents();
progressBar.Increment(1);
return false;
}
catch(Exception e)
{
MessageBox.Show(e.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
return true;
}
return false;
}
public void LocateExes()
{
string windir = Environment.GetEnvironmentVariable("WINDIR");
string localappdata = Environment.GetEnvironmentVariable("LOCALAPPDATA");
string flashPath = Path.Combine(windir, "System32", "Macromed", "Flash");
ScanFolder(flashPath);
flashPath = Path.Combine(windir, "SysWOW64", "Macromed", "Flash");
ScanFolder(flashPath);
flashPath = Path.Combine(localappdata, "Google", "Chrome", "User Data", "PepperFlash");
ScanFolder(flashPath);
flashPath = Path.Combine(localappdata, "Microsoft", "Edge", "User Data", "PepperFlash");
ScanFolder(flashPath);
}
private void FlashPwner_Load(object sender, EventArgs e)
{
LocateExes();
}
private void defuseBomb_Click(object sender, EventArgs e)
{
defuseBomb.Enabled = false;
if(flashExes.Items.Count > 0)
{
progressBar.Maximum = flashExes.Items.Count;
List<string> copyFlashExes = new List<string>();
foreach (string flashExe in flashExes.Items)
{
copyFlashExes.Add(flashExe);
}
bool errored = false;
foreach (string flashExe in copyFlashExes)
{
errored = PatchExe(flashExe);
}
if(!errored)
MessageBox.Show("Patched! Your flash should work again!!!", "SUCCESS", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("No files to patch!", "File Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
defuseBomb.Enabled = true;
}
private void addFile_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Title = "Flash Executable";
ofd.Filter = "PE Executables (*.exe, *.ocx, *.dll)|*.dll;*.exe;*.ocx|ELF Executables (*.so, *.elf, *.dylib)|*.so;*.elf;*.dylib";
DialogResult res = ofd.ShowDialog();
if(res == DialogResult.OK)
{
if (!CheckFileAndAdd(ofd.FileName))
{
MessageBox.Show("File selected does not contain the killswitch timestamp, cannot patch!", "Timestamp Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void patchProjetor(string path)
{
byte[] projBytes = File.ReadAllBytes(path);
byte[] getUrlPattern = new byte[] { 0xF4, 0xE8, 0xBE, 0xFE, 0xFF, 0xFF };
byte[] nops = new byte[] { 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 };
Int64 getUrlLocation = GetPositionAfterMatch(projBytes, getUrlPattern);
if (getUrlLocation == -1)
return;
FileStream fs = File.OpenWrite(path);
fs.Seek(getUrlLocation+1, SeekOrigin.Begin);
fs.Write(nops, 0x00, nops.Length);
fs.Close();
}
private void deleteFile_Click(object sender, EventArgs e)
{
if(flashExes.SelectedIndex >= 0)
flashExes.Items.RemoveAt(flashExes.SelectedIndex);
}
private void projectorPatch_Click(object sender, EventArgs e)
{
MessageBox.Show("This is a patch for the standalone \"projector\" program from adobe, it stops it opening your browser whenever a game tries to call javascript with getURL()\n\nNote: the projector DOES NOT HAVE A KILLSWITCH/TIMEBOMB and this is not needed to use the Flash Projector.", "Projector", MessageBoxButtons.OK, MessageBoxIcon.Information);
OpenFileDialog ofd = new OpenFileDialog();
ofd.Title = "Flash Projector";
ofd.Filter = "PE Executables (*.exe)|*.exe;|ELF Executables (*.elf)|*.elf";
DialogResult res = ofd.ShowDialog();
if(res == DialogResult.OK)
{
patchProjetor(ofd.FileName);
MessageBox.Show("Patched! Projector should no longer open the browser!!!", "SUCCESS", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
}

File diff suppressed because it is too large Load Diff

175
FlashPatcher/FlashPwner.Designer.cs generated Normal file
View File

@ -0,0 +1,175 @@
namespace FlashPatcher
{
partial class FlashPwner
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FlashPwner));
this.label1 = new System.Windows.Forms.Label();
this.addFile = new System.Windows.Forms.Button();
this.cringe = new System.Windows.Forms.Label();
this.defuseBomb = new System.Windows.Forms.Button();
this.console = new System.Windows.Forms.TextBox();
this.flashExes = new System.Windows.Forms.ListBox();
this.deleteFile = new System.Windows.Forms.Button();
this.progressBar = new System.Windows.Forms.ProgressBar();
this.projectorPatch = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(9, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(263, 13);
this.label1.TabIndex = 0;
this.label1.Text = "Flash Executables: (pepflash.dll, NPSWF64, flash.ocx)";
//
// addFile
//
this.addFile.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.addFile.Location = new System.Drawing.Point(434, 2);
this.addFile.Name = "addFile";
this.addFile.Size = new System.Drawing.Size(39, 20);
this.addFile.TabIndex = 1;
this.addFile.Text = "Add ";
this.addFile.UseVisualStyleBackColor = true;
this.addFile.Click += new System.EventHandler(this.addFile_Click);
//
// cringe
//
this.cringe.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.cringe.AutoSize = true;
this.cringe.Location = new System.Drawing.Point(2, 530);
this.cringe.Name = "cringe";
this.cringe.Size = new System.Drawing.Size(211, 13);
this.cringe.TabIndex = 4;
this.cringe.Text = "The quieter you becom, the moar u cn hear";
//
// defuseBomb
//
this.defuseBomb.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.defuseBomb.Location = new System.Drawing.Point(11, 468);
this.defuseBomb.Name = "defuseBomb";
this.defuseBomb.Size = new System.Drawing.Size(462, 23);
this.defuseBomb.TabIndex = 5;
this.defuseBomb.Text = "!!! DEFUSE THE BOMB !!!";
this.defuseBomb.UseVisualStyleBackColor = true;
this.defuseBomb.Click += new System.EventHandler(this.defuseBomb_Click);
//
// console
//
this.console.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.console.Location = new System.Drawing.Point(12, 178);
this.console.Multiline = true;
this.console.Name = "console";
this.console.Size = new System.Drawing.Size(462, 284);
this.console.TabIndex = 6;
//
// flashExes
//
this.flashExes.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.flashExes.FormattingEnabled = true;
this.flashExes.HorizontalScrollbar = true;
this.flashExes.Location = new System.Drawing.Point(12, 25);
this.flashExes.Name = "flashExes";
this.flashExes.Size = new System.Drawing.Size(462, 147);
this.flashExes.TabIndex = 7;
//
// deleteFile
//
this.deleteFile.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.deleteFile.Location = new System.Drawing.Point(386, 2);
this.deleteFile.Name = "deleteFile";
this.deleteFile.Size = new System.Drawing.Size(48, 20);
this.deleteFile.TabIndex = 8;
this.deleteFile.Text = "Delete";
this.deleteFile.UseVisualStyleBackColor = true;
this.deleteFile.Click += new System.EventHandler(this.deleteFile_Click);
//
// progressBar
//
this.progressBar.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.progressBar.Location = new System.Drawing.Point(14, 497);
this.progressBar.Name = "progressBar";
this.progressBar.Size = new System.Drawing.Size(459, 23);
this.progressBar.TabIndex = 9;
//
// projectorPatch
//
this.projectorPatch.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.projectorPatch.Location = new System.Drawing.Point(422, 532);
this.projectorPatch.Name = "projectorPatch";
this.projectorPatch.Size = new System.Drawing.Size(63, 19);
this.projectorPatch.TabIndex = 10;
this.projectorPatch.Text = "Projector+";
this.projectorPatch.UseVisualStyleBackColor = true;
this.projectorPatch.Click += new System.EventHandler(this.projectorPatch_Click);
//
// FlashPwner
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(486, 552);
this.Controls.Add(this.projectorPatch);
this.Controls.Add(this.progressBar);
this.Controls.Add(this.deleteFile);
this.Controls.Add(this.flashExes);
this.Controls.Add(this.console);
this.Controls.Add(this.defuseBomb);
this.Controls.Add(this.cringe);
this.Controls.Add(this.addFile);
this.Controls.Add(this.label1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximumSize = new System.Drawing.Size(1920, 591);
this.MinimumSize = new System.Drawing.Size(502, 591);
this.Name = "FlashPwner";
this.Text = "Flash Pwner";
this.Load += new System.EventHandler(this.FlashPwner_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button addFile;
private System.Windows.Forms.Label cringe;
private System.Windows.Forms.Button defuseBomb;
private System.Windows.Forms.TextBox console;
private System.Windows.Forms.ListBox flashExes;
private System.Windows.Forms.Button deleteFile;
private System.Windows.Forms.ProgressBar progressBar;
private System.Windows.Forms.Button projectorPatch;
}
}

248
FlashPatcher/FlashPwner.cs Normal file
View File

@ -0,0 +1,248 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using System.Security.AccessControl;
using System.Security.Principal;
using System.Windows.Forms;
namespace FlashPatcher
{
public partial class FlashPwner : Form
{
public FlashPwner()
{
InitializeComponent();
}
public byte[] Timestamp = new byte[] { 0x00, 0x00, 0x40, 0x46, 0x3E, 0x6F, 0x77, 0x42 };
public byte[] Infintiy = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x7F };
public Int64 GetPositionAfterMatch(byte[] data, byte[] pattern)
{
for (Int64 i = 0; i < data.LongLength - pattern.LongLength; i++)
{
bool match = true;
for (Int64 k = 0; k < pattern.LongLength; k++)
{
if (data[i + k] != pattern[k])
{
match = false;
break;
}
}
if (match)
{
return i;
}
}
return -1;
}
public void TakeOwn(string filepath)
{
FileSecurity fileS = File.GetAccessControl(filepath);
SecurityIdentifier cu = WindowsIdentity.GetCurrent().User;
SecurityIdentifier everyone = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
try
{
Privileges.EnablePrivilege(SecurityEntity.SE_TAKE_OWNERSHIP_NAME);
}
catch(Exception)
{
console.AppendText("Failed to get SeTakeOwnershipPrivledge\r\n");
}
fileS.SetOwner(cu);
File.SetAccessControl(filepath, fileS);
fileS.SetAccessRuleProtection(false, false);
fileS.RemoveAccessRuleAll(new FileSystemAccessRule(everyone, FileSystemRights.FullControl, AccessControlType.Deny));
fileS.RemoveAccessRuleAll(new FileSystemAccessRule(cu, FileSystemRights.FullControl, AccessControlType.Deny));
fileS.SetAccessRule(new FileSystemAccessRule(everyone, FileSystemRights.FullControl, AccessControlType.Allow));
fileS.SetAccessRule(new FileSystemAccessRule(cu, FileSystemRights.FullControl, AccessControlType.Allow));
File.SetAccessControl(filepath, fileS);
File.SetAttributes(filepath, FileAttributes.Normal);
}
public bool CheckFileAndAdd(string filepath)
{
try
{
byte[] fileData = File.ReadAllBytes(filepath);
Int64 timestampLocation = GetPositionAfterMatch(fileData, Timestamp);
if (timestampLocation != -1)
{
flashExes.Items.Add(filepath);
console.AppendText("Found killswitch timestamp in " + Path.GetFileName(filepath) + " @ 0x" + timestampLocation.ToString("X") + "\r\n");
return true;
}
return false;
}
catch(Exception)
{
return false;
}
}
public void ScanFolder(string path)
{
if(Directory.Exists(path))
{
String[] fileList = Directory.GetFiles(path, "*", SearchOption.AllDirectories);
foreach (string file in fileList)
{
if (file.ToLower().EndsWith(".ocx") || file.ToLower().EndsWith(".dll") || file.ToLower().EndsWith(".exe"))
{
CheckFileAndAdd(file);
}
}
}
}
public bool PatchExe(string filepath)
{
try
{
Process[] lockingProcesses = FileUtil.WhoIsLocking(filepath).ToArray();
foreach(Process proc in lockingProcesses)
{
DialogResult res = MessageBox.Show("Flash is currently in use by (" + proc.Id.ToString() + ")" + proc.ProcessName + "\nEnd Process?", "File in use :/", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
if (res == DialogResult.Yes)
proc.Kill(); // DIE HHAHA
else
return true;
}
byte[] fileData = File.ReadAllBytes(filepath);
Int64 timestampLocation = GetPositionAfterMatch(fileData, Timestamp);
TakeOwn(filepath);
FileStream fs = File.OpenWrite(filepath);
fs.Seek(timestampLocation, SeekOrigin.Begin);
fs.Write(Infintiy, 0x00, Infintiy.Length);
fs.Close();
console.AppendText("Patched: " + Path.GetFileName(filepath) + ".\r\n");
flashExes.Items.Remove(filepath);
Application.DoEvents();
progressBar.Increment(1);
return false;
}
catch(Exception e)
{
MessageBox.Show(e.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
return true;
}
}
public void LocateExes()
{
string windir = Environment.GetEnvironmentVariable("WINDIR");
string localappdata = Environment.GetEnvironmentVariable("LOCALAPPDATA");
string flashPath = Path.Combine(windir, "System32", "Macromed", "Flash");
ScanFolder(flashPath);
flashPath = Path.Combine(windir, "SysWOW64", "Macromed", "Flash");
ScanFolder(flashPath);
flashPath = Path.Combine(localappdata, "Google", "Chrome", "User Data", "PepperFlash");
ScanFolder(flashPath);
flashPath = Path.Combine(localappdata, "Microsoft", "Edge", "User Data", "PepperFlash");
ScanFolder(flashPath);
}
private void FlashPwner_Load(object sender, EventArgs e)
{
LocateExes();
}
private void defuseBomb_Click(object sender, EventArgs e)
{
defuseBomb.Enabled = false;
if(flashExes.Items.Count > 0)
{
progressBar.Maximum = flashExes.Items.Count;
List<string> copyFlashExes = new List<string>();
foreach (string flashExe in flashExes.Items)
{
copyFlashExes.Add(flashExe);
}
bool errored = false;
foreach (string flashExe in copyFlashExes)
{
errored = PatchExe(flashExe);
}
if(!errored)
MessageBox.Show("Patched! Your flash should work again!!!", "SUCCESS", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("No files to patch!", "File Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
defuseBomb.Enabled = true;
}
private void addFile_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Title = "Flash Executable";
ofd.Filter = "PE Executables (*.exe, *.ocx, *.dll)|*.dll;*.exe;*.ocx|ELF Executables (*.so, *.elf, *.dylib)|*.so;*.elf;*.dylib";
DialogResult res = ofd.ShowDialog();
if(res == DialogResult.OK)
{
if (!CheckFileAndAdd(ofd.FileName))
{
MessageBox.Show("File selected does not contain the killswitch timestamp, cannot patch!", "Timestamp Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void patchProjetor(string path)
{
byte[] projBytes = File.ReadAllBytes(path);
byte[] getUrlPattern = new byte[] { 0xF4, 0xE8, 0xBE, 0xFE, 0xFF, 0xFF };
byte[] nops = new byte[] { 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 };
Int64 getUrlLocation = GetPositionAfterMatch(projBytes, getUrlPattern);
if (getUrlLocation == -1)
return;
FileStream fs = File.OpenWrite(path);
fs.Seek(getUrlLocation+1, SeekOrigin.Begin);
fs.Write(nops, 0x00, nops.Length);
fs.Close();
}
private void deleteFile_Click(object sender, EventArgs e)
{
if(flashExes.SelectedIndex >= 0)
flashExes.Items.RemoveAt(flashExes.SelectedIndex);
}
private void projectorPatch_Click(object sender, EventArgs e)
{
MessageBox.Show("This is a patch for the standalone \"projector\" program from adobe, it stops it opening your browser whenever a game tries to call javascript with getURL()\n\nNote: the projector DOES NOT HAVE A KILLSWITCH/TIMEBOMB and this is not needed to use the Flash Projector.", "Projector", MessageBoxButtons.OK, MessageBoxIcon.Information);
OpenFileDialog ofd = new OpenFileDialog();
ofd.Title = "Flash Projector";
ofd.Filter = "PE Executables (*.exe)|*.exe;|ELF Executables (*.elf)|*.elf";
DialogResult res = ofd.ShowDialog();
if(res == DialogResult.OK)
{
patchProjetor(ofd.FileName);
MessageBox.Show("Patched! Projector should no longer open the browser!!!", "SUCCESS", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
}

4615
FlashPatcher/FlashPwner.resx Normal file

File diff suppressed because it is too large Load Diff

176
FlashPatcher/Privileges.cs Normal file
View File

@ -0,0 +1,176 @@

using System;
using System.ComponentModel;
using System.Globalization;
using System.Runtime.InteropServices;
public static class Privileges
{
public static void EnablePrivilege(SecurityEntity securityEntity)
{
if (!Enum.IsDefined(typeof(SecurityEntity), securityEntity))
throw new InvalidEnumArgumentException("securityEntity", (int)securityEntity, typeof(SecurityEntity));
var securityEntityValue = GetSecurityEntityValue(securityEntity);
try
{
var locallyUniqueIdentifier = new NativeMethods.LUID();
if (NativeMethods.LookupPrivilegeValue(null, securityEntityValue, ref locallyUniqueIdentifier))
{
var TOKEN_PRIVILEGES = new NativeMethods.TOKEN_PRIVILEGES();
TOKEN_PRIVILEGES.PrivilegeCount = 1;
TOKEN_PRIVILEGES.Attributes = NativeMethods.SE_PRIVILEGE_ENABLED;
TOKEN_PRIVILEGES.Luid = locallyUniqueIdentifier;
var tokenHandle = IntPtr.Zero;
try
{
var currentProcess = NativeMethods.GetCurrentProcess();
if (NativeMethods.OpenProcessToken(currentProcess, NativeMethods.TOKEN_ADJUST_PRIVILEGES | NativeMethods.TOKEN_QUERY, out tokenHandle))
{
if (NativeMethods.AdjustTokenPrivileges(tokenHandle, false,
ref TOKEN_PRIVILEGES,
1024, IntPtr.Zero, IntPtr.Zero))
{
var lastError = Marshal.GetLastWin32Error();
if (lastError == NativeMethods.ERROR_NOT_ALL_ASSIGNED)
{
var win32Exception = new Win32Exception();
throw new InvalidOperationException("AdjustTokenPrivileges failed.", win32Exception);
}
}
else
{
var win32Exception = new Win32Exception();
throw new InvalidOperationException("AdjustTokenPrivileges failed.", win32Exception);
}
}
else
{
var win32Exception = new Win32Exception();
var exceptionMessage = string.Format(CultureInfo.InvariantCulture,
"OpenProcessToken failed. CurrentProcess: {0}",
currentProcess.ToInt32());
throw new InvalidOperationException(exceptionMessage, win32Exception);
}
}
finally
{
if (tokenHandle != IntPtr.Zero)
NativeMethods.CloseHandle(tokenHandle);
}
}
else
{
var win32Exception = new Win32Exception();
var exceptionMessage = string.Format(CultureInfo.InvariantCulture,
"LookupPrivilegeValue failed. SecurityEntityValue: {0}",
securityEntityValue);
throw new InvalidOperationException(exceptionMessage, win32Exception);
}
}
catch (Exception e)
{
var exceptionMessage = string.Format(CultureInfo.InvariantCulture,
"GrandPrivilege failed. SecurityEntity: {0}",
securityEntityValue);
throw new InvalidOperationException(exceptionMessage, e);
}
}
/// <summary>
/// Gets the security entity value.
/// </summary>
/// <param name="securityEntity">The security entity.</param>
private static string GetSecurityEntityValue(SecurityEntity securityEntity)
{
switch (securityEntity)
{
case SecurityEntity.SE_TAKE_OWNERSHIP_NAME:
return "SeTakeOwnershipPrivilege";
default:
throw new ArgumentOutOfRangeException(typeof(SecurityEntity).Name);
}
}
}
public enum SecurityEntity
{
SE_TAKE_OWNERSHIP_NAME,
}
internal static class NativeMethods
{
[DllImport("advapi32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool LookupPrivilegeValue(string lpsystemname, string lpname, [MarshalAs(UnmanagedType.Struct)] ref LUID lpLuid);
[DllImport("advapi32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool AdjustTokenPrivileges(IntPtr tokenhandle,
[MarshalAs(UnmanagedType.Bool)] bool disableAllPrivileges,
[MarshalAs(UnmanagedType.Struct)] ref TOKEN_PRIVILEGES newstate,
uint bufferlength, IntPtr previousState, IntPtr returnlength);
internal const int SE_PRIVILEGE_ENABLED = 0x00000002;
internal const int ERROR_NOT_ALL_ASSIGNED = 1300;
internal const UInt32 STANDARD_RIGHTS_REQUIRED = 0x000F0000;
internal const UInt32 STANDARD_RIGHTS_READ = 0x00020000;
internal const UInt32 TOKEN_ASSIGN_PRIMARY = 0x0001;
internal const UInt32 TOKEN_DUPLICATE = 0x0002;
internal const UInt32 TOKEN_IMPERSONATE = 0x0004;
internal const UInt32 TOKEN_QUERY = 0x0008;
internal const UInt32 TOKEN_QUERY_SOURCE = 0x0010;
internal const UInt32 TOKEN_ADJUST_PRIVILEGES = 0x0020;
internal const UInt32 TOKEN_ADJUST_GROUPS = 0x0040;
internal const UInt32 TOKEN_ADJUST_DEFAULT = 0x0080;
internal const UInt32 TOKEN_ADJUST_SESSIONID = 0x0100;
internal const UInt32 TOKEN_READ = (STANDARD_RIGHTS_READ | TOKEN_QUERY);
internal const UInt32 TOKEN_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED |
TOKEN_ASSIGN_PRIMARY |
TOKEN_DUPLICATE |
TOKEN_IMPERSONATE |
TOKEN_QUERY |
TOKEN_QUERY_SOURCE |
TOKEN_ADJUST_PRIVILEGES |
TOKEN_ADJUST_GROUPS |
TOKEN_ADJUST_DEFAULT |
TOKEN_ADJUST_SESSIONID);
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
internal static extern IntPtr GetCurrentProcess();
[DllImport("Advapi32.dll", CharSet = CharSet.Auto, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool OpenProcessToken(IntPtr processHandle,
uint desiredAccesss,
out IntPtr tokenHandle);
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern Boolean CloseHandle(IntPtr hObject);
[StructLayout(LayoutKind.Sequential)]
internal struct LUID
{
internal Int32 LowPart;
internal UInt32 HighPart;
}
[StructLayout(LayoutKind.Sequential)]
internal struct TOKEN_PRIVILEGES
{
internal Int32 PrivilegeCount;
internal LUID Luid;
internal Int32 Attributes;
}
}

19
FlashPatcher/Program.cs Normal file
View File

@ -0,0 +1,19 @@
using System;
using System.Windows.Forms;
namespace FlashPatcher
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FlashPatcherForm());
}
}
}

View File

@ -0,0 +1,38 @@
using System.Resources;
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("Flash Patcher")]
[assembly: AssemblyDescription("Enables flash player")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("SilicaAndPina")]
[assembly: AssemblyProduct("Flash Patcher")]
[assembly: AssemblyCopyright("Public Domain 2021")]
[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("ffffffff-ffff-ffff-ffff-ffffffffffff")]
// 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")]
[assembly: NeutralResourcesLanguage("")]

View File

@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace FlashPatcher.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FlashPatcher.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace FlashPatcher.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.8.1.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

View File

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

76
FlashPatcher/app.manifest Normal file
View File

@ -0,0 +1,76 @@
<?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="requireAdministrator" 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. -->
<!--
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
</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>

BIN
FlashPatcher/icon0.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 KiB

View File

@ -1,6 +1,2 @@
# FlashPatcher
Downloads: https://github.com/KuromeSan/FlashPatcher/releases/latest
.NET program to remove timebomb from Adobe Flash Player