예제 #1
0
        private void BTN_LaunchWC3_Click(object sender, EventArgs e)
        {
            string LastInstallPath = Settings.InstallPath;

            if (!File.Exists(Path.Combine(LastInstallPath, "Warcraft III.exe")) &&
                !File.Exists(Path.Combine(LastInstallPath, "war3.exe")))
            {
                OpenFileDialog FDialog = new OpenFileDialog
                {
                    Title  = "워크래프트 실행 파일을 선택하세요.",
                    Filter = "워크래프트 EXE파일|Warcraft III.exe;war3.exe"
                };
                if (FDialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                Settings.InstallPath = LastInstallPath = Path.GetDirectoryName(FDialog.FileName);
                string MixPath = $"{LastInstallPath}\\Cirnix";
                if (!File.Exists(MixPath + ".mix"))
                {
                    File.WriteAllBytes(MixPath + ".mix", Global.Properties.Resources.Cirnix);
                    NativeMethods.WritePrivateProfileString("Cirnix", "Mana Bar", "0", MixPath + ".ini");
                    NativeMethods.WritePrivateProfileString("Cirnix", "Show AS & MS in Number", "1", MixPath + ".ini");
                }
            }
            Process[] proc = Process.GetProcessesByName(TargetProcess);
            if (proc.Length > 0)
            {
                if (MetroDialog.YesNo("기존 프로세스 감지 됨", "Warcraft III 프로세스가 아직 실행 중입니다.\n종료하고 실행하시겠습니까?"))
                {
                    foreach (var item in proc)
                    {
                        try
                        {
                            item.Kill();
                        }
                        catch
                        {
                            proc = Process.GetProcessesByName(TargetProcess);
                            if (proc.Length > 0)
                            {
                                MetroDialog.OK("액세스 오류", "Warcraft III 프로세스를 종료할 수 없었습니다.\n작업 관리자에서 수동으로 프로세스를 종료하세요.");
                                return;
                            }
                        }
                    }
                }
                else
                {
                    return;
                }
            }
            bool isDebug = false;

            if (File.Exists(Path.Combine(ResourcePath, "JNService", "DEBUG.txt")))
            {
                isDebug = true;
            }
            CLRHook.Injector.Init(LastInstallPath, MetroDialog.Select("화면 표기 설정", "창 모드", "전체 창", "전체화면"), true, isDebug);
        }
예제 #2
0
 private void VersionChecker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     if (string.IsNullOrWhiteSpace(infoURL))
     {
         return;
     }
     if (e.Error != null)
     {
         MetroDialog.OK("연결 오류", "업데이트 서버에 연결할 수 없습니다.");
         return;
     }
     isOnline = true;
     if (isUpdated)
     {
         InitHistoryForm();
     }
     if (version[0] > Latest[0])
     {
         return;
     }
     else if (version[0] == Latest[0])
     {
         if (version[1] > Latest[1])
         {
             return;
         }
         else if (version[1] == Latest[1])
         {
             if (version[2] > Latest[2])
             {
                 return;
             }
             else if (version[2] == Latest[2])
             {
                 if (version[3] >= Latest[3])
                 {
                     return;
                 }
             }
         }
     }
     if (MetroDialog.YesNo("업데이트 필요", $"최신 버전이 확인되었습니다.\n 현재: {version[0]}.{version[1]}.{version[2]}.{version[3]}\n 최신: {Latest[0]}.{Latest[1]}.{Latest[2]}.{Latest[3]}\n업데이트 하시겠습니까?"))
     {
         try
         {
             main.Dispose();
             option.Dispose();
             info.Dispose();
             channel.Dispose();
             sepro.Dispose();
             MainTrayIcon.Visible = false;
         }
         catch { }
         finally
         {
             new UpdateForm("Cirnix", LatestURL).ShowDialog();
         }
     }
 }
예제 #3
0
 private void UpdateForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (client.IsBusy)
     {
         if (MetroDialog.YesNo("업데이트 중단", "업데이트를 중단하시겠습니까?"))
         {
             client.CancelAsync();
         }
         else
         {
             e.Cancel = true;
         }
     }
 }
예제 #4
0
        private async void BTN_LaunchWC3_Click(object sender, EventArgs e)
        {
            string LastInstallPath = Settings.InstallPath;

            if (!File.Exists(Path.Combine(LastInstallPath, "JNLoader.exe")))
            {
                OpenFileDialog FDialog = new OpenFileDialog
                {
                    Title  = "실행 파일을 선택하세요.",
                    Filter = "워크래프트 EXE파일|JNLoader.exe;Warcraft III.exe;war3.exe"
                };
                if (FDialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                Settings.InstallPath = LastInstallPath = Path.GetDirectoryName(FDialog.FileName);
                string MixPath = $"{LastInstallPath}\\Cirnix";
                if (!File.Exists(MixPath + ".mix"))
                {
                    File.WriteAllBytes(MixPath + ".mix", Global.Properties.Resources.Cirnix);
                    NativeMethods.WritePrivateProfileString("Cirnix", "Mana Bar", "0", MixPath + ".ini");
                    NativeMethods.WritePrivateProfileString("Cirnix", "Show AS & MS in Number", "1", MixPath + ".ini");
                }
            }
            if (Memory.Component.Warcraft3Info.Process != null)
            {
                if (MetroDialog.YesNo("기존 프로세스 감지 됨", "Warcraft III 프로세스가 아직 실행 중입니다.\n종료하고 실행하시겠습니까?"))
                {
                    if (!Memory.Component.Warcraft3Info.Close())
                    {
                        MetroDialog.OK("액세스 오류", "Warcraft III 프로세스를 종료할 수 없었습니다.\n작업 관리자에서 수동으로 프로세스를 종료하세요.");
                        return;
                    }
                }
                else
                {
                    return;
                }
            }
            GameModule.StartWarcraft3(LastInstallPath, MetroDialog.Select("화면 표기 설정", "창 모드", "전체 창", "전체화면"));
        }
예제 #5
0
        internal static bool ProcessCheck()
        {
            if (GameModule.WarcraftDetect() != WarcraftState.OK ||
                !GameModule.WarcraftCheck())
            {
                InitializedWarcraft = ignoreDetect = false;

                // 프로그램을 찾지 못할 경우 검색 간격 증가
                Thread.Sleep(800);

                return(true);
            }
            if (!InitializedWarcraft)
            {
                InitializedWarcraft = true;
                Delay(2000);
                GameDll.GetOffset();
                GameDelay       = 50;
                RefreshCooldown = 0.01f;
                name            = string.Empty;
                StartDelay      = Settings.StartSpeed > 0 ? Settings.StartSpeed : 0.01f;
                CameraDistance  = Settings.CameraDistance;
                CameraAngleX    = Settings.CameraAngleX;
                CameraAngleY    = Settings.CameraAngleY;
            }
            if (Settings.IsAutoHp && !HPView)
            {
                HPView = true;
            }

            if (Settings.IsAntiZombieProcess)
            {
                if (ignoreDetect && ++ZombieCount > 9000)
                {
                    ignoreDetect = false;
                    ZombieCount  = 0;
                }
                else if (CurrentMusicState == MusicState.None)
                {
                    if (++ZombieCount > 22)
                    {
                        try
                        {
                            PerformanceCounter CPUCounter = new PerformanceCounter("Process", "% Processor Time", TargetProcess);
                            CPUCounter.NextValue();
                            for (int i = 0; i < 5; i++)
                            {
                                Delay(1100);
                                if (CPUCounter.NextValue() >= 0.01f)
                                {
                                    ZombieCount = 0;
                                    break;
                                }
                                if (i != 4)
                                {
                                    continue;
                                }
                                if (MetroDialog.YesNo("워크래프트가 정상적으로 종료되지 않은 것 같습니다.\n강제로 종료하시겠습니까?", "강제 종료 알림"))
                                {
                                    try
                                    {
                                        Warcraft3Info.Process.Kill();
                                    }
                                    catch
                                    {
                                        MetroDialog.OK("워크래프트를 강제로 종료할 수 없었습니다.\n이미 종료되었거나, 백신에 의해 차단된 것 같습니다.", "강제 종료 실패");
                                    }
                                }
                                else
                                {
                                    ignoreDetect = true;
                                }
                            }
                        }
                        catch
                        {
                            ZombieCount = 0;
                        }
                    }
                    return(true);
                }
                else
                {
                    ZombieCount = 0;
                }
            }
            if (Settings.IsMemoryOptimize)
            {
                if (MemoryOptimizeTimer.IsRunning)
                {
                    if (MemoryOptimizeTimer.Elapsed >= new TimeSpan(0, Settings.MemoryOptimizeCoolDown, 0))
                    {
                        CProcess.TrimProcessMemory(TargetProcess, true);
                        MemoryOptimizeTimer.Restart();
                    }
                    else
                    {
                        MemoryOptimizeTimer.Start();
                    }
                }
            }
            else if (MemoryOptimizeTimer.IsRunning)
            {
                MemoryOptimizeTimer.Stop();
            }

            StatusCheck();
            return(false);
        }