Exemplo n.º 1
0
        /*[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);
            }
        }
Exemplo n.º 2
0
        /*[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);
            }
        }