/*[DllImport("MW3_fov_lib.dll", EntryPoint = "SetVals", CallingConvention = CallingConvention.Cdecl)] * public static extern void SetVals(uint nPid = 0, uint nBaseAddr = 0, byte nCheckRange = 0); * [DllImport("MW3_fov_lib.dll", EntryPoint = "ReadFloat", CallingConvention = CallingConvention.Cdecl)] * public static extern float ReadFloat(uint ptr); * [DllImport("MW3_fov_lib.dll", EntryPoint = "WriteFloat", CallingConvention = CallingConvention.Cdecl)] * public static extern void WriteFloat(uint ptr, float val); * [DllImport("MW3_fov_lib.dll", EntryPoint = "FindFoVOffset", CallingConvention = CallingConvention.Cdecl)] * public static extern bool FindFoVOffset(ref uint pFoV, ref byte step);*/ //[DllImport("ntdll.dll", EntryPoint = "RtlAdjustPrivilege")] //public static extern long RtlAdjustPrivilege(long privilege, long bEnablePrivilege, long bCurrentThread, long OldState); bool isRunning(bool init) { Process[] procs = Process.GetProcessesByName(c_exe); if (procs.Length > 0) { if (proc == null && init) { proc = procs[0]; try { mem = new Memory(c_cVar, proc.Id, c_baseAddr, c_checkRange); } catch (Exception err) { ErrMessage(err); Application.Exit(); } TimerVerif.Start(); } return(true); } else { if (proc != null && init) { TimerVerif.Stop(); mem = null; progStop(); } return(false); } }
/*[DllImport("MW3_fov_lib.dll", EntryPoint = "SetVals", CallingConvention = CallingConvention.Cdecl)] * public static extern void SetVals(uint nPid = 0, uint nBaseAddr = 0, byte nCheckRange = 0); * [DllImport("MW3_fov_lib.dll", EntryPoint = "ReadFloat", CallingConvention = CallingConvention.Cdecl)] * public static extern float ReadFloat(uint ptr); * [DllImport("MW3_fov_lib.dll", EntryPoint = "WriteFloat", CallingConvention = CallingConvention.Cdecl)] * public static extern void WriteFloat(uint ptr, float val); * [DllImport("MW3_fov_lib.dll", EntryPoint = "FindFoVOffset", CallingConvention = CallingConvention.Cdecl)] * public static extern bool FindFoVOffset(ref uint pFoV, ref byte step);*/ //[DllImport("ntdll.dll", EntryPoint = "RtlAdjustPrivilege")] //public static extern long RtlAdjustPrivilege(long privilege, long bEnablePrivilege, long bCurrentThread, long OldState); bool isRunning(bool init) { Process[] spProcs = Process.GetProcessesByName(Singleplayer.c_exe); Process[] mpProcs = Process.GetProcessesByName(Multiplayer.c_exe); Process[] procs = new Process[mpProcs.Length + spProcs.Length]; try { spProcs.CopyTo(procs, 0); mpProcs.CopyTo(procs, spProcs.Length); } catch { } if (procs.Length > 0) { if (proc == null && init) { proc = procs[0]; if (proc.ProcessName == Singleplayer.c_exe && !rbSingleplayer.Checked) { rbSingleplayer.Checked = true; } else if (proc.ProcessName == Multiplayer.c_exe && !rbMultiplayer.Checked) { rbMultiplayer.Checked = true; } try { mem = new Memory((string)gameMode.GetValue("c_cVar"), proc.Id, (int)gameMode.GetValue("c_baseAddr"), (byte)gameMode.GetValue("c_checkRange"), c_pOffset); } catch (Exception ex) { ErrMessage(ex); Application.Exit(); } TimerVerif.Start(); } return(true); } else { if (proc != null && init) { TimerVerif.Stop(); mem = null; progStop(); } return(false); } }
private void progStart() { TimerVerif.Stop(); writeAllowed = true; UpdateNumBox(); TimerUpdate.Start(); if (doBeep) { sndGameFound.PlaySync(); } }
private void TimerVerif_Tick(object sender, EventArgs e) { if (proc != null && mem != null && isRunning(false)) { if (btnStartGame.Enabled) { ToggleButton(false); } proc.Refresh(); try { if (proc.PagedMemorySize64 > 0x2000000) { byte step = 0; try { mem.FindFoVOffset(ref pFoV, ref step); if (!isOffsetWrong(pFoV)) { progStart(); } else if (proc.PagedMemorySize64 > (dword_ptr)gameMode.GetValue("c_memSearchRange")) { TimerVerif.Stop(); TimerCheck.Stop(); //bool offsetFound = false; //int ptrSize = IntPtr.Size * 4; /*for (int i = -0x50000; i < 0x50000 && !offsetFound; i += 16) * { * if (mem.ReadFloat(true, pFoV + i) == 65f && !isOffsetWrong(pFoV + i)) * { * pFoV += i; * offsetFound = true; * } * * if (i % 50000 == 0) * { * label1.Text = i.ToString(); * Update(); * } * }*/ //Console.Beep(5000, 100); //MessageBox.Show("find " + pFoV.ToString("X8")); if (isRunning(false) && !mem.FindFoVOffset(ref pFoV, ref step)) { string memory = BitConverter.ToString(BitConverter.GetBytes(mem.ReadFloat(pFoV))); MessageBox.Show(this, "The memory research pattern wasn't able to find the FoV offset in your " + gameMode.GetValue("c_supportMessage") + ".\n" + "Please look for an updated version of this FoV Changer tool.\n\n" + "If you believe this might be a bug, please send me an email at [email protected], and include a screenshot of this:\n" + "\n" + c_toolVer + "\nWorking Set: 0x" + proc.WorkingSet64.ToString("X8") + "\nPaged Memory: 0x" + proc.PagedMemorySize64.ToString("X8") + "\nVirtual Memory: 0x" + proc.VirtualMemorySize64.ToString("X8") + "\nStep: " + step.ToString() + "\nFoV pointer: 0x" + (pFoV - c_pOffset).ToString("X8") + " = " + memory, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); pFoV = (dword_ptr)gameMode.GetValue("c_pFoV"); Application.Exit(); } else { //Console.Beep(5000, 100); SaveSettings(); proc = null; TimerCheck.Start(); } } } catch (Exception ex) { ErrMessage(ex); Application.Exit(); } } } catch (InvalidOperationException) { } } }