示例#1
0
 public void Resume()
 {
     conn.VM_Resume();
 }
示例#2
0
        public void Start(Action <string> consoleCallback)
        {
            Console.WriteLine("Waiting for Vita to connect...");
            ScePsmDevice?vita = null;
            int          ret;

            for (; ;)
            {
                ScePsmDevice[] deviceArray;
                PSMFunctions.ListDevices(out deviceArray);
                foreach (ScePsmDevice dev in deviceArray)
                {
                    if (dev.online > 0)
                    {
                        vita = dev;
                        break;
                    }
                }
                if (vita != null)
                {
                    break;
                }
            }
            Guid   devId  = vita.Value.guid;
            string serial = new string(vita.Value.deviceID, 0, 17);

            Console.WriteLine("Found Vita {0}, serial: {1}", devId, serial);
            if ((ret = PSMFunctions.Connect(devId)) < 0)
            {
                Console.WriteLine("Error connecting to Vita: 0x{0:X}", ret);
                throw new IOException("Cannot connect to Vita.");
            }
            this.handle = devId;

            // request version or other calls will fail
            PSMFunctions.Version(this.handle);

#if USE_APP_KEY
            byte[] buffer = File.ReadAllBytes("kdev.p12");

            if ((ret = PSMFunctions.ExistAppExeKey(this.handle, DRMFunctions.ReadAccountIdFromKdevP12(buffer), "*", "np")) != 1)
            {
                Console.WriteLine("Setting app key to: {0}", appkeypath);
                if ((ret = PSMFunctions.SetAppExeKey(this.handle, appkeypath)) != 0)
                {
                    Console.WriteLine("Error setting key: 0x{0:X}", ret);
                    throw new IOException("Cannot set app key.");
                }
            }
#endif

#if !NO_INSTALL_PACKAGE
            Console.WriteLine("Installing package {0} as {1}.", package, name);
            if ((ret = PSMFunctions.Install(this.handle, package, name)) != 0)
            {
                Console.WriteLine("Error installing package: 0x{0:X}", ret);
                throw new IOException("Cannot connect to Vita.");
            }
#endif

            callback = new PsmDeviceConsoleCallback(consoleCallback);
            Console.WriteLine("Setting console callback.");
            PSMFunctions.SetConsoleWrite(this.handle, Marshal.GetFunctionPointerForDelegate(callback));

            Console.WriteLine("Launching {0}.", name);
            if ((ret = PSMFunctions.Launch(this.handle, name, true, false, false, false, "")) != 0)
            {
                Console.WriteLine("Error running application: 0x{0:X}", ret);
                throw new IOException("Cannot connect to Vita.");
            }

            Console.WriteLine("Connecting debugger.");
            string port = TransportFunctions.GetVitaPortWithSerial(serial);
            if (port == null)
            {
                Console.WriteLine("Cannot find serial port for {0}", serial);
                throw new IOException("Cannot find serial port.");
            }
            conn = new VitaConnection(port);
            conn.EventHandler  = new ConnEventHandler();
            conn.ErrorHandler += HandleConnErrorHandler;
            conn.Connect(out reciever);

            Console.WriteLine("Waiting for app to start up...");
            conn.VM_Resume();
            Thread.Sleep(5000);
            Console.WriteLine("Getting variables.");
            rootdomain = conn.RootDomain;
            corlibid   = conn.Domain_GetCorlib(rootdomain);
            assid      = conn.Domain_GetEntryAssembly(rootdomain);
            foreach (long thread in conn.VM_GetThreads())
            {
                if (conn.Thread_GetName(thread) == "")
                {
                    threadid = thread;
                }
            }
            //Console.WriteLine ("Root Domain: {0}\nCorlib: {1}\nExeAssembly: {2}\nThread: {3}", rootdomain, corlibid, assid, threadid);
            Console.WriteLine("Ready for hacking.");
        }