public virtual int sceKernelLoadExecBufferVSHUsbWlan(int bufferSize, TPointer bufferAddr, TPointer param) { SceKernelLoadExecVSHParam loadExecParam = new SceKernelLoadExecVSHParam(); loadExecParam.read(param); int argSize = 0; int argAddr = 0; if (param.NotNull) { argSize = loadExecParam.args; argAddr = loadExecParam.argp; Console.WriteLine(string.Format("sceKernelLoadExecBufferVSHUsbWlan param={0}", loadExecParam)); } //if (log.DebugEnabled) { Console.WriteLine(string.Format("sceKernelLoadExecBufferVSHUsbWlan buffAddr: {0}", Utilities.getMemoryDump(bufferAddr.Address, System.Math.Min(bufferSize, 1024)))); } sbyte[] moduleBytes = bufferAddr.getArray8(bufferSize); ByteBuffer moduleBuffer = ByteBuffer.wrap(moduleBytes); return(Modules.LoadExecForUserModule.hleKernelLoadExec(moduleBuffer, argSize, argAddr, null, null)); }
public virtual int sceKernelExitVSHVSH_660(TPointer param) { SceKernelLoadExecVSHParam loadExecVSHParam = new SceKernelLoadExecVSHParam(); loadExecVSHParam.read(param); if (param.NotNull) { Console.WriteLine(string.Format("sceKernelExitVSHVSH_660 param={0}", loadExecVSHParam)); } return(0); }
public virtual int sceKernelExitVSHKernel(TPointer param) { SceKernelLoadExecVSHParam loadExecVSHParam = new SceKernelLoadExecVSHParam(); loadExecVSHParam.read(param); // Test in real PSP in "Hatsune Miku Project Diva Extend" chinese patched version, same effect as sceKernelExitGame if (param.NotNull) { Console.WriteLine(string.Format("sceKernelExitVSHKernel param={0}", loadExecVSHParam)); } Emulator.PauseEmu(); RuntimeContext.reset(); Modules.ThreadManForUserModule.stop(); return(0); }
public virtual int sceKernelLoadExecVSHMs2(PspString filename, TPointer param) { SceKernelLoadExecVSHParam loadExecVSHParam = new SceKernelLoadExecVSHParam(); loadExecVSHParam.read(param); //if (log.DebugEnabled) { Console.WriteLine(string.Format("sceKernelLoadExecVSHMs2 param: {0}", loadExecVSHParam)); if (loadExecVSHParam.args > 0) { Console.WriteLine(string.Format("sceKernelLoadExecVSHMs2 argp: {0}", Utilities.getMemoryDump(loadExecVSHParam.argp, loadExecVSHParam.args))); } if (loadExecVSHParam.vshmainArgsSize > 0) { Console.WriteLine(string.Format("sceKernelLoadExecVSHMs2 vshmainArgs: {0}", Utilities.getMemoryDump(loadExecVSHParam.vshmainArgs, loadExecVSHParam.vshmainArgsSize))); } } if (loadExecVSHParam.args > 0 && loadExecVSHParam.argp != 0) { string arg = Utilities.readStringNZ(loadExecVSHParam.argp, loadExecVSHParam.args); if (arg.StartsWith("disc0:", StringComparison.Ordinal)) { Modules.IoFileMgrForUserModule.setfilepath("disc0/"); } else if (arg.StartsWith("ms0:", StringComparison.Ordinal)) { int dirIndex = arg.LastIndexOf('/'); if (dirIndex >= 0) { Modules.IoFileMgrForUserModule.setfilepath(Settings.Instance.getDirectoryMapping("ms0") + arg.Substring(4, dirIndex - 4)); } } } return(Modules.LoadExecForUserModule.hleKernelLoadExec(filename, loadExecVSHParam.args, loadExecVSHParam.argp)); }
public virtual bool loadAndRun() { if (!enableReboot) { return(false); } Memory mem = Memory.Instance; StringBuilder localFileName = new StringBuilder(); IVirtualFileSystem vfs = Modules.IoFileMgrForUserModule.getVirtualFileSystem(rebootFileName, localFileName); if (vfs == null) { return(false); } IVirtualFile vFile = vfs.ioOpen(localFileName.ToString(), IoFileMgrForUser.PSP_O_RDONLY, 0); if (vFile == null) { return(false); } int rebootFileLength = (int)vFile.Length(); if (rebootFileLength <= 0) { return(false); } SceModule rebootModule = new SceModule(true); rebootModule.modname = Name; rebootModule.pspfilename = rebootFileName; rebootModule.baseAddress = rebootBaseAddress; rebootModule.text_addr = rebootBaseAddress; rebootModule.text_size = rebootFileLength; rebootModule.data_size = 0; rebootModule.bss_size = 0x26B80; const bool fromSyscall = false; Emulator.Instance.initNewPsp(fromSyscall); Emulator.Instance.ModuleLoaded = true; HLEModuleManager.Instance.startModules(fromSyscall); Modules.ThreadManForUserModule.Initialise(rebootModule, rebootModule.baseAddress, 0, rebootModule.pspfilename, -1, 0, fromSyscall); int rebootMemSize = rebootModule.text_size + rebootModule.data_size + rebootModule.bss_size; SysMemInfo rebootMemInfo = Modules.SysMemUserForUserModule.malloc(VSHELL_PARTITION_ID, "reboot", PSP_SMEM_Addr, rebootMemSize, rebootModule.text_addr); if (rebootMemInfo == null) { return(false); } TPointer rebootBinAddr = new TPointer(mem, rebootBaseAddress); int readLength = vFile.ioRead(rebootBinAddr, rebootFileLength); vFile.ioClose(); if (readLength != rebootFileLength) { return(false); } markMMIO(); addFunctionNames(rebootModule); SysMemInfo rebootParamInfo = Modules.SysMemUserForUserModule.malloc(VSHELL_PARTITION_ID, "reboot-parameters", PSP_SMEM_Addr, 0x10000, rebootParamAddress); TPointer sceLoadCoreBootInfoAddr = new TPointer(mem, rebootParamInfo.addr); SceLoadCoreBootInfo sceLoadCoreBootInfo = new SceLoadCoreBootInfo(); sceLoadCoreBootInfoAddr.clear(0x1000 + 0x1C000 + 0x380); TPointer startAddr = new TPointer(sceLoadCoreBootInfoAddr, 0x1000); TPointer sceKernelLoadExecVSHParamAddr = new TPointer(startAddr, 0x1C000); TPointer loadModeStringAddr = new TPointer(sceKernelLoadExecVSHParamAddr, 48); loadModeStringAddr.StringZ = "vsh"; SceKernelLoadExecVSHParam sceKernelLoadExecVSHParam = new SceKernelLoadExecVSHParam(); sceKernelLoadExecVSHParamAddr.setValue32(48); sceKernelLoadExecVSHParam.flags = 0x10000; sceKernelLoadExecVSHParam.keyAddr = loadModeStringAddr; sceKernelLoadExecVSHParam.write(sceKernelLoadExecVSHParamAddr); sceLoadCoreBootInfo.memBase = MemoryMap.START_KERNEL; sceLoadCoreBootInfo.memSize = MemoryMap.SIZE_RAM; sceLoadCoreBootInfo.startAddr = startAddr; sceLoadCoreBootInfo.endAddr = new TPointer(sceKernelLoadExecVSHParamAddr, 0x380); sceLoadCoreBootInfo.modProtId = -1; sceLoadCoreBootInfo.modArgProtId = -1; sceLoadCoreBootInfo.model = Model.Model; sceLoadCoreBootInfo.dipswLo = Modules.KDebugForKernelModule.sceKernelDipswLow32(); sceLoadCoreBootInfo.dipswHi = Modules.KDebugForKernelModule.sceKernelDipswHigh32(); sceLoadCoreBootInfo.unknown72 = MemoryMap.END_USERSPACE | unchecked ((int)0x80000000); // Must be larger than 0x89000000 + size of pspbtcnf.bin file sceLoadCoreBootInfo.cpTime = Modules.KDebugForKernelModule.sceKernelDipswCpTime(); sceLoadCoreBootInfo.write(sceLoadCoreBootInfoAddr); SceKernelThreadInfo rootThread = Modules.ThreadManForUserModule.getRootThread(null); if (rootThread != null) { rootThread.cpuContext._a0 = sceLoadCoreBootInfoAddr.Address; rootThread.cpuContext._a1 = sceKernelLoadExecVSHParamAddr.Address; rootThread.cpuContext._a2 = SCE_INIT_APITYPE_KERNEL_REBOOT; rootThread.cpuContext._a3 = Modules.SysMemForKernelModule.sceKernelGetInitialRandomValue(); } // This will set the Log4j MDC values for the root thread Emulator.Scheduler.addAction(new SetLog4jMDC()); //if (log.DebugEnabled) { Console.WriteLine(string.Format("sceReboot arg0={0}, arg1={1}", sceLoadCoreBootInfoAddr, sceKernelLoadExecVSHParamAddr)); } return(true); }