public frmBootstrap() { InitializeComponent(); this.Visible = false; string szSingleInstanceMutexName = "Local\\" + System.Diagnostics.Process.GetCurrentProcess().ProcessName + "_mutex"; bool fMutexCreated = false; this.singleInstanceMutex = new System.Threading.Mutex(true, szSingleInstanceMutexName, out fMutexCreated); if (!fMutexCreated) { string szMessage = String.Format("{0} is already running. Exiting this instance.", System.Diagnostics.Process.GetCurrentProcess().ProcessName); MessageBox.Show(szMessage, "Raccine Startup Error", MessageBoxButtons.OK, MessageBoxIcon.Information); this.singleInstanceMutex.Close(); Close(); } this.alertEvent = NativeApi.CreateEvent(IntPtr.Zero, false, false, "RaccineAlertEvent"); if (this.alertEvent == IntPtr.Zero) { ; // An error occurred creating the handle... } Thread watcher = new Thread(new ThreadStart(WatcherThread.ThreadProc)); WatcherThread.alertEvent = this.alertEvent; watcher.Name = String.Format("RaccineAlertWatcherThread"); watcher.Start(); }
public frmBootstrap() { InitializeComponent(); this.Visible = false; string szSingleInstanceMutexName = "Local\\" + System.Diagnostics.Process.GetCurrentProcess().ProcessName + "_mutex"; bool fMutexCreated = false; this.singleInstanceMutex = new System.Threading.Mutex(true, szSingleInstanceMutexName, out fMutexCreated); if (!fMutexCreated) { string szMessage = String.Format("{0} is already running. Exiting this instance.", System.Diagnostics.Process.GetCurrentProcess().ProcessName); MessageBox.Show(szMessage, "Raccine Startup Error", MessageBoxButtons.OK, MessageBoxIcon.Information); this.singleInstanceMutex.Close(); Close(); return; } this.alertEvent = NativeApi.CreateEvent(IntPtr.Zero, false, false, "RaccineAlertEvent"); if (this.alertEvent == IntPtr.Zero) { ; // An error occurred creating the handle... } Thread watcher = new Thread(new ThreadStart(WatcherThread.ThreadProc)); WatcherThread.alertEvent = this.alertEvent; watcher.Name = String.Format("RaccineAlertWatcherThread"); watcher.Start(); string szRaccineUserContextDirectory = Environment.ExpandEnvironmentVariables("%TEMP%") + "\\RaccineUserContext"; try { Directory.CreateDirectory(szRaccineUserContextDirectory); // currently raccine is creating these files, so don't do this for now //this.envMonitor = new EnvMonitor(szRaccineUserContextDirectory); } catch (Exception ex) { MessageBox.Show(String.Format("Raccine was unable to create user context folder for Yara rules {0}\n{1}", szRaccineUserContextDirectory, ex.Message)); } this.FormClosing += frmBootstrap_FormClosing; SetUacShield(mnuSettings); SetUacShield(mnuUpdateRules); }