Esempio n. 1
0
        public virtual int sceNetMCopydata(TPointer messageAddr, int dataOffset, int Length, TPointer destinationAddr)
        {
            if (destinationAddr.NotNull)
            {
                SceNetIfMessage message = new SceNetIfMessage();
                while (messageAddr.NotNull)
                {
                    message.read(messageAddr);

                    if (dataOffset < message.dataLength)
                    {
                        break;
                    }
                    dataOffset         -= message.dataLength;
                    messageAddr.Address = message.nextDataAddr;
                }

                while (Length > 0 && messageAddr.NotNull)
                {
                    message.read(messageAddr);
                    int copyLength = System.Math.Min(Length, message.dataLength - dataOffset);
                    destinationAddr.memcpy(message.dataAddr + dataOffset, copyLength);
                    Length -= copyLength;
                    destinationAddr.add(copyLength);
                    dataOffset = 0;
                }
            }

            return(0);
        }
Esempio n. 2
0
        protected internal virtual void hleAfterReadContextCallback()
        {
            if (readMessage == null)
            {
                int size = 256;
                int mem  = Modules.sceNetIfhandleModule.hleNetMallocInternal(size);
                if (mem > 0)
                {
                    readMessage = new TPointer(Memory.Instance, mem);
                    readMessage.clear(size);
                    RuntimeContext.debugMemory(mem, size);
                }
            }

            if (readMessage != null)
            {
                // Store dummy message
                SceNetIfMessage message       = new SceNetIfMessage();
                TPointer        data          = new TPointer(Memory.Instance, readMessage.Address + message.@sizeof());
                TPointer        header        = new TPointer(data.Memory, data.Address);
                TPointer        content       = new TPointer(data.Memory, data.Address + 60);
                const int       contentLength = 8;
                // Header information:
                header.setArray(0, Wlan.MacAddress, 6);                                    // destination MAC address
                header.setArray(6, new sbyte[] { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 }, 6); // source MAC address
                header.setValue8(48, (sbyte)1);                                            // 1 or 2
                header.setValue8(49, (sbyte)0);
                header.setValue16(50, (short)endianSwap16(12 + contentLength));            // value must be >= 12
                header.setValue16(52, (short)endianSwap16(0x22C));                         // source port
                header.setValue16(54, (short)endianSwap16(0x22C));                         // destination port
                header.setValue8(58, (sbyte)0);
                header.setValue8(59, (sbyte)0);

                // Real message content:
                content.setValue8(0, (sbyte)1);
                content.setValue8(1, (sbyte)1);
                content.setValue16(2, (short)endianSwap16(contentLength - 4)); // endian-swapped value, Length of following data
                content.setValue8(4, (sbyte)0);                                // Dummy data
                content.setValue8(5, (sbyte)0);
                content.setValue8(6, (sbyte)0);
                content.setValue8(7, (sbyte)0);

                message.dataAddr   = data.Address;
                message.dataLength = 60 + contentLength;
                message.unknown24  = 60 + contentLength;
                message.write(readMessage);

                TPointer readContext = new TPointer(Memory.Instance, readContextAddr.getValue());
                readContext.setValue32(0, readMessage.Address);
                readContext.setValue32(8, readContext.getValue32(8) + 1);
            }

            SceKernelThreadInfo thread = Modules.ThreadManForUserModule.CurrentThread;

            Modules.ThreadManForUserModule.executeCallback(thread, readCallback, null, true);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        public virtual void sceNetMAdj(TPointer messageAddr, int sizeAdj)
        {
            if (messageAddr.Null)
            {
                return;
            }

            SceNetIfMessage message = new SceNetIfMessage();

            if (sizeAdj < 0)
            {
                sizeAdj = -sizeAdj;
                int totalSize          = 0;
                int currentMessageAddr = messageAddr.Address;
                do
                {
                    message.read(messageAddr.Memory, currentMessageAddr);
                    totalSize         += message.dataLength;
                    currentMessageAddr = message.nextDataAddr;
                } while (currentMessageAddr != 0);

                if (message.dataLength < sizeAdj)
                {
                    totalSize -= sizeAdj;
                    message.read(messageAddr);
                    totalSize = System.Math.Max(totalSize - sizeAdj, 0);
                    if ((message.unknown18 & 2) != 0)
                    {
                        message.unknown24 = totalSize;
                        message.write(messageAddr);
                    }

                    currentMessageAddr = messageAddr.Address;
                    while (currentMessageAddr != 0)
                    {
                        message.read(messageAddr.Memory, currentMessageAddr);
                        if (message.dataLength < totalSize)
                        {
                            currentMessageAddr = message.nextDataAddr;
                            totalSize         -= message.dataLength;
                        }
                        else
                        {
                            message.dataLength = totalSize;
                            message.write(messageAddr.Memory, currentMessageAddr);
                            break;
                        }
                    }

                    currentMessageAddr = message.nextDataAddr;
                    while (currentMessageAddr != 0)
                    {
                        message.read(messageAddr.Memory, currentMessageAddr);
                        message.dataLength = 0;
                        message.write(messageAddr.Memory, currentMessageAddr);
                        currentMessageAddr = message.nextDataAddr;
                    }
                }
                else
                {
                    message.read(messageAddr);
                    if ((message.unknown18 & 2) != 0)
                    {
                        message.unknown24 -= sizeAdj;
                        message.write(messageAddr);
                    }
                }
            }
            else
            {
                int totalSizeAdj       = sizeAdj;
                int currentMessageAddr = messageAddr.Address;
                do
                {
                    message.read(messageAddr.Memory, currentMessageAddr);
                    if (sizeAdj < message.dataLength)
                    {
                        message.dataLength -= sizeAdj;
                        message.dataAddr   += sizeAdj;
                        message.write(messageAddr);
                        sizeAdj = 0;
                    }
                    else
                    {
                        sizeAdj           -= message.dataLength;
                        message.dataLength = 0;
                        message.write(messageAddr);
                        currentMessageAddr = message.nextDataAddr;
                    }
                } while (messageAddr.NotNull && sizeAdj > 0);

                message.read(messageAddr);
                if ((message.unknown18 & 2) != 0)
                {
                    message.unknown24 -= totalSizeAdj - sizeAdj;
                    message.write(messageAddr);
                }
            }
        }
Esempio n. 5
0
 public virtual void sceNetIfhandleIfStart(TPointer handleInternalAddr, SceNetIfMessage messageToBeSent)
 {
 }