コード例 #1
0
        /// <summary>
        /// Checks for new processes to attach to; either call this manually, or call Start to do it automatically.
        /// </summary>
        public void Refresh()
        {
            if (!Hooked)
            {
                // After hooking, close all the remaining Processes immediately
                bool cleanup = false;
                foreach (Process process in Process.GetProcesses())
                {
                    bool close   = false;
                    bool is64Bit = false;
                    try
                    {
                        close = cleanup || !Selector(process) || process.HasExited || (DateTime.Now - process.StartTime).TotalMilliseconds < MinLifetime;
                        if (!close && Environment.Is64BitOperatingSystem)
                        {
                            // This is actually really slow, so only do it if everything else passed
                            if (Kernel32.IsWow64Process(process.Handle, out bool result))
                            {
                                is64Bit = !result;
                                close  |= is64Bit && !Environment.Is64BitProcess;
                            }
                            else
                            {
                                close = true;
                            }
                        }
                    }
                    catch (Win32Exception)
                    {
                        close = true;
                    }

                    if (close)
                    {
                        process.Close();
                    }
                    else
                    {
                        cleanup = true;
                        Is64Bit = is64Bit;
                        Process = process;
                        process.EnableRaisingEvents = true;
                        process.Exited += Unhook;

                        if (AOBPointers.Count > 0)
                        {
                            var scanner = new AOBScanner(process);
                            foreach (PHPointerAOB pointer in AOBPointers)
                            {
                                pointer.ScanAOB(scanner);
                            }
                        }

                        Hooked = true;
                        RaiseOnHooked();
                    }
                }
            }
        }
コード例 #2
0
        internal override void ScanAOB(AOBScanner scanner)
        {
            IntPtr result  = scanner.Scan(AOB);
            IntPtr temp    = result + AddressOffset;
            uint   address = Kernel32.ReadUInt32(Hook.Handle, temp);

            AOBResult = (IntPtr)((ulong)(result + InstructionSize) + address);
        }
コード例 #3
0
 /// <summary>
 /// Manually rescans all AOB pointers.
 /// </summary>
 public void RescanAOB()
 {
     if (Hooked && AOBPointers.Count > 0)
     {
         var scanner = new AOBScanner(Process);
         foreach (PHPointerAOB pointer in AOBPointers)
         {
             pointer.ScanAOB(scanner);
         }
     }
 }
コード例 #4
0
        internal override bool ScanAOB(AOBScanner scanner)
        {
            IntPtr result = scanner.Scan(AOB);

            if (result == IntPtr.Zero)
            {
                AOBResult = result;
                return(false);
            }

            uint address = Kernel32.ReadUInt32(Hook.Handle, result + AddressOffset);

            AOBResult = (IntPtr)((ulong)(result + InstructionSize) + address);
            return(true);
        }
コード例 #5
0
ファイル: PHook.cs プロジェクト: jakewestrip/RoguelikeSouls
 /// <summary>
 /// Manually rescans all AOB pointers.
 /// </summary>
 public void RescanAOB()
 {
     if (Hooked)
     {
         bool aobSuccess = true;
         if (AOBPointers.Count > 0)
         {
             var scanner = new AOBScanner(Process);
             foreach (PHPointerAOB pointer in AOBPointers)
             {
                 aobSuccess &= pointer.ScanAOB(scanner);
             }
         }
         AOBScanSucceeded = aobSuccess;
     }
 }
コード例 #6
0
ファイル: PHPointerAOB.cs プロジェクト: swordworld/dstools
 internal abstract void ScanAOB(AOBScanner scanner);
コード例 #7
0
 /// <summary>
 /// Creates and registers a new absolute AOB pointer with a CE-style AOB string.
 /// </summary>
 public PHPointer RegisterAbsoluteAOB(string aob, params int[] offsets)
 {
     return(RegisterAbsoluteAOB(AOBScanner.StringToAOB(aob), offsets));
 }
コード例 #8
0
 /// <summary>
 /// Create and register a new relative AOB pointer with a CE-style AOB string.
 /// </summary>
 public PHPointer RegisterRelativeAOB(string aob, int addressOffset, int instructionSize, params int[] offsets)
 {
     return(RegisterRelativeAOB(AOBScanner.StringToAOB(aob), addressOffset, instructionSize, offsets));
 }
コード例 #9
0
 internal override bool ScanAOB(AOBScanner scanner)
 {
     AOBResult = scanner.Scan(AOB);
     return(AOBResult != IntPtr.Zero);
 }
コード例 #10
0
 internal abstract bool ScanAOB(AOBScanner scanner);