Пример #1
0
    /// <summary>
    /// 是否置顶指定窗口
    /// </summary>
    public static void TopMostProcess(string processName, bool isTopMost)
    {
        try
        {
            if (!IsAppRun(processName))
            {
                MsgBoxUtil.Warning($"未发现 {processName} 进程");
                return;
            }

            var process      = Process.GetProcessesByName(processName)[0];
            var windowHandle = process.MainWindowHandle;

            if (isTopMost)
            {
                WinAPI.SetWindowPos(windowHandle, -1, 0, 0, 0, 0, 1 | 2);
            }
            else
            {
                WinAPI.SetWindowPos(windowHandle, -2, 0, 0, 0, 0, 1 | 2);
            }
        }
        catch (Exception ex)
        {
            MsgBoxUtil.Exception(ex);
        }
    }
Пример #2
0
    /// <summary>
    /// 以管理员权限打开指定程序,不需要后缀.exe
    /// </summary>
    /// <param name="processName">程序名字,要带后缀名</param>
    /// <param name="isKiddion">是否在Kiddion目录下</param>
    public static void OpenProcess(string processName, bool isKiddion)
    {
        try
        {
            if (IsAppRun(processName))
            {
                MsgBoxUtil.Warning($"请不要重复打开,{processName} 已经在运行了");
            }
            else
            {
                string path = string.Empty;
                if (isKiddion)
                {
                    path = FileUtil.Kiddion_Path;
                }
                else
                {
                    path = FileUtil.Cache_Path;
                }

                Directory.SetCurrentDirectory(path);
                path = Path.Combine(path, processName + ".exe");
                Process.Start(new ProcessStartInfo(path)
                {
                    UseShellExecute = true,
                    Verb            = "runas"
                });
            }
        }
        catch (Exception ex)
        {
            MsgBoxUtil.Exception(ex);
        }
    }
    private void Button_WritePlayerName_Click(object sender, RoutedEventArgs e)
    {
        AudioUtil.ClickSound();

        if (TextBox_OnlineList.Text != "" &&
            TextBox_ChatName.Text != "" &&
            TextBox_ExternalDisplay.Text != "")
        {
            Memory.WriteString(Globals.WorldPTR, Offsets.OnlineListPlayerName, TextBox_OnlineList.Text + "\0");
            Memory.WriteString(Globals.PlayerChatterNamePTR + 0xBC, null, TextBox_ChatName.Text + "\0");
            Memory.WriteString(Globals.PlayerExternalDisplayNamePTR + 0x84, null, TextBox_ExternalDisplay.Text + "\0");

            MsgBoxUtil.Information("写入成功,请切换战局生效");
        }
        else
        {
            MsgBoxUtil.Warning("内容不能为空");
        }
    }
    private void Button_InjectGameProcess_Click(object sender, RoutedEventArgs e)
    {
        AudioUtil.ClickSound();

        SaveBlcokWords();

        var InjectInfo = new InjectInfo();

        InjectInfo.DLLPath = FileUtil.Inject_Path + "BlcokMsg.dll";

        if (string.IsNullOrEmpty(InjectInfo.DLLPath))
        {
            MsgBoxUtil.Warning("发生异常,DLL路径为空");
            return;
        }

        var process = Process.GetProcessesByName("GTA5")[0];

        InjectInfo.PID           = process.Id;
        InjectInfo.PName         = process.ProcessName;
        InjectInfo.MWindowHandle = process.MainWindowHandle;

        foreach (ProcessModule module in Process.GetProcessById(InjectInfo.PID).Modules)
        {
            if (module.FileName == InjectInfo.DLLPath)
            {
                MsgBoxUtil.Warning("该DLL已经被注入过了,请勿重复注入");
                return;
            }
        }

        try
        {
            BaseInjector.SetForegroundWindow(InjectInfo.MWindowHandle);
            BaseInjector.DLLInjector(InjectInfo.PID, InjectInfo.DLLPath);
        }
        catch (Exception ex)
        {
            MsgBoxUtil.Exception(ex);
        }
    }