@@ -136,7 +136,7 @@ static void Main()
136
136
{
137
137
overwolfSubscriptionsPath = dir + "\\ Overwolf.Subscriptions.dll" ;
138
138
Console . WriteLine ( "Overwolf.Subscriptions.dll found!" ) ;
139
- }
139
+ }
140
140
if ( File . Exists ( dir + "\\ OverWolf.Client.BL.dll" ) )
141
141
{
142
142
overwolfBDDllPath = dir + "\\ OverWolf.Client.BL.dll" ;
@@ -179,7 +179,7 @@ static void Main()
179
179
Console . WriteLine ( "||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||" ) ;
180
180
Console . WriteLine ( "|| OverWolf.Client.Core.dll ||" ) ;
181
181
Console . WriteLine ( "|| ||" ) ;
182
- var resolver = new DefaultAssemblyResolver ( ) ;
182
+ var resolver = new DefaultAssemblyResolver ( ) ;
183
183
resolver . AddSearchDirectory ( Path . GetDirectoryName ( overwolfCorePath ) ) ;
184
184
ReaderParameters reader = new ReaderParameters { AssemblyResolver = resolver , ReadWrite = true , InMemory = true } ;
185
185
AssemblyDefinition overwolfCore = AssemblyDefinition . ReadAssembly ( overwolfCorePath , reader ) ;
@@ -228,14 +228,15 @@ static void Main()
228
228
try
229
229
{
230
230
overwolfCoreGES = InjectMethods . OverwolfCoreGetExtensionSubscriptions ( ref overwolfCore , overwolfCoreGES ) ;
231
- } catch ( Exception e )
231
+ }
232
+ catch ( Exception e )
232
233
{
233
234
successful = false ;
234
235
Console . WriteLine ( "Error, Overwolf.Core will not be patched: " ) ;
235
236
Console . WriteLine ( e ) ;
236
237
}
237
238
}
238
-
239
+
239
240
//
240
241
}
241
242
@@ -257,7 +258,8 @@ static void Main()
257
258
{
258
259
overwolfCoreExtensionWebAppStratContentValidation . Body . Instructions . Clear ( ) ;
259
260
overwolfCoreExtensionWebAppStratContentValidation . Body . Instructions . Add ( Instruction . Create ( OpCodes . Ret ) ) ;
260
- } catch ( Exception e )
261
+ }
262
+ catch ( Exception e )
261
263
{
262
264
successful = false ;
263
265
Console . WriteLine ( "Error, Overwolf.Core will not be patched: " ) ;
@@ -279,8 +281,8 @@ static void Main()
279
281
if ( File . Exists ( backupFilePath ) )
280
282
File . Delete ( backupFilePath ) ;
281
283
File . Copy ( overwolfCorePath , backupFilePath ) ;
282
- if ( successful )
283
- overwolfCore . Write ( overwolfCorePath ) ;
284
+ if ( successful )
285
+ overwolfCore . Write ( overwolfCorePath ) ;
284
286
Console . WriteLine ( "|| ------ Patched successfully ||" ) ;
285
287
}
286
288
catch ( System . UnauthorizedAccessException )
@@ -300,25 +302,75 @@ static void Main()
300
302
301
303
if ( File . Exists ( overwolfBDDllPath ) )
302
304
{
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! ||" ) ;
303
311
var resolver = new DefaultAssemblyResolver ( ) ;
304
312
resolver . AddSearchDirectory ( Path . GetDirectoryName ( overwolfBDDllPath ) ) ;
305
313
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" ) ;
308
316
309
- foreach ( var m in overwolfSubscriptionsModel . Methods )
317
+ if ( overwolfBD != null )
310
318
{
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 )
312
324
{
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!" ) ;
314
331
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!" ) ;
317
340
341
+ if ( isWhiteListForValidationMethod != null )
342
+ {
343
+ Console . WriteLine ( "|| -- IsWhiteListForValidation method found! ||" ) ;
344
+ InjectMethods . PatchReturn ( ref isWhiteListForValidationMethod , true ) ;
345
+ Console . WriteLine ( "|| ---- IsWhiteListForValidation method patched! ||" ) ;
318
346
}
347
+ else
348
+ Console . WriteLine ( "IsWhiteListForValidation not found!" ) ;
319
349
}
320
350
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 ( "||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||" ) ;
322
374
}
323
375
324
376
if ( File . Exists ( overwolfSubscriptionsPath ) )
0 commit comments