コード例 #1
0
        public virtual int sceGeSetCallback(TPointer cbdata_addr)
        {
            pspGeCallbackData cbdata = new pspGeCallbackData();

            cbdata.read(cbdata_addr);

            // The cbid returned has a value in the range [0..15].
            int cbid = SceUidManager.getNewId(geCallbackPurpose, 0, 15);

            if (cbid == SceUidManager.INVALID_ID)
            {
                Console.WriteLine(string.Format("sceGeSetCallback no more callback ID available"));
                return(SceKernelErrors.ERROR_OUT_OF_MEMORY);
            }

            //if (log.DebugEnabled)
            {
                Console.WriteLine(string.Format("sceGeSetCallback signalFunc=0x{0:X8}, signalArg=0x{1:X8}, finishFunc=0x{2:X8}, finishArg=0x{3:X8}, result cbid=0x{4:X}", cbdata.signalFunction, cbdata.signalArgument, cbdata.finishFunction, cbdata.finishArgument, cbid));
            }

            ThreadManForUser      threadMan      = Modules.ThreadManForUserModule;
            SceKernelCallbackInfo callbackSignal = threadMan.hleKernelCreateCallback("GeCallbackSignal", cbdata.signalFunction, cbdata.signalArgument);
            SceKernelCallbackInfo callbackFinish = threadMan.hleKernelCreateCallback("GeCallbackFinish", cbdata.finishFunction, cbdata.finishArgument);

            signalCallbacks[cbid] = callbackSignal;
            finishCallbacks[cbid] = callbackFinish;

            return(cbid);
        }
コード例 #2
0
        public virtual int sceGeUnsetCallback(int cbid)
        {
            ThreadManForUser      threadMan      = Modules.ThreadManForUserModule;
            SceKernelCallbackInfo callbackSignal = signalCallbacks.Remove(cbid);
            SceKernelCallbackInfo callbackFinish = finishCallbacks.Remove(cbid);

            if (callbackSignal != null)
            {
                threadMan.hleKernelDeleteCallback(callbackSignal.Uid);
            }
            if (callbackFinish != null)
            {
                threadMan.hleKernelDeleteCallback(callbackFinish.Uid);
            }
            SceUidManager.releaseId(cbid, geCallbackPurpose);

            return(0);
        }
コード例 #3
0
        private void triggerAsyncCallback(int cbid, int listId, int listPc, int behavior, int signalId, Dictionary <int, SceKernelCallbackInfo> callbacks)
        {
            SceKernelCallbackInfo callback = callbacks[cbid];

            if (callback != null && callback.hasCallbackFunction())
            {
                //if (log.DebugEnabled)
                {
                    Console.WriteLine(string.Format("Scheduling Async Callback {0}, listId=0x{1:X}, listPc=0x{2:X8}, behavior={3:D}, signalId=0x{4:X}", callback.ToString(), listId, listPc, behavior, signalId));
                }
                GeCallbackInterruptHandler geCallbackInterruptHandler = new GeCallbackInterruptHandler(callback.CallbackFunction, callback.CallbackArgument, listPc);
                GeInterruptHandler         geInterruptHandler         = new GeInterruptHandler(geCallbackInterruptHandler, listId, behavior, signalId);
                Emulator.Scheduler.addAction(geInterruptHandler);
            }
            else
            {
                hleGeOnAfterCallback(listId, behavior, false);
            }
        }
コード例 #4
0
        public virtual int LoadExecForUser_362A956B()
        {
            //if (log.DebugEnabled)
            {
                Console.WriteLine(string.Format("LoadExecForUser_362A956B registeredExitCallbackUid=0x{0:X}", registeredExitCallbackUid));
            }

            SceKernelCallbackInfo callbackInfo = Modules.ThreadManForUserModule.getCallbackInfo(registeredExitCallbackUid);

            if (callbackInfo == null)
            {
                //if (log.DebugEnabled)
                {
                    Console.WriteLine(string.Format("LoadExecForUser_362A956B registeredExitCallbackUid=0x{0:x} callback not found", registeredExitCallbackUid));
                }
                return(SceKernelErrors.ERROR_KERNEL_NOT_FOUND_CALLBACK);
            }
            int callbackArgument = callbackInfo.CallbackArgument;

            if (!Memory.isAddressGood(callbackArgument))
            {
                //if (log.DebugEnabled)
                {
                    Console.WriteLine(string.Format("LoadExecForUser_362A956B invalid address for callbackArgument=0x{0:X8}", callbackArgument));
                }
                return(SceKernelErrors.ERROR_KERNEL_ILLEGAL_ADDR);
            }

            Memory mem = Processor.memory;

            int unknown1 = mem.read32(callbackArgument - 8);

            if (unknown1 < 0 || unknown1 >= 4)
            {
                //if (log.DebugEnabled)
                {
                    Console.WriteLine(string.Format("LoadExecForUser_362A956B invalid value unknown1=0x{0:X8}", unknown1));
                }
                return(SceKernelErrors.ERROR_KERNEL_ILLEGAL_ARGUMENT);
            }

            int parameterArea = mem.read32(callbackArgument - 4);

            if (!Memory.isAddressGood(parameterArea))
            {
                //if (log.DebugEnabled)
                {
                    Console.WriteLine(string.Format("LoadExecForUser_362A956B invalid address for parameterArea=0x{0:X8}", parameterArea));
                }
                return(SceKernelErrors.ERROR_KERNEL_ILLEGAL_ADDR);
            }

            int size = mem.read32(parameterArea);

            if (size < 12)
            {
                //if (log.DebugEnabled)
                {
                    Console.WriteLine(string.Format("LoadExecForUser_362A956B invalid parameter area size {0:D}", size));
                }
                return(SceKernelErrors.ERROR_KERNEL_ILLEGAL_SIZE);
            }

            mem.write32(parameterArea + 4, 0);
            mem.write32(parameterArea + 8, -1);

            return(0);
        }
コード例 #5
0
        public virtual int sceNpAuthCreateStartRequest(TPointer paramAddr)
        {
            SceNpAuthRequestParameter param = new SceNpAuthRequestParameter();

            param.read(paramAddr);
            if (log.InfoEnabled)
            {
                Console.WriteLine(string.Format("sceNpAuthCreateStartRequest param: {0}", param));
            }

            serviceId = param.serviceId;

            if (!useDummyTicket)
            {
                string loginId = JOptionPane.showInputDialog("Enter your PSN Sign-In ID (Email Address)");
                if (!string.ReferenceEquals(loginId, null))
                {
                    string password = JOptionPane.showInputDialog("Enter your PSN Password");
                    if (!string.ReferenceEquals(password, null))
                    {
                        StringBuilder @params = new StringBuilder();
                        addURLParam(@params, "serviceid", serviceId);
                        addURLParam(@params, "loginid", loginId);
                        addURLParam(@params, "password", password);
                        if (param.cookie != 0)
                        {
                            addURLParam(@params, "cookie", param.cookie, param.cookieSize);
                        }
                        if (param.entitlementIdAddr != 0)
                        {
                            addURLParam(@params, "entitlementid", param.entitlementId);
                            addURLParam(@params, "consumedcount", Convert.ToString(param.consumedCount));
                        }

                        HttpURLConnection connection = null;
                        ticketBytesLength = 0;
                        try
                        {
                            connection = (HttpURLConnection)(new URL("https://auth.np.ac.playstation.net/nav/auth")).openConnection();
                            connection.setRequestProperty("X-I-5-Version", "2.1");
                            connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
                            connection.setRequestProperty("X-Platform-Version", "PSP 06.60");
                            connection.setRequestProperty("Content-Length", Convert.ToString(@params.Length));
                            connection.setRequestProperty("User-Agent", "Lediatio Lunto Ritna");
                            connection.RequestMethod = "POST";
                            connection.DoOutput      = true;
                            System.IO.Stream os = connection.OutputStream;
                            os.WriteByte(@params.ToString().GetBytes());
                            os.Close();
                            connection.connect();
                            int responseCode = connection.ResponseCode;
                            //if (log.DebugEnabled)
                            {
                                Console.WriteLine(string.Format("Response code: {0:D}", responseCode));
                                foreach (KeyValuePair <string, IList <string> > entry in connection.HeaderFields.entrySet())
                                {
                                    Console.WriteLine(string.Format("{0}: {1}", entry.Key, entry.Value));
                                }
                            }

                            if (responseCode == 200)
                            {
                                System.IO.Stream @in = connection.InputStream;
                                while (true)
                                {
                                    int Length = @in.Read(ticketBytes, ticketBytesLength, ticketBytes.Length - ticketBytesLength);
                                    if (Length < 0)
                                    {
                                        break;
                                    }
                                    ticketBytesLength += Length;
                                }
                                @in.Close();

                                //if (log.DebugEnabled)
                                {
                                    Console.WriteLine(string.Format("Received ticket: {0}", Utilities.getMemoryDump(ticketBytes, 0, ticketBytesLength)));
                                }
                            }
                        }
                        catch (MalformedURLException e)
                        {
                            Console.WriteLine(e);
                        }
                        catch (IOException e)
                        {
                            Console.WriteLine(e);
                        }
                        finally
                        {
                            if (connection != null)
                            {
                                connection.disconnect();
                            }
                        }
                    }
                }
            }

            if (param.ticketCallback != 0)
            {
                int ticketLength = ticketBytesLength > 0 ? ticketBytesLength : 248;
                npAuthCreateTicketCallback = Modules.ThreadManForUserModule.hleKernelCreateCallback("sceNpAuthCreateStartRequest", param.ticketCallback, param.callbackArgument);
                if (Modules.ThreadManForUserModule.hleKernelRegisterCallback(THREAD_CALLBACK_USER_DEFINED, npAuthCreateTicketCallback.Uid))
                {
                    Modules.ThreadManForUserModule.hleKernelNotifyCallback(THREAD_CALLBACK_USER_DEFINED, npAuthCreateTicketCallback.Uid, ticketLength);
                }
            }

            return(0);
        }
コード例 #6
0
 public SceKernelCallbackStatus(SceKernelCallbackInfo outerInstance)
 {
     this.outerInstance = outerInstance;
 }