Example #1
0
        /// <summary>
        /// Injects the hook into the specified process
        /// </summary>
        /// <param name="process">The process to inject into</param>
        public void Inject(Process process)
        {
            // Skip if the process is already hooked, or if there is no main window
            if (this.GraphicsInterface != null || this.SpeedHackInterface != null || (process == null || process.MainWindowHandle == IntPtr.Zero))
            {
                return;
            }

            String projectDirectory = Path.GetDirectoryName(ProjectExplorerViewModel.GetInstance().ProjectFilePath);
            String channelName      = null;

            this.GraphicsInterface  = GraphicsFactory.GetGraphicsInterface(projectDirectory);
            this.SpeedHackInterface = new SpeedHackInterface();

            // Initialize the IPC server, giving the server access to the interfaces defined here
            RemoteHooking.IpcCreateServer <HookClient>(ref channelName, WellKnownObjectMode.Singleton, this);

            try
            {
                // Inject DLL into target process
                RemoteHooking.Inject(
                    process.Id,
                    InjectionOptions.Default,
                    typeof(HookClient).Assembly.Location,
                    typeof(HookClient).Assembly.Location,
                    channelName,
                    projectDirectory);
            }
            catch (Exception ex)
            {
                throw new Exception("Unable to Inject:" + ex);
            }
        }
Example #2
0
        /// <summary>
        /// Adds the given scan results to the project explorer.
        /// </summary>
        /// <param name="scanResults">The scan results to add to the project explorer.</param>
        private void AddScanResults(IEnumerable <PointerItem> scanResults)
        {
            if (scanResults == null)
            {
                return;
            }

            ProjectExplorerViewModel.GetInstance().AddNewProjectItems(addToSelected: false, projectItems: scanResults);
        }
Example #3
0
        /// <summary>
        /// Adds the given instructions to the project explorer.
        /// </summary>
        /// <param name="instructions">The instructions to add to the project explorer.</param>
        private void AddInstructions(IEnumerable <InstructionItem> instructions)
        {
            if (instructions == null)
            {
                return;
            }

            ProjectExplorerViewModel.GetInstance().AddNewProjectItems(addToSelected: false, projectItems: instructions);
        }
Example #4
0
        /// <summary>
        /// Adds the given instructions to the project explorer.
        /// </summary>
        /// <param name="instructions">The instructions to add to the project explorer.</param>
        private void AddInstructions(IEnumerable <InstructionItem> instructions)
        {
            if (instructions == null)
            {
                return;
            }

            ProjectExplorerViewModel.GetInstance().AddProjectItems(instructions.ToArray());
        }
        /// <summary>
        /// Closes the main window.
        /// </summary>
        /// <param name="window">The window to close.</param>
        private void Close(Window window)
        {
            if (!ProjectExplorerViewModel.GetInstance().PromptSave())
            {
                return;
            }

            window.Close();
        }
Example #6
0
        private void ExtractPointer(Int32 levelIndex)
        {
            Pointer pointer = this.DiscoveredPointers.GetRandomPointer(levelIndex);

            if (pointer != null)
            {
                PointerItem pointerItem = new PointerItem(pointer.BaseAddress, this.ActiveType, "New Pointer", null, pointer.Offsets);
                ProjectExplorerViewModel.GetInstance().AddProjectItems(pointerItem);
            }
        }
Example #7
0
        /// <summary>
        /// Adds a .Net object to the project explorer.
        /// </summary>
        /// <param name="dotNetObjectViewModel">The view model of the .Net object.</param>
        private void AddDotNetObject(DotNetObjectViewModel dotNetObjectViewModel)
        {
            DotNetObject dotNetObject = dotNetObjectViewModel.DotNetObject;
            DotNetItem   dotnetItem   = new DotNetItem(
                dotNetObject.Name,
                dotNetObject.ElementType == DataType.Boolean ? DataType.Byte : dotNetObject.ElementType,
                dotNetObject.GetFullName());

            ProjectExplorerViewModel.GetInstance().AddProjectItems(dotnetItem);
        }
Example #8
0
        /// <summary>
        /// Adds a .Net object to the project explorer.
        /// </summary>
        /// <param name="dotNetObjectViewModel">The view model of the .Net object.</param>
        private void AddDotNetObject(DotNetObjectViewModel dotNetObjectViewModel)
        {
            DotNetObject dotNetObject = dotNetObjectViewModel.DotNetObject;
            DotNetItem   dotnetItem   = new DotNetItem(
                dotNetObject.Name,
                dotNetObject.ElementType == typeof(Boolean) ? typeof(Byte) : dotNetObject.ElementType,
                dotNetObject.GetFullName()
                );

            ProjectExplorerViewModel.GetInstance().AddNewProjectItems(true, dotnetItem);
        }
Example #9
0
        /// <summary>
        /// Adds the given scan results to the project explorer.
        /// </summary>
        /// <param name="scanResults">The scan results to add to the project explorer.</param>
        private void AddScanResults(IEnumerable <ScanResult> scanResults)
        {
            if (scanResults == null)
            {
                return;
            }

            IEnumerable <PointerItem> projectItems = scanResults.Select(scanResult => scanResult.PointerItem);

            ProjectExplorerViewModel.GetInstance().AddNewProjectItems(addToSelected: true, projectItems: projectItems);
        }
Example #10
0
        /// <summary>
        /// Adds the given scan results to the project explorer.
        /// </summary>
        /// <param name="scanResults">The scan results to add to the project explorer.</param>
        private void AddScanResults(IEnumerable <ScanResult> scanResults)
        {
            if (scanResults == null)
            {
                return;
            }

            IEnumerable <PointerItem> projectItems = scanResults.Select(scanResult => scanResult.PointerItem?.ProjectItem as PointerItem);

            ProjectExplorerViewModel.GetInstance().AddProjectItems(projectItems.ToArray());
        }
Example #11
0
        /// <summary>
        /// Closes the main window.
        /// </summary>
        /// <param name="window">The window to close.</param>
        protected override void Close(Window window)
        {
            if (!ProjectExplorerViewModel.GetInstance().ProjectItemStorage.PromptSave())
            {
                return;
            }

            SettingsViewModel.GetInstance().Save();
            ProjectExplorerViewModel.GetInstance().DisableAllProjectItems();

            base.Close(window);
        }
        /// <summary>
        /// Adds the given scan results to the project explorer.
        /// </summary>
        /// <param name="scanResults">The scan results to add to the project explorer.</param>
        private void AddScanResults(IEnumerable <ScanResult> scanResults)
        {
            if (scanResults == null)
            {
                return;
            }

            foreach (ScanResult scanResult in scanResults)
            {
                ProjectExplorerViewModel.GetInstance().AddSpecificAddressItem(scanResult.ElementAddress, this.ActiveType);
            }
        }
Example #13
0
        /// <summary>
        /// Adds the given code trace results to the project explorer.
        /// </summary>
        /// <param name="codeTraceResults">The code trace results to add to the project explorer.</param>
        private void AddCodeTraceResults(IEnumerable <CodeTraceResult> codeTraceResults)
        {
            if (codeTraceResults == null)
            {
                return;
            }

            IEnumerable <InstructionItem> projectItems = codeTraceResults.Select(
                codeTraceEvent => new InstructionItem(codeTraceEvent.Address, "", "nop", new Byte[] { 0x90 }));

            ProjectExplorerViewModel.GetInstance().AddProjectItems(projectItems.ToArray());
        }
Example #14
0
        /// <summary>
        /// Adds a .Net object to the project explorer.
        /// </summary>
        /// <param name="dotNetObjectViewModel">The view model of the .Net object.</param>
        private void AddDotNetObject(DotNetObjectViewModel dotNetObjectViewModel)
        {
            DotNetObject dotNetObject = dotNetObjectViewModel.DotNetObject;
            AddressItem  addressItem  = new AddressItem();

            addressItem.Description    = dotNetObject.Name;
            addressItem.ElementType    = dotNetObject.ElementType == typeof(Boolean) ? typeof(Byte) : dotNetObject.ElementType;
            addressItem.BaseIdentifier = dotNetObject.GetFullName();
            addressItem.ResolveType    = AddressResolver.ResolveTypeEnum.DotNet;

            ProjectExplorerViewModel.GetInstance().AddNewProjectItems(true, addressItem);
        }
Example #15
0
        /// <summary>
        /// Closes the main window.
        /// </summary>
        /// <param name="window">The window to close.</param>
        private void Close(Window window)
        {
            if (!ProjectExplorerViewModel.GetInstance().ProjectItemStorage.PromptSave())
            {
                return;
            }

            SettingsViewModel.GetInstance().Save();
            ProjectExplorerViewModel.GetInstance().DisableAllProjectItems();

            window.Close();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ProjectExplorer" /> class.
        /// </summary>
        public ProjectExplorer()
        {
            this.InitializeComponent();

            this.nodeCache   = new BiDictionary <ProjectItem, ProjectNode>();
            this.projectTree = new TreeModel();

            this.InitializeDesigner();
            this.projectExplorerTreeViewContainer.Children.Add(WinformsHostingHelper.CreateHostedControl(this.projectExplorerTreeView));

            EngineCore.GetInstance().Input?.GetKeyboardCapture().Subscribe(this);
            ProjectExplorerViewModel.GetInstance().Subscribe(this);
        }
Example #17
0
 /// <summary>
 /// Event invoked when a download has been completed in the browser.
 /// </summary>
 /// <param name="sender">Sending object.</param>
 /// <param name="e">Download event args.</param>
 private void DownloadDataCompleted(Object sender, DownloadDataCompletedEventArgs e)
 {
     try
     {
         // Load and import the file.
         String file = Path.GetTempFileName();
         File.WriteAllBytes(file, e.Result);
         ProjectExplorerViewModel.GetInstance().ImportSpecificProjectCommand.Execute(file);
     }
     catch
     {
     }
 }
Example #18
0
        /// <summary>
        /// Adds a project item as a child under this one.
        /// </summary>
        /// <param name="newChild">The child project item.</param>
        public void AddChild(ProjectItem newChild)
        {
            lock (this.ChildrenLock)
            {
                newChild.Parent = this;

                if (this.Children == null)
                {
                    this.Children = new List <ProjectItem>();
                }

                this.Children.Add(newChild);
            }

            ProjectExplorerViewModel.GetInstance().HasUnsavedChanges = true;
        }
Example #19
0
        /// <summary>
        /// Adds a project item as a sibling to the specified object.
        /// </summary>
        /// <param name="targetChild">The child project item.</param>
        /// <param name="newChild">The new child project item to add as a sibling.</param>
        /// <param name="after">A value indicating whether or not the new child should be inserted before or after the target.</param>
        public void AddSibling(ProjectItem targetChild, ProjectItem newChild, Boolean after)
        {
            lock (this.ChildrenLock)
            {
                if (!this.Children.Contains(targetChild))
                {
                    return;
                }

                newChild.Parent = this;

                if (after)
                {
                    this.Children?.Insert(this.Children.IndexOf(targetChild) + 1, newChild);
                }
                else
                {
                    this.Children?.Insert(this.Children.IndexOf(targetChild), newChild);
                }
            }

            ProjectExplorerViewModel.GetInstance().HasUnsavedChanges = true;
        }
        public void AddSelectionToTable(Int32 minIndex, Int32 maxIndex)
        {
            if (minIndex < 0)
            {
                minIndex = 0;
            }

            if (maxIndex > this.AcceptedPointers.Count)
            {
                maxIndex = this.AcceptedPointers.Count;
            }

            Int32 count = 0;

            for (Int32 index = minIndex; index <= maxIndex; index++)
            {
                String pointerValue = String.Empty;
                this.IndexValueMap.TryGetValue(index, out pointerValue);

                AddressItem newPointer = new AddressItem(
                    this.AcceptedPointers[index].Item1,
                    this.ElementType,
                    "New Pointer",
                    AddressResolver.ResolveTypeEnum.Module,
                    String.Empty,
                    this.AcceptedPointers[index].Item2,
                    false,
                    pointerValue);

                ProjectExplorerViewModel.GetInstance().AddNewProjectItems(true, newPointer);

                if (++count >= PointerScannerModel.MaxAdd)
                {
                    break;
                }
            }
        }
Example #21
0
        /// <summary>
        /// Removes the specified item from this item's children recursively.
        /// </summary>
        /// <param name="projectItem">The item to remove.</param>
        /// <returns>Returns true if the removal succeeded.</returns>
        public Boolean RemoveNode(ProjectItem projectItem)
        {
            Boolean removeSuccess = false;

            if (projectItem == null)
            {
                return(false);
            }

            lock (this.ChildrenLock)
            {
                if (this.Children.Contains(projectItem))
                {
                    projectItem.Parent = null;
                    this.Children.Remove(projectItem);
                    removeSuccess = true;
                }
                else
                {
                    foreach (ProjectItem child in this.Children)
                    {
                        if (child is FolderItem)
                        {
                            if (child != null && (child as FolderItem).RemoveNode(projectItem))
                            {
                                removeSuccess = true;
                            }
                        }
                    }
                }
            }

            ProjectExplorerViewModel.GetInstance().HasUnsavedChanges = true;

            return(removeSuccess);
        }
Example #22
0
 /// <summary>
 /// Adds the given instruction to the project explorer.
 /// </summary>
 /// <param name="instruction">The instruction to add to the project explorer.</param>
 private void AddInstruction(InstructionItem instruction)
 {
     ProjectExplorerViewModel.GetInstance().AddProjectItems(instruction);
 }
Example #23
0
 /// <summary>
 /// Adds the given instruction to the project explorer.
 /// </summary>
 /// <param name="instruction">The instruction to add to the project explorer.</param>
 private void AddInstruction(InstructionItem instruction)
 {
     ProjectExplorerViewModel.GetInstance().AddNewProjectItems(addToSelected: false, projectItems: instruction);
 }
Example #24
0
 /// <summary>
 /// Adds the given scan result to the project explorer.
 /// </summary>
 /// <param name="scanResult">The scan result to add to the project explorer.</param>
 private void AddScanResult(ScanResult scanResult)
 {
     ProjectExplorerViewModel.GetInstance().AddNewProjectItems(addToSelected: true, projectItems: scanResult?.PointerItem);
 }
Example #25
0
        /// <summary>
        /// Adds the given code trace result to the project explorer.
        /// </summary>
        /// <param name="codeTraceResult">The code trace result to add to the project explorer.</param>
        private void AddCodeTraceResult(CodeTraceResult codeTraceResult)
        {
            InstructionItem instructionItem = new InstructionItem(codeTraceResult.Address, "", "nop", new Byte[] { 0x90 });

            ProjectExplorerViewModel.GetInstance().AddProjectItems(instructionItem);
        }
 /// <summary>
 /// Adds the given scan result address to the project explorer.
 /// </summary>
 /// <param name="scanResult">The scan result to add to the project explorer.</param>
 private void AddAddress(ScanResult scanResult)
 {
     ProjectExplorerViewModel.GetInstance().AddSpecificAddressItem(scanResult.ElementAddress, this.ActiveType);
 }
Example #27
0
 /// <summary>
 /// Adds the given scan result to the project explorer.
 /// </summary>
 /// <param name="scanResult">The scan result to add to the project explorer.</param>
 private void AddScanResult(ScanResult scanResult)
 {
     ProjectExplorerViewModel.GetInstance().AddProjectItems(scanResult?.PointerItem?.ProjectItem);
 }
Example #28
0
 /// <summary>
 /// Adds the given scan result address to the project explorer.
 /// </summary>
 /// <param name="scanResult">The scan result to add to the project explorer.</param>
 private void AddAddress(PointerItem scanResult)
 {
     ProjectExplorerViewModel.GetInstance().AddNewProjectItems(addToSelected: false, projectItems: scanResult);
 }
 /// <summary>
 /// Adds the given scan result address to the project explorer.
 /// </summary>
 /// <param name="scanResult">The scan result to add to the project explorer.</param>
 private void AddAddress(PointerScanResult scanResult)
 {
     ProjectExplorerViewModel.GetInstance().AddSpecificAddressItem(scanResult.ElementAddress, typeof(Int32));
 }