1
0
mirror of https://github.com/mastercodeon314/KsDumper-11.git synced 2024-11-24 06:50:10 +01:00
KsDumper-11/DriverInterface/KduSelfExtract.cs
mastercodeon314 785233a68f v1.3 update.
Updated to KDU v1.3.4
Added new Provider Selector
Updated DarkControls
Many bug fixes
2023-10-06 18:53:56 -06:00

155 lines
4.3 KiB
C#

using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace KsDumper11
{
public class KduSelfExtract
{
public static void DisableDriverBlockList()
{
RegistryKey configKey = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Control\CI\Config", true);
if (configKey == null)
{
configKey = Registry.LocalMachine.CreateSubKey(@"SYSTEM\CurrentControlSet\Control\CI\Config");
}
if (configKey != null)
{
if (configKey.GetValue("VulnerableDriverBlocklistEnable") == null)
{
configKey.SetValue("VulnerableDriverBlocklistEnable", 0);
}
}
}
static string asmDir = "";
static string driverDir = "";
static KduSelfExtract()
{
DisableDriverBlockList();
asmDir = AssemblyDirectory;
driverDir = asmDir + @"\Driver";
}
public static string AssemblyDirectory
{
get
{
string codeBase = Assembly.GetExecutingAssembly().CodeBase;
UriBuilder uri = new UriBuilder(codeBase);
string path = Uri.UnescapeDataString(uri.Path);
return Path.GetDirectoryName(path);
}
}
public static string KduPath
{
get
{
return driverDir + @"\kdu.exe";
}
}
private static bool Extracted()
{
bool result = false;
string driverPath = driverDir + @"\KsDumperDriver.sys";
string kduPath = driverDir + @"\kdu.exe";
string drv64Path = driverDir + @"\drv64.dll";
string taigei64Path = driverDir + @"\Taigei64.dll";
if (!Directory.Exists(driverDir))
{
return false;
}
else
{
if (!File.Exists(driverPath))
{
return false;
}
else
{
result = true;
}
if (!File.Exists(kduPath))
{
return false;
}
else
{
result = true;
}
if (!File.Exists(drv64Path))
{
return false;
}
else
{
result = true;
}
if (!File.Exists(taigei64Path))
{
return false;
}
else
{
result = true;
}
}
return result;
}
public static void Extract()
{
if (!Extracted())
{
string asmDir = AssemblyDirectory;
string driverDir = asmDir + @"\Driver";
if (!Directory.Exists(driverDir))
{
Directory.CreateDirectory(driverDir);
}
string driverPath = driverDir + @"\KsDumperDriver.sys";
string kduPath = driverDir + @"\kdu.exe";
string drv64Path = driverDir + @"\drv64.dll";
string taigei64Path = driverDir + @"\Taigei64.dll";
if (!File.Exists(driverPath))
{
File.WriteAllBytes(driverPath, DriverInterface.Properties.Resources.KsDumperDriver);
}
if (!File.Exists(kduPath))
{
File.WriteAllBytes(kduPath, DriverInterface.Properties.Resources.kdu);
}
if (!File.Exists(drv64Path))
{
File.WriteAllBytes(drv64Path, DriverInterface.Properties.Resources.drv64);
}
if (!File.Exists(taigei64Path))
{
File.WriteAllBytes(taigei64Path, DriverInterface.Properties.Resources.Taigei64);
}
}
}
}
}