1- using System ;
2- using System . Collections . Generic ;
3- using System . Linq ;
4- using System . Text ;
5- using System . Threading . Tasks ;
6- using System . Security . Principal ;
7- using System . IO ;
8- using Mono . Cecil ;
1+ using Mono . Cecil ;
92using Mono . Cecil . Cil ;
10- using System . Threading ;
3+ using System ;
114using System . Diagnostics ;
5+ using System . IO ;
6+ using System . Linq ;
7+ using System . Security . Principal ;
128
139namespace OverwolfInsiderPatcher
1410{
1511 class Program
1612 {
17- static void Main ( string [ ] args )
13+ static void Main ( )
1814 {
15+ Console . Title = "Overwolf patcher by Decode 1.1" ;
16+
1917 string overwolfCorePath = "" ;
18+ string overwolfCoreCUPath = "" ;
2019
2120 bool isElevated ;
2221 using ( WindowsIdentity identity = WindowsIdentity . GetCurrent ( ) )
@@ -47,7 +46,7 @@ static void Main(string[] args)
4746
4847
4948 string winDir = Path . GetPathRoot ( Environment . SystemDirectory ) ;
50-
49+ Console . WriteLine ( ) ;
5150 string [ ] directories = Directory . GetDirectories ( winDir + "Program Files (x86)\\ Overwolf" ) ;
5251 foreach ( string dir in directories )
5352 {
@@ -56,52 +55,78 @@ static void Main(string[] args)
5655 overwolfCorePath = dir + "\\ OverWolf.Client.Core.dll" ;
5756 Console . WriteLine ( "Overwolf.Client.Core.dll found!" ) ;
5857 }
58+ if ( File . Exists ( dir + "\\ OverWolf.Client.CommonUtils.dll" ) )
59+ {
60+ overwolfCoreCUPath = dir + "\\ OverWolf.Client.CommonUtils.dll" ;
61+ Console . WriteLine ( "OverWolf.Client.CommonUtils.dll found!" ) ;
62+ }
5963 }
64+ //Console.Write("Enter \"Overwolf.Client.Core.dll\" path");
65+ //if (overwolfCorePath != "")
66+ //{
67+ // Console.Write(" (press enter to use default path)");
68+ //}
69+ //Console.Write(": ");
6070
61- Console . Write ( "Enter \" Overwolf.Client.Core.dll\" path" ) ;
62- if ( overwolfCorePath != "" )
63- {
64- Console . Write ( " (press enter to use default path)" ) ;
65- }
66- Console . Write ( ": " ) ;
6771
72+ //string overwolfCoreNewPath = Console.ReadLine().ToString();
73+ //if (overwolfCoreNewPath != "" && File.Exists(overwolfCoreNewPath))
74+ //{
75+ // overwolfCorePath = overwolfCoreNewPath;
76+ //}
6877
69- string overwolfCoreNewPath = Console . Read ( ) . ToString ( ) ;
70- if ( overwolfCoreNewPath != "" && File . Exists ( overwolfCoreNewPath ) )
71- {
72- overwolfCorePath = overwolfCoreNewPath ;
73- }
78+ //Console.Write("Enter \"OverWolf.Client.CommonUtils.dll\" path");
79+ //if (overwolfCorePath != "")
80+ //{
81+ // Console.Write(" (press enter to use default path)");
82+ //}
83+ //Console.Write(": ");
84+
85+ //string overwolfCoreCUNewPath = Console.ReadLine().ToString();
86+ //if (overwolfCoreCUNewPath != "" && File.Exists(overwolfCoreCUNewPath))
87+ //{
88+ // overwolfCoreCUPath = overwolfCoreCUNewPath;
89+ //}
7490
91+ //Console.WriteLine(overwolfCoreCUNewPath);
7592 if ( File . Exists ( overwolfCorePath ) )
7693 {
94+ Console . WriteLine ( ) ;
95+ Console . WriteLine ( ) ;
96+ Console . WriteLine ( "|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||" ) ;
97+ Console . WriteLine ( "|| OverWolf.Client.Core.dll ||" ) ;
7798 var resolver = new DefaultAssemblyResolver ( ) ;
7899 resolver . AddSearchDirectory ( Path . GetDirectoryName ( overwolfCorePath ) ) ;
79100 ReaderParameters reader = new ReaderParameters { AssemblyResolver = resolver , ReadWrite = true , ReadingMode = ReadingMode . Immediate , InMemory = true } ;
80101 AssemblyDefinition overwolfCore = AssemblyDefinition . ReadAssembly ( overwolfCorePath , reader ) ;
81102 TypeDefinition overwolfCoreWManager = overwolfCore . MainModule . GetType ( "OverWolf.Client.Core.Managers.WindowsInsiderSupportHelper" ) ;
82103 if ( overwolfCoreWManager != null )
83104 {
84- Console . WriteLine ( "-- OverWolf.Client.Core.Managers.WindowsInsiderSupportHelper type found!" ) ;
85- MethodDefinition showInsiderBlockMessageMethod = null ;
86- try
87- {
88- showInsiderBlockMessageMethod = overwolfCoreWManager . Methods . Single ( x => x . Name == "ShowInsiderBlockMessage" ) ;
89- }
90- catch ( InvalidOperationException e )
91- {
92- Console . WriteLine ( "ShowInsiderBlockMessage1 not found: " + e . Message ) ;
93- }
94- catch ( Exception e )
95- {
96- Console . WriteLine ( "Error: " + e ) ;
97- }
105+ Console . WriteLine ( "|| OverWolf.Client.Core.Managers.WindowsInsiderSupportHelper type found! ||" ) ;
106+ MethodDefinition showInsiderBlockMessageMethod = overwolfCoreWManager . Methods . SingleOrDefault ( x => x . Name == "ShowInsiderBlockMessage" ) ;
98107 if ( showInsiderBlockMessageMethod != null )
99108 {
100- Console . WriteLine ( "---- ShowInsiderBlockMessage method found!" ) ;
109+ Console . WriteLine ( "|| -- ShowInsiderBlockMessage method found! || " ) ;
101110 showInsiderBlockMessageMethod . Body . Instructions . Clear ( ) ;
102111 showInsiderBlockMessageMethod . Body . Instructions . Add ( Instruction . Create ( OpCodes . Ldc_I4_0 ) ) ;
103112 showInsiderBlockMessageMethod . Body . Instructions . Add ( Instruction . Create ( OpCodes . Ret ) ) ;
104- Console . WriteLine ( "------ ShowInsiderBlockMessage method patched!" ) ;
113+ Console . WriteLine ( "|| ---- ShowInsiderBlockMessage method patched! ||" ) ;
114+
115+ TypeDefinition overwolfCoreIU = overwolfCore . MainModule . GetType ( "OverWolf.Client.Core.ODKv2.OverwolfInternalUtils" ) ;
116+ if ( overwolfCoreIU != null )
117+ {
118+ MethodDefinition overwolfCoreGPI = overwolfCoreIU . Methods . SingleOrDefault ( x => x . Name == "getProductInformation" ) ;
119+ if ( overwolfCoreGPI != null )
120+ {
121+ foreach ( Instruction instr in overwolfCoreGPI . Body . Instructions )
122+ {
123+ if ( instr . Operand != null && instr . Operand . GetType ( ) == typeof ( string ) && ( ( string ) instr . Operand ) . StartsWith ( "Copyright Overwolf © " ) && ! ( ( string ) instr . Operand ) . EndsWith ( " (Patched by Decode)" ) )
124+ {
125+ instr . Operand = instr . Operand . ToString ( ) + " (Patched by Decode)" ;
126+ }
127+ }
128+ }
129+ }
105130
106131 try
107132 {
@@ -110,7 +135,7 @@ static void Main(string[] args)
110135 File . Delete ( backupFilePath ) ;
111136 File . Copy ( overwolfCorePath , backupFilePath ) ;
112137 overwolfCore . Write ( overwolfCorePath ) ;
113- Console . WriteLine ( "-------- Patched successfully" ) ;
138+ Console . WriteLine ( "|| ------ Patched successfully || " ) ;
114139 }
115140 catch ( System . UnauthorizedAccessException )
116141 {
@@ -121,14 +146,81 @@ static void Main(string[] args)
121146 Console . WriteLine ( e ) ;
122147 }
123148 }
149+ else
150+ {
151+ Console . WriteLine ( "|| ShowInsiderBlockMessage not found! ||" ) ;
152+ }
124153
125154 }
126155 else
127156 {
128157 Console . WriteLine ( "OverWolf.Client.Core.Managers.WindowsInsiderSupportHelper type not found!" ) ;
129158 }
159+ Console . WriteLine ( "|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||" ) ;
130160 }
131161
162+ if ( File . Exists ( overwolfCoreCUPath ) )
163+ {
164+ Console . WriteLine ( ) ;
165+ Console . WriteLine ( ) ;
166+ Console . WriteLine ( "||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||" ) ;
167+ Console . WriteLine ( "|| OverWolf.Client.CommonUtils.dll ||" ) ;
168+ var resolver = new DefaultAssemblyResolver ( ) ;
169+ resolver . AddSearchDirectory ( Path . GetDirectoryName ( overwolfCoreCUPath ) ) ;
170+ ReaderParameters reader = new ReaderParameters { AssemblyResolver = resolver , ReadWrite = true , ReadingMode = ReadingMode . Immediate , InMemory = true } ;
171+ AssemblyDefinition overwolfCore = AssemblyDefinition . ReadAssembly ( overwolfCoreCUPath , reader ) ;
172+ TypeDefinition overwolfCoreCUFeatures = overwolfCore . MainModule . GetType ( "OverWolf.Client.CommonUtils.Features.CommonFeatures" ) ;
173+ if ( overwolfCoreCUFeatures != null )
174+ {
175+ Console . WriteLine ( "|| OverWolf.Client.CommonUtils.Features.CommonFeatures type found! ||" ) ;
176+ MethodDefinition enableDevToolsForQA = overwolfCoreCUFeatures . Methods . SingleOrDefault ( x => x . Name == "EnableDevToolsForQA" ) ;
177+ if ( enableDevToolsForQA != null )
178+ {
179+ Console . WriteLine ( "|| -- EnableDevToolsForQA method found! ||" ) ;
180+ enableDevToolsForQA . Body . Variables . Clear ( ) ;
181+ enableDevToolsForQA . Body . Instructions . Clear ( ) ;
182+ enableDevToolsForQA . Body . ExceptionHandlers . Clear ( ) ;
183+ enableDevToolsForQA . Body . Instructions . Add ( Instruction . Create ( OpCodes . Ldc_I4_1 ) ) ;
184+ enableDevToolsForQA . Body . Instructions . Add ( Instruction . Create ( OpCodes . Ret ) ) ;
185+ Console . WriteLine ( "|| ---- EnableDevToolsForQA method patched! ||" ) ;
186+
187+ try
188+ {
189+ string backupFilePath = Path . GetDirectoryName ( overwolfCoreCUPath ) + "\\ " + Path . GetFileNameWithoutExtension ( overwolfCoreCUPath ) + "_bak.dll" ;
190+ if ( File . Exists ( backupFilePath ) )
191+ File . Delete ( backupFilePath ) ;
192+ File . Copy ( overwolfCoreCUPath , backupFilePath ) ;
193+ overwolfCore . Write ( overwolfCoreCUPath ) ;
194+ Console . WriteLine ( "|| ------ Patched successfully ||" ) ;
195+ }
196+ catch ( System . UnauthorizedAccessException )
197+ {
198+ Console . WriteLine ( "Permission denied" ) ;
199+ }
200+ catch ( Exception e )
201+ {
202+ Console . WriteLine ( e ) ;
203+ }
204+ }
205+ else
206+ {
207+ Console . WriteLine ( "EnableDevToolsForQA not found!" ) ;
208+ }
209+
210+ }
211+ else
212+ {
213+ Console . WriteLine ( "OverWolf.Client.CommonUtils.Features.CommonFeatures type not found!" ) ;
214+ }
215+ Console . WriteLine ( "||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||" ) ;
216+ }
217+
218+
219+ Console . WriteLine ( ) ;
220+ Console . WriteLine ( ) ;
221+
222+ Console . WriteLine ( "Complete!" ) ;
223+
132224 Console . ReadKey ( ) ;
133225 }
134226 }
0 commit comments