Exemple #1
0
        private static long ScanForSignature(Process proc, SearchSignature s, IntPtr baseAddr, long size)
        {
            long next = (long)baseAddr;
            long end  = next + size;

            while (true)
            {
                long patternIndex = BayerMooreScanForPattern(proc, s.Pattern, (IntPtr)next, end - next);

                if (patternIndex >= 0)
                {
                    long result = next + patternIndex - s.Address.Offset;
                    next += patternIndex + 4;

                    bool verified = true;
                    foreach (var(ptr, val) in s.Verification)
                    {
                        uint value = (uint)ReadProcessInt32(proc, (IntPtr)(result + ptr.Offset), out int r);
                        if (value != val)
                        {
                            verified = false;
                            break;
                        }
                    }
                    if (verified)
                    {
                        return(result);
                    }
                }
                else
                {
                    return(-1);
                }
            }
        }
Exemple #2
0
        private static long ScanForSignature(Process proc, SearchSignature s, IntPtr baseAddr, long size)
        {
            long next = (long)baseAddr;
            long end  = next + size;

            while (true)
            {
                long patternIndex = BayerMooreScanForPattern(proc, s.PrimaryPattern.Pattern, (IntPtr)next, end - next);

                if (patternIndex >= 0)
                {
                    long result = next + patternIndex - s.PrimaryPattern.Address.Offset;
                    next += patternIndex + 4;

                    bool verified = true;
                    foreach (var pattern in s.SecondaryPatterns)
                    {
                        if (!TestSecondaryPattern(proc, pattern, result))
                        {
                            verified = false;
                            break;
                        }
                    }
                    if (verified)
                    {
                        return(result);
                    }
                }
                else
                {
                    return(-1);
                }
            }
        }
Exemple #3
0
        public static Emulator Trainer(SearchSignature sig)
        {
            Console.WriteLine("Begin scanning...");
            //"mupen64plus.dll"
            var processes = Process.GetProcesses();

            foreach (var p in processes)
            {
                if (p.ProcessName.ToLowerInvariant().Contains("project64"))
                {
                    Console.WriteLine($"Project64 detected, {p.WorkingSet64:X8}");
                    Console.WriteLine($"Note: PJ64 uses dynamic memory allocation; Address changes on program re-launch");

                    long result = ScanForSignature(p, sig, (IntPtr)0, 0xFFFF_FFFF);

                    if (result >= 0)
                    {
                        Console.WriteLine($"RDRAM begins at {result:X8}");
                        return(new Emulator(p.ProcessName, $"generated", 32, $"{result:X8}", 0));
                    }

                    Console.WriteLine("RDRAM not found");
                    return(null);
                }
                try
                {
                    foreach (ProcessModule m in p.Modules)
                    {
                        if (m.ModuleName == "mupen64plus.dll")
                        {
                            long baseAddr = (long)m.BaseAddress;
                            Console.WriteLine($"Process {p.ProcessName} contains mupen64plus.dll at address {baseAddr:X16}");

                            long result = ScanForSignature(p, m, sig);

                            if (result < 0)
                            {
                                Console.WriteLine("RDRAM not found");
                                continue;
                            }
                            else
                            {
                                Console.WriteLine($"RDRAM begins at {result:X16}");
                                return(new Emulator(p.ProcessName, "generated", 32, $"`{m.ModuleName}`+{result-baseAddr:X8}", 0));
                            }
                        }
                    }
                }
                catch (Exception) { }
            }
            Console.WriteLine("Finished");
            return(null);
        }
Exemple #4
0
 private static long ScanForSignature(Process proc, ProcessModule m, SearchSignature s)
 {
     return(ScanForSignature(proc, s, m.BaseAddress, m.ModuleMemorySize));
 }