private void HookStateChangedHandler(Hook hook, IRunningProcess aProcess, eNktHookState previousState, eNktHookState currentState) { var aStateChangeInfo = new HookStateChangeInfo(hook, aProcess, previousState, currentState); var aHook = aStateChangeInfo.Hook; if (aStateChangeInfo.CurrentState == eNktHookState.stRemoved) { _view.RemoveHook(aHook); _view.RemoveHookEnabled = false; _view.RemoveAllHooksEnabled = _spyManager.AtLeastOneHookWasCreated; _view.ExportHookingSettings = _spyManager.AtLeastOneHookWasCreated; } else { _view.DisplayHookStatus(aStateChangeInfo); } if (!aProcess.IsHooked()) { _view.DisplayRecentlyUnhookedProcess(aProcess); } else if (aProcess.AtLeastOneHookIsActive()) { _view.DisplayRecentlyHookedProcessAsActive(aProcess); } else { _view.DisplayRecentlyHookedProcessAsInactive(aProcess); } _view.RefreshModulesView(); }
public HookStateChangeInfo(Hook aHook, IRunningProcess aProcess, eNktHookState previousState, eNktHookState currentState) { Process = aProcess; PreviousState = previousState; CurrentState = currentState; Hook = aHook; }
public void Update(Hook aHook, IRunningProcess aProcess, eNktHookState currentState, eNktHookState previousState) { var module = aProcess.ModuleByName(aHook.ModuleName); lock (_syncLock) { if (currentState == eNktHookState.stRemoved) { _hooks.ValueOrInitialize(aProcess).Remove(aHook); _activeHooks.ValueOrInitialize(aProcess).Remove(aHook.Id); if (previousState == eNktHookState.stActive) { _hookCountByModule.Update(aProcess, moduleDictionary => { moduleDictionary.Update(module, oldCount => -- oldCount); return(moduleDictionary); }); } } else { _hooks.ValueOrInitialize(aProcess).Add(aHook); if (currentState == eNktHookState.stActive) { _activeHooks.ValueOrInitialize(aProcess).Add(aHook.Id); _hookCountByModule.Update(aProcess, moduleDictionary => { moduleDictionary.Update(module, oldCount => ++ oldCount); return(moduleDictionary); }); } } } }
public HookStateChangeInfo(Hook aHook, IRunningProcess aProcess, eNktHookState previousState, eNktHookState currentState) { Process = aProcess; PreviousState = previousState; CurrentState = currentState; Hook = aHook; }
private void HandleHookStateChanged(NktHook aHook, NktProcess aProcess, eNktHookState currentState, eNktHookState previousState) { var consoleHook = CreateConsoleHookFrom(aHook); var consoleProcess = CreateConsoleProcessFrom(aProcess); _hooksByProcesses.Update(consoleHook, consoleProcess, currentState, previousState); HookStateChangedHandler(consoleHook, consoleProcess, previousState, currentState); }
void _functionHook_OnStateChanged(NktHook Hook, NktProcess proc, eNktHookState newState, eNktHookState oldState) { Console.WriteLine("--- Hook state changed {0} from {1} to {2}", Hook.FunctionName, oldState.ToString(), newState.ToString()); if (newState == eNktHookState.stRemoved) { Environment.Exit(0); } }
private void HookStateChangedHandler(Hook hook, IRunningProcess aProcess, eNktHookState previousState, eNktHookState currentState) { var aStateChangeInfo = new HookStateChangeInfo(hook, aProcess, previousState, currentState); var aHook = aStateChangeInfo.Hook; if (aStateChangeInfo.CurrentState == eNktHookState.stRemoved) { _view.RemoveHook(aHook); _view.RemoveHookEnabled = false; _view.RemoveAllHooksEnabled = _spyManager.AtLeastOneHookWasCreated; _view.ExportHookingSettings = _spyManager.AtLeastOneHookWasCreated; } else _view.DisplayHookStatus(aStateChangeInfo); if (!aProcess.IsHooked()) _view.DisplayRecentlyUnhookedProcess(aProcess); else if (aProcess.AtLeastOneHookIsActive()) _view.DisplayRecentlyHookedProcessAsActive(aProcess); else _view.DisplayRecentlyHookedProcessAsInactive(aProcess); _view.RefreshModulesView(); }
public void UpdateState(eNktHookState aState) { Text = _functionName + " (" + aState + ")"; }
public void UpdateState(eNktHookState aState) { Text = _functionName + " (" + aState + ")"; }
public void Update(Hook aHook, IRunningProcess aProcess, eNktHookState currentState, eNktHookState previousState) { var module = aProcess.ModuleByName(aHook.ModuleName); lock (_syncLock) { if (currentState == eNktHookState.stRemoved) { _hooks.ValueOrInitialize(aProcess).Remove(aHook); _activeHooks.ValueOrInitialize(aProcess).Remove(aHook.Id); if (previousState == eNktHookState.stActive) _hookCountByModule.Update(aProcess, moduleDictionary => { moduleDictionary.Update(module, oldCount => --oldCount); return moduleDictionary; }); } else { _hooks.ValueOrInitialize(aProcess).Add(aHook); if (currentState == eNktHookState.stActive) { _activeHooks.ValueOrInitialize(aProcess).Add(aHook.Id); _hookCountByModule.Update(aProcess, moduleDictionary => { moduleDictionary.Update(module, oldCount => ++oldCount); return moduleDictionary; }); } } } }
private void HandleHookStateChanged(NktHook aHook, NktProcess aProcess, eNktHookState currentState, eNktHookState previousState) { var consoleHook = CreateConsoleHookFrom(aHook); var consoleProcess = CreateConsoleProcessFrom(aProcess); _hooksByProcesses.Update(consoleHook, consoleProcess, currentState, previousState); HookStateChangedHandler(consoleHook, consoleProcess, previousState, currentState); }
void _functionHook_OnStateChanged(NktHook Hook, NktProcess proc, eNktHookState newState, eNktHookState oldState) { Console.WriteLine("--- Hook state changed {0} from {1} to {2}", Hook.FunctionName, oldState.ToString(), newState.ToString()); if (newState == eNktHookState.stRemoved) { Environment.Exit(0); } }