示例#1
0
        /// <summary>
        /// Add a NID loaded from a module.
        /// </summary>
        /// <param name="module">     the loaded module </param>
        /// <param name="moduleName"> the module name </param>
        /// <param name="nid">        the nid </param>
        /// <param name="address">    the address of the nid </param>
        /// <param name="variableExport"> coming from a function or variable export </param>
        public virtual void addModuleNid(SceModule module, string moduleName, int nid, int address, bool variableExport)
        {
            address &= Memory.addressMask;

            NIDInfo info = getNIDInfoByNid(moduleName, nid);

            if (info != null)
            {
                // Only modules from flash0 are allowed to overwrite NIDs from syscalls
                if (string.ReferenceEquals(module.pspfilename, null) || !module.pspfilename.StartsWith("flash0:", StringComparison.Ordinal))
                {
                    return;
                }
                if (log.InfoEnabled)
                {
                    Console.WriteLine(string.Format("NID {0}[0x{1:X8}] at address 0x{2:X8} from module '{3}' overwriting an HLE syscall", info.Name, nid, address, moduleName));
                }
                info.overwrite(address);
                addressMap[address] = info;
            }
            else
            {
                info = new NIDInfo(nid, address, moduleName, variableExport);

                addNIDInfo(info);
            }
        }
示例#2
0
        private void removeNIDInfo(NIDInfo info)
        {
            IDictionary <int, NIDInfo> moduleMap = moduleNidMap[info.ModuleName];

            if (moduleMap != null)
            {
                moduleMap.Remove(info.Nid);
                if (moduleMap.Count == 0)
                {
                    moduleNidMap.Remove(info.ModuleName);
                }
            }

            // For HLE NID's, do not trust the module names defined in pspsharp, use only the NID.
            if (!info.ValidModuleName)
            {
                nidMap.Remove(info.Nid);
            }

            if (info.hasAddress())
            {
                addressMap.Remove(info.Address);
            }

            if (info.hasSyscall())
            {
                syscallMap.Remove(info.Syscall);
            }

            if (info.hasName())
            {
                nameMap.Remove(info.Name);
            }
        }
示例#3
0
        private void addNIDInfo(NIDInfo info)
        {
            IDictionary <int, NIDInfo> moduleMap = moduleNidMap[info.ModuleName];

            if (moduleMap == null)
            {
                moduleMap = new Dictionary <int, NIDInfo>();
                moduleNidMap[info.ModuleName] = moduleMap;
            }
            moduleMap[info.Nid] = info;

            // For HLE NID's, do not trust the module names defined in pspsharp, use only the NID.
            if (!info.ValidModuleName)
            {
                nidMap[info.Nid] = info;
            }

            if (info.hasAddress())
            {
                addressMap[info.Address] = info;
            }

            if (info.hasSyscall())
            {
                syscallMap[info.Syscall] = info;
            }

            if (info.hasName())
            {
                nameMap[info.Name] = info;
            }
        }
示例#4
0
        public virtual bool isVariableExportByAddress(int address)
        {
            NIDInfo info = getNIDInfoByAddress(address);

            if (info == null)
            {
                return(false);
            }

            return(info.VariableExport);
        }
示例#5
0
        public virtual int getNidByAddress(int address)
        {
            NIDInfo info = getNIDInfoByAddress(address);

            if (info == null)
            {
                return(0);
            }

            return(info.Nid);
        }
示例#6
0
        public virtual int getNidBySyscall(int syscall)
        {
            NIDInfo info = getNIDInfoBySyscall(syscall);

            if (info == null)
            {
                return(0);
            }

            return(info.Nid);
        }
示例#7
0
        public virtual string getNameBySyscall(int syscall)
        {
            NIDInfo info = getNIDInfoBySyscall(syscall);

            if (info == null)
            {
                return(null);
            }

            return(info.Name);
        }
示例#8
0
        public virtual int getAddressByName(string name)
        {
            NIDInfo info = getNIDInfoByName(name);

            if (info == null || !info.hasAddress())
            {
                return(0);
            }

            return(info.Address);
        }
示例#9
0
        public virtual int getAddressBySyscall(int syscall)
        {
            NIDInfo info = getNIDInfoBySyscall(syscall);

            if (info == null || !info.hasAddress())
            {
                return(0);
            }

            return(info.Address);
        }
示例#10
0
 public virtual void unloadNid(int nid)
 {
     // Search for the NID in all the modules
     foreach (string moduleName in moduleNidMap.Keys)
     {
         NIDInfo info = getNIDInfoByNid(moduleName, nid);
         if (info != null)
         {
             info.Loaded = false;
         }
     }
 }
示例#11
0
        public virtual int getSyscallByNid(int nid, string moduleName)
        {
            NIDInfo info = getNIDInfoByNid(moduleName, nid);

            if (info == null || !info.hasSyscall())
            {
                return(-1);
            }

            if (!string.ReferenceEquals(moduleName, null) && !info.isFromModule(moduleName))
            {
                Console.WriteLine(string.Format("Trying to resolve {0} from module '{1}'", info, moduleName));
            }

            return(info.Syscall);
        }
示例#12
0
        private NIDInfo getNIDInfoByNid(string moduleName, int nid)
        {
            NIDInfo info = null;

            IDictionary <int, NIDInfo> moduleMap = moduleNidMap[moduleName];

            if (moduleMap != null)
            {
                info = moduleMap[nid];
            }

            // For HLE NID's, do not trust the module names defined in pspsharp, use only the NID.
            if (info == null)
            {
                info = nidMap[nid];
            }

            return(info);
        }
示例#13
0
        /// <summary>
        /// Add a NID from an HLE syscall.
        /// </summary>
        /// <param name="nid">             the nid </param>
        /// <param name="name">            the function name </param>
        /// <param name="moduleName">      the module name </param>
        /// <param name="firmwareVersion"> the firmware version defining this nid </param>
        /// <returns>                true if the NID has been added
        ///                        false if the NID was already added </returns>
        public virtual bool addHLENid(int nid, string name, string moduleName, int firmwareVersion)
        {
            NIDInfo info = getNIDInfoByNid(moduleName, nid);

            if (info != null)
            {
                // This NID is already added, verify that we are trying to use the same data
                if (!name.Equals(info.Name) || !moduleName.Equals(info.ModuleName) || firmwareVersion != info.FirmwareVersion)
                {
                    return(false);
                }
                return(true);
            }

            int syscall = NewSyscallNumber;

            info = new NIDInfo(nid, syscall, name, moduleName, firmwareVersion);

            addNIDInfo(info);

            return(true);
        }