diff --git a/src/aex/Entry.cs b/src/aex/Entry.cs index 94be7b0..5c65896 100644 --- a/src/aex/Entry.cs +++ b/src/aex/Entry.cs @@ -2,8 +2,11 @@ using System.Runtime.InteropServices; using RGiesecke.DllExport; using System; +using System.IO; using System.Threading; using System.Threading.Tasks; +using System.Collections.Generic; + /* * File: Entry.cs @@ -13,6 +16,70 @@ * Do not remvoe these comment blocks! */ +#if !A3COMPAT +using System.Text.RegularExpressions; +class main +{ + static Regex cr = new Regex(@"(\[.*?\])|(\"".*?\"")|(\d)"); + static bool Loaded = false; + static string sid; + static void Main() + { + bool exit = false; + StringBuilder output = new StringBuilder(); + if (!Loaded) + { + aex.EntryPoint.RvExtension(ref output, 1024, "load"); + sid = output.ToString(); + output.Clear(); + Loaded = true; + } + + while (!exit) + { + try + { + string cmd = Console.ReadLine(); + MatchCollection cm = cr.Matches(cmd); + List parameters = new List(); + string command = ""; + + parameters.Add(sid); + + foreach (Match x in cm) + { + string y = x.ToString(); + Console.WriteLine(y); + if (y.StartsWith("[")) { + command = y.Trim(new char[] { '[', ']' }); + Console.WriteLine(command); + } else if (y.StartsWith("\"")) + parameters.Add(y.Trim(new char[] { '"', '"' })); + else + parameters.Add(y); + } + if (command != "" && parameters.Count > 1) + { + int res = aex.EntryPoint.RvExtensionArgs(ref output, 1024, command, parameters.ToArray(), parameters.Count); + } + else if (command == "version") + aex.EntryPoint.RvExtensionVersion(ref output, 1024); + else + aex.EntryPoint.RvExtension(ref output, 1024, command); + + Console.Write(output.ToString()); + output.Clear(); + } + catch (Exception e) + { + Console.WriteLine(e); + } + } + } +} +#endif + + namespace aex { public class EntryPoint @@ -21,23 +88,29 @@ public class EntryPoint internal static string sessionid = Utility.Session.CreateID(); internal static string[] modules = { "Discord Disabled", "MySql Disabled" }; internal static readonly string version = "1.0.00"; +#if A3COMPAT #if is64 [DllExport("RVExtensionVersion", CallingConvention = CallingConvention.Winapi)] #else [DllExport("_RVExtensionVersion@8", CallingConvention = CallingConvention.Winapi)] #endif - public static void RvExtensionVersion(StringBuilder output, int outputSize) +#endif + public static void RvExtensionVersion(ref StringBuilder output, int outputSize) { outputSize--; output.Append(version); } + +#if A3COMPAT #if is64 [DllExport("RVExtension", CallingConvention = CallingConvention.Winapi)] #else [DllExport("_RVExtension@12", CallingConvention = CallingConvention.Winapi)] #endif - public static void RvExtension(StringBuilder output, int outputSize, [MarshalAs(UnmanagedType.LPStr)] string function) +#else + public static void RvExtension(ref StringBuilder output, int outputSize, string function) +#endif { outputSize--; if (function == "load") @@ -52,16 +125,13 @@ public static void RvExtension(StringBuilder output, int outputSize, [MarshalAs( Mysql.ModuleInit(); string ActiveModules = "[AEX::INIT::MODULES] " + modules[0] + " | " + modules[1]; Utility.Session.LogThis(ActiveModules); + output.Append(sessionid); init = true; } catch (Exception e) { Utility.Session.LogThis("[AEX::EXCEPTION] " + e.ToString()); } - if (!init) - { - output.Append(sessionid); - } } else { @@ -71,6 +141,7 @@ public static void RvExtension(StringBuilder output, int outputSize, [MarshalAs( } } +#if A3COMPAT #if is64 [DllExport("RVExtensionArgs", CallingConvention = CallingConvention.Winapi)] #else @@ -79,6 +150,9 @@ public static void RvExtension(StringBuilder output, int outputSize, [MarshalAs( public static int RvExtensionArgs(StringBuilder output, int outputSize, [MarshalAs(UnmanagedType.LPStr)] string function, [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPStr, SizeParamIndex = 4)] string[] args, int argCount) +#else + public static int RvExtensionArgs(ref StringBuilder output, int outputSize, string function, string[] args, int argCount) +#endif { outputSize--; try @@ -135,7 +209,7 @@ public static int RvExtensionArgs(StringBuilder output, int outputSize, case "mysql:async": if (args.Length == 3) { - Task SQLAsync = Mysql.ExecuteAsync(args[1], Convert.ToBoolean(args[2])); + Task SQLAsync = Mysql.ExecuteAsync(args[1], Convert.ToBoolean(Convert.ToInt32(args[2]))); SQLAsync.Wait(); output.Append(SQLAsync.Result); } else @@ -167,9 +241,12 @@ public static int RvExtensionArgs(StringBuilder output, int outputSize, } catch (Exception e) { +#if !A3COMPAT + output.Append(e.ToString()); +#endif Utility.Session.LogThis("[AEX::EXCEPTION] " + e.ToString()); return 1; } } } -} +} \ No newline at end of file diff --git a/src/aex/Mysql.cs b/src/aex/Mysql.cs index 56b1ecf..e56b3d4 100644 --- a/src/aex/Mysql.cs +++ b/src/aex/Mysql.cs @@ -22,9 +22,9 @@ public class Mysql private static readonly string DefaultDatabase = (string)Utility.JSON.readJSON("mysql", "database"); internal static readonly string cstr = "Server= " + DatabaseAddress + ";Port= " + PortNumber + ";Database=" + DefaultDatabase + ";Uid=" + DatabaseUsername + ";Pwd=" + DatabasePassword + ";Pooling=false;"; internal static MySqlConnection conn = new MySqlConnection(cstr); - internal static readonly int MaxReturnSize = 8192; + internal static readonly int MaxReturnSize = (int)Utility.JSON.readJSON("misc", "datamaxreturn"); - internal static string[][] SQLResultBuffer = new string[256][]; + internal static string[][] SQLResultBuffer = new string[(int)Utility.JSON.readJSON("mysql", "buffer")][]; internal static void ModuleInit() { diff --git a/src/aex/Utils.cs b/src/aex/Utils.cs index 2c4f8a4..2db9cd5 100644 --- a/src/aex/Utils.cs +++ b/src/aex/Utils.cs @@ -132,6 +132,12 @@ internal class JSONFormat [JsonProperty("MysqlDatabase")] public string MysqlDatabase; + [JsonProperty("MysqlBufferSize")] + public int MysqlBufferSize; + + [JsonProperty("DataMaxReturnSize")] + public int DataMaxReturnSize; + [JsonProperty("EnableDebug")] public bool EnableDebug; } @@ -300,9 +306,10 @@ public static object[] readJSONArray(string module, string attrib) { case "apid": return ds.DiscordApid; - case "apikey": return ds.DiscordApikey; + case "channels": + return ds.DiscordChannels; default: return new string[1]{ "ERR_INVALID_ATTRIB" }; @@ -391,7 +398,8 @@ public static object readJSON(string module, string attrib) case "database": return ds.MysqlDatabase; - + case "buffer": + return ds.MysqlBufferSize; case "enable": return ds.EnableMysql; @@ -399,6 +407,16 @@ public static object readJSON(string module, string attrib) return "ERR_INVALID_ATTRIB"; } } + else if (module == "misc") + { + switch (attrib) + { + case "datamaxreturn": + return ds.DataMaxReturnSize; + case "enabledebug": + return ds.EnableDebug; + } + } return "ERR_INVALID_PARAMS"; } } diff --git a/src/aex/aex.csproj b/src/aex/aex.csproj index 18cb2a1..4ff8de0 100644 --- a/src/aex/aex.csproj +++ b/src/aex/aex.csproj @@ -5,7 +5,7 @@ Debug AnyCPU {9192B246-99F7-4115-B289-2352495FD5F3} - Library + Exe Properties aex aex @@ -21,18 +21,20 @@ full false bin\Debug\ - TRACE;DEBUG;is64 + TRACE;DEBUG;is64; prompt 4 x64 + true pdbonly true bin\Release\ - TRACE + TRACE;is64;A3COMPAT prompt 4 + true true @@ -78,6 +80,9 @@ false + + + ..\packages\BouncyCastle.1.8.3.1\lib\BouncyCastle.Crypto.dll @@ -92,9 +97,8 @@ ..\packages\MySql.Data.8.0.18\lib\net452\MySql.Data.dll - + ..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll - False ..\packages\SSH.NET.2016.1.0\lib\net40\Renci.SshNet.dll @@ -115,6 +119,8 @@ C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\System.Core.dll + + C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\System.Data.Linq.dll diff --git a/src/aex/aex.csproj.user b/src/aex/aex.csproj.user new file mode 100644 index 0000000..31ed913 --- /dev/null +++ b/src/aex/aex.csproj.user @@ -0,0 +1,6 @@ + + + + I:\aexsrc\packages\ + + \ No newline at end of file diff --git a/src/aex/packages.config b/src/aex/packages.config index bc2a473..94a9a14 100644 --- a/src/aex/packages.config +++ b/src/aex/packages.config @@ -5,6 +5,7 @@ +