我的.exe在其他计算机上打开和关闭

时间:2020-04-27 18:04:19

标签: c# exe

我制作了一个fifa15培训者脚本,但是在将其发送给其他人时遇到了麻烦,要对其进行调试,我要求另一个用户运行.exe并将日志发送给我,但是他说该程序只是打开和关闭。这可能是兼容性问题吗?

我的代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;

namespace cheat_birthyear
{
class Program
{
    public static string path;
    public static IntPtr BaseAddress = IntPtr.Zero;
    static void Main(string[] args)
    {
        Process[] processes = Process.GetProcessesByName("fifa15");
        if(processes.Length > 0)
        {
            IntPtr BaseAddress = IntPtr.Zero;
            Process MyProc = processes[0];
            foreach(ProcessModule module in MyProc.Modules)
            {
                if (module.ModuleName.Contains("fifa15"))
                {
                    BaseAddress = module.BaseAddress;
                    path = module.FileName;
                    Console.WriteLine(path);

                }
            }

            if (BaseAddress != IntPtr.Zero)
            {


                VAMemory memory = new VAMemory("fifa15");
                long finalAddress = memory.ReadInt64((IntPtr)BaseAddress + 0x01F441E8);
                Console.WriteLine(finalAddress);
                int newaddr = memory.ReadInt32( (IntPtr)finalAddress + 0x390);
                Console.WriteLine(newaddr);
                Console.ReadLine();
                string yearPath = path.Replace("fifa15.exe", "cheat_birthyear\\birthyear.txt");
                string[] lines = System.IO.File.ReadAllLines(@yearPath);
                string yearVal = lines[0];
                //float Basefifthvalue = memory.ReadFloat((IntPtr)newaddr);
                //Console.WriteLine(Basefifthvalue);

                memory.WriteInt32((IntPtr)finalAddress + 0x390, 1998);

            }
            else
            {
                Console.WriteLine("baseaddress não encontrado");
                Console.ReadLine();
            }
        }
        else
        {
            Console.WriteLine("jogo não encontrado");
            Console.ReadLine();
        }
    }
}
 }

这些是我编译并生成发布版本时的生成器文件

Print of the folder

有什么方法可以调试,所以我知道程序是否在另一台计算机上正确运行了吗?

1 个答案:

答案 0 :(得分:0)

您的应用可以采用3种路径

  1. 没有Fifa15进程
  2. BaseAddress是IntPtr.Zero
  3. BaseAddress不是IntPtr.Zero(该应用程序有效)
  4. 出事了

在第一种情况和第二种情况下,您添加了一个Console.ReadLine()调用,它将在代码完成后使控制台保持打开状态。看来您在#3和#4中忘记了这一点。

也许尝试重组代码以始终调用Console.ReadLine(),以便控制台保持打开状态,他们可以看到结果。可能是这样的:

using System;
//... the rest of the imports

namespace cheat_birthyear
{
    class Program
    {
        //... other class code

        static void Main(string[] args)
        {
            try {
                //... your code here
            } finally {
                Console.ReadLine()
            }
        }
    }
}