Skip to content

Commit fa6187d

Browse files
committed
better wait to check for "main" and "base"
1 parent cabec1a commit fa6187d

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

Memory/memory.cs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -419,9 +419,11 @@ public UIntPtr GetCode(string name, string path = "", int size = 8)
419419
}
420420
int[] offsets = offsetsList.ToArray();
421421

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)
423425
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("+"))
425427
{
426428
string[] moduleName = theCode.Split('+');
427429
IntPtr altModule = IntPtr.Zero;
@@ -465,9 +467,11 @@ public UIntPtr GetCode(string name, string path = "", int size = 8)
465467
int trueCode = Convert.ToInt32(newOffsets, 16);
466468
IntPtr altModule = IntPtr.Zero;
467469
//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)
469473
altModule = mProc.MainModule.BaseAddress;
470-
else if (!theCode.ToLower().Equals("base") && !theCode.ToLower().Equals("main") && theCode.Contains("+"))
474+
else if (!mainBase && theCode.Contains("+"))
471475
{
472476
string[] moduleName = theCode.Split('+');
473477
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)
567571
}
568572
Int64[] offsets = offsetsList.ToArray();
569573

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)
571577
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("+"))
573579
{
574580
string[] moduleName = theCode.Split('+');
575581
IntPtr altModule = IntPtr.Zero;
@@ -608,9 +614,12 @@ public UIntPtr Get64BitCode(string name, string path = "", int size = 16)
608614
{
609615
Int64 trueCode = Convert.ToInt64(newOffsets, 16);
610616
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)
612621
altModule = mProc.MainModule.BaseAddress;
613-
else if (!theCode.ToLower().Equals("base") && !theCode.ToLower().Equals("main") && theCode.Contains("+"))
622+
else if (!mainBase && theCode.Contains("+"))
614623
{
615624
string[] moduleName = theCode.Split('+');
616625
if (!moduleName[0].ToLower().Contains(".dll") && !moduleName[0].ToLower().Contains(".exe") && !moduleName[0].ToLower().Contains(".bin"))

0 commit comments

Comments
 (0)