Skip to content

Commit

Permalink
WriteMemory's ChangeProtection was missing file argument
Browse files Browse the repository at this point in the history
  • Loading branch information
erfg12 committed Jan 7, 2022
1 parent 74beeee commit d3d0720
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Memory/Methods/Write.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,10 @@ public bool WriteMemory(string code, string type, string write, string file = ""
MemoryProtection OldMemProt = 0x00;
bool WriteProcMem = false;
if (RemoveWriteProtection)
ChangeProtection(code, MemoryProtection.ExecuteReadWrite, out OldMemProt); // change protection
ChangeProtection(code, MemoryProtection.ExecuteReadWrite, out OldMemProt, file); // change protection
WriteProcMem = WriteProcessMemory(mProc.Handle, theCode, memory, (UIntPtr)size, IntPtr.Zero);
if (RemoveWriteProtection)
ChangeProtection(code, OldMemProt, out _); // restore
ChangeProtection(code, OldMemProt, out _, file); // restore
return WriteProcMem;
}

Expand Down
13 changes: 8 additions & 5 deletions Memory/memory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,13 @@ public string LoadCode(string name, string iniFile)
StringBuilder returnCode = new StringBuilder(1024);
uint read_ini_result;

if (iniFile != "")
if (!String.IsNullOrEmpty(iniFile))
{
if (File.Exists(iniFile))
{
read_ini_result = GetPrivateProfileString("codes", name, "", returnCode, (uint)returnCode.Capacity, iniFile);
//Debug.WriteLine("read_ini_result=" + read_ini_result); number of characters returned
}
else
Debug.WriteLine("ERROR: ini file \"" + iniFile + "\" not found!");
}
Expand Down Expand Up @@ -356,12 +359,12 @@ public UIntPtr GetCode(string name, string path = "", int size = 8)
return Get64BitCode(name, path, size); //jump over to 64bit code grab
}

if (path != "")
if (!String.IsNullOrEmpty(path))
theCode = LoadCode(name, path);
else
theCode = name;

if (theCode == "")
if (String.IsNullOrEmpty(theCode))
{
//Debug.WriteLine("ERROR: LoadCode returned blank. NAME:" + name + " PATH:" + path);
return UIntPtr.Zero;
Expand Down Expand Up @@ -492,12 +495,12 @@ public UIntPtr GetCode(string name, string path = "", int size = 8)
public UIntPtr Get64BitCode(string name, string path = "", int size = 16)
{
string theCode = "";
if (path != "")
if (!String.IsNullOrEmpty(path))
theCode = LoadCode(name, path);
else
theCode = name;

if (theCode == "")
if (String.IsNullOrEmpty(theCode))
return UIntPtr.Zero;

// remove spaces
Expand Down

0 comments on commit d3d0720

Please sign in to comment.