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);
        }
예제 #2
0
 /// <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;
     }
 }
 internal override bool ScanAOB(AOBScanner scanner)
 {
     AOBResult = scanner.Scan(AOB);
     return(AOBResult != IntPtr.Zero);
 }
예제 #4
0
 internal abstract bool ScanAOB(AOBScanner scanner);
예제 #5
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));
 }
예제 #6
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));
 }
예제 #7
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;

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

                        Hooked = true;
                        RaiseOnHooked();
                    }
                }
            }
        }