示例#1
0
        public virtual int sceHeapAllocHeapMemory(TPointer heapAddr, int memSize)
        {
            // Try to allocate memory from the heap and return it's address.
            HeapInfo heapInfo = heapMap[heapAddr.Address];

            if (heapInfo == null)
            {
                return(0);
            }

            int allocatedAddr = heapInfo.alloc(memSize, defaultAllocAlignment);

            if (log.TraceEnabled)
            {
                log.trace(string.Format("sceHeapAllocHeapMemory returns 0x{0:X8}, after allocation: {1}", allocatedAddr, heapInfo));
            }

            return(allocatedAddr);
        }
示例#2
0
        public virtual int sceHeapAllocHeapMemoryWithOption(TPointer heapAddr, int memSize, TPointer32 paramAddr)
        {
            int alignment = defaultAllocAlignment;

            if (paramAddr.NotNull)
            {
                int paramSize = paramAddr.getValue(0);
                if (paramSize == 8)
                {
                    alignment = paramAddr.getValue(4);
                    //if (log.DebugEnabled)
                    {
                        Console.WriteLine(string.Format("sceHeapAllocHeapMemoryWithOption options: struct size={0:D}, alignment=0x{1:X}", paramSize, alignment));
                    }
                }
                else
                {
                    Console.WriteLine(string.Format("sceHeapAllocHeapMemoryWithOption option at {0}(size={1:D})", paramAddr, paramSize));
                }
            }

            // Try to allocate memory from the heap and return it's address.
            HeapInfo heapInfo = heapMap[heapAddr.Address];

            if (heapInfo == null)
            {
                return(0);
            }

            int allocatedAddr = heapInfo.alloc(memSize, alignment);

            if (log.TraceEnabled)
            {
                log.trace(string.Format("sceHeapAllocHeapMemoryWithOption returns 0x{0:X8}, after allocation: {1}", allocatedAddr, heapInfo));
            }

            return(allocatedAddr);
        }