diff --git a/Memory/Methods/Write.cs b/Memory/Methods/Write.cs index 49124ef..3e51b85 100644 --- a/Memory/Methods/Write.cs +++ b/Memory/Methods/Write.cs @@ -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; } diff --git a/Memory/memory.cs b/Memory/memory.cs index b8f57dc..c2f3a96 100644 --- a/Memory/memory.cs +++ b/Memory/memory.cs @@ -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!"); } @@ -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; @@ -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