diff --git a/plugins/BinLogReader/App.ico b/plugins/BinLogReader/App.ico new file mode 100644 index 00000000..3a5525fd Binary files /dev/null and b/plugins/BinLogReader/App.ico differ diff --git a/plugins/BinLogReader/AssemblyInfo.cs b/plugins/BinLogReader/AssemblyInfo.cs new file mode 100644 index 00000000..9f89a328 --- /dev/null +++ b/plugins/BinLogReader/AssemblyInfo.cs @@ -0,0 +1,58 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("1.0.*")] + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project output directory which is +// %Project Directory%\obj\. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] +[assembly: AssemblyKeyName("")] diff --git a/plugins/BinLogReader/BinLog.cs b/plugins/BinLogReader/BinLog.cs new file mode 100644 index 00000000..f51cc891 --- /dev/null +++ b/plugins/BinLogReader/BinLog.cs @@ -0,0 +1,40 @@ +using System; +using System.IO; + +namespace BinLogReader +{ + /// + /// binary log stuff yah + /// + public class BinLog + { + private static uint BINLOG_MAGIC = 0x414D424C + private static short BINLOG_VERSION = 0x0100; + + public static BinLog FromFile(string filename) + { + if (!File.Exists(filename)) + return null; + + System.IO.FileStream stream = File.Open(filename, System.IO.FileMode.Open); + if (stream == null) + return null; + BinaryReader br = new BinaryReader(stream); + if (br == null) + return null; + + try + { + } + catch + { + } + finally + { + br.Close(); + stream.Close(); + GC.Collect(); + } + } + } +} diff --git a/plugins/BinLogReader/BinLogReader.csproj b/plugins/BinLogReader/BinLogReader.csproj new file mode 100644 index 00000000..330f5f56 --- /dev/null +++ b/plugins/BinLogReader/BinLogReader.csproj @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/BinLogReader/BinLogReader.sln b/plugins/BinLogReader/BinLogReader.sln new file mode 100644 index 00000000..10da71fc --- /dev/null +++ b/plugins/BinLogReader/BinLogReader.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BinLogReader", "BinLogReader.csproj", "{5EB15D49-0E00-424F-A8E2-14A17FE78DD1}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {5EB15D49-0E00-424F-A8E2-14A17FE78DD1}.Debug.ActiveCfg = Debug|.NET + {5EB15D49-0E00-424F-A8E2-14A17FE78DD1}.Debug.Build.0 = Debug|.NET + {5EB15D49-0E00-424F-A8E2-14A17FE78DD1}.Release.ActiveCfg = Release|.NET + {5EB15D49-0E00-424F-A8E2-14A17FE78DD1}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/plugins/BinLogReader/Form1.cs b/plugins/BinLogReader/Form1.cs new file mode 100644 index 00000000..e487d125 --- /dev/null +++ b/plugins/BinLogReader/Form1.cs @@ -0,0 +1,143 @@ +using System; +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; +using System.Data; + +namespace BinLogReader +{ + /// + /// Summary description for Form1. + /// + public class Form1 : System.Windows.Forms.Form + { + private System.Windows.Forms.MainMenu mainMenu1; + private System.Windows.Forms.MenuItem menuItem1; + private System.Windows.Forms.MenuItem menuItem2; + private System.Windows.Forms.MenuItem menuItem3; + private System.Windows.Forms.MenuItem menuItem4; + private System.Windows.Forms.MenuItem menuItem5; + private System.Windows.Forms.MenuItem menuItem6; + /// + /// Required designer variable. + /// + private System.ComponentModel.Container components = null; + + public Form1() + { + // + // Required for Windows Form Designer support + // + InitializeComponent(); + + // + // TODO: Add any constructor code after InitializeComponent call + // + } + + /// + /// Clean up any resources being used. + /// + protected override void Dispose( bool disposing ) + { + if( disposing ) + { + if (components != null) + { + components.Dispose(); + } + } + base.Dispose( disposing ); + } + + #region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.mainMenu1 = new System.Windows.Forms.MainMenu(); + this.menuItem1 = new System.Windows.Forms.MenuItem(); + this.menuItem2 = new System.Windows.Forms.MenuItem(); + this.menuItem3 = new System.Windows.Forms.MenuItem(); + this.menuItem4 = new System.Windows.Forms.MenuItem(); + this.menuItem5 = new System.Windows.Forms.MenuItem(); + this.menuItem6 = new System.Windows.Forms.MenuItem(); + // + // mainMenu1 + // + this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.menuItem1, + this.menuItem5}); + // + // menuItem1 + // + this.menuItem1.Index = 0; + this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.menuItem2, + this.menuItem3, + this.menuItem4}); + this.menuItem1.Text = "&File"; + // + // menuItem2 + // + this.menuItem2.Index = 0; + this.menuItem2.Text = "&Open"; + // + // menuItem3 + // + this.menuItem3.Index = 1; + this.menuItem3.Text = "-"; + // + // menuItem4 + // + this.menuItem4.Index = 2; + this.menuItem4.Text = "E&xit"; + this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click); + // + // menuItem5 + // + this.menuItem5.Index = 1; + this.menuItem5.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.menuItem6}); + this.menuItem5.Text = "&Help"; + // + // menuItem6 + // + this.menuItem6.Index = 0; + this.menuItem6.Text = "&About"; + // + // Form1 + // + this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); + this.ClientSize = new System.Drawing.Size(772, 437); + this.Menu = this.mainMenu1; + this.Name = "Form1"; + this.Text = "AMX Mod X BinLogReader"; + this.Load += new System.EventHandler(this.Form1_Load); + + } + #endregion + + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.Run(new Form1()); + } + + private void Form1_Load(object sender, System.EventArgs e) + { + PluginDb db = PluginDb.FromFile("c:\\hlserver\\cstrike\\addons\\amxmodx\\data\\binlogs\\bindb0001.bdb"); + } + + private void menuItem4_Click(object sender, System.EventArgs e) + { + Application.Exit(); + } + } +} diff --git a/plugins/BinLogReader/Form1.resx b/plugins/BinLogReader/Form1.resx new file mode 100644 index 00000000..43a90519 --- /dev/null +++ b/plugins/BinLogReader/Form1.resx @@ -0,0 +1,175 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Private + + + 17, 17 + + + Private + + + Private + + + Private + + + Private + + + Private + + + Private + + + Private + + + Private + + + Private + + + Private + + + Private + + + Private + + + Private + + + False + + + (Default) + + + False + + + False + + + 4, 4 + + + Form1 + + + True + + + 80 + + + True + + + Private + + \ No newline at end of file diff --git a/plugins/BinLogReader/Plugin.cs b/plugins/BinLogReader/Plugin.cs new file mode 100644 index 00000000..fce17c27 --- /dev/null +++ b/plugins/BinLogReader/Plugin.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections; + +namespace BinLogReader +{ + /// + /// plugin data + /// + public class Plugin + { + private byte status; + private string Filename; + private ArrayList Natives; + private ArrayList Publics; + + public Plugin(string name, int natives, int publics, byte _status) + { + Filename = name; + Natives = new ArrayList(natives); + Publics = new ArrayList(publics); + status = _status; + } + + public void AddNative(string name) + { + Natives.Add(name); + } + + public void AddPublic(string pubname) + { + Publics.Add(pubname); + } + + public string FindNative(int id) + { + if (id < 0 || id >= Natives.Count) + return null; + + return (string)Natives[id]; + } + + public string FindPublic(int id) + { + if (id < 0 || id >= Publics.Count) + return null; + + return (string)Publics[id]; + } + + public bool IsValid() + { + return status != 0; + } + + public bool IsDebug() + { + return status == 2; + } + } +} diff --git a/plugins/BinLogReader/PluginDb.cs b/plugins/BinLogReader/PluginDb.cs new file mode 100644 index 00000000..593966e2 --- /dev/null +++ b/plugins/BinLogReader/PluginDb.cs @@ -0,0 +1,110 @@ +using System; +using System.Collections; +using System.IO; +using System.Text; + +namespace BinLogReader +{ + /// + /// Aggregates plugin information + /// + public class PluginDb + { + private static uint BINDB_MAGIC = 0x414D4244; + private static short BINDB_VERSION = 0x0100; + private ArrayList PluginList; + + public PluginDb(uint plugins) + { + PluginList = new ArrayList((int)plugins); + } + + public Plugin GetPluginById(ushort id) + { + return GetPluginById((int)id); + } + + public Plugin GetPluginById(int id) + { + if (id < 0 || id >= PluginList.Count) + return null; + + return (Plugin)PluginList[id]; + } + + public static PluginDb FromFile(string filename) + { + if (!File.Exists(filename)) + return null; + + System.IO.FileStream stream = File.Open(filename, System.IO.FileMode.Open); + if (stream == null) + return null; + BinaryReader br = new BinaryReader(stream); + if (br == null) + return null; + + PluginDb db; + + try + { + //check header + uint magic = br.ReadUInt32(); + if (magic != BINDB_MAGIC) + throw new Exception("Invalid magic number"); + //check version + ushort vers = br.ReadUInt16(); + if (vers > BINDB_VERSION) + throw new Exception("Unknown version"); + //read plugins + uint plugins = br.ReadUInt32(); + db = new PluginDb(plugins); + for (uint i=0; i