Compare commits

..

No commits in common. "master" and "v1.9" have entirely different histories.

10 changed files with 129 additions and 454 deletions

126
.gitignore vendored
View file

@ -1,126 +0,0 @@
# Ignore Visual Studio temporary files, build results, and
# build logs directory.
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific folders
.vs/
.vscode/
.idea/
.vscode-test/
# Mono Auto Generated Files
mono_crash.*
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
$RECYCLE.BIN/
# VS Code directories
.vscode/
# Windows Installer files
*.cab
*.msi
*.msm
*.msp
# Windows shortcuts
*.lnk
# DotNet Core
project.lock.json
project.fragment.lock.json
artifacts/
# NuGet
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# Include only NuGet's .gitignore
!/.nuget/
!/.nuget/NuGet.Config
!/.nuget/NuGet.exe
# If using the new MSBuild .csproj format, uncomment this to ignore .NET Core / NuGet cache
#!**/[Dd]ebug/
#!**/[Rr]elease/
# Include only DLLs in the bin directory
bin/**/*.dll
# Include only the package directory itself
!**/[Pp]ackages/
# Ignore temp files
**/bin
**/obj
**/TempPE
# Rider specific files
.idea/
*.sln.iml
# .NET Core directories
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopCache.xml
# Files generated by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Recycle Bin used by Visual Studio
*.cachefile
# Exclude folder containing source code
src/
!src/**/*.cs

View file

@ -40,7 +40,6 @@
this.controlloBackup = new System.Windows.Forms.CheckBox(); this.controlloBackup = new System.Windows.Forms.CheckBox();
this.cfileoffsett = new System.Windows.Forms.CheckBox(); this.cfileoffsett = new System.Windows.Forms.CheckBox();
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.cchangeOwnership = new System.Windows.Forms.CheckBox();
this.SuspendLayout(); this.SuspendLayout();
// //
// label7 // label7
@ -62,7 +61,7 @@
this.t1337.Location = new System.Drawing.Point(90, 5); this.t1337.Location = new System.Drawing.Point(90, 5);
this.t1337.Name = "t1337"; this.t1337.Name = "t1337";
this.t1337.ReadOnly = true; this.t1337.ReadOnly = true;
this.t1337.Size = new System.Drawing.Size(343, 20); this.t1337.Size = new System.Drawing.Size(309, 20);
this.t1337.TabIndex = 16; this.t1337.TabIndex = 16;
this.t1337.TabStop = false; this.t1337.TabStop = false;
this.t1337.Text = "Select 1337 File..."; this.t1337.Text = "Select 1337 File...";
@ -89,7 +88,7 @@
this.texe.Location = new System.Drawing.Point(90, 31); this.texe.Location = new System.Drawing.Point(90, 31);
this.texe.Name = "texe"; this.texe.Name = "texe";
this.texe.ReadOnly = true; this.texe.ReadOnly = true;
this.texe.Size = new System.Drawing.Size(370, 20); this.texe.Size = new System.Drawing.Size(336, 20);
this.texe.TabIndex = 14; this.texe.TabIndex = 14;
this.texe.TabStop = false; this.texe.TabStop = false;
this.texe.Text = "Name of Exe/Dll to Patch..."; this.texe.Text = "Name of Exe/Dll to Patch...";
@ -100,7 +99,7 @@
this.btnSelect1337.CausesValidation = false; this.btnSelect1337.CausesValidation = false;
this.btnSelect1337.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F); this.btnSelect1337.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F);
this.btnSelect1337.ForeColor = System.Drawing.Color.DarkRed; this.btnSelect1337.ForeColor = System.Drawing.Color.DarkRed;
this.btnSelect1337.Location = new System.Drawing.Point(436, 2); this.btnSelect1337.Location = new System.Drawing.Point(402, 3);
this.btnSelect1337.Margin = new System.Windows.Forms.Padding(0); this.btnSelect1337.Margin = new System.Windows.Forms.Padding(0);
this.btnSelect1337.Name = "btnSelect1337"; this.btnSelect1337.Name = "btnSelect1337";
this.btnSelect1337.Size = new System.Drawing.Size(24, 23); this.btnSelect1337.Size = new System.Drawing.Size(24, 23);
@ -115,7 +114,7 @@
this.linkdfox.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.linkdfox.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.linkdfox.ForeColor = System.Drawing.Color.BlueViolet; this.linkdfox.ForeColor = System.Drawing.Color.BlueViolet;
this.linkdfox.LinkColor = System.Drawing.Color.Indigo; this.linkdfox.LinkColor = System.Drawing.Color.Indigo;
this.linkdfox.Location = new System.Drawing.Point(256, 61); this.linkdfox.Location = new System.Drawing.Point(226, 62);
this.linkdfox.Name = "linkdfox"; this.linkdfox.Name = "linkdfox";
this.linkdfox.Size = new System.Drawing.Size(77, 13); this.linkdfox.Size = new System.Drawing.Size(77, 13);
this.linkdfox.TabIndex = 73; this.linkdfox.TabIndex = 73;
@ -127,7 +126,7 @@
// //
this.Patch.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.Patch.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Patch.ForeColor = System.Drawing.Color.DarkBlue; this.Patch.ForeColor = System.Drawing.Color.DarkBlue;
this.Patch.Location = new System.Drawing.Point(372, 56); this.Patch.Location = new System.Drawing.Point(338, 57);
this.Patch.Name = "Patch"; this.Patch.Name = "Patch";
this.Patch.Size = new System.Drawing.Size(88, 23); this.Patch.Size = new System.Drawing.Size(88, 23);
this.Patch.TabIndex = 74; this.Patch.TabIndex = 74;
@ -143,7 +142,7 @@
this.controlloBackup.Cursor = System.Windows.Forms.Cursors.Hand; this.controlloBackup.Cursor = System.Windows.Forms.Cursors.Hand;
this.controlloBackup.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.controlloBackup.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.controlloBackup.ForeColor = System.Drawing.Color.Teal; this.controlloBackup.ForeColor = System.Drawing.Color.Teal;
this.controlloBackup.Location = new System.Drawing.Point(8, 60); this.controlloBackup.Location = new System.Drawing.Point(3, 61);
this.controlloBackup.Name = "controlloBackup"; this.controlloBackup.Name = "controlloBackup";
this.controlloBackup.Size = new System.Drawing.Size(69, 17); this.controlloBackup.Size = new System.Drawing.Size(69, 17);
this.controlloBackup.TabIndex = 76; this.controlloBackup.TabIndex = 76;
@ -159,7 +158,7 @@
this.cfileoffsett.Cursor = System.Windows.Forms.Cursors.Hand; this.cfileoffsett.Cursor = System.Windows.Forms.Cursors.Hand;
this.cfileoffsett.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.cfileoffsett.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.cfileoffsett.ForeColor = System.Drawing.Color.Teal; this.cfileoffsett.ForeColor = System.Drawing.Color.Teal;
this.cfileoffsett.Location = new System.Drawing.Point(79, 60); this.cfileoffsett.Location = new System.Drawing.Point(74, 61);
this.cfileoffsett.Name = "cfileoffsett"; this.cfileoffsett.Name = "cfileoffsett";
this.cfileoffsett.Size = new System.Drawing.Size(80, 17); this.cfileoffsett.Size = new System.Drawing.Size(80, 17);
this.cfileoffsett.TabIndex = 77; this.cfileoffsett.TabIndex = 77;
@ -167,27 +166,11 @@
this.cfileoffsett.UseVisualStyleBackColor = true; this.cfileoffsett.UseVisualStyleBackColor = true;
this.cfileoffsett.CheckedChanged += new System.EventHandler(this.cfileoffsett_CheckedChanged); this.cfileoffsett.CheckedChanged += new System.EventHandler(this.cfileoffsett_CheckedChanged);
// //
// cchangeOwnership
//
this.cchangeOwnership.AutoSize = true;
this.cchangeOwnership.Checked = true;
this.cchangeOwnership.CheckState = System.Windows.Forms.CheckState.Checked;
this.cchangeOwnership.Cursor = System.Windows.Forms.Cursors.Hand;
this.cchangeOwnership.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold);
this.cchangeOwnership.ForeColor = System.Drawing.Color.Teal;
this.cchangeOwnership.Location = new System.Drawing.Point(165, 60);
this.cchangeOwnership.Name = "cchangeOwnership";
this.cchangeOwnership.Size = new System.Drawing.Size(93, 17);
this.cchangeOwnership.TabIndex = 78;
this.cchangeOwnership.Text = "Unlock DLL";
this.cchangeOwnership.UseVisualStyleBackColor = true;
this.cchangeOwnership.CheckedChanged += new System.EventHandler(this.cchangeOwnership_CheckedChanged);
//
// Form1 // Form1
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(472, 83); this.ClientSize = new System.Drawing.Size(432, 83);
this.Controls.Add(this.cfileoffsett); this.Controls.Add(this.cfileoffsett);
this.Controls.Add(this.controlloBackup); this.Controls.Add(this.controlloBackup);
this.Controls.Add(this.Patch); this.Controls.Add(this.Patch);
@ -197,11 +180,10 @@
this.Controls.Add(this.t1337); this.Controls.Add(this.t1337);
this.Controls.Add(this.label6); this.Controls.Add(this.label6);
this.Controls.Add(this.texe); this.Controls.Add(this.texe);
this.Controls.Add(this.cchangeOwnership);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false; this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(488, 122); this.MaximumSize = new System.Drawing.Size(448, 122);
this.MinimumSize = new System.Drawing.Size(488, 122); this.MinimumSize = new System.Drawing.Size(448, 122);
this.Name = "Form1"; this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Win 1337 Apply Patch File"; this.Text = "Win 1337 Apply Patch File";
@ -222,7 +204,6 @@
private System.Windows.Forms.CheckBox controlloBackup; private System.Windows.Forms.CheckBox controlloBackup;
private System.Windows.Forms.CheckBox cfileoffsett; private System.Windows.Forms.CheckBox cfileoffsett;
private System.Windows.Forms.ToolTip toolTip1; private System.Windows.Forms.ToolTip toolTip1;
private System.Windows.Forms.CheckBox cchangeOwnership;
} }
} }

View file

@ -3,8 +3,6 @@ using System;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
using System.Security.AccessControl;
using System.Security.Principal;
namespace Win_1337_Patch namespace Win_1337_Patch
{ {
@ -24,30 +22,23 @@ namespace Win_1337_Patch
this.Text = "Win 1337 Apply Patch File " + ver; this.Text = "Win 1337 Apply Patch File " + ver;
linkdfox.Text = ver + " By DeltaFoX"; linkdfox.Text = ver + " By DeltaFoX";
} }
private void set() private void set()
{
try
{ {
t1337.Text = Ellipsis.Compact(f1337, t1337, EllipsisFormat.Path); t1337.Text = Ellipsis.Compact(f1337, t1337, EllipsisFormat.Path);
toolTip1.SetToolTip(t1337, f1337); toolTip1.SetToolTip(t1337, f1337);
Properties.Settings.Default["url1337"] = f1337; Properties.Settings.Default["url1337"] = f1337;
Properties.Settings.Default.Save(); Properties.Settings.Default.Save();
string[] lines = File.ReadAllLines(f1337); string[] lines = File.ReadAllLines(f1337);
if (!check_Symbol(lines[0])) if (!check_Symbol(lines[0]))
return; return;
string unf = lines[0].Substring(1).ToLower().Trim(); string unf = lines[0].Substring(1).ToLower().Trim();
string nf = Path.GetFileName(unf); string nf = Path.GetFileName(unf);
string ext = Path.GetExtension(unf); string ext = Path.GetExtension(unf);
OpenFileDialog apriDialogoFile1 = new OpenFileDialog OpenFileDialog apriDialogoFile1 = new OpenFileDialog();
{ apriDialogoFile1.FileName = nf;
FileName = nf, apriDialogoFile1.Filter = "File " + ext + "|" + nf;
Filter = "File " + ext + "|" + nf, apriDialogoFile1.FilterIndex = 0;
FilterIndex = 0, apriDialogoFile1.Title = "Select the file \"" + nf + "\" File...";
Title = "Select the file \"" + nf + "\" File..."
};
if (apriDialogoFile1.ShowDialog() == DialogResult.OK) if (apriDialogoFile1.ShowDialog() == DialogResult.OK)
{ {
@ -65,12 +56,6 @@ namespace Win_1337_Patch
exe = String.Empty; exe = String.Empty;
} }
} }
catch (Exception ex)
{
MessageBox.Show($"An error occurred while setting up the file: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void t1337_DragDrop(object sender, DragEventArgs e) private void t1337_DragDrop(object sender, DragEventArgs e)
{ {
try try
@ -78,48 +63,40 @@ namespace Win_1337_Patch
f1337 = ((string[])e.Data.GetData(DataFormats.FileDrop, false))[0]; f1337 = ((string[])e.Data.GetData(DataFormats.FileDrop, false))[0];
set(); set();
} }
catch (Exception ex) catch
{ {
MessageBox.Show($"An error occurred while processing drag and drop: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); //Nothing;
} }
return;
} }
private void btnSelect1337_Click(object sender, EventArgs e) private void btnSelect1337_Click(object sender, EventArgs e)
{ {
try try
{ {
string url1337 = Properties.Settings.Default["url1337"].ToString(); string url1337 = Properties.Settings.Default["url1337"].ToString();
OpenFileDialog apriDialogoFile1 = new OpenFileDialog OpenFileDialog apriDialogoFile1 = new OpenFileDialog();
{ apriDialogoFile1.Filter = "File 1337|*.*";
Filter = "File 1337|*.*", apriDialogoFile1.FilterIndex = 0;
FilterIndex = 0, apriDialogoFile1.Title = "Select the .1337 File...";
Title = "Select the .1337 File...", apriDialogoFile1.InitialDirectory = url1337 != "" ? url1337 : Directory.GetCurrentDirectory() + "\\";
InitialDirectory = url1337 != "" ? url1337 : Directory.GetCurrentDirectory() + "\\", apriDialogoFile1.RestoreDirectory = true;
RestoreDirectory = true
};
if (apriDialogoFile1.ShowDialog() == DialogResult.OK) if (apriDialogoFile1.ShowDialog() == DialogResult.OK)
{ {
f1337 = apriDialogoFile1.FileName; f1337 = apriDialogoFile1.FileName;
set(); set();
} }
} }
catch (Exception ex) catch
{ {
MessageBox.Show($"An error occurred while selecting the .1337 file: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); //Nothing;
} }
return;
} }
private void t1337_DragEnter(object sender, DragEventArgs e) private void t1337_DragEnter(object sender, DragEventArgs e)
{
try
{ {
e.Effect = DragDropEffects.All; e.Effect = DragDropEffects.All;
} }
catch (Exception ex)
{
MessageBox.Show($"An error occurred during DragEnter: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private bool check_Symbol(string s) private bool check_Symbol(string s)
{ {
@ -142,12 +119,12 @@ namespace Win_1337_Patch
{ {
DFoX_Patch(); DFoX_Patch();
} }
catch (Exception ex) catch
{ {
MessageBox.Show($"A problem occurred when patching: {ex.Message}", "Info...", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Problem occured when Patching...", "Info...", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
} }
} }
private void DFoX_Patch() private void DFoX_Patch()
{ {
if (!File.Exists(exe) || !File.Exists(f1337)) if (!File.Exists(exe) || !File.Exists(f1337))
@ -155,20 +132,6 @@ namespace Win_1337_Patch
MessageBox.Show("Files are no Longer Present...", "Info...", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Files are no Longer Present...", "Info...", MessageBoxButtons.OK, MessageBoxIcon.Error);
return; return;
} }
if (cchangeOwnership.Checked)
{
try
{
UnlockDLL(exe);
}
catch (Exception ex)
{
MessageBox.Show($"An error occurred while changing ownership: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
string[] lines = File.ReadAllLines(f1337); string[] lines = File.ReadAllLines(f1337);
if (!check_Symbol(lines[0])) if (!check_Symbol(lines[0]))
return; return;
@ -202,12 +165,9 @@ namespace Win_1337_Patch
{ {
if (controlloBackup.Checked == true) if (controlloBackup.Checked == true)
{ {
string dateSuffix = DateTime.Now.ToString("yyyy-MM-dd_hh-mm-ss-tt"); if (File.Exists(exe + ".BAK"))
string backupFileName = $"{exe}.{dateSuffix}.BAK"; File.Delete(exe + ".BAK");
File.Copy(exe, exe + ".BAK");
if (File.Exists(backupFileName))
File.Delete(backupFileName);
File.Copy(exe, backupFileName);
} }
if (File.Exists(exe)) if (File.Exists(exe))
File.Delete(exe); File.Delete(exe);
@ -215,8 +175,8 @@ namespace Win_1337_Patch
SistemaPeCks(exe); SistemaPeCks(exe);
MessageBox.Show("File " + Path.GetFileName(exe) + " Patched...", "Info...", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show("File " + Path.GetFileName(exe) + " Patched...", "Info...", MessageBoxButtons.OK, MessageBoxIcon.Information);
} }
return;
} }
private void SistemaPeCks(string file) private void SistemaPeCks(string file)
{ {
try try
@ -224,34 +184,23 @@ namespace Win_1337_Patch
using (FileStream fs = new FileStream(file, FileMode.Open, FileAccess.ReadWrite)) using (FileStream fs = new FileStream(file, FileMode.Open, FileAccess.ReadWrite))
{ {
ImageRemoveCertificate(fs.SafeFileHandle.DangerousGetHandle(), 0); ImageRemoveCertificate(fs.SafeFileHandle.DangerousGetHandle(), 0);
fs.Close();
} }
checked
{
mCheckSum PE = new mCheckSum(); mCheckSum PE = new mCheckSum();
PE.FixCheckSum(file); PE.FixCheckSum(file);
} }
} catch
catch (OverflowException ex)
{ {
MessageBox.Show($"Overflow error occurred while processing PE checksum: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); //Nothing
} }
catch (Exception ex) return;
{
MessageBox.Show($"An error occurred while processing PE checksum: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
}
private void DFoX_Load(object sender, EventArgs e) private void DFoX_Load(object sender, EventArgs e)
{
try
{ {
string urlexe = Properties.Settings.Default["urlexe"].ToString().Trim(); string urlexe = Properties.Settings.Default["urlexe"].ToString().Trim();
string url1337 = Properties.Settings.Default["url1337"].ToString().Trim(); string url1337 = Properties.Settings.Default["url1337"].ToString().Trim();
cfileoffsett.Checked = (bool)Properties.Settings.Default["fixoffset"]; cfileoffsett.Checked = (bool)Properties.Settings.Default["fixoffset"];
controlloBackup.Checked = (bool)Properties.Settings.Default["backup"]; controlloBackup.Checked = (bool)Properties.Settings.Default["backup"];
cchangeOwnership.Checked = (bool)Properties.Settings.Default["changeOwnership"];
if (urlexe != "") if (urlexe != "")
{ {
texe.Text = Ellipsis.Compact(Path.GetFileName(urlexe), texe, EllipsisFormat.Path); texe.Text = Ellipsis.Compact(Path.GetFileName(urlexe), texe, EllipsisFormat.Path);
@ -260,7 +209,6 @@ namespace Win_1337_Patch
} }
else else
texe.Text = "Select the Exe/Dll to Patch..."; texe.Text = "Select the Exe/Dll to Patch...";
if (url1337 != "" && urlexe != "") if (url1337 != "" && urlexe != "")
{ {
t1337.Text = Ellipsis.Compact(url1337, t1337, EllipsisFormat.Path); t1337.Text = Ellipsis.Compact(url1337, t1337, EllipsisFormat.Path);
@ -270,63 +218,23 @@ namespace Win_1337_Patch
else else
t1337.Text = "Select a .1337 File..."; t1337.Text = "Select a .1337 File...";
} }
catch (Exception ex)
{
MessageBox.Show($"An error occurred during form load: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void cfileoffsett_CheckedChanged(object sender, EventArgs e) private void cfileoffsett_CheckedChanged(object sender, EventArgs e)
{
try
{ {
Properties.Settings.Default["fixoffset"] = cfileoffsett.Checked; Properties.Settings.Default["fixoffset"] = cfileoffsett.Checked;
Properties.Settings.Default.Save(); Properties.Settings.Default.Save();
} }
catch (Exception ex)
{
MessageBox.Show($"An error occurred while saving fix offset setting: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void controlloBackup_CheckedChanged(object sender, EventArgs e) private void controlloBackup_CheckedChanged(object sender, EventArgs e)
{
try
{ {
Properties.Settings.Default["backup"] = controlloBackup.Checked; Properties.Settings.Default["backup"] = controlloBackup.Checked;
Properties.Settings.Default.Save(); Properties.Settings.Default.Save();
} }
catch (Exception ex)
{
MessageBox.Show($"An error occurred while saving backup setting: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void cchangeOwnership_CheckedChanged(object sender, EventArgs e)
{
try
{
Properties.Settings.Default["changeOwnership"] = cchangeOwnership.Checked;
Properties.Settings.Default.Save();
}
catch (Exception ex)
{
MessageBox.Show($"An error occurred while saving change ownership setting: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void linkdfox_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) private void linkdfox_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
try
{ {
_apriUrl(@"https://github.com/Deltafox79/Win_1337_Apply_Patch"); _apriUrl(@"https://github.com/Deltafox79/Win_1337_Apply_Patch");
} }
catch (Exception ex)
{
MessageBox.Show($"An error occurred while opening the URL: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void _apriUrl(string url) private void _apriUrl(string url)
{ {
try try
@ -334,21 +242,16 @@ namespace Win_1337_Patch
string browserPath = ottieniLaPathBrowser(); string browserPath = ottieniLaPathBrowser();
if (browserPath == string.Empty) if (browserPath == string.Empty)
browserPath = "iexplore"; browserPath = "iexplore";
Process process = new Process Process process = new Process();
{ process.StartInfo = new ProcessStartInfo(browserPath);
StartInfo = new ProcessStartInfo(browserPath) process.StartInfo.Arguments = url;
{
Arguments = url
}
};
process.Start(); process.Start();
} }
catch (Exception ex) catch
{ {
MessageBox.Show($"An error occurred while opening the browser: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); //Nothing
} }
} }
private static string ottieniLaPathBrowser() private static string ottieniLaPathBrowser()
{ {
string name = String.Empty; string name = String.Empty;
@ -363,10 +266,11 @@ namespace Win_1337_Patch
if (!name.EndsWith("exe")) if (!name.EndsWith("exe"))
name = name.Substring(0, name.LastIndexOf(".exe") + 4); name = name.Substring(0, name.LastIndexOf(".exe") + 4);
} }
catch (Exception ex) catch
{ {
MessageBox.Show($"An error occurred while retrieving browser path: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return String.Empty;
} }
finally finally
{ {
@ -377,58 +281,8 @@ namespace Win_1337_Patch
} }
private void t1337_DoubleClick(object sender, EventArgs e) private void t1337_DoubleClick(object sender, EventArgs e)
{
try
{ {
btnSelect1337.PerformClick(); btnSelect1337.PerformClick();
} }
catch (Exception ex)
{
MessageBox.Show($"An error occurred during double click: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void UnlockDLL(string filePath)
{
if (!File.Exists(filePath))
{
MessageBox.Show("The specified file does not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
try
{
ProcessStartInfo psi = new ProcessStartInfo("cmd.exe")
{
UseShellExecute = false,
RedirectStandardInput = true,
RedirectStandardOutput = true,
CreateNoWindow = true
};
using (Process process = new Process())
{
process.StartInfo = psi;
process.Start();
using (StreamWriter sw = process.StandardInput)
{
if (sw.BaseStream.CanWrite)
{
sw.WriteLine($"takeown /F \"{filePath}\"");
sw.WriteLine($"icacls \"{filePath}\" /grant Administrators:F");
}
}
process.WaitForExit();
}
MessageBox.Show($"Ownership and permissions of {filePath} have been successfully changed.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show($"An error occurred while changing ownership: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
} }
} }

View file

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// È possibile specificare tutti i valori oppure impostare valori predefiniti per i numeri relativi alla revisione e alla build // È possibile specificare tutti i valori oppure impostare valori predefiniti per i numeri relativi alla revisione e alla build
// usando l'asterisco '*' come illustrato di seguito: // usando l'asterisco '*' come illustrato di seguito:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.1.0.0")] [assembly: AssemblyVersion("1.9.0.0")]
[assembly: AssemblyFileVersion("2.1.0.0")] [assembly: AssemblyFileVersion("1.9.0.0")]

View file

@ -1,10 +1,10 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // Il codice è stato generato da uno strumento.
// Runtime Version:4.0.30319.42000 // Versione runtime:4.0.30319.42000
// //
// Changes to this file may cause incorrect behavior and will be lost if // Le modifiche apportate a questo file possono provocare un comportamento non corretto e andranno perse se
// the code is regenerated. // il codice viene rigenerato.
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -13,13 +13,13 @@ namespace Win_1337_Patch.Properties {
/// <summary> /// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc. /// Classe di risorse fortemente tipizzata per la ricerca di stringhe localizzate e così via.
/// </summary> /// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder // Questa classe è stata generata automaticamente dalla classe StronglyTypedResourceBuilder.
// class via a tool like ResGen or Visual Studio. // tramite uno strumento quale ResGen o Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen // Per aggiungere o rimuovere un membro, modificare il file con estensione ResX ed eseguire nuovamente ResGen
// with the /str option, or rebuild your VS project. // con l'opzione /str oppure ricompilare il progetto VS.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources { internal class Resources {
@ -33,7 +33,7 @@ namespace Win_1337_Patch.Properties {
} }
/// <summary> /// <summary>
/// Returns the cached ResourceManager instance used by this class. /// Restituisce l'istanza di ResourceManager nella cache utilizzata da questa classe.
/// </summary> /// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager { internal static global::System.Resources.ResourceManager ResourceManager {
@ -47,8 +47,8 @@ namespace Win_1337_Patch.Properties {
} }
/// <summary> /// <summary>
/// Overrides the current thread's CurrentUICulture property for all /// Esegue l'override della proprietà CurrentUICulture del thread corrente per tutte le
/// resource lookups using this strongly typed resource class. /// ricerche di risorse eseguite utilizzando questa classe di risorse fortemente tipizzata.
/// </summary> /// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture { internal static global::System.Globalization.CultureInfo Culture {

View file

@ -1,10 +1,10 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // Il codice è stato generato da uno strumento.
// Runtime Version:4.0.30319.42000 // Versione runtime:4.0.30319.42000
// //
// Changes to this file may cause incorrect behavior and will be lost if // Le modifiche apportate a questo file possono provocare un comportamento non corretto e andranno perse se
// the code is regenerated. // il codice viene rigenerato.
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -12,7 +12,7 @@ namespace Win_1337_Patch.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.10.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.8.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
@ -70,17 +70,5 @@ namespace Win_1337_Patch.Properties {
this["backup"] = value; this["backup"] = value;
} }
} }
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
public bool changeOwnership {
get {
return ((bool)(this["changeOwnership"]));
}
set {
this["changeOwnership"] = value;
}
}
} }
} }

View file

@ -14,8 +14,5 @@
<Setting Name="backup" Type="System.Boolean" Scope="User"> <Setting Name="backup" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value> <Value Profile="(Default)">True</Value>
</Setting> </Setting>
<Setting Name="changeOwnership" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>

View file

@ -8,10 +8,9 @@
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<RootNamespace>Win_1337_Patch</RootNamespace> <RootNamespace>Win_1337_Patch</RootNamespace>
<AssemblyName>Win_1337_Patch</AssemblyName> <AssemblyName>Win_1337_Patch</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic> <Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@ -22,7 +21,6 @@
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@ -32,7 +30,6 @@
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<ApplicationIcon>vampire.ico</ApplicationIcon> <ApplicationIcon>vampire.ico</ApplicationIcon>

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8" ?>
<configuration> <configuration>
<configSections> <configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="Win_1337_Patch.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/> <section name="Win_1337_Patch.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup> </sectionGroup>
</configSections> </configSections>
<userSettings> <userSettings>
@ -19,9 +19,6 @@
<setting name="backup" serializeAs="String"> <setting name="backup" serializeAs="String">
<value>True</value> <value>True</value>
</setting> </setting>
<setting name="changeOwnership" serializeAs="String">
<value>True</value>
</setting>
</Win_1337_Patch.Properties.Settings> </Win_1337_Patch.Properties.Settings>
</userSettings> </userSettings>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup></configuration> </configuration>

View file

@ -28,7 +28,7 @@ namespace Win_1337_Patch
IMAGE_DOS_HEADER DHD = new IMAGE_DOS_HEADER(); IMAGE_DOS_HEADER DHD = new IMAGE_DOS_HEADER();
IMAGE_NT_HEADERS NHD = new IMAGE_NT_HEADERS(); IMAGE_NT_HEADERS NHD = new IMAGE_NT_HEADERS();
long iPointer = 0; int iPointer = 0;
uint uOriginal = 0; uint uOriginal = 0;
uint uRecalculated = 0; uint uRecalculated = 0;
uint uRet = 0; uint uRet = 0;
@ -36,23 +36,16 @@ namespace Win_1337_Patch
try try
{ {
using (BinaryReader bReader = new BinaryReader(new FileStream(sFilePath, FileMode.Open, FileAccess.Read))) BinaryReader bReader = new BinaryReader(new FileStream(sFilePath, FileMode.Open, FileAccess.Read));
{
fBytes = bReader.ReadBytes((int)bReader.BaseStream.Length); fBytes = bReader.ReadBytes((int)bReader.BaseStream.Length);
bReader.Close();
} }
} catch { }
catch
{
return false;
}
if (fBytes.Length <= 0) { return false; } if (fBytes.Length <= 0) { return false; }
GCHandle gHandle = GCHandle.Alloc(fBytes, GCHandleType.Pinned); GCHandle gHandle = GCHandle.Alloc(fBytes, GCHandleType.Pinned);
checked iPointer = gHandle.AddrOfPinnedObject().ToInt32();
{
iPointer = gHandle.AddrOfPinnedObject().ToInt64();
}
DHD = (IMAGE_DOS_HEADER)Marshal.PtrToStructure(new IntPtr(iPointer), typeof(IMAGE_DOS_HEADER)); DHD = (IMAGE_DOS_HEADER)Marshal.PtrToStructure(new IntPtr(iPointer), typeof(IMAGE_DOS_HEADER));
NHD = (IMAGE_NT_HEADERS)Marshal.PtrToStructure(new IntPtr(iPointer + DHD.e_lfanew), typeof(IMAGE_NT_HEADERS)); NHD = (IMAGE_NT_HEADERS)Marshal.PtrToStructure(new IntPtr(iPointer + DHD.e_lfanew), typeof(IMAGE_NT_HEADERS));
gHandle.Free(); gHandle.Free();
@ -81,23 +74,17 @@ namespace Win_1337_Patch
NHD.OptionalHeader.CheckSum = uRecalculated; NHD.OptionalHeader.CheckSum = uRecalculated;
byte[] bNHD = getBytes_(NHD); byte[] bNHD = getBytes_(NHD);
if (fBytes.Length - (DHD.e_lfanew + bNHD.Length) <= 0) if (fBytes.Length - (DHD.e_lfanew + bNHD.Length) <= 0) { Array.Resize(ref fBytes, (int)(fBytes.Length + bNHD.Length)); }
{
Array.Resize(ref fBytes, (int)(fBytes.Length + bNHD.Length));
}
Array.Copy(bNHD, 0, fBytes, DHD.e_lfanew, bNHD.Length); Array.Copy(bNHD, 0, fBytes, DHD.e_lfanew, bNHD.Length);
try try
{ {
using (BinaryWriter bWriter = new BinaryWriter(new FileStream(sFilePath, FileMode.Open))) BinaryWriter bWriter = new BinaryWriter(new FileStream(sFilePath, FileMode.Open));
{
bWriter.Write(fBytes); bWriter.Write(fBytes);
bWriter.Flush();
bWriter.Close();
} }
} catch { return false; }
catch
{
return false;
}
return true; return true;
} }