/// <summary> /// The Custom Inspector you will see in a custom location /// in which this static function is called. /// (IE: In MultiObjectWindow.cs) /// </summary> /// <param name="obj">GameObject with the script Enemy attached</param> public static void OnCustomInspectorGUI(GameObject obj) { Enemy e = obj.GetComponent <Enemy>(); // Produce error or e = null ? if (e == null) { CustomAPI.ErrorGUI(obj, typeof(Enemy)); } else { EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); addCVX(e); e.maxHP = (int)EditorGUILayout.Knob(new Vector2(25, 25), (float)e.maxHP, minMaxHP, maxMaxHP, "maxHP", Color.white, Color.cyan, true, GUILayout.MaxWidth(75)); if (e.currentHP > e.maxHP) { e.currentHP = e.maxHP; } e.currentHP = (int)EditorGUILayout.Knob(new Vector2(25, 25), (float)e.currentHP, 0, e.maxHP, "curHP", Color.white, Color.cyan, true, GUILayout.MaxWidth(75)); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); } }
public MethodAPI( APILine[] majorAPI, CustomMethodAPI[] customAPI, APILine[] optionalAPI) { MajorAPI.AddRange(majorAPI ?? EnumerableExt <APILine> .Empty); CustomAPI.AddRange(customAPI ?? EnumerableExt <CustomMethodAPI> .Empty); OptionalAPI.AddRange(optionalAPI ?? EnumerableExt <APILine> .Empty); }
private void btnSimplifyCustom_Click(object sender, EventArgs e) { CustomKind = CustomAPI.SIMPLIFY; DisableParam(); txtBodyIndex1.Enabled = true; ckEnableParam.Enabled = true; btnCustomAPI.Enabled = true; }
private void btnCutSurfaceCustom_Click(object sender, EventArgs e) { CustomKind = CustomAPI.CUT_SURFACE; DisableParam(); txtBodyIndex1.Enabled = true; txtBodyIndex2.Enabled = true; btnCustomAPI.Enabled = true; }
// ================================================ // Event - Mesh Edit (Custom) // ================================================ private void btnMergeBodyCustom_Click(object sender, EventArgs e) { CustomKind = CustomAPI.MERGE_BODY; DisableParam(); txtBodyIndex1.Enabled = true; txtBodyIndex2.Enabled = true; btnCustomAPI.Enabled = true; }
public void Initialize() { //Set title and print version Console.Title = string.Format("RockSniffer {0}", version); Logger.Log("RockSniffer {0} ({1}bits)", version, CustomAPI.Is64Bits() ? "64" : "32"); //Initialize and load configuration config = new Config(); try { config.Load(); } catch (Exception e) { Logger.LogError("Could not load configuration: {0}\r\n{1}", e.Message, e.StackTrace); throw e; } //Run version check if (!config.debugSettings.disableVersionCheck) { VersionCheck(); } //Transfer logging options Logger.logStateMachine = config.debugSettings.debugStateMachine; Logger.logCache = config.debugSettings.debugCache; Logger.logFileDetailQuery = config.debugSettings.debugFileDetailQuery; Logger.logMemoryReadout = config.debugSettings.debugMemoryReadout; Logger.logSongDetails = config.debugSettings.debugSongDetails; Logger.logSystemHandleQuery = config.debugSettings.debugSystemHandleQuery; //Initialize cache cache = new SQLiteCache(); //Create directories Directory.CreateDirectory("output"); //Enable addon service if configured if (config.addonSettings.enableAddons) { try { addonService = new AddonService(config.addonSettings.ipAddress, config.addonSettings.port, new SQLiteStorage()); } catch (SocketException e) { Logger.LogError("Please verify that the IP address is valid and the port is not already in use"); Logger.LogError("Could not start addon service: {0}\r\n{1}", e.Message, e.StackTrace); } catch (Exception e) { Logger.LogError("Could not start addon service: {0}\r\n{1}", e.Message, e.StackTrace); } } }
private void btnMoveVertexCustom_Click(object sender, EventArgs e) { CustomKind = CustomAPI.MOVE_VERTEX; DisableParam(); txtBodyIndex1.Enabled = true; txtVertex1.Enabled = true; txtVertex2.Enabled = true; btnCustomAPI.Enabled = true; }
private List <string> SniffFileHandles() { //Build a list of all song files being accessed List <string> songFiles = new List <string>(); //Get all handles from the rocksmith process var handles = CustomAPI.GetHandles(rsProcess); //If there aren't any handles, return if (handles == null) { return(null); } var strTemp = ""; FileDetails fd = null; //Go through all the handles for (int i = 0; i < handles.Count; i++) { //Read the filename from the file handle try { fd = FileDetails.GetFileDetails(rsProcess.Handle, handles[i]); } catch (Exception e) { continue; } //If getting file details failed for this handle, skip it if (fd == null) { continue; } strTemp = fd.Name; //Add songs.psarc if (strTemp.EndsWith("songs.psarc")) { songFiles.Add(strTemp); } //Check if it matches the dlc pattern if (dlcPSARCMatcher.IsMatch(strTemp)) { //Add dlc files songFiles.Add(strTemp); } } return(songFiles); }
private void btnMoveLineCustom_Click(object sender, EventArgs e) { CustomKind = CustomAPI.MOVE_LINE; DisableParam(); txtBodyIndex1.Enabled = true; txtVertex1.Enabled = true; txtVertex2.Enabled = true; txtVertex3.Enabled = true; lb2.Text = "Line1"; lb3.Text = "Line2"; btnCustomAPI.Enabled = true; }
private void btnMoveSurfaceCustom_Click(object sender, EventArgs e) { CustomKind = CustomAPI.MOVE_SURFACE; DisableParam(); txtBodyIndex1.Enabled = true; txtVertex1.Enabled = true; txtVertex2.Enabled = true; txtVertex3.Enabled = true; lb2.Text = "Plane"; lb3.Text = "Normal"; btnCustomAPI.Enabled = true; }
public void Initialize() { //Set title and print version Console.Title = string.Format("RockSniffer {0}", version); Console.WriteLine("RockSniffer {0} ({1}bits)", version, CustomAPI.Is64Bits() ? "64" : "32"); //Initialize and load configuration config = new Config(); config.Load(); //Transfer logging options Logger.logStateMachine = config.debugSettings.debugStateMachine; Logger.logCache = config.debugSettings.debugCache; Logger.logFileDetailQuery = config.debugSettings.debugFileDetailQuery; Logger.logHIRCScan = config.debugSettings.debugHIRCScan; Logger.logMemoryReadout = config.debugSettings.debugMemoryReadout; Logger.logSongDetails = config.debugSettings.debugSongDetails; Logger.logSystemHandleQuery = config.debugSettings.debugSystemHandleQuery; //Initialize cache cache = new FileCache(cachedir); //Create directories Directory.CreateDirectory("output"); //Enable addon service if configured if (config.addonSettings.enableAddons) { try { addonService = new AddonService(config.addonSettings.ipAddress, config.addonSettings.port); } catch (SocketException e) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Please verify that the IP address is valid and the port is not already in use"); Console.WriteLine("Could not start addon service: {0}", e.Message); Console.WriteLine(e.StackTrace); Console.ResetColor(); } catch (Exception e) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Could not start addon service: {0}", e.Message); Console.WriteLine(e.StackTrace); Console.ResetColor(); } } }
/// <summary> /// The Custom Inspector you will see in a custom location /// in which this static function is called. /// (IE: In MultiObjectWindow.cs) /// </summary> /// <param name="obj">GameObject with the script Enemy attached</param> public static void OnCustomInspectorGUI(GameObject obj) { Test comp = obj.GetComponent <Test>(); // Produce error or e = null ? if (comp == null) { CustomAPI.ErrorGUI(obj, typeof(Test)); } else { addCVX(comp); GUILayout.Label("Goodbye World"); } }
/// <summary> /// Implement this method in your custom editor script too add these features: /// Copy - Paste - Cut Script Buttons /// </summary> /// <param name="comp"></param> protected static void addCVX(Component comp) { valCVX = CustomAPI.CVX(copied, comp); if (valCVX < 0) { DestroyImmediate(comp); } else if (valCVX > 0) { copied = true; } else { copied = false; } }
/// <summary> /// Database server /// </summary> public Server() { TcpListener listener = null; bool errorOccured = false; try { listener = new TcpListener(IPAddress.Parse(listenerAddress), 3351); listener.Start(); CustomAPI.logging("Listening to " + listenerAddress + ":3351"); Console.WriteLine("Waiting for connection..."); while (true) { TcpClient client = listener.AcceptTcpClient(); CustomAPI.logging("Webserver connected"); Thread t = new Thread(ProcessClientConnection); t.Start(client); } } catch (SocketException e) { CustomAPI.logging("Socket Exception, " + e); errorOccured = true; } catch (Exception e) { CustomAPI.logging("Unknown Exception, " + e); errorOccured = true; } finally { CustomAPI.logging("Server down"); if (listener != null) { listener.Stop(); } if (errorOccured) { Console.WriteLine("[Restarting server]"); new Server(); } } }
/// <summary> /// Calculate the amount payable for user after discount. /// </summary> /// <returns>Calculated final price after discount</returns> /// public double calculatePrice() { int totalNoOfDays = (int)(Booking.CheckOutDate - Booking.CheckInDate).TotalDays; double pricePerPerson = 0; double BasePrice = House.OriginalPrice / House.MaxNoOfPeople; double FinalPrice; int totalNoOfPeopleDay = NoOfPeopleBooked + NoOfGuest; double newDiscount = 0; double discountedAmount = 0; double dayPrice = 0; if (totalNoOfPeopleDay > 1) { for (int i = 1; i < totalNoOfPeopleDay; i++) { if (i == 1) { newDiscount = START_DISCOUNT; } else { if (newDiscount > 1) { try { newDiscount = newDiscount / 2; } catch (ArithmeticException e) { CustomAPI.logging(e.Message); } } } if (discountedAmount < 50) { discountedAmount += newDiscount; } } } FinalPrice = (BasePrice * NoOfGuest * totalNoOfDays) * ((100 - discountedAmount) / 100); return(FinalPrice); }
public EntityReference Register(IOrganizationService client, EntityReference parentPlugin) { var apiEntity = new CustomAPI() { Name = this.Name, UniqueName = this.Name, DisplayName = this.FriendlyName, Description = this.Description, PluginTypeId = parentPlugin, IsFunction = this.IsFunction, IsPrivate = this.IsPrivate, BindingType = this.BindingType, AllowedCustomProcessingStepType = this.AllowedCustomProcessingStepType, ExecutePrivilegeName = this.ExecutePrivilegeName }; var existingApiQuery = this.GetExistingQuery(parentPlugin.Id); return(apiEntity.CreateOrUpdate(client, existingApiQuery)); }
/// <summary> /// Webserver attempts to connect to the database /// </summary> public static void RegisterDataAccess() { //TODO: Key exchange between database server and webserver try { client = new TcpClient("127.0.0.1", 3351); sr = new StreamReader(client.GetStream(), Encoding.UTF8, true, BUFFER_SIZE); sw = new StreamWriter(client.GetStream(), Encoding.UTF8, BUFFER_SIZE); sw.AutoFlush = true; Debug.WriteLine("Waiting for database server"); bool proceed = false; while (!proceed) { proceed = Convert.ToBoolean(sr.ReadLine()); Debug.WriteLine("WAITING"); } if (!auth_bypass) { bool dbPublicKeyRetrieved = false; bool keyExchanged = false; string password = "******"; //Key in from user int rsaKeySize = 1024; string wsPublicKey = null; string wsPrivateKey = null; string dbPublicKey = null; while (true) { //TODO: Authentication between servers if (!dbPublicKeyRetrieved) { Debug.WriteLine("Generating a {0} size key", rsaKeySize); EncryptionRSA.GenerateKeys(rsaKeySize, out wsPublicKey, out wsPrivateKey); sw.WriteLine(wsPublicKey); //Sending database public key to webserver in plain sw.Flush(); dbPublicKey = sr.ReadLine(); dbPublicKeyRetrieved = true; } else if (!keyExchanged) { using (ECDiffieHellmanCng ecd = new ECDiffieHellmanCng()) { ecd.KeyDerivationFunction = ECDiffieHellmanKeyDerivationFunction.Hash; ecd.KeySize = 256; ecd.HashAlgorithm = CngAlgorithm.Sha256; tempKey = ecd.PublicKey.ToByteArray(); //Generate shared secret key string encryptTempKey = EncryptionRSA.Encrypt(Convert.ToBase64String(tempKey), rsaKeySize, dbPublicKey); sw.WriteLine(encryptTempKey); //Sending database temp key to webserver server sw.Flush(); string encryptDbTempKey = sr.ReadLine(); //Retrieve webserver temp key byte[] dbTempKey = Convert.FromBase64String(EncryptionRSA.Decrypt(encryptDbTempKey, rsaKeySize, wsPrivateKey)); masterKey = ecd.DeriveKeyMaterial(CngKey.Import(dbTempKey, CngKeyBlobFormat.EccPublicBlob)); CustomAPI.readContent(masterKey); Debug.WriteLine("Master Key Generated"); //Generate an new IV using (Aes aes = new AesCryptoServiceProvider()) { iv = aes.IV; } sw.WriteLine(Convert.ToBase64String(iv)); sw.Flush(); keyExchanged = true; } } else { break; } } } sw.AutoFlush = false; } catch (Exception e) { CustomAPI.logging(e.Message); } }
/// <summary> /// Initiate new client to connect /// </summary> /// <param name="args"></param> private async void ProcessClientConnection(object args) { TcpClient client = (TcpClient)args; StreamReader sr; StreamWriter sw; try { sr = new StreamReader(client.GetStream(), Encoding.UTF8, true, BUFFER_SIZE); sw = new StreamWriter(client.GetStream(), Encoding.UTF8, BUFFER_SIZE); sw.AutoFlush = true; while (true) { bool testDecrypted = false; Console.Write("Enter AES encryption key: "); string tempKey = "/gUFEqNJ17CV52nJTs1ruB8BsZ8kNBpyDVMJH26AGIE="; //string tempKey = Console.ReadLine(); Console.Write("Enter AES IV: "); string tempIV = "UaTwfDMLvZb2uh96KTKmvQ=="; //string tempIV = Console.ReadLine(); Console.Write("Enter Password: "******"doyouknowdawae"; //string password = Console.ReadLine(); //Load key and IV into constructor EncryptionAES.password = tempKey; EncryptionAES.iv = tempIV; //Create(password); //Response r = Login(password); //while (r.Success == false) //{ // Console.Write("Enter AES encryption key: "); // tempKey = Console.ReadLine(); // Console.Write("Enter AES IV: "); // tempIV = Console.ReadLine(); // Console.Write("Enter Password: "******"true"); //Sending database public key to webserver in plain await sw.FlushAsync(); break; } else { CustomAPI.logging("Incorrect encryption key or IV entered"); } } if (!auth_bypass) { bool wsPublicKeyRetrieved = false; string password = "******"; int rsaKeySize = 1024; string dbPublicKey = null; string dbPrivateKey = null; string wsPublicKey = null; //bool proceed = true; //if (!proceed) //{ // return; //} while (true) { //TODO: Authentication between servers if (!wsPublicKeyRetrieved) { try { Console.WriteLine("Generating a {0} size key ...", rsaKeySize); EncryptionRSA.GenerateKeys(rsaKeySize, out dbPublicKey, out dbPrivateKey); await sw.WriteLineAsync(dbPublicKey); //Sending database public key to webserver in plain await sw.FlushAsync(); wsPublicKey = sr.ReadLine(); Console.WriteLine("Webserver public key received"); wsPublicKeyRetrieved = true; } catch (Exception e) { CustomAPI.logging(e.Message); wsPublicKeyRetrieved = false; } } else if (!keyExchanged) { using (ECDiffieHellmanCng ecd = new ECDiffieHellmanCng()) { ecd.KeyDerivationFunction = ECDiffieHellmanKeyDerivationFunction.Hash; ecd.KeySize = 256; ecd.HashAlgorithm = CngAlgorithm.Sha256; tempKey = ecd.PublicKey.ToByteArray(); //Generate shared secret key string encryptTempKey = EncryptionRSA.Encrypt(Convert.ToBase64String(tempKey), rsaKeySize, wsPublicKey); await sw.WriteLineAsync(encryptTempKey); //Sending database temp key to webserver server await sw.FlushAsync(); string encryptedWsTempKey = sr.ReadLine(); //Retrieve webserver temp key byte[] wsTempKey = Convert.FromBase64String(EncryptionRSA.Decrypt(encryptedWsTempKey, rsaKeySize, dbPrivateKey)); masterKey = ecd.DeriveKeyMaterial(CngKey.Import(wsTempKey, CngKeyBlobFormat.EccPublicBlob)); CustomAPI.readContent(masterKey); Console.Write("Master Key Generated"); iv = Convert.FromBase64String(sr.ReadLine()); //IV Generated from webserver set to here keyExchanged = true; } } else { break; //Configuration between servers have been completed } } } if (keyExchanged) { ListeningToClient(sr, sw); } } catch (Exception e) { Console.WriteLine(e); if (client != null) { client.Close(); } } }
private List <string> SniffFileHandles() { //Build a list of all song files being accessed List <string> songFiles = new List <string>(); List <FileDetails> fds = new List <FileDetails>(); switch (Environment.OSVersion.Platform) { case PlatformID.MacOSX: case PlatformID.Unix: int numPath = 0; IntPtr pathPointers = MacOSAPI.proc_pidinfo_wrapper(memReader.PInfo.PID, out numPath); //Logger.Log("Num Paths: " + numPath); IntPtr[] pIntPtrArray = new IntPtr[numPath]; var ManagedStringArray = new string[numPath]; Marshal.Copy(pathPointers, pIntPtrArray, 0, numPath); for (int i = 0; i < numPath; i++) { ManagedStringArray[i] = Marshal.PtrToStringAnsi(pIntPtrArray[i]); fds.Add(new FileDetails() { Name = ManagedStringArray[i] }); } MacOSAPI.free_wrapper(pathPointers); break; default: //Get all handles from the rocksmith process var handles = CustomAPI.GetHandles(rsProcess); //If there aren't any handles, return if (handles == null) { return(null); } for (int i = 0; i < handles.Count; i++) { //Read the filename from the file handle try { var fd = FileDetails.GetFileDetails(rsProcess.Handle, handles[i]); fds.Add(fd); } catch (Exception) { continue; } } break; } var strTemp = ""; //Go through all the handles for (int i = 0; i < fds.Count; i++) { FileDetails fd = fds[i]; //If getting file details failed for this handle, skip it if (fd == null) { continue; } strTemp = fd.Name; //Add songs.psarc if (strTemp.EndsWith("songs.psarc")) { songFiles.Add(strTemp); } //Check if it matches the dlc pattern if (dlcPSARCMatcher.IsMatch(strTemp)) { //Add dlc files songFiles.Add(strTemp); } } return(songFiles); }
public void Run() { //Clear output / create output files ClearOutput(); Logger.Log(string.Format("Waiting for rocksmith on {0}", Environment.OSVersion.Platform)); //Loop infinitely trying to find rocksmith process while (true) { var processes = Process.GetProcessesByName("Rocksmith2014"); //Sleep for 1 second if no processes found if (processes.Length == 0) { Thread.Sleep(1000); continue; } //Select the first rocksmith process and open a handle rsProcess = processes[0]; if (rsProcess.HasExited || (!CustomAPI.IsRunningOnMono() && !rsProcess.Responding)) { Thread.Sleep(1000); continue; } break; } Logger.Log("Rocksmith found! Sniffing..."); Sniffer.SnifferActions actions = Sniffer.SnifferActions.NONE; if (!config.debugSettings.disableFileHandleSniffing) { actions = Sniffer.SnifferActions.SNIFF_FILE_HANDLES; } // can optionally turn off sniffer actions via config.debugSettings actions |= Sniffer.SnifferActions.MEMORY_READOUT; actions |= Sniffer.SnifferActions.STATE_MACHINE; //Initialize file handle reader and memory reader Sniffer sniffer = new Sniffer(rsProcess, cache, actions); //Listen for events sniffer.OnSongChanged += Sniffer_OnCurrentSongChanged; sniffer.OnMemoryReadout += Sniffer_OnMemoryReadout; //Inform AddonService if (config.addonSettings.enableAddons && addonService != null) { addonService.SetSniffer(sniffer); } while (true) { if (rsProcess == null || rsProcess.HasExited) { break; } //OutputDetails(); //GOTTA GO FAST Thread.Sleep(1000); if (random.Next(0, 100) > 99) { Console.WriteLine("*sniff sniff*"); } } sniffer.Stop(); //Clean up as best as we can rsProcess.Dispose(); rsProcess = null; Logger.Log("This is rather unfortunate, the Rocksmith2014 process has vanished :/"); }