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); }
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(); } } }
private void webClient_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) { LabelTitle.Text = "업데이트 완료!"; LabelMsg.Text = "잠시 후, 자동으로 종료됩니다.\n프로그램을 다시 실행시켜주세요!"; successfullyDownload = true; LabelMsg.Text = "잠시 후, 자동으로 재시작됩니다."; MetroDialog.OK("업데이트 완료!", "\"확인\"을 누르면 다시 시작됩니다."); ProceedRestartBat(); }
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("화면 표기 설정", "창 모드", "전체 창", "전체화면")); }
private void Select_Click(object sender, EventArgs e) { Process proc = ProcessList.FocusedItem.Tag as Process; switch (GameModule.InitWarcraft3Info(proc)) { case WarcraftState.OK: MetroDialog.OK("지정 완료", $"{proc.ProcessName} ({proc.Id}) 가 지정되었습니다."); break; case WarcraftState.Closed: MetroDialog.OK("오류", $"{proc.ProcessName} ({proc.Id}) 는 이미 화면이 종료된 상태이므로 강제로 프로세스를 종료합니다."); break; case WarcraftState.Error: MetroDialog.OK("오류", "프로세스를 초기화 하는데에 실패했습니다."); break; } procs.Remove(proc); Close(); }
private async void webClient_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) { if (e.Cancelled) { if (!IsSingle) { File.Delete($"{name}.exe"); File.Move("update.tmp", Path.GetFileName(ProgramPath)); } Close(); } else if (e.Error != null) { LabelTitle.Text = "업데이트 실패!"; MetroDialog.OK("오류 발생!", "업데이트 파일을 불러오는데 실패했습니다."); Close(); } else { LabelTitle.Text = "업데이트 완료!"; if (IsSingle) { LabelMsg.Text = "잠시 후, 자동으로 창이 종료됩니다."; MetroDialog.OK("업데이트 완료!", "\"확인\"을 누르면 창이 종료됩니다."); await Task.Delay(3000); Close(); } else { LabelMsg.Text = "잠시 후, 자동으로 재시작됩니다."; MetroDialog.OK("업데이트 완료!", "\"확인\"을 누르면 다시 시작됩니다."); ProceedRestartBat(); } } }
public static async Task <WarcraftState> StartWarcraft3(string path, int windowState = 0) { Global.Registry.Warcraft.SetFullQualityGraphics(); string EXEPath = $"{path}\\JNLoader.exe"; string updaterPath = $"{path}\\JNUpdater.exe"; if (!File.Exists(EXEPath) || !File.Exists(updaterPath)) { try { if (File.Exists(updaterPath)) { File.Delete(updaterPath); } File.WriteAllBytes(updaterPath, Properties.Resources.JNUpdater); ProcessStartInfo info = new ProcessStartInfo("JNUpdater.exe", "-updateonly -force"); info.WorkingDirectory = path; using (Process proc = Process.Start(info)) { proc.WaitForExit(); int ExitCode = proc.ExitCode; if (ExitCode >> 16 < 0 || ExitCode << 16 >> 16 < 0) { MetroDialog.OK("오류", "JNLoader 설치에 실패했습니다.\n백신에 의해 차단됬을 수도 있습니다."); return(0); } } } catch { return(0); } } string WindowsStateString; switch (windowState) { case 0: WindowsStateString = "-windows"; break; case 1: WindowsStateString = string.Empty; break; case 2: WindowsStateString = "-nativefullscr"; break; default: return(0); } try { using (Process proc = Process.Start(EXEPath, WindowsStateString)) { proc.WaitForExit(); int procId = proc.ExitCode; if (procId <= 0) { return(WarcraftState.Error); } return(InitWarcraft3Info(procId)); } } catch (ArgumentException ex) { MetroDialog.OK("오류", "Warcraft III를 실행하지 못했습니다.\nCirnix를 다시 실행시켜주세요."); ExceptionSender.ExceptionSendAsync(ex); return(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); }