예제 #1
0
        /// <summary>
        /// Initialize a new RamController object
        /// </summary>
        /// <param name="updateGuiStatisticsEvent">An event to indicate that a GUI update should occur</param>
        /// <param name="ramClearingCompletedEvcent">An event to indicate that the RAM has been cleared</param>
        /// <param name="ramUpdateTimerInterval">The interval for which RAM usage statistics should be updated</param>
        /// <param name="logController">The LogController object that can be used to add logs</param>
        internal RamController(UpdateGuiStatistics updateGuiStatisticsEvent, RamClearingCompleted ramClearingCompletedEvcent, int ramUpdateTimerInterval, LogController logController)
        {
            _logController = logController ?? throw new ArgumentNullException(nameof(logController));
            _logController.AddLog(new ApplicationLog("Initializing RamController"));

            if (ramUpdateTimerInterval <= 0)
            {
                throw new ArgumentException("Timer interval cannot be less than or equal to zero!");
            }
            UpdateGuiStatisticsEvent   = updateGuiStatisticsEvent ?? throw new ArgumentNullException(nameof(updateGuiStatisticsEvent));
            RamClearingCompletedEvcent = ramClearingCompletedEvcent ?? throw new ArgumentNullException(nameof(ramClearingCompletedEvcent));

            RamSavings = 0;

            _info = new ComputerInfo();

            _ramOptimizer        = new RamOptimizer(_logController);
            EmptyWorkingSets     = true;
            ClearStandbyCache    = true;
            ClearFileSystemCache = true;

            _ramTimer          = new Timer();
            _ramTimer.Elapsed += OnTimedEvent;
            _ramTimer.Interval = ramUpdateTimerInterval;
            _ramTimer.Enabled  = false;

            _logController.AddLog(new ApplicationLog("Done initializing RamController"));
        }
예제 #2
0
        /// <summary>
        /// Initialize a new RamController object
        /// </summary>
        /// <param name="ramUsageAddedEvent">An event to indicate that RamUsage object has been added</param>
        /// <param name="ramClearingCompletedEvent">An event to indicate that the RAM has been cleared</param>
        /// <param name="ramUpdateTimerInterval">The interval for which RAM usage statistics should be updated</param>
        /// <param name="enableRamStatistics">True if RamUsage objects should be kept in memory, otherwise false</param>
        /// <param name="maxUsageHistory">The total amount of RamUsage objects that should be stored for historical reasons</param>
        /// <param name="logController">The LogController object that can be used to add logs</param>
        internal RamController(RamUsageAdded ramUsageAddedEvent, RamClearingCompleted ramClearingCompletedEvent, int ramUpdateTimerInterval, bool enableRamStatistics, int maxUsageHistory, LogController logController)
        {
            _logController = logController ?? throw new ArgumentNullException(nameof(logController));
            _logController.AddLog(new ApplicationLog("Initializing RamController"));

            if (ramUpdateTimerInterval <= 0)
            {
                throw new ArgumentException("Timer interval cannot be less than or equal to zero!");
            }
            RamUsageAddedEvent        = ramUsageAddedEvent;
            RamClearingCompletedEvent = ramClearingCompletedEvent;

            RamSavings = 0;

            _info                = new ComputerInfo();
            _ramUsageHistory     = new List <RamUsage>();
            EnableRamStatistics  = enableRamStatistics;
            MaxUsageHistoryCount = maxUsageHistory;
            _ramOptimizer        = new RamOptimizer(_logController);
            EmptyWorkingSets     = true;
            ClearStandbyCache    = true;
            ClearFileSystemCache = true;

            _ramTimer          = new Timer();
            _ramTimer.Elapsed += OnTimedEvent;
            _ramTimer.Interval = ramUpdateTimerInterval;
            _ramTimer.Enabled  = false;

            _logController.AddLog(new ApplicationLog("Done initializing RamController"));
        }
예제 #3
0
        /// <summary>
        /// Retrieve a list of ProcessDetail objects
        /// </summary>
        /// <param name="logController">The LogController object that can be used to add logs</param>
        /// <returns>A list of ProcessDetail objects that are currently available</returns>
        internal static async Task <List <ProcessDetail> > GetProcessDetails(LogController logController)
        {
            logController.AddLog(new ProcessLog("Retrieving process details"));
            List <ProcessDetail> processDetailsList = new List <ProcessDetail>();

            await Task.Run(() =>
            {
                foreach (Process p in Process.GetProcesses())
                {
                    try
                    {
                        ProcessDetail pd = new ProcessDetail
                        {
                            ProcessId       = p.Id,
                            ProcessName     = p.ProcessName,
                            ProcessLocation = p.MainModule.FileName,
                            MemoryUsage     = (p.WorkingSet64 / (1024 * 1024)).ToString("F2") + " MB",
                            MemoryUsageLong = p.WorkingSet64
                        };
                        processDetailsList.Add(pd);
                    }
                    catch (Exception ex)
                    {
                        logController.AddLog(new ProcessLog(p.ProcessName + ": " + ex.Message));
                    }
                }
            });

            logController.AddLog(new ProcessLog("Done retrieving process details"));
            return(processDetailsList);
        }
예제 #4
0
        /// <summary>
        /// Change the language of the application, depending on the settings
        /// </summary>
        /// <param name="logController">The LogController object that can be used to add logs</param>
        internal static void ChangeLanguage(LogController logController)
        {
            logController.AddLog(new ApplicationLog("Changing language"));
            ResourceDictionary dict = new ResourceDictionary();
            Uri langUri;

            try
            {
                switch (Properties.Settings.Default.SelectedLanguage)
                {
                default:
                    langUri = new Uri("..\\Resources\\Languages\\en_US.xaml", UriKind.Relative);
                    break;

                case 0:
                    langUri = new Uri("..\\Resources\\Languages\\de_DE.xaml", UriKind.Relative);
                    break;

                case 2:
                    langUri = new Uri("..\\Resources\\Languages\\es_ES.xaml", UriKind.Relative);
                    break;

                case 3:
                    langUri = new Uri("..\\Resources\\Languages\\fr_FR.xaml", UriKind.Relative);
                    break;

                case 4:
                    langUri = new Uri("..\\Resources\\Languages\\gl_ES.xaml", UriKind.Relative);
                    break;

                case 5:
                    langUri = new Uri("..\\Resources\\Languages\\it_IT.xaml", UriKind.Relative);
                    break;

                case 6:
                    langUri = new Uri("..\\Resources\\Languages\\nl_BE.xaml", UriKind.Relative);
                    break;

                case 7:
                    langUri = new Uri("..\\Resources\\Languages\\nl_NL.xaml", UriKind.Relative);
                    break;
                }
            }
            catch (Exception ex)
            {
                langUri = new Uri("..\\Resources\\Languages\\en.xaml", UriKind.Relative);
                logController.AddLog(new ApplicationLog(ex.Message));
                MessageBox.Show(ex.Message, "MemPlus", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            dict.Source = langUri;
            Application.Current.Resources.MergedDictionaries.Clear();
            Application.Current.Resources.MergedDictionaries.Add(dict);

            logController.AddLog(new ApplicationLog("Done changing language"));
        }
예제 #5
0
        /// <summary>
        /// Initialize a new HotKeyController
        /// </summary>
        /// <param name="helper">The WindowInteropHelper object that can be used to retrieve the Window handle</param>
        /// <param name="logController">The LogController object that can be used to add logs</param>
        internal HotKeyController(WindowInteropHelper helper, LogController logController)
        {
            _logController = logController;
            _logController?.AddLog(new ApplicationLog("Initializing HotKeyController"));

            _helper = helper;
            _source = HwndSource.FromHwnd(_helper.Handle);

            _logController?.AddLog(new ApplicationLog("Done initializing HotKeyController"));
        }
예제 #6
0
        /// <inheritdoc />
        /// <summary>
        /// Initialize a new AnalyzerWindow object
        /// </summary>
        /// <param name="logController">The LogController object that can be used to add logs</param>
        public RamAnalyzerWindow(LogController logController)
        {
            _logController = logController;
            _logController.AddLog(new ApplicationLog("Initializing AnalyzerWindow"));

            InitializeComponent();
            ChangeVisualStyle();
            LoadProperties();

            _logController.AddLog(new ApplicationLog("Done initializing AnalyzerWindow"));
        }
예제 #7
0
        /// <inheritdoc />
        /// <summary>
        /// Initialize a new ProcessAnalyzerWindow object
        /// </summary>
        /// <param name="logController">The LogController object that can be used to add logs</param>
        internal ProcessAnalyzerWindow(LogController logController)
        {
            _logController = logController;
            _logController.AddLog(new ApplicationLog("Initializing ProcessAnalyzerWindow"));

            InitializeComponent();
            ChangeVisualStyle();
            LoadProperties();
            RefreshProcessDetails();

            _logController.AddLog(new ApplicationLog("Done initializing ProcessAnalyzerWindow"));
        }
예제 #8
0
        /// <summary>
        /// Register a hotkey or not, depending on the properties
        /// </summary>
        internal void HotKeyModifier(WindowInteropHelper helper)
        {
            _logController?.AddLog(new ApplicationLog("Initializing hotkey hook"));
            try
            {
                if (Properties.Settings.Default.UseHotKey)
                {
                    _hotKeyController?.Dispose();

                    if (Properties.Settings.Default.HotKey == Key.None)
                    {
                        return;
                    }

                    _hotKeyController = new HotKeyController(helper, _logController);
                    _hotKeyController.HotKeyPressedEvent += HotKeyPressed;

                    string[] mods = Properties.Settings.Default.HotKeyModifiers.Split('+');

                    uint values = 0;
                    foreach (string s in mods)
                    {
                        // ReSharper disable once SwitchStatementMissingSomeCases
                        switch (s)
                        {
                        case "Ctrl":
                            values |= (uint)ModifierKeys.Control;
                            break;

                        case "Alt":
                            values |= (uint)ModifierKeys.Alt;
                            break;

                        case "Shift":
                            values |= (uint)ModifierKeys.Shift;
                            break;
                        }
                    }
                    _hotKeyController.RegisterHotKey(values, (Keys)KeyInterop.VirtualKeyFromKey(Properties.Settings.Default.HotKey));
                }
                else
                {
                    _hotKeyController?.Dispose();
                }
            }
            catch (Exception ex)
            {
                _logController?.AddLog(new ErrorLog(ex.Message));
                MessageBox.Show(ex.Message, "MemPlus", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            _logController?.AddLog(new ApplicationLog("Done initializing hotkey hook"));
        }
예제 #9
0
        /// <inheritdoc />
        /// <summary>
        /// Initialize a new SettingsWindow object
        /// </summary>
        /// <param name="mainWindow">The MainWindow object that can be used to change the properties</param>
        /// <param name="logController">The LogController object that can be used to add logs</param>
        public SettingsWindow(MainWindow mainWindow, LogController logController)
        {
            _logController = logController;
            _logController.AddLog(new ApplicationLog("Initializing SettingsWindow"));

            _mainWindow = mainWindow;

            InitializeComponent();
            ChangeVisualStyle();
            LoadProperties();

            _logController.AddLog(new ApplicationLog("Done initializing SettingsWindow"));
        }
예제 #10
0
        /// <inheritdoc />
        /// <summary>
        /// Initialize a new AboutWindow
        /// </summary>
        /// <param name="logController">The LogController that can be used to add logs</param>
        public AboutWindow(LogController logController)
        {
            _logController = logController;
            _logController.AddLog(new ApplicationLog("Initializing AboutWindow"));

            InitializeComponent();
            ChangeVisualStyle();
            LoadProperties();

            TxbInfo.Text = ((string)Application.Current.FindResource("AboutInfo"))?.Replace("\\n", Environment.NewLine).Replace("%", Assembly.GetExecutingAssembly().GetName().Version.ToString());

            _logController.AddLog(new ApplicationLog("Done initializing AboutWindow"));
        }
예제 #11
0
        /// <summary>
        /// Logs the 404 error to a table for later checking
        /// </summary>
        /// <param name="request"></param>
        /// <param name="settings"></param>
        /// <param name="result"></param>
        public static void Log404(HttpRequest request, FriendlyUrlSettings settings, UrlAction result)
        {
            var controller = new LogController();
            var log        = new LogInfo
            {
                LogTypeKey  = EventLogController.EventLogType.PAGE_NOT_FOUND_404.ToString(),
                LogPortalID = (result.PortalAlias != null) ? result.PortalId : -1
            };

            log.LogProperties.Add(new LogDetailInfo("TabId", (result.TabId > 0) ? result.TabId.ToString() : String.Empty));
            log.LogProperties.Add(new LogDetailInfo("PortalAlias", (result.PortalAlias != null) ? result.PortalAlias.HTTPAlias : String.Empty));
            log.LogProperties.Add(new LogDetailInfo("OriginalUrl", result.RawUrl));

            if (request != null)
            {
                if (request.UrlReferrer != null)
                {
                    log.LogProperties.Add(new LogDetailInfo("Referer", request.UrlReferrer.AbsoluteUri));
                }
                log.LogProperties.Add(new LogDetailInfo("Url", request.Url.AbsoluteUri));
                log.LogProperties.Add(new LogDetailInfo("UserAgent", request.UserAgent));
                log.LogProperties.Add(new LogDetailInfo("HostAddress", request.UserHostAddress));
                log.LogProperties.Add(new LogDetailInfo("HostName", request.UserHostName));
            }

            controller.AddLog(log);
        }
예제 #12
0
        internal ClipboardModule(System.Windows.Window window, bool logDate, LogController logController)
        {
            _clipboardHook = new ClipboardHook(window);
            _clipboardLog  = new ClipboardLog(logDate);

            _clipboardHook.ClipboardChanged += ClipboardChanged;

            logController.AddLog(_clipboardLog);
        }
예제 #13
0
        /// <summary>
        /// Refresh RAM data
        /// </summary>
        private void RefreshRamData()
        {
            _logController.AddLog(new RamLog("Refreshing RAM data"));
            try
            {
                TrvRam.Items.Clear();
                List <RamStick> ramSticks = Utils.GetRamSticks();

                if (ramSticks == null || ramSticks.Count == 0)
                {
                    MessageBox.Show((string)Application.Current.FindResource("CouldNotRetrieveInformation"), "MemPlus", MessageBoxButton.OK, MessageBoxImage.Error);
                    _logController.AddLog(new RamLog("Could not retrieve RAM Analyzer information"));
                    Close();
                    return;
                }

                foreach (RamStick s in ramSticks)
                {
                    TreeViewItem treeItem = new TreeViewItem {
                        Header = s.GetValue("BankLabel")
                    };

                    foreach (RamData data in s.GetRamData())
                    {
                        TreeViewItem headerItem = new TreeViewItem {
                            Header = data.Key
                        };
                        headerItem.Items.Add(new TreeViewItem {
                            Header = data.Value
                        });
                        treeItem.Items.Add(headerItem);
                    }

                    TrvRam.Items.Add(treeItem);
                }
            }
            catch (Exception ex)
            {
                _logController.AddLog(new ErrorLog(ex.Message));
                MessageBox.Show(ex.Message, "MemPlus", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            _logController.AddLog(new RamLog("Done refreshing RAM data"));
        }
예제 #14
0
        /// <summary>
        /// Register a hotkey
        /// </summary>
        /// <param name="modifier">The modifiers that are associated with the hotkey</param>
        /// <param name="key">The key that is associated with the hotkey</param>
        internal void RegisterHotKey(uint modifier, Keys key)
        {
            _logController?.AddLog(new ApplicationLog("Registering hotkey"));
            // Increment the counter.
            _currentId++;

            // Register the hotkey.
            _source = HwndSource.FromHwnd(_helper.Handle);
            if (_source == null)
            {
                throw new ArgumentNullException(nameof(_source));
            }
            _source.AddHook(HwndHook);

            if (!NativeMethods.RegisterHotKey(_helper.Handle, _currentId, modifier, (uint)key))
            {
                throw new Exception("RegisterHotKey: ", new Win32Exception(Marshal.GetLastWin32Error()));
            }
            _logController?.AddLog(new ApplicationLog("Done registering hotkey"));
        }
예제 #15
0
        private void LogBannedIPAttempt(string ipAddress)
        {
            var controller = new LogController();
            var log        = new LogInfo
            {
                LogTypeKey = EventLogController.EventLogType.IP_LOGIN_BANNED.ToString()
            };

            log.LogProperties.Add(new LogDetailInfo("HostAddress", ipAddress));
            controller.AddLog(log);
        }
예제 #16
0
 /// <summary>
 /// Load the properties of the application
 /// </summary>
 private void LoadProperties()
 {
     _logController.AddLog(new ApplicationLog("Loading AboutWindow properties"));
     try
     {
         if (Properties.Settings.Default.WindowDragging)
         {
             MouseDown += OnMouseDown;
         }
     }
     catch (Exception ex)
     {
         _logController.AddLog(new ErrorLog(ex.Message));
         MessageBox.Show(ex.Message, "MemPlus", MessageBoxButton.OK, MessageBoxImage.Error);
     }
     _logController.AddLog(new ApplicationLog("Done loading AboutWindow properties"));
 }
예제 #17
0
        /// <inheritdoc />
        /// <summary>
        /// Initialize a new LogWindow object
        /// </summary>
        /// /// <param name="ramController">The RamController object that can be used to view RamUsage objects</param>
        /// <param name="logController">The LogController object that can be used to add logs</param>
        internal RamStatisticsWindow(RamController ramController, LogController logController)
        {
            _logController = logController;
            _logController.AddLog(new ApplicationLog("Initializing RamStatisticsWindow"));

            InitializeComponent();
            ChangeVisualStyle();
            LoadProperties();

            _ramController = ramController;

            FillLogView();

            _ramController.RamUsageAddedEvent   += RamUsageAddedEvent;
            _ramController.RamUsageRemovedEvent += RamUsageRemovedEvent;
            _ramController.RamUsageClearedEvent += RamUsageClearedEvent;

            _autoScroll = true;

            _logController.AddLog(new ApplicationLog("Done initializing RamStatisticsWindow"));
        }
예제 #18
0
        /// <inheritdoc />
        /// <summary>
        /// Initialize a new LogWindow object
        /// </summary>
        /// <param name="logController">The LogController object that can be used to add and view logs</param>
        /// <param name="logType">The LogType that is currently being monitored</param>
        public LogWindow(LogController logController, LogType logType)
        {
            _logController = logController;
            _logController.AddLog(new ApplicationLog("Initializing LogWindow"));

            _logType = logType;

            InitializeComponent();
            ChangeVisualStyle();
            LoadProperties();

            FillLogView();

            _logController.LogAddedEvent       += LogAddedEvent;
            _logController.LogsClearedEvent    += LogsClearedEvent;
            _logController.LogDeletedEvent     += LogDeletedEvent;
            _logController.LogTypeClearedEvent += LogTypeClearedEvent;

            _autoScroll = true;

            _logController.AddLog(new ApplicationLog("Done initializing LogWindow"));
        }
예제 #19
0
        internal MonitorModule(int delay, LogController logController)
        {
            if (delay <= 0)
            {
                throw new ArgumentException("Monitor delay cannot be equal to or smaller than zero!");
            }

            _delay  = delay;
            _active = false;
            _log    = new MonitorLog();

            logController.AddLog(_log);
        }
예제 #20
0
        /// <summary>
        /// Export logs to the disk
        /// </summary>
        /// <param name="logType">The LogType that should be exported (can be null to export all logs)</param>
        /// <param name="logController">The LogController object that can be used to export logs</param>
        /// <returns>True if the operation completed successfully, otherwise false</returns>
        internal static bool ExportLogs(LogType?logType, LogController logController)
        {
            if (logType != null)
            {
                if (logController.GetLogs(logType).Count == 0)
                {
                    return(false);
                }
            }

            SaveFileDialog sfd = new SaveFileDialog
            {
                Filter = "Text file (*.txt)|*.txt|HTML file (*.html)|*.html|CSV file (*.csv)|*.csv|Excel file (*.csv)|*.csv"
            };

            if (sfd.ShowDialog() != true)
            {
                return(false);
            }
            ExportTypes.ExportType type;
            switch (sfd.FilterIndex)
            {
            default:
                type = ExportTypes.ExportType.Text;
                break;

            case 2:
                type = ExportTypes.ExportType.Html;
                break;

            case 3:
                type = ExportTypes.ExportType.Csv;
                break;

            case 4:
                type = ExportTypes.ExportType.Excel;
                break;
            }

            try
            {
                logController.Export(sfd.FileName, logType, type);
                return(true);
            }
            catch (Exception ex)
            {
                logController.AddLog(new ApplicationLog(ex.Message));
                MessageBox.Show(ex.Message, "MemPlus", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            return(false);
        }
예제 #21
0
        /// <summary>
        /// Export all RamStick objects
        /// </summary>
        /// <param name="logController">The LogController object that can be used to add logs</param>
        /// <returns>True if the operation completed successfully, otherwise false</returns>
        internal static bool ExportRamSticks(LogController logController)
        {
            List <RamStick> ramSticks = GetRamSticks();

            if (ramSticks == null || ramSticks.Count == 0)
            {
                return(false);
            }

            SaveFileDialog sfd = new SaveFileDialog
            {
                Filter = "Text file (*.txt)|*.txt|HTML file (*.html)|*.html|CSV file (*.csv)|*.csv|Excel file (*.csv)|*.csv"
            };

            if (sfd.ShowDialog() != true)
            {
                return(false);
            }
            try
            {
                // ReSharper disable once SwitchStatementMissingSomeCases
                switch (sfd.FilterIndex)
                {
                //Filterindex starts at 1
                case 1:
                    RamDataExporter.ExportText(sfd.FileName, ramSticks);
                    break;

                case 2:
                    RamDataExporter.ExportHtml(sfd.FileName, ramSticks);
                    break;

                case 3:
                    RamDataExporter.ExportCsv(sfd.FileName, ramSticks);
                    break;

                case 4:
                    RamDataExporter.ExportExcel(sfd.FileName, ramSticks);
                    break;
                }

                return(true);
            }
            catch (Exception ex)
            {
                logController.AddLog(new ApplicationLog(ex.Message));
                MessageBox.Show(ex.Message, "MemPlus", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            return(false);
        }
예제 #22
0
        internal FileSystemModule(string path, string fileTypes, bool changed, bool created, bool deleted, bool renamed, bool subDirectories, LogController logController)
        {
            _context        = SynchronizationContext.Current;
            _path           = path;
            _fileTypes      = fileTypes;
            _changed        = changed;
            _created        = created;
            _deleted        = deleted;
            _renamed        = renamed;
            _subDirectories = subDirectories;

            _fileSystemLog = new FileSystemLog(true);
            logController.AddLog(_fileSystemLog);
        }
예제 #23
0
        /// <summary>
        /// Export all ProcessDetail objects
        /// </summary>
        /// <param name="logController">The LogController object that can be used to add logs</param>
        /// <returns>True if the operation completed successfully, otherwise false</returns>
        internal static async Task <bool> ExportProcessDetails(LogController logController)
        {
            SaveFileDialog sfd = new SaveFileDialog
            {
                Filter = "Text file (*.txt)|*.txt|HTML file (*.html)|*.html|CSV file (*.csv)|*.csv|Excel file (*.csv)|*.csv"
            };

            if (sfd.ShowDialog() != true)
            {
                return(false);
            }
            try
            {
                // ReSharper disable once SwitchStatementMissingSomeCases
                switch (sfd.FilterIndex)
                {
                // Filter index starts at 1
                case 1:
                    ProcessDetailExporter.ExportText(sfd.FileName, await GetProcessDetails(logController));
                    break;

                case 2:
                    ProcessDetailExporter.ExportHtml(sfd.FileName, await GetProcessDetails(logController));
                    break;

                case 3:
                    ProcessDetailExporter.ExportCsv(sfd.FileName, await GetProcessDetails(logController));
                    break;

                case 4:
                    ProcessDetailExporter.ExportExcel(sfd.FileName, await GetProcessDetails(logController));
                    break;
                }

                return(true);
            }
            catch (Exception ex)
            {
                logController.AddLog(new ApplicationLog(ex.Message));
                MessageBox.Show(ex.Message, "MemPlus", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            return(false);
        }
예제 #24
0
        /// <summary>
        /// Initialize a new KeyboardModule
        /// </summary>
        /// <param name="special">A boolean to indicate whether special keys should be logged or not</param>
        /// <param name="control">A boolean to indicate whether control keys should be logged or not</param>
        /// <param name="enterKeyNewLine">A boolean to indicate whether the Enter key should be displayed as a new line or not</param>
        /// <param name="keyUp">A boolean to indicate wheter the KeyUp event should be fired or not</param>
        /// <param name="keyDown">A boolean to indicate whether the KeyDown event should be fired or not</param>
        /// <param name="windowTitle">A boolean to indicate whether the currently active window title should be logged or not</param>
        /// <param name="logController">The globally available LogController which holds the repository of logs</param>
        internal KeyboardModule(bool special, bool control, bool enterKeyNewLine, bool keyUp, bool keyDown, bool windowTitle, LogController logController)
        {
            _keyboardHook = new KeyboardHook(special, control, enterKeyNewLine);
            _log          = new KeyboardLog();
            _windowModule = new WindowHook();

            _currentWindowTitle = "";
            _windowTitle        = windowTitle;

            if (keyUp)
            {
                _keyboardHook.KeyUp += KeyPress;
            }

            if (keyDown)
            {
                _keyboardHook.KeyDown += KeyPress;
            }

            logController.AddLog(_log);
        }
예제 #25
0
        public void AddEventLog(string username, int userId, string portalName, string ip, EventLogType logType, string message)
        {
            //initialize log record
            var objSecurity = new PortalSecurity();
            var log         = new LogInfo
            {
                LogTypeKey    = logType.ToString(),
                LogPortalID   = PortalId,
                LogPortalName = portalName,
                LogUserName   = objSecurity.InputFilter(username, PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoAngleBrackets | PortalSecurity.FilterFlag.NoMarkup),
                LogUserID     = userId
            };

            log.AddProperty("IP", ip);
            log.AddProperty("Message", message);

            //create log record
            var logctr = new LogController();

            logctr.AddLog(log);
        }
예제 #26
0
 /// <summary>
 /// Run the application using Administrative rights
 /// </summary>
 internal static void RunAsAdministrator(LogController logController)
 {
     try
     {
         Process proc = new Process
         {
             StartInfo =
             {
                 FileName        = Assembly.GetExecutingAssembly().Location,
                 UseShellExecute = true,
                 Verb            = "runas"
             }
         };
         proc.Start();
         Application.Current.Shutdown();
     }
     catch (Exception ex)
     {
         logController.AddLog(new ApplicationLog(ex.Message));
         MessageBox.Show(ex.Message, "MemPlus", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
예제 #27
0
 /// <summary>
 /// Change the visual style of the controls, depending on the settings.
 /// </summary>
 private void ChangeVisualStyle()
 {
     _logController.AddLog(new ApplicationLog("Changing ProcessAnalyzerWindow theme style"));
     GuiManager.ChangeStyle(this);
     _logController.AddLog(new ApplicationLog("Done changing ProcessAnalyzerWindow theme style"));
 }
예제 #28
0
 /// <summary>
 /// Change the visual style of the controls, depending on the settings.
 /// </summary>
 private void ChangeVisualStyle()
 {
     _logController.AddLog(new ApplicationLog("Changing SettingsWindow theme style"));
     StyleManager.ChangeStyle(this);
     _logController.AddLog(new ApplicationLog("Done changing SettingsWindow theme style"));
 }
예제 #29
0
        /// <summary>
        /// Enable RAM usage monitoring
        /// </summary>
        internal void EnableMonitor()
        {
            if (_ramTimer.Enabled)
            {
                return;
            }

            _ramTimer.Enabled = true;
            RamMonitorEnabled = true;

            try
            {
                UpdateRamUsage();
            }
            catch (Exception ex)
            {
                _logController.AddLog(new ErrorLog(ex.Message));
            }

            _logController.AddLog(new ApplicationLog("The RAM monitor has been enabled"));
        }
예제 #30
0
        /// <summary>
        /// Clear the working sets of all processes that are available to the application
        /// </summary>
        /// <param name="processExceptions">A list of processes that should be excluded from memory optimisation</param>
        internal void EmptyWorkingSetFunction(List <string> processExceptions)
        {
            _logController.AddLog(new RamLog("Emptying working set"));

            if (processExceptions != null && processExceptions.Count > 0)
            {
                processExceptions = processExceptions.ConvertAll(d => d.ToLower());
            }

            foreach (Process process in Process.GetProcesses())
            {
                try
                {
                    if (processExceptions == null || processExceptions.Count == 0 || !processExceptions.Contains(process.MainModule.FileName.ToLower()))
                    {
                        _logController.AddLog(new RamLog("Emptying working set for process: " + process.ProcessName));
                        NativeMethods.EmptyWorkingSet(process.Handle);
                        _logController.AddLog(new RamLog("Successfully emptied working set for process " + process.ProcessName));
                    }
                    else
                    {
                        _logController.AddLog(new RamLog("Excluded process: " + process.ProcessName));
                    }
                }
                catch (Exception ex)
                {
                    _logController.AddLog(new RamLog("Could not empty working set for process " + process.ProcessName + ": " + ex.Message));
                }
            }

            _logController.AddLog(new RamLog("Done emptying working set"));
        }