public virtual int mp4msv_3C2183C7(int unknown, TPointer addr) { if (addr.NotNull) { // addr is pointing to five 32-bit values (20 bytes) Console.WriteLine(string.Format("mp4msv_3C2183C7 unknown values: {0}", Utilities.getMemoryDump(addr.Address, 20, 4, 20))); } // mp4msv_3C2183C7 is called by sceMp4Init Modules.sceMp4Module.hleMp4Init(); return(0); }
public virtual int sceSdRemoveValue(TPointer ctx2Addr, TPointer data, int size) { SAVEDATA.SD_Ctx1 ctx = new SAVEDATA.SD_Ctx1(); ctx.read(ctx2Addr); sbyte[] bytes = new sbyte[size]; Utilities.readBytes(data.Address, size, bytes, 0); int result = crypto.SAVEDATAEngine.hleSdRemoveValue(ctx, bytes, size); ctx.write(ctx2Addr); return(result); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public bool pollRecv(pspsharp.HLE.TPointer srcMacAddr, pspsharp.HLE.TPointer16 portAddr, pspsharp.HLE.TPointer data, pspsharp.HLE.TPointer32 dataLengthAddr, pspsharp.HLE.kernel.types.SceKernelThreadInfo thread) throws java.io.IOException public virtual bool pollRecv(TPointer srcMacAddr, TPointer16 portAddr, TPointer data, TPointer32 dataLengthAddr, SceKernelThreadInfo thread) { int Length = dataLengthAddr.getValue(); bool completed = false; if (rcvdMessages.Count == 0) { update(); } if (rcvdMessages.Count > 0) { AdhocBufferMessage bufferMessage = rcvdMessages.First.Value; if (Length < bufferMessage.Length) { // Buffer is too small to contain all the available data. // Return the buffer size that would be required. dataLengthAddr.setValue(bufferMessage.Length); setReturnValue(thread, SceKernelErrors.ERROR_NET_BUFFER_TOO_SMALL); } else { // Copy the data already received dataLengthAddr.setValue(bufferMessage.Length); Memory.Instance.memcpy(data.Address, buffer.addr + bufferMessage.offset, bufferMessage.Length); if (srcMacAddr != null && !srcMacAddr.Null) { bufferMessage.macAddress.write(srcMacAddr); } if (portAddr != null && portAddr.NotNull) { portAddr.Value = bufferMessage.port; } removeFirstReceivedMessage(); //if (log.DebugEnabled) { Console.WriteLine(string.Format("Returned received data: {0:D} bytes from {1} on port {2:D}", dataLengthAddr.getValue(), bufferMessage.macAddress, portAddr.Value)); if (log.TraceEnabled) { log.trace(string.Format("Returned data: {0}", Utilities.getMemoryDump(data.Address, dataLengthAddr.getValue()))); } } setReturnValue(thread, 0); } completed = true; } return(completed); }
public virtual int sceUriUnescape(TPointer unescapedAddr, TPointer32 unescapedLengthAddr, int unescapedBufferLength, TPointer source) { IMemoryReader memoryReader = MemoryReader.getMemoryReader(source.Address, 1); IMemoryWriter memoryWriter = null; if (unescapedAddr.NotNull) { memoryWriter = MemoryWriter.getMemoryWriter(unescapedAddr.Address, unescapedBufferLength, 1); } int unescapedLength = 0; while (true) { int c = memoryReader.readNext(); if (c == 0) { if (unescapedAddr.NotNull) { if (unescapedLength < unescapedBufferLength) { memoryWriter.writeNext(c); } } unescapedLength++; break; } if (unescapedAddr.NotNull) { if (unescapedLength + 1 > unescapedBufferLength) { break; } if (c == '%') { int hex1 = memoryReader.readNext(); int hex2 = memoryReader.readNext(); c = (getHexValue(hex1) << 4) + getHexValue(hex2); } // Remark: '+' sign is not unescaped to ' ' by this function memoryWriter.writeNext(c); } unescapedLength++; } if (memoryWriter != null) { memoryWriter.flush(); } unescapedLengthAddr.setValue(unescapedLength); return(0); }
public virtual int sceUsbMicInputBlocking(int maxSamples, int frequency, TPointer buffer) { if (maxSamples <= 0 || (maxSamples & 0x3F) != 0) { return(SceKernelErrors.ERROR_USBMIC_INVALID_MAX_SAMPLES); } if (frequency != 44100 && frequency != 22050 && frequency != 11025) { return(SceKernelErrors.ERROR_USBMIC_INVALID_FREQUENCY); } return(Modules.sceAudioModule.hleAudioInputBlocking(maxSamples, frequency, buffer)); }
public virtual int sceUmdGetDiscInfo(TPointer pspUmdInfoAddr) { pspUmdInfo umdInfo = new pspUmdInfo(); umdInfo.read(pspUmdInfoAddr); if (umdInfo.@sizeof() != 8) { return(SceKernelErrors.ERROR_ERRNO_INVALID_ARGUMENT); } umdInfo.type = pspUmdInfo.PSP_UMD_TYPE_GAME; umdInfo.write(pspUmdInfoAddr); return(0); }
public override int ioWrite(TPointer inputPointer, int inputLength) { try { Utilities.write(file, inputPointer.Address, inputLength); } catch (IOException e) { Console.WriteLine("ioWrite", e); return(IO_ERROR); } return(inputLength); }
/* * Perform the ioRead in PSP memory using the ioRead for a byte array. */ protected internal virtual int ioReadBuf(TPointer outputPointer, int outputLength) { if (outputLength <= 0) { return(0); } sbyte[] outputBuffer = new sbyte[outputLength]; int readLength = ioRead(outputBuffer, 0, outputLength); Utilities.writeBytes(outputPointer.Address, readLength, outputBuffer, 0); return(readLength); }
public virtual int sceCodepage_driver_855C5C2E(TPointer destAddr, int destLength, string src) { sbyte[] destBytes = src.GetBytes(charset16); int Length = System.Math.Min(destLength, destBytes.Length); destAddr.setArray(destBytes, Length); // Add trailing "\0\0" if (Length <= destLength - 2) { destAddr.clear(Length, 2); } return(src.Length); }
public virtual int sceVideocodecSetMemory(TPointer buffer, int type) { int unknown1 = buffer.getValue32(64); int unknown2 = buffer.getValue32(68); int unknown3 = buffer.getValue32(72); int unknown4 = buffer.getValue32(76); //if (log.DebugEnabled) { Console.WriteLine(string.Format("sceVideocodecSetMemory unknown1=0x{0:X8}, unknown2=0x{1:X8}, unknown3=0x{2:X8}, unknown4=0x{3:X8}", unknown1, unknown2, unknown3, unknown4)); } return(0); }
public virtual int init(TPointer ctxAddr) { ctxAddr.setValue32(0, part1); ctxAddr.setValue32(4, part2); ctxAddr.setValue32(8, part3); ctxAddr.setValue32(12, part4); ctxAddr.setValue32(16, part5); ctxAddr.setValue16(20, tmpBytesRemaining); ctxAddr.setValue16(22, tmpBytesCalculated); ctxAddr.setValue64(24, fullDataSize); ctxAddr.setArray(32, buf, 64); return(0); }
public virtual int strcat(TPointer destAddr, TPointer srcAddr) { if (destAddr.Null || srcAddr.Null) { return(0); } int dstLength = AbstractNativeCodeSequence.getStrlen(destAddr.Address); int srcLength = AbstractNativeCodeSequence.getStrlen(srcAddr.Address); destAddr.memcpy(dstLength, srcAddr.Address, srcLength + 1); return(destAddr.Address); }
public virtual int sceNetMFreem(TPointer messageAddr) { SceNetIfMessage message = new SceNetIfMessage(); while (messageAddr.NotNull) { message.read(messageAddr); int nextMessage = message.nextDataAddr; sceNetFreeInternal(messageAddr.Address); messageAddr = new TPointer(messageAddr.Memory, nextMessage); } return(0); }
public virtual int sceAudioOutput(int channel, int vol, TPointer pvoid_buf) { if (pspPCMChannels[channel].OutputBlocking) { return(SceKernelErrors.ERROR_AUDIO_CHANNEL_BUSY); } changeChannelVolume(pspPCMChannels[channel], vol, vol); int result = doAudioOutput(pspPCMChannels[channel], pvoid_buf.Address); Modules.ThreadManForUserModule.hleRescheduleCurrentThread(); return(result); }
public virtual int sceRtcFormatRFC3339LocalTime(TPointer resultString, TPointer64 srcPtr) { DateTime date = getDateFromTick(srcPtr.Value); string result = formatRFC3339(date); //if (log.DebugEnabled) { Console.WriteLine(string.Format("sceRtcFormatRFC3339LocalTime src={0:D}, returning '{1}'", srcPtr.Value, result)); } resultString.StringZ = result; return(0); }
public virtual int sceNpGetUserProfile(TPointer buffer) { // The first 20 bytes are the onlineId buffer.setStringNZ(0, 20, OnlineId); // The next 16 bytes are unknown buffer.clear(20, 16); // The next 127 bytes are the avatar URL buffer.setStringNZ(36, 128, AvatarUrl); // The next 52 bytes are unknown buffer.clear(164, 52); // Total size 216 bytes return(0); }
public virtual int sceSfmt19937InitByArray(TPointer sfmtctx, TPointer seeds, int seedsLength) { // Read and store the seeds. int[] s = new int[seedsLength]; for (int i = 0; i < seedsLength; i++) { s[i] = seeds.getValue32(); } // Assign and store the current context. sfmt19937Ctx ctx = new sfmt19937Ctx(sfmtctx, s); ctxMap[sfmtctx] = ctx; return(0); }
// SceKernelThreadRunStatus. // Represents a smaller subset of SceKernelThreadInfo containing only the most volatile parts // of the thread (mostly used for debugging). public virtual void writeRunStatus(TPointer pointer) { start(pointer.Memory, pointer.Address); base.write(); write32(status); write32(currentPriority); write32(waitType); write32(waitId); write32(wakeupCount); write64(runClocks); write32(intrPreemptCount); write32(threadPreemptCount); write32(releaseCount); }
public virtual int sceKernelReferLwMutexStatusByID(int uid, TPointer addr) { SceKernelLwMutexInfo info = lwMutexMap[uid]; if (info == null) { Console.WriteLine("sceKernelReferLwMutexStatus unknown UID " + uid.ToString("x")); return(ERROR_KERNEL_LWMUTEX_NOT_FOUND); } info.write(addr); return(0); }
public virtual int sceResmgr_9DC14891(TPointer buffer, int bufferSize, TPointer32 resultLengthAddr) { string result = "release:6.60:\n"; result += "build:5455,0,3,1,0:builder@vsh-build6\n"; result += "system:57716@release_660,0x06060010:\n"; result += "vsh:p6616@release_660,v58533@release_660,20110727:\n"; result += "target:1:WorldWide\n"; buffer.StringZ = result; resultLengthAddr.setValue(result.Length); return(0); }
public virtual int sceAacInit(TPointer parameters, int unknown1, int unknown2, int unknown3) { if (parameters.Null) { return(ERROR_AAC_INVALID_ADDRESS); } long startPos = parameters.getValue64(0); // Audio data frame start position. long endPos = parameters.getValue64(8); // Audio data frame end position. int bufferAddr = parameters.getValue32(16); // Input AAC data buffer. int bufferSize = parameters.getValue32(20); // Input AAC data buffer size. int outputAddr = parameters.getValue32(24); // Output PCM data buffer. int outputSize = parameters.getValue32(28); // Output PCM data buffer size. int freq = parameters.getValue32(32); // Frequency. int reserved = parameters.getValue32(36); // Always null. //if (log.DebugEnabled) { Console.WriteLine(string.Format("sceAacInit parameters: startPos=0x{0:X}, endPos=0x{1:X}, " + "bufferAddr=0x{2:X8}, bufferSize=0x{3:X}, outputAddr=0x{4:X8}, outputSize=0x{5:X}, freq={6:D}, reserved=0x{7:X8}", startPos, endPos, bufferAddr, bufferSize, outputAddr, outputSize, freq, reserved)); } if (bufferAddr == 0 || outputAddr == 0) { return(ERROR_AAC_INVALID_ADDRESS); } if (startPos < 0 || startPos > endPos) { return(ERROR_AAC_INVALID_PARAMETER); } if (bufferSize < 8192 || outputSize < 8192 || reserved != 0) { return(ERROR_AAC_INVALID_PARAMETER); } if (freq != 44100 && freq != 32000 && freq != 48000 && freq != 24000) { return(ERROR_AAC_INVALID_PARAMETER); } int id = FreeAacId; if (id < 0) { return(id); } ids[id].init(bufferAddr, bufferSize, outputAddr, outputSize, startPos, endPos); return(id); }
public virtual void copy(ThreadWaitInfo that) { forever = that.forever; microTimeTimeout = that.microTimeTimeout; micros = that.micros; waitTimeoutAction = that.waitTimeoutAction; waitStateChecker = that.waitStateChecker; ThreadEnd_id = that.ThreadEnd_id; ThreadEnd_returnExitStatus = that.ThreadEnd_returnExitStatus; EventFlag_id = that.EventFlag_id; EventFlag_bits = that.EventFlag_bits; EventFlag_wait = that.EventFlag_wait; EventFlag_outBits_addr = that.EventFlag_outBits_addr; Semaphore_id = that.Semaphore_id; Semaphore_signal = that.Semaphore_signal; Mutex_id = that.Mutex_id; Mutex_count = that.Mutex_count; LwMutex_id = that.LwMutex_id; LwMutex_count = that.LwMutex_count; Io_id = that.Io_id; Io_resultAddr = that.Io_resultAddr; wantedUmdStat = that.wantedUmdStat; MsgPipe_id = that.MsgPipe_id; MsgPipe_address = that.MsgPipe_address; MsgPipe_size = that.MsgPipe_size; MsgPipe_waitMode = that.MsgPipe_waitMode; MsgPipe_resultSize_addr = that.MsgPipe_resultSize_addr; MsgPipe_isSend = that.MsgPipe_isSend; Mbx_id = that.Mbx_id; Mbx_resultAddr = that.Mbx_resultAddr; Fpl_id = that.Fpl_id; Fpl_dataAddr = that.Fpl_dataAddr; Vpl_id = that.Vpl_id; Vpl_size = that.Vpl_size; Vpl_dataAddr = that.Vpl_dataAddr; onUnblockAction = that.onUnblockAction; }
public override int ioRead(TPointer outputPointer, int outputLength) { int remaining = (int)System.Math.Min(outputLength, contents.Length - filePointer); int offset = 0; for (int i = 0; remaining > 0 && i < sections.Length; i++) { int Length = ioRead(sections[i], outputPointer, offset, remaining); filePointer += Length; offset += Length; remaining -= Length; } return(offset); }
public virtual int sceSfmt19937FillArray64(TPointer sfmtctx, TPointer array, int arrayLength) { // Check if the context has been initialized. if (ctxMap.ContainsKey(sfmtctx)) { sfmt19937Ctx ctx = ctxMap[sfmtctx]; ctx.generate(); // Fill the array with the random values. for (int i = 0; i < arrayLength; i++) { array.setValue64(i, ctx.NextRand64); } } return(0); }
public virtual int sceHeapIsAllocatedHeapMemory(TPointer heapAddr, TPointer memAddr) { if (!heapMap.ContainsKey(heapAddr.Address)) { return(SceKernelErrors.ERROR_INVALID_ID); } HeapInfo heapInfo = heapMap[heapAddr.Address]; if (heapInfo.allocatedMemoryChunks.ContainsKey(memAddr.Address)) { return(1); } return(0); }
public virtual int sceVideocodecDecode(TPointer buffer, int type) { if (type != 0 && type != 1) { Console.WriteLine(string.Format("sceVideocodecDecode unknown type=0x{0:X}", type)); return(-1); } int threadUid = Modules.ThreadManForUserModule.CurrentThreadID; Modules.ThreadManForUserModule.hleBlockCurrentThread(SceKernelThreadInfo.JPCSP_WAIT_VIDEO_DECODER); videocodecDecoderThread.trigger(buffer, type, threadUid, Emulator.Clock.microTime() + videocodecDecodeDelay); return(0); }
public virtual int hleKernelSendMsgPipe(int uid, TPointer msgAddr, int size, int waitMode, TPointer32 resultSizeAddr, TPointer32 timeoutAddr, bool doCallbacks, bool poll) { SceKernelMppInfo info = msgMap[uid]; if (info.bufSize != 0 && size > info.bufSize) { Console.WriteLine(string.Format("hleKernelSendMsgPipe illegal size 0x{0:X} max 0x{1:X}", size, info.bufSize)); return(ERROR_KERNEL_ILLEGAL_SIZE); } ThreadManForUser threadMan = Modules.ThreadManForUserModule; if (!trySendMsgPipe(info, msgAddr, size, waitMode, resultSizeAddr)) { if (!poll) { // Failed, but it's ok, just wait a little //if (log.DebugEnabled) { Console.WriteLine(string.Format("hleKernelSendMsgPipe {0} waiting for 0x{1:X} bytes to become available", info, size)); } SceKernelThreadInfo currentThread = threadMan.CurrentThread; info.sendThreadWaitingList.addWaitingThread(currentThread); // Wait on a specific MsgPipe. currentThread.wait.MsgPipe_isSend = true; currentThread.wait.MsgPipe_id = uid; currentThread.wait.MsgPipe_address = msgAddr; currentThread.wait.MsgPipe_size = size; currentThread.wait.MsgPipe_resultSize_addr = resultSizeAddr; threadMan.hleKernelThreadEnterWaitState(PSP_WAIT_MSGPIPE, uid, msgPipeSendWaitStateChecker, timeoutAddr.Address, doCallbacks); } else { Console.WriteLine(string.Format("hleKernelSendMsgPipe illegal size 0x{0:X}, max 0x{1:X} (pipe needs consuming)", size, info.freeSize)); return(ERROR_KERNEL_MESSAGE_PIPE_FULL); } } else { // Success, do not reschedule the current thread. //if (log.DebugEnabled) { Console.WriteLine(string.Format("hleKernelSendMsgPipe {0} fast check succeeded", info)); } onMsgPipeReceiveModified(info); } return(0); }
public virtual int sceZlibDecompress(TPointer outBufferAddr, int outBufferLength, TPointer inBufferAddr, TPointer32 crc32Addr) { sbyte[] inBuffer = new sbyte[4096]; sbyte[] outBuffer = new sbyte[4096]; int inBufferPtr = 0; IMemoryReader reader = MemoryReader.getMemoryReader(inBufferAddr.Address, 1); IMemoryWriter writer = MemoryWriter.getMemoryWriter(outBufferAddr.Address, outBufferLength, 1); CRC32 crc32 = new CRC32(); Inflater inflater = new Inflater(); while (!inflater.finished()) { if (inflater.needsInput()) { for (inBufferPtr = 0; inBufferPtr < inBuffer.Length; ++inBufferPtr) { inBuffer[inBufferPtr] = (sbyte)reader.readNext(); } inflater.Input = inBuffer; } try { int count = inflater.inflate(outBuffer); if (inflater.TotalOut > outBufferLength) { Console.WriteLine(string.Format("sceZlibDecompress : zlib decompress buffer too small inBuffer={0}, outLength={1:D}", inBufferAddr, outBufferLength)); return(SceKernelErrors.ERROR_INVALID_SIZE); } crc32.update(outBuffer, 0, count); for (int i = 0; i < count; ++i) { writer.writeNext(outBuffer[i] & 0xFF); } } catch (DataFormatException) { Console.WriteLine(string.Format("sceZlibDecompress : malformed zlib stream inBuffer={0}", inBufferAddr)); return(SceKernelErrors.ERROR_INVALID_FORMAT); } } writer.flush(); crc32Addr.setValue((int)crc32.Value); return(inflater.TotalOut); }
public virtual int sceKernelFreeFpl(int uid, TPointer dataAddr) { SceKernelFplInfo info = fplMap[uid]; int block = info.findBlockByAddress(dataAddr.Address); if (block < 0) { Console.WriteLine(string.Format("sceKernelFreeFpl unknown block address={0}", dataAddr)); return(ERROR_KERNEL_ILLEGAL_MEMBLOCK); } info.freeBlock(block); onFplFree(info); return(0); }
public virtual int sceMeAudio_30BE34E4(int uid, TPointer dataAddr, int offset, int size) { if (uid != ebootPbpUid) { return(-1); } long seekOffset = offset & 0xFFFFFFFFL; long result = vFileEbootPbp.ioLseek(seekOffset); if (result != seekOffset) { return(-1); } return(vFileEbootPbp.ioRead(dataAddr, size)); }