@@ -419,9 +419,11 @@ public UIntPtr GetCode(string name, string path = "", int size = 8)
419
419
}
420
420
int [ ] offsets = offsetsList . ToArray ( ) ;
421
421
422
- if ( theCode . ToLower ( ) . Equals ( "base" ) || theCode . ToLower ( ) . Equals ( "main" ) )
422
+ bool mainBase = ( theCode . ToLower ( ) . Contains ( "base" ) || theCode . ToLower ( ) . Contains ( "main" ) ) && ! theCode . ToLower ( ) . Contains ( ".dll" ) && ! theCode . ToLower ( ) . Contains ( ".exe" ) ;
423
+
424
+ if ( mainBase )
423
425
ReadProcessMemory ( mProc . Handle , ( UIntPtr ) ( ( int ) mProc . MainModule . BaseAddress + offsets [ 0 ] ) , memoryAddress , ( UIntPtr ) size , IntPtr . Zero ) ;
424
- else if ( ! theCode . ToLower ( ) . Equals ( "base" ) && ! theCode . ToLower ( ) . Equals ( "main" ) && theCode . Contains ( "+" ) )
426
+ else if ( ! mainBase && theCode . Contains ( "+" ) )
425
427
{
426
428
string [ ] moduleName = theCode . Split ( '+' ) ;
427
429
IntPtr altModule = IntPtr . Zero ;
@@ -465,9 +467,11 @@ public UIntPtr GetCode(string name, string path = "", int size = 8)
465
467
int trueCode = Convert . ToInt32 ( newOffsets , 16 ) ;
466
468
IntPtr altModule = IntPtr . Zero ;
467
469
//Debug.WriteLine("newOffsets=" + newOffsets);
468
- if ( theCode . ToLower ( ) . Equals ( "base" ) || theCode . ToLower ( ) . Equals ( "main" ) )
470
+ bool mainBase = ( theCode . ToLower ( ) . Contains ( "base" ) || theCode . ToLower ( ) . Contains ( "main" ) ) && ! theCode . ToLower ( ) . Contains ( ".dll" ) && ! theCode . ToLower ( ) . Contains ( ".exe" ) ;
471
+
472
+ if ( mainBase )
469
473
altModule = mProc . MainModule . BaseAddress ;
470
- else if ( ! theCode . ToLower ( ) . Equals ( "base" ) && ! theCode . ToLower ( ) . Equals ( "main" ) && theCode . Contains ( "+" ) )
474
+ else if ( ! mainBase && theCode . Contains ( "+" ) )
471
475
{
472
476
string [ ] moduleName = theCode . Split ( '+' ) ;
473
477
if ( ! moduleName [ 0 ] . ToLower ( ) . Contains ( ".dll" ) && ! moduleName [ 0 ] . ToLower ( ) . Contains ( ".exe" ) && ! moduleName [ 0 ] . ToLower ( ) . Contains ( ".bin" ) )
@@ -567,9 +571,11 @@ public UIntPtr Get64BitCode(string name, string path = "", int size = 16)
567
571
}
568
572
Int64 [ ] offsets = offsetsList . ToArray ( ) ;
569
573
570
- if ( theCode . ToLower ( ) . Equals ( "base" ) || theCode . ToLower ( ) . Equals ( "main" ) )
574
+ bool mainBase = ( theCode . ToLower ( ) . Contains ( "base" ) || theCode . ToLower ( ) . Contains ( "main" ) ) && ! theCode . ToLower ( ) . Contains ( ".dll" ) && ! theCode . ToLower ( ) . Contains ( ".exe" ) ;
575
+
576
+ if ( mainBase )
571
577
ReadProcessMemory ( mProc . Handle , ( UIntPtr ) ( ( Int64 ) mProc . MainModule . BaseAddress + offsets [ 0 ] ) , memoryAddress , ( UIntPtr ) size , IntPtr . Zero ) ;
572
- else if ( ! theCode . ToLower ( ) . Equals ( "base" ) && ! theCode . ToLower ( ) . Equals ( "main" ) && theCode . Contains ( "+" ) )
578
+ else if ( ! mainBase && theCode . Contains ( "+" ) )
573
579
{
574
580
string [ ] moduleName = theCode . Split ( '+' ) ;
575
581
IntPtr altModule = IntPtr . Zero ;
@@ -608,9 +614,12 @@ public UIntPtr Get64BitCode(string name, string path = "", int size = 16)
608
614
{
609
615
Int64 trueCode = Convert . ToInt64 ( newOffsets , 16 ) ;
610
616
IntPtr altModule = IntPtr . Zero ;
611
- if ( theCode . ToLower ( ) . Equals ( "base" ) || theCode . ToLower ( ) . Equals ( "main" ) )
617
+
618
+ bool mainBase = ( theCode . ToLower ( ) . Contains ( "base" ) || theCode . ToLower ( ) . Contains ( "main" ) ) && ! theCode . ToLower ( ) . Contains ( ".dll" ) && ! theCode . ToLower ( ) . Contains ( ".exe" ) ;
619
+
620
+ if ( mainBase )
612
621
altModule = mProc . MainModule . BaseAddress ;
613
- else if ( ! theCode . ToLower ( ) . Equals ( "base" ) && ! theCode . ToLower ( ) . Equals ( "main" ) && theCode . Contains ( "+" ) )
622
+ else if ( ! mainBase && theCode . Contains ( "+" ) )
614
623
{
615
624
string [ ] moduleName = theCode . Split ( '+' ) ;
616
625
if ( ! moduleName [ 0 ] . ToLower ( ) . Contains ( ".dll" ) && ! moduleName [ 0 ] . ToLower ( ) . Contains ( ".exe" ) && ! moduleName [ 0 ] . ToLower ( ) . Contains ( ".bin" ) )
0 commit comments