public int sceKernelLoadModule(string Path, uint Flags, SceKernelLMOption *SceKernelLMOption) { return(sceKernelLoadModuleWithStream( () => { return HleIoManager.HleIoWrapper.Open(Path, Vfs.HleIoFlags.Read, Vfs.SceMode.All); }, Path, Flags, SceKernelLMOption)); }
public int sceKernelLoadModuleWithStream(Func <Stream> GetStreamAction, string Path, uint Flags, SceKernelLMOption *SceKernelLMOption) { var Module = InjectContext.NewInstance <HleModuleGuest>(); try { Path = Path.ToLowerInvariant(); if (Path.StartsWith(@"disc0:/PSP_GAME/USRDIR/kmodule")) { throw (new Exception("Ignore kmodule!")); } if ( Path.EndsWith(@"/libatrac3plus.prx") || Path.EndsWith(@"/videocodec.prx") || Path.EndsWith(@"/audiocodec.prx") || Path.EndsWith(@"/mpeg.prx") || Path.EndsWith(@"/mpegbase.prx") || Path.EndsWith(@"/libfont.prx") || false) { Logger.Warning("Ignore {0}!", Path); throw (new Exception("Ignore " + Path + "!")); //var ModuleId = Modules.Create(new HleModule()); //Module.ID = ModuleId; //return ModuleId; } var ModuleStream = GetStreamAction(); var HleModuleGuest = Loader.LoadModule( ModuleStream, new PspMemoryStream(Memory), MemoryManager.GetPartition(MemoryPartitions.User), ModuleManager, "", moduleName: Path, isMainModule: false ); var SceModulePartition = MemoryManager.GetPartition(MemoryPartitions.Kernel0).Allocate(sizeof(SceModule)); var SceModulePtr = (SceModule *)Memory.PspAddressToPointerSafe(SceModulePartition.Low, Marshal.SizeOf(typeof(SceModule))); SceModulePtr->Attributes = HleModuleGuest.ModuleInfo.ModuleAtributes; SceModulePtr->Version = HleModuleGuest.ModuleInfo.ModuleVersion; SceModulePtr->ModuleName = HleModuleGuest.ModuleInfo.Name; SceModulePtr->GP = HleModuleGuest.ModuleInfo.Gp; SceModulePtr->ent_top = HleModuleGuest.ModuleInfo.ExportsStart; SceModulePtr->ent_size = HleModuleGuest.ModuleInfo.ExportsEnd - HleModuleGuest.ModuleInfo.ExportsStart; SceModulePtr->stub_top = HleModuleGuest.ModuleInfo.ImportsStart; SceModulePtr->stub_size = HleModuleGuest.ModuleInfo.ImportsEnd - HleModuleGuest.ModuleInfo.ImportsStart; Module.ModuleInfo = HleModuleGuest.ModuleInfo; Module.InitInfo = HleModuleGuest.InitInfo; Module.Loaded = true; Module.SceModuleStructPartition = SceModulePartition; //Loader.InitInfo.GP } catch (Exception Exception) { Console.WriteLine(Exception); Module.Loaded = false; } var ModuleId = Modules.Create(Module); Module.ID = ModuleId; return(ModuleId); }