void IInjectInitialize.Initialize()
        {
            if (HleConfig.HleModulesDll == null)
            {
                throw (new ArgumentNullException("PspEmulatorContext.PspConfig.HleModulesDll Can't be null"));
            }

            HleModuleTypes = GetAllHleModules(HleConfig.HleModulesDll).ToDictionary(Type => Type.Name);
            Console.WriteLine("HleModuleTypes: {0}", HleModuleTypes.Count);

            if (HleModuleTypes.Count < 10)
            {
                ConsoleUtils.SaveRestoreConsoleColor(ConsoleColor.Red, () =>
                {
                    Console.WriteLine("!!!!!!!!!!!!!!!!!!!!!!!!");
                    Console.WriteLine("Can't find HLE modules!!");
                    Console.WriteLine("!!!!!!!!!!!!!!!!!!!!!!!!");
                });
            }

#if false
            CpuProcessor.RegisterNativeSyscall(SyscallInfo.NativeCallSyscallCode, (CpuThreadState, Code) =>
            {
                uint Info = CpuThreadState.CpuProcessor.Memory.ReadSafe <uint>(CpuThreadState.PC + 4);
                DelegateInfo DelegateInfo;
                if (!DelegateTable.TryGetValue(Info, out DelegateInfo))
                {
                    throw (new Exception(String.Format("Can't find DelegateInfo for PC={0:X8}, Info=0x{1:X8}", CpuThreadState.PC, Info)));
                }
                if (PspConfig.TraceLastSyscalls)
                {
                    //Console.WriteLine("{0:X}", CpuThreadState.RA);
                    DelegateInfo.CallIndex = LastCallIndex++;
                    DelegateInfo.PC        = CpuThreadState.PC;
                    DelegateInfo.RA        = CpuThreadState.RA;
                    DelegateInfo.Thread    = HleThreadManager.Current;

#if false
//#if true
                    Console.Error.WriteLine("HleModuleManager: " + DelegateInfo);
#endif

                    if (DelegateInfo.ModuleImportName != "Kernel_Library")
                    {
                        LastCalledCallbacks.Enqueue(DelegateInfo);
                        if (HleThreadManager != null && HleThreadManager.Current != null)
                        {
                            HleThreadManager.Current.LastCalledHleFunction = DelegateInfo;
                        }
                    }
                    if (LastCalledCallbacks.Count > 10)
                    {
                        LastCalledCallbacks.Dequeue();
                    }
                }
                DelegateInfo.Action(CpuThreadState);
                CpuThreadState.PC = CpuThreadState.RA;
            });
#endif
        }
Esempio n. 2
0
        void RegisterModuleSyscall <TType>(int SyscallCode, string FunctionName) where TType : HleModuleHost
        {
            var Delegate = HleState.ModuleManager.GetModuleDelegate <TType>(FunctionName);

            CpuProcessor.RegisterNativeSyscall(SyscallCode, (Code, CpuThreadState) =>
            {
                Delegate(CpuThreadState);
            });
        }
Esempio n. 3
0
        public void SyscallTest()
        {
            var Events = new List <int>();

            Processor.RegisterNativeSyscall(1, () =>
            {
                Events.Add(1);
            });

            Processor.RegisterNativeSyscall(1000, () =>
            {
                Events.Add(1000);
            });

            ExecuteAssembly(@"
				syscall 1
				syscall 1000
			"            );

            Assert.AreEqual("[1,1000]", Events.ToJson());
        }
Esempio n. 4
0
        void RegisterModuleSyscall <TType>(int syscallCode, string functionName) where TType : HleModuleHost
        {
            var Delegate = ModuleManager.GetModuleDelegate <TType>(functionName);

            CpuProcessor.RegisterNativeSyscall(syscallCode, (cpuThreadState, code) => { Delegate(cpuThreadState); });
        }