Ejemplo n.º 1
0
        public static void StartClient()
        {
            try
            {
                ConsoleEx.WriteLine("Starting Vanguard Client");
                Thread.Sleep(500); //When starting in Multiple Startup Project, the first try will be uncessful since
                                   //the server takes a bit more time to start then the client.

                var spec = new NetCoreReceiver();
                spec.Attached         = VanguardCore.attached;
                spec.MessageReceived += OnMessageReceived;

                connector = new RTCV.Vanguard.VanguardConnector(spec);
            }
            catch (Exception ex)
            {
                if (VanguardCore.ShowErrorDialog(ex, true) == DialogResult.Abort)
                {
                    throw new RTCV.NetCore.AbortEverythingException();
                }
            }
        }
Ejemplo n.º 2
0
        private static void OnMessageReceived(object sender, NetCoreEventArgs e)
        {
            try
            {
                // This is where you implement interaction.
                // Warning: Any error thrown in here will be caught by NetCore and handled by being displayed in the console.

                var message         = e.message;
                var simpleMessage   = message as NetCoreSimpleMessage;
                var advancedMessage = message as NetCoreAdvancedMessage;

                ConsoleEx.WriteLine(message.Type);
                switch (message.Type) //Handle received messages here
                {
                case RTCV.NetCore.Commands.Remote.AllSpecSent:
                {
                    //We still need to set the emulator's path
                    AllSpec.VanguardSpec.Update(VSPEC.EMUDIR, UnityWatch.currentDir);
                    SyncObjectSingleton.FormExecute(() =>
                        {
                            UnityWatch.UpdateDomains();
                        });
                }
                break;

                case RTCV.NetCore.Commands.Basic.SaveSavestate:
                    e.setReturnValue("");
                    break;

                case RTCV.NetCore.Commands.Basic.LoadSavestate:
                    e.setReturnValue(true);
                    break;

                case RTCV.NetCore.Commands.Remote.PreCorruptAction:
                    if (UnityWatch.currentFileInfo.TerminateBeforeExecution)
                    {
                        UnityWatch.KillProcess();
                    }
                    UnityWatch.currentFileInfo.targetInterface.CloseStream();
                    UnityWatch.RestoreTarget();
                    break;

                case RTCV.NetCore.Commands.Remote.PostCorruptAction:
                    //var fileName = advancedMessage.objectValue as String;
                    UnityWatch.currentFileInfo.targetInterface.CloseStream();
                    SyncObjectSingleton.FormExecute(() =>
                    {
                        Executor.Execute();
                    });
                    break;

                case RTCV.NetCore.Commands.Remote.CloseGame:
                    SyncObjectSingleton.FormExecute(() =>
                    {
                        UnityWatch.KillProcess();
                    });
                    break;

                case RTCV.NetCore.Commands.Remote.DomainGetDomains:
                    SyncObjectSingleton.FormExecute(() =>
                    {
                        e.setReturnValue(UnityWatch.GetInterfaces());
                    });
                    break;

                case RTCV.NetCore.Commands.Remote.EventEmuMainFormClose:
                    SyncObjectSingleton.FormExecute(() =>
                    {
                        Environment.Exit(0);
                    });
                    break;

                case RTCV.NetCore.Commands.Remote.IsNormalAdvance:
                    e.setReturnValue(true);
                    break;

                case RTCV.NetCore.Commands.Remote.EventCloseEmulator:
                    Environment.Exit(-1);
                    break;
                }
            }
            catch (Exception ex)
            {
                if (VanguardCore.ShowErrorDialog(ex, true) == DialogResult.Abort)
                {
                    throw new RTCV.NetCore.AbortEverythingException();
                }
            }
        }
Ejemplo n.º 3
0
        private static void OnMessageReceived(object sender, NetCoreEventArgs e)
        {
            try
            {
                // This is where you implement interaction.
                // Warning: Any error thrown in here will be caught by NetCore and handled by being displayed in the console.

                var message         = e.message;
                var simpleMessage   = message as NetCoreSimpleMessage;
                var advancedMessage = message as NetCoreAdvancedMessage;

                ConsoleEx.WriteLine(message.Type);
                switch (message.Type) //Handle received messages here
                {
                case RTCV.NetCore.Commands.Remote.AllSpecSent:
                {
                    //We still need to set the emulator's path
                    AllSpec.VanguardSpec.Update(VSPEC.EMUDIR, Hook.currentDir);
                    SyncObjectSingleton.FormExecute(() =>
                        {
                            Hook.UpdateDomains();
                        });
                }
                break;

                case RTCV.NetCore.Commands.Basic.SaveSavestate:
                    e.setReturnValue("");
                    break;

                case RTCV.NetCore.Commands.Basic.LoadSavestate:
                    e.setReturnValue(true);
                    break;

                case RTCV.NetCore.Commands.Remote.PreCorruptAction:

                    //SyncObjectSingleton.FormExecute(() =>
                    //{
                    //    lock (Hook.CorruptLock)
                    //    {
                    //        if (Hook.SuspendProcess)
                    //        {
                    //            if (!Hook.p?.Suspend() ?? true && !suspendWarned)
                    //            {
                    //                suspendWarned = (MessageBox.Show("Failed to suspend a thread!\nWould you like to continue to receive warnings?", "Failed to suspend thread", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.Yes);
                    //            }
                    //        }

                    //        Hook.DontChangeMemoryProtection = true;
                    //        var count = 0;
                    //        foreach (var m in MemoryDomains.MemoryInterfaces.Values)
                    //        {
                    //            if (m.MD is ProcessMemoryDomain pmd)
                    //            {
                    //                if (!pmd.SetMemoryProtection(ProcessExtensions.MemoryProtection.ExecuteReadWrite))
                    //                    count++;
                    //            }
                    //        }

                    //        Console.WriteLine($"PreCorrupt\n" +
                    //                          $"Total domains: {MemoryDomains.MemoryInterfaces.Values.Count}\n" +
                    //                          $"Errors: {count}");
                    //    }
                    //});

                    break;

                case RTCV.NetCore.Commands.Remote.PostCorruptAction:
                    //SyncObjectSingleton.FormExecute(() =>
                    //{
                    //    lock (Hook.CorruptLock)
                    //    {
                    //        foreach (var m in MemoryDomains.MemoryInterfaces.Values)
                    //        {
                    //            if (m.MD is ProcessMemoryDomain pmd)
                    //            {
                    //                pmd.ResetMemoryProtection();
                    //                pmd.FlushInstructionCache();
                    //            }
                    //        }
                    //        Hook.DontChangeMemoryProtection = false;
                    //        if (Hook.SuspendProcess)
                    //        {
                    //            if (!Hook.p?.Resume() ?? true && !suspendWarned)
                    //            {
                    //                suspendWarned = (MessageBox.Show("Failed to resume a thread!\nWould you like to continue to receive warnings?", "Failed to resume thread", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.Yes);
                    //            }
                    //        }
                    //    }
                    //});
                    break;

                case RTCV.NetCore.Commands.Remote.CloseGame:
                    break;

                case RTCV.NetCore.Commands.Remote.DomainGetDomains:
                    SyncObjectSingleton.FormExecute(() =>
                    {
                        e.setReturnValue(Hook.GetInterfaces());
                    });
                    break;

                case RTCV.NetCore.Commands.Remote.DomainRefreshDomains:
                    SyncObjectSingleton.FormExecute(() => { Hook.UpdateDomains(); });
                    break;

                case RTCV.NetCore.Commands.Remote.EventEmuMainFormClose:
                    SyncObjectSingleton.FormExecute(() =>
                    {
                        Environment.Exit(0);
                    });
                    break;

                case RTCV.NetCore.Commands.Remote.IsNormalAdvance:
                    e.setReturnValue(true);
                    break;

                case RTCV.NetCore.Commands.Remote.EventCloseEmulator:
                    Environment.Exit(-1);
                    break;
                }
            }
            catch (Exception ex)
            {
                if (VanguardCore.ShowErrorDialog(ex, true) == DialogResult.Abort)
                {
                    throw new AbortEverythingException();
                }
            }
        }
Ejemplo n.º 4
0
        private static void OnMessageReceived(object sender, NetCoreEventArgs e)
        {
            try
            {
                // This is where you implement interaction.
                // Warning: Any error thrown in here will be caught by NetCore and handled by being displayed in the console.

                var message         = e.message;
                var simpleMessage   = message as NetCoreSimpleMessage;
                var advancedMessage = message as NetCoreAdvancedMessage;

                ConsoleEx.WriteLine(message.Type);
                switch (message.Type) //Handle received messages here
                {
                case RTCV.NetCore.Commands.Remote.AllSpecSent:
                {
                    //We still need to set the emulator's path
                    AllSpec.VanguardSpec.Update(VSPEC.EMUDIR, CemuWatch.currentGameInfo.cemuExeFile.Directory.FullName);
                    SyncObjectSingleton.FormExecute(() =>
                        {
                            CemuWatch.UpdateDomains();
                        });
                }
                break;

                case RTCV.NetCore.Commands.Basic.SaveSavestate:
                    SyncObjectSingleton.FormExecute(() =>
                    {
                        e.setReturnValue(VanguardCore.SaveSavestate_NET(advancedMessage.objectValue as string));
                        //e.setReturnValue("");
                    });
                    break;

                case RTCV.NetCore.Commands.Basic.LoadSavestate:
                {
                    var cmd      = advancedMessage.objectValue as object[];
                    var path     = cmd[0] as string;
                    var location = (StashKeySavestateLocation)cmd[1];
                    SyncObjectSingleton.FormExecute(() =>
                        {
                            e.setReturnValue(VanguardCore.LoadSavestate_NET(path, location));
                        });


                    e.setReturnValue(true);
                    break;
                }

                case RTCV.NetCore.Commands.Remote.PreCorruptAction:
                    CemuWatch.KillCemuProcess(false);
                    CemuWatch.RestoreBackup();
                    break;

                case RTCV.NetCore.Commands.Remote.PostCorruptAction:
                {
                    //var fileName = advancedMessage.objectValue as String;
                    SyncObjectSingleton.FormExecute(() =>
                        {
                            CemuWatch.StartRpx();
                        });
                }
                break;

                case RTCV.NetCore.Commands.Remote.CloseGame:
                    SyncObjectSingleton.FormExecute(() =>
                    {
                        CemuWatch.KillCemuProcess(false);
                    });

                    break;

                case RTCV.NetCore.Commands.Remote.DomainGetDomains:
                    SyncObjectSingleton.FormExecute(() =>
                    {
                        e.setReturnValue(CemuWatch.GetInterfaces());
                    });
                    break;

                case RTCV.NetCore.Commands.Remote.EventEmuMainFormClose:
                    SyncObjectSingleton.FormExecute(() =>
                    {
                        Environment.Exit(0);
                    });
                    break;

                case RTCV.NetCore.Commands.Remote.IsNormalAdvance:
                    e.setReturnValue(true);
                    //e.setReturnValue(Hooks.isNormalAdvance);
                    break;

                case RTCV.NetCore.Commands.Remote.EventCloseEmulator:
                    Environment.Exit(-1);
                    break;
                }
            }
            catch (Exception ex)
            {
                if (VanguardCore.ShowErrorDialog(ex, true) == DialogResult.Abort)
                {
                    throw new RTCV.NetCore.AbortEverythingException();
                }
            }
        }
Ejemplo n.º 5
0
        private static void OnMessageReceived(object sender, NetCoreEventArgs e)
        {
            try
            {
                // This is where you implement interaction.
                // Warning: Any error thrown in here will be caught by NetCore and handled by being displayed in the console.

                var message         = e.message;
                var simpleMessage   = message as NetCoreSimpleMessage;
                var advancedMessage = message as NetCoreAdvancedMessage;

                ConsoleEx.WriteLine(message.Type);
                switch (message.Type) //Handle received messages here
                {
                case REMOTE_ALLSPECSSENT:
                {
                    //We still need to set the emulator's path
                    AllSpec.VanguardSpec.Update(VSPEC.EMUDIR, FileWatch.currentDir);
                    SyncObjectSingleton.FormExecute(() =>
                        {
                            FileWatch.UpdateDomains();
                        });
                }
                break;

                case SAVESAVESTATE:
                    e.setReturnValue("");
                    break;

                case LOADSAVESTATE:
                    e.setReturnValue(true);
                    break;

                case REMOTE_PRECORRUPTACTION:
                    FileWatch.KillProcess();
                    FileWatch.currentFileInfo.targetInterface.CloseStream();
                    FileWatch.RestoreTarget();
                    break;

                case REMOTE_POSTCORRUPTACTION:
                    //var fileName = advancedMessage.objectValue as String;
                    FileWatch.currentFileInfo.targetInterface.CloseStream();
                    SyncObjectSingleton.FormExecute(() =>
                    {
                        Executor.Execute();
                    });
                    break;

                case REMOTE_CLOSEGAME:
                    SyncObjectSingleton.FormExecute(() =>
                    {
                        FileWatch.KillProcess();
                    });
                    break;

                case REMOTE_DOMAIN_GETDOMAINS:
                    SyncObjectSingleton.FormExecute(() =>
                    {
                        e.setReturnValue(FileWatch.GetInterfaces());
                    });
                    break;

                case REMOTE_EVENT_EMU_MAINFORM_CLOSE:
                    SyncObjectSingleton.FormExecute(() =>
                    {
                        Environment.Exit(0);
                    });
                    break;

                case REMOTE_ISNORMALADVANCE:
                    e.setReturnValue(true);
                    break;

                case REMOTE_EVENT_CLOSEEMULATOR:
                    Environment.Exit(-1);
                    break;
                }
            }
            catch (Exception ex)
            {
                if (VanguardCore.ShowErrorDialog(ex, true) == DialogResult.Abort)
                {
                    throw new RTCV.NetCore.AbortEverythingException();
                }
            }
        }
        private static void OnMessageReceived(object sender, NetCoreEventArgs e)
        {
            try
            {
                // This is where you implement interaction.
                // Warning: Any error thrown in here will be caught by NetCore and handled by being displayed in the console.

                var message         = e.message;
                var simpleMessage   = message as NetCoreSimpleMessage;
                var advancedMessage = message as NetCoreAdvancedMessage;

                ConsoleEx.WriteLine(message.Type);
                switch (message.Type) //Handle received messages here
                {
                case RTCV.NetCore.Commands.Remote.AllSpecSent:
                {
                    //We still need to set the emulator's path
                    AllSpec.VanguardSpec.Update(VSPEC.EMUDIR, FileWatch.currentDir);
                    SyncObjectSingleton.FormExecute(() =>
                        {
                            FileWatch.UpdateDomains();
                        });
                }
                break;

                case RTCV.NetCore.Commands.Basic.SaveSavestate:

                    string key = (advancedMessage.objectValue as string);

                    //TODO: Sync states with keys

                    SyncObjectSingleton.FormExecute(() =>
                    {
                        S.GET <StubForm>().btnRamSaveState_Click(null, null);
                        string returnKey = VanguardCore.SaveSavestate_NET(key);
                        e.setReturnValue(returnKey);
                    });

                    break;

                case RTCV.NetCore.Commands.Basic.LoadSavestate:

                    var cmd      = advancedMessage.objectValue as object[];
                    var path     = cmd[0] as string;
                    var location = (StashKeySavestateLocation)cmd[1];

                    SyncObjectSingleton.FormExecute(() =>
                    {
                        //e.setReturnValue(VanguardCore.LoadSavestate_NET(path, location));
                        VanguardCore.LoadSavestate_NET(path, location);
                        S.GET <StubForm>().RepackState(false);
                    });

                    e.setReturnValue(true);

                    break;

                case RTCV.NetCore.Commands.Remote.PreCorruptAction:
                    FileWatch.KillProcess();
                    FileWatch.currentFileInfo.targetInterface.CloseStream();
                    FileWatch.RestoreTarget();
                    break;

                case RTCV.NetCore.Commands.Remote.PostCorruptAction:
                    //var fileName = advancedMessage.objectValue as String;
                    FileWatch.currentFileInfo.targetInterface?.CloseStream();
                    SyncObjectSingleton.FormExecute(() =>
                    {
                        Executor.Execute();
                    });
                    break;

                case RTCV.NetCore.Commands.Remote.CloseGame:
                    SyncObjectSingleton.FormExecute(() =>
                    {
                        FileWatch.KillProcess();
                    });
                    break;

                case RTCV.NetCore.Commands.Remote.DomainGetDomains:
                    SyncObjectSingleton.FormExecute(() =>
                    {
                        e.setReturnValue(FileWatch.GetInterfaces());
                    });
                    break;

                case RTCV.NetCore.Commands.Remote.EventEmuMainFormClose:
                    SyncObjectSingleton.FormExecute(() =>
                    {
                        Environment.Exit(0);
                    });
                    break;

                case RTCV.NetCore.Commands.Remote.IsNormalAdvance:
                    e.setReturnValue(true);
                    break;

                case RTCV.NetCore.Commands.Remote.EventCloseEmulator:
                    Environment.Exit(-1);
                    break;
                }
            }
            catch (Exception ex)
            {
                if (VanguardCore.ShowErrorDialog(ex, true) == DialogResult.Abort)
                {
                    throw new RTCV.NetCore.AbortEverythingException();
                }
            }
        }
Ejemplo n.º 7
0
        private static void OnMessageReceived(object sender, NetCoreEventArgs e)
        {
            try
            {
                // This is where you implement interaction.
                // Warning: Any error thrown in here will be caught by NetCore and handled by being displayed in the console.

                var message         = e.message;
                var simpleMessage   = message as NetCoreSimpleMessage;
                var advancedMessage = message as NetCoreAdvancedMessage;

                ConsoleEx.WriteLine(message.Type);
                switch (message.Type) //Handle received messages here
                {
                case REMOTE_ALLSPECSSENT:
                {
                    //We still need to set the emulator's path
                    AllSpec.VanguardSpec.Update(VSPEC.EMUDIR, CemuWatch.currentGameInfo.cemuExeFile.Directory.FullName);
                    SyncObjectSingleton.FormExecute(() =>
                        {
                            CemuWatch.UpdateDomains();
                        });
                }
                break;

                case SAVESAVESTATE:
                    SyncObjectSingleton.FormExecute(() =>
                    {
                        e.setReturnValue(VanguardCore.SaveSavestate_NET(advancedMessage.objectValue as string));
                        //e.setReturnValue("");
                    });
                    break;

                case LOADSAVESTATE:
                {
                    var cmd      = advancedMessage.objectValue as object[];
                    var path     = cmd[0] as string;
                    var location = (StashKeySavestateLocation)cmd[1];
                    SyncObjectSingleton.FormExecute(() =>
                        {
                            e.setReturnValue(VanguardCore.LoadSavestate_NET(path, location));
                        });


                    e.setReturnValue(true);
                    break;
                }

                case REMOTE_PRECORRUPTACTION:
                    CemuWatch.KillCemuProcess(false);
                    CemuWatch.RestoreBackup();
                    break;

                case REMOTE_POSTCORRUPTACTION:
                {
                    //var fileName = advancedMessage.objectValue as String;
                    SyncObjectSingleton.FormExecute(() =>
                        {
                            CemuWatch.StartRpx();
                        });
                }
                break;

                case REMOTE_CLOSEGAME:
                    SyncObjectSingleton.FormExecute(() =>
                    {
                        CemuWatch.KillCemuProcess(false);
                    });

                    break;

                case REMOTE_DOMAIN_GETDOMAINS:
                    SyncObjectSingleton.FormExecute(() =>
                    {
                        e.setReturnValue(CemuWatch.GetInterfaces());
                    });
                    break;

                case REMOTE_EVENT_EMU_MAINFORM_CLOSE:
                    SyncObjectSingleton.FormExecute(() =>
                    {
                        Environment.Exit(0);
                    });
                    break;

                case REMOTE_ISNORMALADVANCE:
                    e.setReturnValue(true);
                    //e.setReturnValue(Hooks.isNormalAdvance);
                    break;

                case REMOTE_EVENT_CLOSEEMULATOR:
                    Environment.Exit(-1);
                    break;
                }
            }
            catch (Exception ex)
            {
                if (VanguardCore.ShowErrorDialog(ex, true) == DialogResult.Abort)
                {
                    throw new RTCV.NetCore.AbortEverythingException();
                }
            }
        }