示例#1
0
        public static ulong SystemCall(uint ID, ulong r3 = 0, ulong r4 = 0, ulong r5 = 0, ulong r6 = 0, ulong r7 = 0, ulong r8 = 0, ulong r9 = 0, ulong r10 = 0)
        {
            if (!PS3RPC.Install())
            {
                return(0);
            }

            ulong ret = 0;

            PS3.Ext.WriteUInt64(RPC_STACK_ADDR + SYS_CALL_RET, 0xDEADC0DE);

            PS3.Ext.WriteUInt64(RPC_STACK_ADDR + SYS_CALL_R3, r3);
            PS3.Ext.WriteUInt64(RPC_STACK_ADDR + SYS_CALL_R4, r4);
            PS3.Ext.WriteUInt64(RPC_STACK_ADDR + SYS_CALL_R5, r5);
            PS3.Ext.WriteUInt64(RPC_STACK_ADDR + SYS_CALL_R6, r6);
            PS3.Ext.WriteUInt64(RPC_STACK_ADDR + SYS_CALL_R7, r7);
            PS3.Ext.WriteUInt64(RPC_STACK_ADDR + SYS_CALL_R8, r8);
            PS3.Ext.WriteUInt64(RPC_STACK_ADDR + SYS_CALL_R9, r9);
            PS3.Ext.WriteUInt64(RPC_STACK_ADDR + SYS_CALL_R10, r10);

            PS3.Ext.WriteUInt32(RPC_STACK_ADDR + SYS_CALL_ID, ID);

            while ((ret = PS3.Ext.ReadUInt64(RPC_STACK_ADDR + SYS_CALL_RET)) == 0xDEADC0DE)
            {
                Thread.Sleep(1);
            }

            return(ret);
        }
示例#2
0
        public static ulong LoadModule(string path)
        {
            if (!PS3RPC.Install())
            {
                return(0);
            }

            ulong ret = 0;

            PS3.Ext.WriteString(RPC_STACK_ADDR + PRX_MODULE_PATH, path);

            ulong prxId = SystemCall(0x1E0, RPC_STACK_ADDR + PRX_MODULE_PATH, 0, 0);

            if ((long)prxId < 0)
            {
                return(prxId);
            }

            PS3.Ext.WriteUInt64(RPC_STACK_ADDR + PRX_FLAGS, 0x28);
            PS3.Ext.WriteUInt64(RPC_STACK_ADDR + PRX_FLAGS + 0x8, 0x1);
            PS3.Ext.WriteUInt64(RPC_STACK_ADDR + PRX_FLAGS + 0x10, 0x0);
            PS3.Ext.WriteUInt64(RPC_STACK_ADDR + PRX_FLAGS + 0x18, 0x0);
            PS3.Ext.WriteUInt64(RPC_STACK_ADDR + PRX_FLAGS + 0x20, UInt64.MaxValue);
            ret = SystemCall(0x1E1, prxId, 0x0, RPC_STACK_ADDR + PRX_FLAGS);
            if ((long)ret < 0)
            {
                return(ret);
            }

            ulong OPD     = PS3.Ext.ReadUInt64(RPC_STACK_ADDR + PRX_FLAGS + 0x10);
            uint  address = PS3.Ext.ReadUInt32((uint)OPD);
            uint  toc     = PS3.Ext.ReadUInt32((uint)OPD + 0x4);

            CallTOC <int>(address, toc);

            PS3.Ext.WriteUInt64(RPC_STACK_ADDR + PRX_FLAGS, 0x28);
            PS3.Ext.WriteUInt64(RPC_STACK_ADDR + PRX_FLAGS + 0x8, 0x2);
            PS3.Ext.WriteUInt64(RPC_STACK_ADDR + PRX_FLAGS + 0x10, 0x0);
            PS3.Ext.WriteUInt64(RPC_STACK_ADDR + PRX_FLAGS + 0x18, 0x0);
            PS3.Ext.WriteUInt64(RPC_STACK_ADDR + PRX_FLAGS + 0x20, UInt64.MaxValue);
            ret = SystemCall(0x1E1, prxId, 0x0, RPC_STACK_ADDR + PRX_FLAGS);
            if ((long)ret < 0)
            {
                return(ret);
            }

            return(0x0);
        }
示例#3
0
        public static ulong UnloadModule(uint prxId)
        {
            if (!PS3RPC.Install())
            {
                return(0);
            }

            ulong ret = 0;

            PS3.Ext.WriteUInt64(RPC_STACK_ADDR + PRX_FLAGS, 0x28);
            PS3.Ext.WriteUInt64(RPC_STACK_ADDR + PRX_FLAGS + 0x8, 0x1);
            PS3.Ext.WriteUInt64(RPC_STACK_ADDR + PRX_FLAGS + 0x10, 0x0);
            PS3.Ext.WriteUInt64(RPC_STACK_ADDR + PRX_FLAGS + 0x18, 0x0);
            PS3.Ext.WriteUInt64(RPC_STACK_ADDR + PRX_FLAGS + 0x20, UInt64.MaxValue);
            ret = SystemCall(0x1E2, prxId, 0x0, RPC_STACK_ADDR + PRX_FLAGS);

            if ((long)ret < 0)
            {
                return(ret);
            }

            ulong OPD     = PS3.Ext.ReadUInt64(RPC_STACK_ADDR + PRX_FLAGS + 0x10);
            uint  address = PS3.Ext.ReadUInt32((uint)OPD);
            uint  toc     = PS3.Ext.ReadUInt32((uint)OPD + 0x4);

            CallTOC <int>(address, toc);

            PS3.Ext.WriteUInt64(RPC_STACK_ADDR + PRX_FLAGS, 0x28);
            PS3.Ext.WriteUInt64(RPC_STACK_ADDR + PRX_FLAGS + 0x8, 0x2);
            PS3.Ext.WriteUInt64(RPC_STACK_ADDR + PRX_FLAGS + 0x10, 0x0);
            PS3.Ext.WriteUInt64(RPC_STACK_ADDR + PRX_FLAGS + 0x18, 0x0);
            PS3.Ext.WriteUInt64(RPC_STACK_ADDR + PRX_FLAGS + 0x20, UInt64.MaxValue);
            ret = SystemCall(0x1E2, prxId, 0x0, RPC_STACK_ADDR + PRX_FLAGS);
            if ((long)ret < 0)
            {
                return(ret);
            }

            ret = SystemCall(0x1E3, prxId, 0, 0, 0);
            if ((long)ret < 0)
            {
                return(ret);
            }

            return(0x0);
        }
示例#4
0
        public static T CallTOC <T>(uint address, uint toc, params object[] parameters)
        {
            if (!PS3RPC.Install())
            {
                return((T)Convert.ChangeType(0, typeof(int)));
            }

            PS3.Ext.WriteUInt64(RPC_STACK_ADDR + FUNC_CALL_RX_RET, 0xDEADC0DE);
            PS3.Ext.WriteUInt64(RPC_STACK_ADDR + FUNC_CALL_FX_RET, 0xDEADC0DE);

            int  index           = 0;
            uint intCount        = 0;
            uint floatCount      = 0;
            uint stringOffset    = 0;
            uint floatArrayCount = 0;

            while (index < parameters.Length)
            {
                if (parameters[index] is int || parameters[index] is uint || parameters[index] is long || parameters[index] is ulong)
                {
                    PS3.Ext.WriteUInt64(RPC_STACK_ADDR + FUNC_CALL_RX + (intCount++ *0x8), Convert.ToUInt64(parameters[index]));
                }
                else if (parameters[index] is float)
                {
                    PS3.Ext.WriteFloat(RPC_STACK_ADDR + FUNC_CALL_FX + (floatCount++ *0x8), (float)parameters[index]);
                }
                else if (parameters[index] is double)
                {
                    PS3.Ext.WriteDouble(RPC_STACK_ADDR + FUNC_CALL_FX + (floatCount++ *0x8), (double)parameters[index]);
                }
                else if (parameters[index] is float[])
                {
                    PS3.Ext.WriteUInt64(RPC_STACK_ADDR + FUNC_CALL_RX + (intCount++ *0x8), RPC_STACK_ADDR + FUNC_CALL_FLOATS + (floatArrayCount * 0x4));
                    PS3.Ext.WriteFloats(RPC_STACK_ADDR + FUNC_CALL_FLOATS + (floatArrayCount * 0x4), (float[])parameters[index]);
                    floatArrayCount += (uint)((float[])parameters[index]).Length + 0x4;
                }
                else if (parameters[index] is string)
                {
                    string value = (string)parameters[index];
                    PS3.Ext.WriteString(RPC_STACK_ADDR + FUNC_CALL_STR + stringOffset, value);
                    PS3.Ext.WriteUInt64(RPC_STACK_ADDR + FUNC_CALL_RX + (intCount++ *0x8), RPC_STACK_ADDR + FUNC_CALL_STR + stringOffset);
                    stringOffset += (uint)value.Length + 0x4;
                }
                index++;
            }

            PS3.Ext.WriteUInt64(RPC_STACK_ADDR + FUNC_CALL_TOC_NEW, toc);
            PS3.Ext.WriteUInt32(RPC_STACK_ADDR + FUNC_CALL_ADDR, address);

            Type type = Nullable.GetUnderlyingType(typeof(T)) ?? typeof(T);

            if (type == typeof(float))
            {
                float ret = 0.0f;
                while ((ret = PS3.Ext.ReadFloat(RPC_STACK_ADDR + FUNC_CALL_FX_RET)) == 0xDEADC0DE)
                {
                    Thread.Sleep(10);
                }

                return((T)Convert.ChangeType(ret, typeof(T)));
            }
            else if (type == typeof(string))
            {
                ulong ret = 0;
                while ((ret = PS3.Ext.ReadUInt64(RPC_STACK_ADDR + FUNC_CALL_RX_RET)) == 0xDEADC0DE)
                {
                    Thread.Sleep(10);
                }
                string value = PS3.Ext.ReadString((uint)ret);

                return((T)Convert.ChangeType(value, typeof(T)));
            }
            else
            {
                ulong ret = 0;
                while ((ret = PS3.Ext.ReadUInt64(RPC_STACK_ADDR + FUNC_CALL_RX_RET)) == 0xDEADC0DE)
                {
                    Thread.Sleep(10);
                }

                return((T)Convert.ChangeType(ret, typeof(T)));
            }
        }