@@ -136,7 +136,7 @@ static void Main()
136136 {
137137 overwolfSubscriptionsPath = dir + "\\ Overwolf.Subscriptions.dll" ;
138138 Console . WriteLine ( "Overwolf.Subscriptions.dll found!" ) ;
139- }
139+ }
140140 if ( File . Exists ( dir + "\\ OverWolf.Client.BL.dll" ) )
141141 {
142142 overwolfBDDllPath = dir + "\\ OverWolf.Client.BL.dll" ;
@@ -179,7 +179,7 @@ static void Main()
179179 Console . WriteLine ( "||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||" ) ;
180180 Console . WriteLine ( "|| OverWolf.Client.Core.dll ||" ) ;
181181 Console . WriteLine ( "|| ||" ) ;
182- var resolver = new DefaultAssemblyResolver ( ) ;
182+ var resolver = new DefaultAssemblyResolver ( ) ;
183183 resolver . AddSearchDirectory ( Path . GetDirectoryName ( overwolfCorePath ) ) ;
184184 ReaderParameters reader = new ReaderParameters { AssemblyResolver = resolver , ReadWrite = true , InMemory = true } ;
185185 AssemblyDefinition overwolfCore = AssemblyDefinition . ReadAssembly ( overwolfCorePath , reader ) ;
@@ -228,14 +228,15 @@ static void Main()
228228 try
229229 {
230230 overwolfCoreGES = InjectMethods . OverwolfCoreGetExtensionSubscriptions ( ref overwolfCore , overwolfCoreGES ) ;
231- } catch ( Exception e )
231+ }
232+ catch ( Exception e )
232233 {
233234 successful = false ;
234235 Console . WriteLine ( "Error, Overwolf.Core will not be patched: " ) ;
235236 Console . WriteLine ( e ) ;
236237 }
237238 }
238-
239+
239240 //
240241 }
241242
@@ -257,7 +258,8 @@ static void Main()
257258 {
258259 overwolfCoreExtensionWebAppStratContentValidation . Body . Instructions . Clear ( ) ;
259260 overwolfCoreExtensionWebAppStratContentValidation . Body . Instructions . Add ( Instruction . Create ( OpCodes . Ret ) ) ;
260- } catch ( Exception e )
261+ }
262+ catch ( Exception e )
261263 {
262264 successful = false ;
263265 Console . WriteLine ( "Error, Overwolf.Core will not be patched: " ) ;
@@ -279,8 +281,8 @@ static void Main()
279281 if ( File . Exists ( backupFilePath ) )
280282 File . Delete ( backupFilePath ) ;
281283 File . Copy ( overwolfCorePath , backupFilePath ) ;
282- if ( successful )
283- overwolfCore . Write ( overwolfCorePath ) ;
284+ if ( successful )
285+ overwolfCore . Write ( overwolfCorePath ) ;
284286 Console . WriteLine ( "|| ------ Patched successfully ||" ) ;
285287 }
286288 catch ( System . UnauthorizedAccessException )
@@ -300,25 +302,75 @@ static void Main()
300302
301303 if ( File . Exists ( overwolfBDDllPath ) )
302304 {
305+ Console . WriteLine ( ) ;
306+ Console . WriteLine ( ) ;
307+ Console . WriteLine ( "||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||" ) ;
308+ Console . WriteLine ( "|| OverWolf.Client.BL.dll ||" ) ;
309+ Console . WriteLine ( "|| ||" ) ;
310+ Console . WriteLine ( "|| OverWolf.Client.BL.ODKv2.Managers.DataManager.ExtensionDataManager type found! ||" ) ;
303311 var resolver = new DefaultAssemblyResolver ( ) ;
304312 resolver . AddSearchDirectory ( Path . GetDirectoryName ( overwolfBDDllPath ) ) ;
305313 ReaderParameters reader = new ReaderParameters { AssemblyResolver = resolver , ReadWrite = true , ReadingMode = ReadingMode . Immediate , InMemory = true } ;
306- AssemblyDefinition overwolfSubscriptions = AssemblyDefinition . ReadAssembly ( overwolfBDDllPath , reader ) ;
307- TypeDefinition overwolfSubscriptionsModel = overwolfSubscriptions . MainModule . GetType ( "OverWolf.Client.BL.ODKv2.Managers.DataManager.ExtensionDataManager" ) ;
314+ AssemblyDefinition overwolfBD = AssemblyDefinition . ReadAssembly ( overwolfBDDllPath , reader ) ;
315+ TypeDefinition overwolfExtensionDataManager = overwolfBD . MainModule . GetType ( "OverWolf.Client.BL.ODKv2.Managers.DataManager.ExtensionDataManager" ) ;
308316
309- foreach ( var m in overwolfSubscriptionsModel . Methods )
317+ if ( overwolfBD != null )
310318 {
311- if ( m . Name == "BlockUnauthorizedExtension" || m . Name == "ValidateExtension" || m . Name == "IsWhiteListForValidation" )
319+ MethodDefinition validateExtensionMethod = overwolfExtensionDataManager . Methods . SingleOrDefault ( x => x . Name == "ValidateExtension" ) ;
320+ MethodDefinition blockUnauthorizedExtensionMethod = overwolfExtensionDataManager . Methods . SingleOrDefault ( x => x . Name == "BlockUnauthorizedExtension" ) ;
321+ MethodDefinition isWhiteListForValidationMethod = overwolfExtensionDataManager . Methods . SingleOrDefault ( x => x . Name == "IsWhiteListForValidation" ) ;
322+
323+ if ( validateExtensionMethod != null )
312324 {
313- m . Body . Instructions . Clear ( ) ;
325+ Console . WriteLine ( "|| -- ValidateExtension method found! ||" ) ;
326+ InjectMethods . PatchReturn ( ref validateExtensionMethod , true ) ;
327+ Console . WriteLine ( "|| ---- ValidateExtension method patched! ||" ) ;
328+ }
329+ else
330+ Console . WriteLine ( "ValidateExtension not found!" ) ;
314331
315- m . Body . Instructions . Add ( Instruction . Create ( OpCodes . Ldc_I4_0 ) ) ;
316- m . Body . Instructions . Add ( Instruction . Create ( OpCodes . Ret ) ) ;
332+ if ( blockUnauthorizedExtensionMethod != null )
333+ {
334+ Console . WriteLine ( "|| -- BlockUnauthorizedExtension method found! ||" ) ;
335+ InjectMethods . PatchReturn ( ref blockUnauthorizedExtensionMethod , false ) ;
336+ Console . WriteLine ( "|| ---- BlockUnauthorizedExtension method patched! ||" ) ;
337+ }
338+ else
339+ Console . WriteLine ( "BlockUnauthorizedExtension not found!" ) ;
317340
341+ if ( isWhiteListForValidationMethod != null )
342+ {
343+ Console . WriteLine ( "|| -- IsWhiteListForValidation method found! ||" ) ;
344+ InjectMethods . PatchReturn ( ref isWhiteListForValidationMethod , true ) ;
345+ Console . WriteLine ( "|| ---- IsWhiteListForValidation method patched! ||" ) ;
318346 }
347+ else
348+ Console . WriteLine ( "IsWhiteListForValidation not found!" ) ;
319349 }
320350
321- overwolfSubscriptions . Write ( overwolfBDDllPath ) ;
351+ string backupFilePath = Path . GetDirectoryName ( overwolfBDDllPath ) + "\\ " + Path . GetFileNameWithoutExtension ( overwolfBDDllPath ) + "_bak.dll" ;
352+
353+ try
354+ {
355+ if ( File . Exists ( backupFilePath ) )
356+ File . Delete ( backupFilePath ) ;
357+ File . Copy ( overwolfBDDllPath , backupFilePath ) ;
358+ overwolfBD . Write ( overwolfBDDllPath ) ;
359+ Console . WriteLine ( "|| ------ Patched successfully ||" ) ;
360+ }
361+ catch ( System . UnauthorizedAccessException )
362+ {
363+ Console . WriteLine ( "Permission denied" ) ;
364+ }
365+ catch ( Exception e )
366+ {
367+ File . Delete ( overwolfBDDllPath ) ;
368+ if ( File . Exists ( backupFilePath ) )
369+ File . Copy ( backupFilePath , overwolfBDDllPath ) ;
370+ Console . WriteLine ( e ) ;
371+ }
372+ resolver . Dispose ( ) ;
373+ Console . WriteLine ( "||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||" ) ;
322374 }
323375
324376 if ( File . Exists ( overwolfSubscriptionsPath ) )
0 commit comments