Exemplo n.º 1
0
        public void ImportModules()
        {
            foreach (var ModuleImports in ModulesImports)
            {
                HleModuleHost HleModuleHost = null;
                try
                {
                    HleModuleHost = ModuleManager.GetModuleByName(ModuleImports.Name);
                }
                catch (Exception Exception)
                {
                    //Logger.Error(Exception);
                    Console.Error.WriteLine(Exception);
                }

                // Can't use a host module. Try to use a Guest module.
                if (HleModuleHost == null)
                {
                    var HleModuleGuest =
                        ModuleManager.LoadedGuestModules.FirstOrDefault(ModuleExports =>
                                                                        ModuleExports.Name == ModuleImports.Name);
                    if (HleModuleGuest != null)
                    {
                        HleModuleGuest.ExportModules(this);
                        continue;
                    }
                }

                Logger.Info("'{0}' - {1}", ModuleImports.Name,
                            HleModuleHost != null ? HleModuleHost.ModuleLocation : "?");
                foreach (var Function in ModuleImports.Functions)
                {
                    var NID         = Function.Key;
                    var CallAddress = Function.Value.Address;

                    var DefaultEntry = new HleFunctionEntry()
                    {
                        NID         = 0x00000000,
                        Name        = CStringFormater.Sprintf("__<unknown:0x%08X>", (int)NID),
                        Description = "Unknown",
                        Module      = null,
                        ModuleName  = ModuleImports.Name,
                    };
                    var FunctionEntry = HleModuleHost?.EntriesByNID.GetOrDefault(NID, DefaultEntry) ?? DefaultEntry;
                    FunctionEntry.NID = NID;
                    //var Delegate = Module.DelegatesByNID.GetOrDefault(NID, null);

                    LinkFunction(CallAddress, FunctionEntry);
                }
            }
        }
Exemplo n.º 2
0
        protected Action<CpuThreadState> CreateDelegate(HleModuleManager ModuleManager, HleModuleHost Module, uint NID, string ModuleImportName, string NIDName)
        {
            Action<CpuThreadState> Callback = null;
            if (Module != null)
            {
                if (Module.EntriesByNID.ContainsKey(NID))
                {
                    Callback = Module.EntriesByNID[NID].Delegate;
                }
                else
                {
                    Callback = null;
                }
            }

            return (CpuThreadState) =>
            {
                if (Callback == null)
                {
                    if (CpuThreadState.CpuProcessor.CpuConfig.DebugSyscalls)
                    {
                        Console.WriteLine(
                            "Thread({0}:'{1}'):{2}:{3}",
                            HleThreadManager.Current.Id,
                            HleThreadManager.Current.Name,
                            ModuleImportName, NIDName
                        );
                    }
                    throw (new NotImplementedException("Not Implemented '" + String.Format("{0}:{1}", ModuleImportName, NIDName) + "'"));
                }
                else
                {
                    Callback(CpuThreadState);
                }
            };
        }
        protected Action <CpuThreadState> CreateDelegate(HleModuleManager ModuleManager, HleModuleHost Module, uint NID,
                                                         string ModuleImportName, string NIDName)
        {
            Action <CpuThreadState> Callback = null;

            if (Module != null)
            {
                if (Module.EntriesByNID.ContainsKey(NID))
                {
                    Callback = Module.EntriesByNID[NID].Delegate;
                }
                else
                {
                    Callback = null;
                }
            }

            return((CpuThreadState) =>
            {
                if (Callback == null)
                {
                    if (CpuThreadState.CpuProcessor.CpuConfig.DebugSyscalls)
                    {
                        Console.WriteLine(
                            "Thread({0}:'{1}'):{2}:{3}",
                            HleThreadManager.Current.Id,
                            HleThreadManager.Current.Name,
                            ModuleImportName, NIDName
                            );
                    }
                    throw (new NotImplementedException("Not Implemented '" +
                                                       $"{ModuleImportName}:{NIDName}" + "'"));
                }
                else
                {
                    Callback(CpuThreadState);
                }
            });
        }
Exemplo n.º 4
0
        protected Action<CpuThreadState> CreateDelegate(HleModuleManager ModuleManager, HleModuleHost Module, uint NID, string ModuleImportName, string NIDName)
        {
            Action<CpuThreadState> Callback = null;
            if (Module != null)
            {
                Callback = Module.DelegatesByNID.GetOrDefault(NID, null);
            }

            return (CpuThreadState) =>
            {
                if (Callback == null)
                {
                    if (CpuThreadState.CpuProcessor.PspConfig.DebugSyscalls)
                    {
                        Console.WriteLine(
                            "Thread({0}:'{1}'):{2}:{3}",
                            PspEmulatorContext.GetInstance<HleThreadManager>().Current.Id,
                            PspEmulatorContext.GetInstance<HleThreadManager>().Current.Name,
                            ModuleImportName, NIDName
                        );
                    }
                    throw (new NotImplementedException("Not Implemented '" + String.Format("{0}:{1}", ModuleImportName, NIDName) + "'"));
                }
                else
                {
                    Callback(CpuThreadState);
                }
            };
        }