@ -1,6 +1,7 @@
using System ;
using System ;
using System.Diagnostics ;
using System.Diagnostics ;
using System.IO ;
using System.IO ;
using System.IO.Compression ;
using System.Net ;
using System.Net ;
using System.Reflection ;
using System.Reflection ;
using HarmonyLib ;
using HarmonyLib ;
@ -36,12 +37,17 @@ namespace DeezShade {
}
}
}
}
var installerUrl = "https://gshade.org/releases/GShade.Latest.Installer.exe" ;
var installerUrl =
"https://github.com/Mortalitas/GShade/releases/latest/download/GShade.Latest.Installer.exe" ;
var zipUrl = "https://github.com/Mortalitas/GShade/releases/latest/download/GShade.Latest.zip" ;
var exePath = tempPath + "GShade.Latest.Installer.exe" ;
var exePath = tempPath + "GShade.Latest.Installer.exe" ;
var zipPath = tempPath + "GShade.Latest.zip" ;
Console . WriteLine ( "Downloading GShade installer..." ) ;
Console . WriteLine ( "Downloading GShade installer..." ) ;
using ( var client = new WebClient ( ) ) {
using ( var client = new WebClient ( ) ) {
client . DownloadFile ( installerUrl , exePath ) ;
client . DownloadFile ( installerUrl , exePath ) ;
client . DownloadFile ( zipUrl , zipPath ) ;
}
}
// I'm using the official GShade installer, am I not? :^
// I'm using the official GShade installer, am I not? :^
@ -54,10 +60,10 @@ namespace DeezShade {
// Patch GShade from shutting off your computer (LMAO)
// Patch GShade from shutting off your computer (LMAO)
Console . WriteLine ( "Patching GShade malware..." ) ;
Console . WriteLine ( "Patching GShade malware..." ) ;
type . GetField ( "_instReady" ) . SetValue ( null , true ) ; // wp
var harmony = new Harmony ( "com.notnite.thanks-marot" ) ;
var harmony = new Harmony ( "com.notnite.thanks-marot" ) ;
var lolMethod = type . GetMethod ( "www" , BindingFlags . Static | BindingFlags . NonPublic ) ;
var getProcessesByName = typeof ( Process ) . GetMethod ( "GetProcessesByName" , new [ ] { typeof ( string ) } ) ;
harmony . Patch ( lolMethod , new HarmonyMethod ( typeof ( Program ) . GetMethod ( nameof ( LolDetour ) ) ) ) ;
harmony . Patch ( getProcessesByName , new HarmonyMethod ( typeof ( Program ) . GetMethod ( nameof ( ProcessDetour ) ) ) ) ;
Console . WriteLine ( "Requesting new files through GShade installer..." ) ;
Console . WriteLine ( "Requesting new files through GShade installer..." ) ;
type . GetMethod ( "CopyZipDeployProcess" ) . Invoke ( null , null ) ;
type . GetMethod ( "CopyZipDeployProcess" ) . Invoke ( null , null ) ;
@ -66,7 +72,7 @@ namespace DeezShade {
// File.Copy gives an access denied error, so let's make it ourself
// File.Copy gives an access denied error, so let's make it ourself
var src = tempPath + "gshade-shaders" ;
var src = tempPath + "gshade-shaders" ;
var dst = Path . Combine ( gameInstall , " re shade-shaders") ;
var dst = Path . Combine ( gameInstall , " g shade-shaders") ;
void RecursiveClone ( string path ) {
void RecursiveClone ( string path ) {
var path2 = Path . Combine ( src , path ) ;
var path2 = Path . Combine ( src , path ) ;
@ -89,52 +95,61 @@ namespace DeezShade {
Console . WriteLine ( "Moving shaders to game directory..." ) ;
Console . WriteLine ( "Moving shaders to game directory..." ) ;
RecursiveClone ( "" ) ;
RecursiveClone ( "" ) ;
Directory . CreateDirectory ( Path . Combine ( gameInstall , " re shade-addons") ) ;
Directory . CreateDirectory ( Path . Combine ( gameInstall , " g shade-addons") ) ;
Directory . Move ( Path . Combine ( gameInstall , "gshade-presets" ) , Path . Combine ( gameInstall , "reshade-presets" ) ) ;
Console . Write ( "Use ReShade (y/n)? " ) ;
var useReShade = Console . ReadLine ( ) . ToLower ( ) = = "y" ;
Console . WriteLine ( "Downloading ReShade..." ) ;
if ( useReShade ) {
var reshadeUrl = "http://reshade.me/downloads/ReShade_Setup_5.7.0_Addon.exe" ;
Console . WriteLine ( "Downloading ReShade..." ) ;
var reshadePath = tempPath + "ReShade_Setup_5.7.0_Addon.exe" ;
var reshadeUrl = "http://static.reshade.me/downloads/ReShade_Setup_5.6.0_Addon.exe" ;
using ( var client = new WebClient ( ) ) {
var reshadePath = tempPath + "ReShade_Setup_5.6.0_Addon.exe" ;
client . DownloadFile ( reshadeUrl , reshadePath ) ;
using ( var client = new WebClient ( ) ) {
}
client . DownloadFile ( reshadeUrl , reshadePath ) ;
}
Console . WriteLine ( "Installing ReShade..." ) ;
Console . WriteLine ( "Installing ReShade..." ) ;
if ( File . Exists ( Path . Combine ( gameInstall , "dxgi.dll" ) ) ) {
if ( File . Exists ( Path . Combine ( gameInstall , "dxgi.dll" ) ) ) {
File . Move ( Path . Combine ( gameInstall , "dxgi.dll" ) , Path . Combine ( gameInstall , "dxgi.dll.old" ) ) ;
File . Move ( Path . Combine ( gameInstall , "dxgi.dll" ) , Path . Combine ( gameInstall , "dxgi.dll.old" ) ) ;
}
}
var reshadeProcess = new Process ( ) ;
var reshadeProcess = new Process ( ) ;
reshadeProcess . StartInfo . FileName = reshadePath ;
reshadeProcess . StartInfo . FileName = reshadePath ;
reshadeProcess . StartInfo . Arguments =
reshadeProcess . StartInfo . Arguments =
$"\" { Path . Combine ( gameInstall , "ffxiv_dx11.exe" ) } \ " --api dxgi --headless" ;
$"\" { Path . Combine ( gameInstall , "ffxiv_dx11.exe" ) } \ " --api dxgi --headless" ;
reshadeProcess . Start ( ) ;
reshadeProcess . Start ( ) ;
var configPath = Path . Combine ( gameInstall , "ReShade.ini" ) ;
var configPath = Path . Combine ( gameInstall , "ReShade.ini" ) ;
if ( ! File . Exists ( configPath ) ) {
if ( ! File . Exists ( configPath ) ) {
Console . WriteLine ( "Writing ReShade config..." ) ;
Console . WriteLine ( "Writing ReShade config..." ) ;
var configText = @ "[GENERAL]
var configText = @ "[GENERAL]
[GENERAL]
[GENERAL]
EffectSearchPaths = . \ re shade- shaders \ Shaders \ * *
EffectSearchPaths = . \ g shade- shaders \ Shaders \ * *
TextureSearchPaths = . \ re shade- shaders \ Textures \ * *
TextureSearchPaths = . \ g shade- shaders \ Textures \ * *
".Trim();
".Trim();
File . WriteAllText ( configPath , configText ) ;
File . WriteAllText ( configPath , configText ) ;
}
} else {
Console . WriteLine ( "Extracting DLL and config..." ) ;
var zip = ZipFile . OpenRead ( zipPath ) ;
if ( File . Exists ( Path . Combine ( gameInstall , "dxgi.dll" ) ) ) {
File . Move ( Path . Combine ( gameInstall , "dxgi.dll" ) , Path . Combine ( gameInstall , "dxgi.dll.old" ) ) ;
}
zip . GetEntry ( "GShade64.dll" ) . ExtractToFile ( Path . Combine ( gameInstall , "dxgi.dll" ) , true ) ;
zip . GetEntry ( "GShade.ini" ) . ExtractToFile ( Path . Combine ( gameInstall , "GShade.ini" ) , true ) ;
}
}
Console . WriteLine ( "Done!\nSupport FOSS, and thank you for using DeezShade!\nPress any key to continue." ) ;
Console . WriteLine ( "Done!\nSupport FOSS, and thank you for using DeezShade!\nPress any key to continue." ) ;
Console . ReadKey ( ) ;
Console . ReadKey ( ) ;
}
}
public static bool ProcessDetour ( ref Process [ ] __result , string processName ) {
public static bool LolDetour ( ) {
if ( processName = = "GShade.Installer" ) {
// thank you for writing malware marot
__result = Array . Empty < Process > ( ) ;
return false ;
return false ;
}
return true ;
}
}
}
}
}
}