Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        private void _UpdateModuleImports()
        {
            //var BaseMemoryStream = ElfLoader.MemoryStream.SliceWithLength(BaseAddress);
            var importsStream = ElfLoader.MemoryStream.SliceWithBounds(HleModuleGuest.ModuleInfo.ImportsStart,
                                                                       HleModuleGuest.ModuleInfo.ImportsEnd);
            //Console.WriteLine("ImportsStream.Length: {0}", ImportsStream.Length);
            var moduleImports = importsStream.ReadStructVectorUntilTheEndOfStream <ElfPsp.ModuleImport>();

            Logger.Info("BASE ADDRESS: 0x{0:X}", BaseAddress);

            Logger.Info("Imports ({0:X8}-{1:X8}):", HleModuleGuest.ModuleInfo.ImportsStart,
                        HleModuleGuest.ModuleInfo.ImportsEnd);

            foreach (var moduleImport in moduleImports)
            {
                var moduleImportName = "INVALID";
                try
                {
                    moduleImportName = ElfLoader.MemoryStream.ReadStringzAt(moduleImport.Name);
                }
                catch (Exception e)
                {
                    Console.Error.WriteLine(e);
                }

                var hleModuleImports = new HleModuleImports
                {
                    Name    = moduleImportName,
                    Flags   = moduleImport.Flags,
                    Version = moduleImport.Version
                };

                var nidStreamReader = new BinaryReader(ElfLoader.MemoryStream.SliceWithLength(moduleImport.NidAddress,
                                                                                              moduleImport.FunctionCount * sizeof(uint)));

                for (var n = 0; n < moduleImport.FunctionCount; n++)
                {
                    var nid         = nidStreamReader.ReadUInt32();
                    var callAddress = (uint)(moduleImport.CallAddress + n * 8);

                    hleModuleImports.Functions[nid] = new HleModuleImportsExports.Entry()
                    {
                        Address = callAddress
                    };
                }

                HleModuleGuest.ModulesImports.Add(hleModuleImports);
            }

            HleModuleGuest.ImportModules();

            //Console.ReadKey();
        }
Esempio n. 2
0
        /// <summary>
        /// 
        /// </summary>
        private void _UpdateModuleImports()
        {
            var BaseMemoryStream = ElfLoader.MemoryStream.SliceWithLength(BaseAddress);
            var ImportsStream = BaseMemoryStream.SliceWithBounds(HleModuleGuest.ModuleInfo.ImportsStart, HleModuleGuest.ModuleInfo.ImportsEnd);
            var ModuleImports = ImportsStream.ReadStructVectorUntilTheEndOfStream<ElfPsp.ModuleImport>();

            Console.WriteLine("BASE ADDRESS: 0x{0:X}", BaseAddress);

            Console.WriteLine("Imports:");

            foreach (var ModuleImport in ModuleImports)
            {
                String ModuleImportName = "INVALID";
                try { ModuleImportName = ElfLoader.MemoryStream.ReadStringzAt(ModuleImport.Name); } catch { }

                var HleModuleImports = new HleModuleImports();
                HleModuleImports.Name = ModuleImportName;
                HleModuleImports.Flags = ModuleImport.Flags;
                HleModuleImports.Version = ModuleImport.Version;

                var NidStreamReader = new BinaryReader(ElfLoader.MemoryStream.SliceWithLength(ModuleImport.NidAddress, ModuleImport.FunctionCount * sizeof(uint)));

                for (int n = 0; n < ModuleImport.FunctionCount; n++)
                {
                    var NID = NidStreamReader.ReadUInt32();
                    var CallAddress = (uint)(ModuleImport.CallAddress + n * 8);

                    HleModuleImports.Functions[NID] = new HleModuleImportsExports.Entry() { Address = CallAddress };
                }

                HleModuleGuest.ModulesImports.Add(HleModuleImports);
            }

            HleModuleGuest.ImportModules();

            //Console.ReadKey();
        }