protected virtual void KillPlayer() { Logger.ReportVerbose("Killing {0}", ControllerName); string processName = CurrentProcessName; if (CurrentProcess != null) { Logger.ReportVerbose("Killing " + ControllerName); try { CurrentProcess.Kill(); } catch (Exception ex) { Logger.ReportException("Error killing {0}", ex, ControllerName); } } if (!string.IsNullOrEmpty(processName)) { KillProcesses(processName); } }
void CheckLoop() { while (CheckThread != null) { IsInjected = false; CurrentProcess = Process.GetProcessesByName(ProcessName).FirstOrDefault(); if (CurrentProcess != null) { if (ProcessFound != null) { ProcessFound(this, CurrentProcess); } CurrentProcess.WaitForExit(); if (ProcessExited != null) { ProcessExited(this, CurrentProcess); } } else { Task.Delay(100).Wait(); } } }
public override void Stop() { if (!IsDebugging) { MessageService.ShowMessage(errorNotDebugging, "${res:XML.MainMenu.DebugMenu.Stop}"); return; } if (IsAttached) { StopAttachedProcessDialogResult result = ShowStopAttachedProcessDialog(); switch (result) { case StopAttachedProcessDialogResult.Terminate: CurrentProcess.Terminate(); attached = false; break; case StopAttachedProcessDialogResult.Detach: Detach(); attached = false; break; } } else { CurrentProcess.Terminate(); } }
public override void Continue() { if (CurrentProcess != null && CurrentProcess.IsPaused) { CurrentProcess.AsyncContinue(); } }
/// <summary> /// Patches all jumps pointing to originalJmpTarget to point to newJmpTarget. /// </summary> /// <param name="searchRange">Range of addresses where to patch jumps.</param> /// <param name="originalJmpTarget">Address range of JMP targets to patch with newJmpTarget.</param> /// <param name="newJmpTarget">The new address instructions should jmp to.</param> internal List <Patch> PatchJumpTargets(AddressRange searchRange, AddressRange originalJmpTarget, long newJmpTarget) { var patches = new List <Patch>(); int length = (int)(searchRange.EndPointer - searchRange.StartPointer); CurrentProcess.SafeReadRaw((IntPtr)searchRange.StartPointer, out byte[] memory, length); Disassembler disassembler = new Disassembler(memory, _architecture, (ulong)searchRange.StartPointer, true); Instruction[] instructions = disassembler.Disassemble().ToArray(); for (int x = 0; x < instructions.Length; x++) { Instruction instruction = instructions[x]; Instruction nextInstruction = (x + 1 < instructions.Length) ? instructions[x + 1] : null; if (IsRelativeJump(instruction)) { PatchRelativeJump(instruction, ref originalJmpTarget, newJmpTarget, patches); } if (IsRIPRelativeJump(instruction)) { PatchRIPRelativeJump(instruction, ref originalJmpTarget, newJmpTarget, patches); } if (IsPushReturn(instruction, nextInstruction)) { PatchPushReturn(instruction, ref originalJmpTarget, newJmpTarget, patches); } } // Return all the addresses to patch!. return(patches); }
/* == Patch Function == * * First a function stub is generated containing: * 1. Opcodes between Instruction.PC and "newAddress" * 2. a jmp to "newAddress". * * Then these functions look at the original JMP target and look for jumps back to * the end of the instruction. * * Patches are then generated that convert those jumps back to jumps to the location of * function stub. * * Patches are added to patch.Patches. */ private void PatchReturnAddresses(JumpDetails jumpDetails, FunctionPatch patch, long newAddress) { long originalJmpTarget = jumpDetails.JumpOpcodeTarget; GetSearchRange(ref originalJmpTarget, out long searchLength); /* Get original opcodes after original JMP instruction. */ IntPtr startRemainingOpcodes = (IntPtr)jumpDetails.JumpOpcodeEnd; int lengthRemainingOpcodes = (int)(newAddress - (long)startRemainingOpcodes); CurrentProcess.ReadRaw(startRemainingOpcodes, out byte[] remainingInstructions, lengthRemainingOpcodes); /* Build function stub + patches. */ // Must guarantee relative jumps to be patches can reach our new prologue // as such must get range of search first before creating stub. long maxDisplacement = Int32.MaxValue - searchLength; IntPtr newOriginalPrologue = Utilities.InsertJump(remainingInstructions, Is64Bit(), newAddress, originalJmpTarget, maxDisplacement); var patches = PatchJumpTargets(new AddressRange(originalJmpTarget, originalJmpTarget + searchLength), new AddressRange((long)startRemainingOpcodes, newAddress), (long)newOriginalPrologue); patch.Patches.AddRange(patches); }
public virtual void WaitForExit() { if (CurrentProcess != null) { CurrentProcess.WaitForExit(); } }
public MediaController(CurrentProcess currentProcess , IHostingEnvironment hosting , IMediaBusiness mediaBusiness) : base(currentProcess) { _bizMedia = mediaBusiness; _hosting = hosting; }
public GroupBusiness(IGroupRepository groupRepository, IEmployeeRepository employeeRepository, IMapper mapper, CurrentProcess process) : base(mapper, process) { _rpGroup = groupRepository; _rpEmployee = employeeRepository; }
public HosoBusiness(CurrentProcess process, IHosoRepository hosoRepository, IMapper mapper) : base(mapper, process) { _mapper = mapper; _rpHoso = hosoRepository; }
//protected HttpRequest _request; public BaseController(HttpClient httpClient, IOptions <ClientConfig> clientConfig, CurrentProcess currentProcess) { _httpClient = httpClient; _clientConfig = clientConfig.Value; _currentProcess = currentProcess; //_request = request; }
/// <summary> /// Runs the specified URL. /// </summary> /// <param name="url">The URL.</param> /// <remarks>...</remarks> public static void Run(string url = null) { try { if (CurrentProcess != null) { if (!CurrentProcess.HasExited) { CurrentProcess.Kill(); } CurrentProcess = null; } } catch /* Eat */ { /* Tasty ? */ } try { var p = new Process(); if (string.IsNullOrWhiteSpace(url)) { p.StartInfo.Arguments = string.Format("--data-path=\"{0}\"", Api.CacheRoot); } else { p.StartInfo.Arguments = string.Format("--data-path=\"{0}\" --url=\"{1}\"", Api.CacheRoot, url); } p.StartInfo.FileName = Path.Combine(Location, "nw.exe"); p.StartInfo.UseShellExecute = true; p.Start(); App.Current.ShowNotification(new Notification(Definitions.NWRunHelpTitle, Definitions.NWRunHelpContent)); CurrentProcess = p; } catch /* Eat */ { /* Tasty ? */ } }
public async Task Invoke(HttpContext httpContext, CurrentProcess process, IEmployeeBusiness rpEmployee) { var raw = httpContext.Session.Get(SESSION_KEY); if (raw == null) { var user = httpContext.GetUserInfo(); if (user == null) { await _next(httpContext); return; } raw = Utils.ToBinary(user); httpContext.Session.Set(SESSION_KEY, raw); } var account = Utils.FromBinary(raw); var isActive = await rpEmployee.GetStatusAsync(account.Id); if (!isActive && httpContext.Request.Path.Value != "/Account/Login") { httpContext.Response.Redirect("/Account/Login"); return; } account.IsActive = isActive; process.User = account; CurrentProcess.CurrentUser = account; await _next(httpContext); }
private nuint GetRewriteRIPRelativeJumpTarget(Instruction instruction) { var pointerAddress = instruction.IPRelativeMemoryAddress; CurrentProcess.Read((nuint)pointerAddress, out nuint targetAddress); return(targetAddress); }
private void DataGridViewConstructorList() { try { if (dtg.Rows.Count > 0) { dtg.Rows.Clear(); } string[] i = new string[Enum.GetValues(typeof(Col)).Length]; foreach (var c in _controller.ListOfContacts) { i[(int)Col.ID] = c.Id.ToString(); i[(int)Col.Name] = c.Name.ToString(); i[(int)Col.Email] = c.Email.ToString(); i[(int)Col.Phone] = c.Phone.ToString(); i[(int)Col.Birthday] = c.Birth.ToShortDateString(); i[(int)Col.Action] = "X"; i[(int)Col.Edit] = "E"; dtg.Rows.Add(i); dtg.Refresh(); } } catch (Exception ex) { MessageBox.Show(ex.Message, MessageBoxHelper.ERROR_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error); _currentProcess = CurrentProcess.Exception; } }
public virtual void GlobalSetup() { DebugInfoThis(); Info("Data type is {0}.", typeof(TData).Name); CurrentProcess.Refresh(); InitialPrivateMemorySize = CurrentProcess.PeakWorkingSet64; }
public frmMain(ContactsListController controller) { InitializeComponent(); _currentProcess = CurrentProcess.Init; _message = "0"; _controller = controller; _hasEmailException = false; _hasDate = false; #region TEXTBOX ADD EVENTS txtFullName.GotFocus += txtFullName_GotFocus; txtFullName.Click += txtFullName_Click; txtFullName.KeyPress += txtFullName_KeyPress; txtFullName.KeyDown += txtFullName_KeyDown; txtFullName.TextChanged += txtFullName_TextChanged; txtEmail.GotFocus += txtEmail_GotFocus; txtEmail.Click += txtEmail_Click; txtEmail.KeyPress += txtEmail_KeyPress; txtEmail.KeyDown += txtEmail_KeyDown; txtPhone.GotFocus += txtPhone_GotFocus; txtPhone.Click += txtPhone_Click; txtPhone.KeyPress += txtPhone_KeyPress; txtPhone.KeyDown += txtPhone_KeyDown; txtPhone.TextChanged += txtPhone_TextChanged; txtBirth.ValueChanged += txtBirth_ValueChanged; #endregion }
public CompanyBusiness(ICompanyRepository companyRepository, INoteRepository noteRepository, IMapper mapper, CurrentProcess process) : base(mapper, process) { _rpCompany = companyRepository; _rpNote = noteRepository; }
public ProductBusiness(IProductRepository productRepository, IServiceProvider svProvider, IMapper mapper, CurrentProcess process) : base(mapper, process) { _rpProduct = productRepository; _svProvider = svProvider; }
private IntPtr GetRewriteRIPRelativeJumpTarget(Instruction instruction) { IntPtr pointerAddress = (IntPtr)((long)instruction.PC + GetOperandOffset(instruction.Operands[0])); CurrentProcess.Read(pointerAddress, out IntPtr targetAddress); return(targetAddress); }
public ConfigController(IConfigBusiness configBusiness, IMCreditService mCreditService, CurrentProcess process) : base(process) { _bizConfig = configBusiness; _svMcredit = mCreditService; }
internal void StopInternal() { switch (State) { case ESimState.Construction: case ESimState.Elaboration: throw new InvalidOperationException("Model not yet elaborated"); case ESimState.Simulation: case ESimState.StopRequested: // inside simulation State = ESimState.StopRequested; CurrentProcess.Stop(); break; // not reached case ESimState.SimulationPaused: // outside simulation State = ESimState.StopRequested; CallSimulationStoppedHandlers(); State = ESimState.Stopped; break; case ESimState.Stopped: throw new InvalidOperationException("Simulation already stopped"); default: throw new NotImplementedException(); } }
public AccountBusiness(IAccountRepository accountRepository, IOptions <AppSettings> appSettings, CurrentProcess process, IMapper mapper) : base(mapper, process) { _rpAccount = accountRepository; _appSettings = appSettings.Value; }
public override void Break() { if (CurrentProcess != null && CurrentProcess.IsRunning) { CurrentProcess.Break(); } }
public NetSdkMsiInstallerClient(InstallElevationContextBase elevationContext, ISetupLogger logger, IWorkloadResolver workloadResolver, SdkFeatureBand sdkFeatureBand, INuGetPackageDownloader nugetPackageDownloader = null, VerbosityOptions verbosity = VerbosityOptions.normal, PackageSourceLocation packageSourceLocation = null, IReporter reporter = null) : base(elevationContext, logger, reporter) { _packageSourceLocation = packageSourceLocation; _nugetPackageDownloader = nugetPackageDownloader; _sdkFeatureBand = sdkFeatureBand; _workloadResolver = workloadResolver; _dependent = $"{DependentPrefix},{sdkFeatureBand},{HostArchitecture}"; Log?.LogMessage($"Executing: {CurrentProcess.GetCommandLine()}, PID: {CurrentProcess.Id}, PPID: {ParentProcess.Id}"); Log?.LogMessage($"{nameof(IsElevated)}: {IsElevated}"); Log?.LogMessage($"{nameof(Is64BitProcess)}: {Is64BitProcess}"); Log?.LogMessage($"{nameof(RebootPending)}: {RebootPending}"); Log?.LogMessage($"{nameof(ProcessorArchitecture)}: {ProcessorArchitecture}"); Log?.LogMessage($"{nameof(HostArchitecture)}: {HostArchitecture}"); Log?.LogMessage($"{nameof(SdkDirectory)}: {SdkDirectory}"); Log?.LogMessage($"SDK feature band: {_sdkFeatureBand}"); if (IsElevated) { // Turn off automatic updates. We don't want MU to potentially patch the SDK // and it also reduces the risk of hitting ERROR_INSTALL_ALREADY_RUNNING. UpdateAgent.Stop(); } }
public void LongRelativeJump() { using var assembler = new Assembler.Assembler(); const int expectedResult = 42069; string[] customFunction = new string[] { $"{_use32}", $"mov {_eax}, {expectedResult}", $"ret" }; // Make target and source. var target = _highMemoryAllocator.Write(assembler.Assemble(customFunction)); var src = _lowAlloc.Allocate(100); // for our jump instruction // Assert original works. var tgtMethod = ReloadedHooks.Instance.CreateFunction <GetValueFunction>(target.ToSigned()); Assert.Equal(expectedResult, tgtMethod.GetWrapper()()); CurrentProcess.WriteRaw(src, Utilities.AssembleRelativeJump(src, target, Environment.Is64BitProcess)); // Call the code. var srcMethod = ReloadedHooks.Instance.CreateFunction <GetValueFunction>(src.ToSigned()); Assert.Equal(expectedResult, srcMethod.GetWrapper()()); }
public RevokeDebtBusiness(IRevokeDebtRepository revokeDebtRepository, IServiceProvider serviceProvider, IMapper mapper, CurrentProcess process) : base(mapper, process) { _svProvider = serviceProvider; _rpRevoke = revokeDebtRepository; }
public PersonBusiness(MongoI.IPersonRepository personRepoM, NeoI.IPersonRepository personRepoN, SqlI.IPersonRepository personRepositoryS, CurrentProcess process) : base(process) { m_personRepositoryM = personRepoM; m_personRepositoryN = personRepoN; m_personRepositoryS = personRepositoryS; }
private static void Create(Hook <TFunction> hook, ReverseWrapper <TFunction> reverseWrapper, long functionAddress, int minHookLength = -1) { /* * === Hook Summary === * * A. Insert Absolute Jump to ReverseWrapper (Convention => CDECL Marshaller) * A1. Backup original bytes and patch between start and end of JMP for (B). * * B. Setup Wrapper to call original function (CDECL => Convention Marshaller) * B1. Take bytes backed up from A, and create stub function with those * bytes and JMP to end of hook. * B2. Assign OriginalFunction to that function stub. */ /* Create Convention => CDECL Wrapper. */ List <byte> jumpOpcodes = Utilities.AssembleAbsoluteJump(reverseWrapper.WrapperPointer, false).ToList(); /* Calculate Hook Length (Unless Explicit) */ if (minHookLength == -1) { minHookLength = Utilities.GetHookLength((IntPtr)functionAddress, jumpOpcodes.Count, ArchitectureMode.x86_32); } // Sometimes our hook can be larger than the amount of bytes taken by the jmp opcode. // We need to fill the remaining bytes with NOPs. if (minHookLength > jumpOpcodes.Count) { int nopBytes = minHookLength - jumpOpcodes.Count; for (int x = 0; x < nopBytes; x++) { jumpOpcodes.Add(0x90); } } /* Get bytes from original function prologue and patch them. */ CurrentProcess.SafeReadRaw((IntPtr)functionAddress, out byte[] originalFunction, minHookLength); var functionPatcher = new FunctionPatcher(ArchitectureMode.x86_32); var functionPatch = functionPatcher.Patch(originalFunction.ToList(), (IntPtr)functionAddress); IntPtr hookEndAddress = (IntPtr)(functionAddress + minHookLength); functionPatch.NewFunction.AddRange(Utilities.AssembleAbsoluteJump(hookEndAddress, false)); /* Commit the original modified function to memory. */ byte[] patchedFunction = functionPatch.NewFunction.ToArray(); var buffer = Utilities.FindOrCreateBufferInRange(patchedFunction.Length); var patchedFunctionAddress = buffer.Add(patchedFunction); /* Create Hook instance. */ hook.OriginalFunctionAddress = patchedFunctionAddress; hook.OriginalFunction = Wrapper.Create <TFunction>((long)patchedFunctionAddress); hook.ReverseWrapper = reverseWrapper; hook._otherHookPatches = functionPatch.Patches; hook._hookPatch = new Patch((IntPtr)functionAddress, jumpOpcodes.ToArray()); }
public static void RunGraph(string graph_path, ReadInput input_function) { if (CurrentProcess != null && !CurrentProcess.HasExited) { CurrentProcess.Kill(); } CurrentProcess = FetchNewProcess(graph_path); Aborting = false; if (input_function != null) { CurrentProcess.StartInfo.RedirectStandardInput = true; } try { //Start process and asynchronous reading CurrentProcess.Start(); CurrentProcess.BeginOutputReadLine(); CurrentProcess.BeginErrorReadLine(); if (input_function != null) { using (StreamWriter writer = new StreamWriter(CurrentProcess.StandardInput.BaseStream, Encoding.ASCII)) { while (!CurrentProcess.HasExited && !Aborting) { byte[] input = input_function(); if (input != null && input.Length != 0) { writer.WriteLine(Encoding.ASCII.GetString(input)); } else { writer.Flush(); } } } } if (Aborting && !CurrentProcess.HasExited) { CurrentProcess.Kill(); CurrentProcess.WaitForExit(); VSLogger.Log("Aborted current process."); } } catch (Win32Exception exception) { VSLogger.LogError("Output:\n" + exception.ToString()); } CurrentProcess.WaitForExit(); CurrentProcess = null; Aborting = false; }