// For Pdp sockets, data is read one packet at a time. // The caller has to provide enough space to fully read the available packet. public virtual int recv(TPointer srcMacAddr, TPointer16 portAddr, TPointer data, TPointer32 dataLengthAddr, int timeout, int nonblock) { int result = 0; try { SceKernelThreadInfo thread = Modules.ThreadManForUserModule.CurrentThread; if (pollRecv(srcMacAddr, portAddr, data, dataLengthAddr, thread)) { // Recv completed immediately result = thread.cpuContext._v0; } else if (nonblock != 0) { // Recv cannot be completed in non-blocking mode result = SceKernelErrors.ERROR_NET_ADHOC_NO_DATA_AVAILABLE; } else { // Block current thread BlockedPdpAction blockedPdpAction = new BlockedPdpRecv(this, srcMacAddr, portAddr, data, dataLengthAddr, timeout); blockedPdpAction.blockCurrentThread(); } } catch (IOException e) { result = SceKernelErrors.ERROR_NET_ADHOC_DISCONNECTED; Console.WriteLine("recv", e); } return(result); }
public BlockedPdpRecv(PdpObject pdpObject, TPointer srcMacAddr, TPointer16 portAddr, TPointer data, TPointer32 dataLengthAddr, long timeout) : base(pdpObject, timeout) { this.srcMacAddr = srcMacAddr; this.portAddr = portAddr; this.data = data; this.dataLengthAddr = dataLengthAddr; }
public virtual int scePwm_driver_36F98EBA(int unknown1, TPointer16 unknown2, TPointer16 unknown3, TPointer32 unknown4) { unknown2.Value = 0; unknown3.Value = 0; unknown4.setValue(0); return(0); }
public virtual int sceNpMatching2GetServerIdListLocal(int ctxId, TPointer16 serverIds, int maxServerIds) { // Return dummy values for debugging for (int i = 0; i < maxServerIds; i++) { serverIds.setValue(i * 2, i + 0x1234); } return(maxServerIds); }
public virtual int sceNpMatching2GetServerInfo(int ctxId, TPointer16 serverIdAddr, TPointer32 unknown1, TPointer32 unknown2) { int serverId = serverIdAddr.Value; //if (log.DebugEnabled) { Console.WriteLine(string.Format("sceNpMatching2GetServerInfo serverId=0x{0:X}, unknown1: {1}, unknown2: {2}", serverId, Utilities.getMemoryDump(unknown1.Address, 16), Utilities.getMemoryDump(unknown2.Address, 20))); } unknown2.setValue(0x00010000); return(0); }
//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 sceNpMatching2GetWorldInfoList(int ctxId, TPointer16 serverIdAddr, TPointer optParam, TPointer32 assignedReqId) { if (optParam.NotNull) { int callbackFunction = optParam.getValue32(0); int callbackArgument = optParam.getValue32(4); int timeout = optParam.getValue32(8); int appReqId = optParam.getValue16(12); //if (log.DebugEnabled) { Console.WriteLine(string.Format("sceNpMatching2GetWorldInfoList callbackFunction=0x{0:X8}, callbackArgument=0x{1:X}, timeout=0x{2:X}, appReqId=0x{3:X}", callbackFunction, callbackArgument, timeout, appReqId)); } } int serverId = serverIdAddr.Value; //if (log.DebugEnabled) { Console.WriteLine(string.Format("sceNpMatching2GetWorldInfoList serverId=0x{0:X}", serverId)); } return(0); }
public virtual int sceNpMatching2CreateContext(TPointer communicationId, TPointer passPhrase, TPointer16 ctxId, int unknown) { //if (log.DebugEnabled) { Console.WriteLine(string.Format("sceNpMatching2CreateContext communicationId={0}, passPhrase={1}", Utilities.getMemoryDump(communicationId.Address, 12), Utilities.getMemoryDump(passPhrase.Address, 128))); } // Returning a ctxId in range [1..7] int uid = SceUidManager.getNewId(idContextPurpose, 1, 7); if (uid == SceUidManager.INVALID_ID) { return(-1); } contextMap[uid] = new MatchingContext(); //if (log.DebugEnabled) { Console.WriteLine(string.Format("sceNpMatching2CreateContext returning 0x{0:X}", uid)); } ctxId.Value = uid; return(0); }
public virtual int sceCodepage_driver_907CBFD2(TPointer8 destAddr, int destLength, TPointer16 srcAddr) { int result = destLength; sbyte[] bytes = new sbyte[2]; for (int i = 0, j = 0; j < destLength; i += 2, j++) { int char16 = srcAddr.getValue(i); if (char16 == 0) { result = j; break; } bytes[0] = (sbyte)char16; bytes[1] = (sbyte)(char16 >> 8); sbyte char8 = (sbyte)(StringHelper.NewString(bytes, charset16))[0]; destAddr.setValue(j, char8); } if (result < destLength) { // Add trailing '\0' destAddr.setValue(result, (sbyte)0); } return(result); }