├── .gitattributes ├── .gitignore ├── App.config ├── DecompFillerForm.Designer.cs ├── DecompFillerForm.cs ├── DecompFillerForm.resx ├── Form1.Designer.cs ├── Form1.cs ├── Form1.resx ├── Form2.Designer.cs ├── Form2.cs ├── Form2.resx ├── Form3.Designer.cs ├── Form3.cs ├── Form3.resx ├── Formats ├── DOL.cs └── MAP.cs ├── Helpers ├── DecompFiller.cs ├── Demangler.cs ├── MAPParsing.cs ├── SYMParsing.cs └── SyncTextBox.cs ├── IO ├── BigEndianReader.cs └── BigEndianWriter.cs ├── LICENSE ├── Program.cs ├── Properties ├── AssemblyInfo.cs ├── Resources.Designer.cs ├── Resources.resx ├── Settings.Designer.cs └── Settings.settings ├── README.md ├── TODO.md ├── build.map ├── logo.ico ├── mapdas.csproj ├── mapdas.sln └── packages.config /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Aa][Rr][Mm]/ 27 | [Aa][Rr][Mm]64/ 28 | bld/ 29 | [Bb]in/ 30 | [Oo]bj/ 31 | [Ll]og/ 32 | [Ll]ogs/ 33 | 34 | # Visual Studio 2015/2017 cache/options directory 35 | .vs/ 36 | # Uncomment if you have tasks that create the project's static files in wwwroot 37 | #wwwroot/ 38 | 39 | # Visual Studio 2017 auto generated files 40 | Generated\ Files/ 41 | 42 | # MSTest test Results 43 | [Tt]est[Rr]esult*/ 44 | [Bb]uild[Ll]og.* 45 | 46 | # NUnit 47 | *.VisualState.xml 48 | TestResult.xml 49 | nunit-*.xml 50 | 51 | # Build Results of an ATL Project 52 | [Dd]ebugPS/ 53 | [Rr]eleasePS/ 54 | dlldata.c 55 | 56 | # Benchmark Results 57 | BenchmarkDotNet.Artifacts/ 58 | 59 | # .NET Core 60 | project.lock.json 61 | project.fragment.lock.json 62 | artifacts/ 63 | 64 | # StyleCop 65 | StyleCopReport.xml 66 | 67 | # Files built by Visual Studio 68 | *_i.c 69 | *_p.c 70 | *_h.h 71 | *.ilk 72 | *.meta 73 | *.obj 74 | *.iobj 75 | *.pch 76 | *.pdb 77 | *.ipdb 78 | *.pgc 79 | *.pgd 80 | *.rsp 81 | *.sbr 82 | *.tlb 83 | *.tli 84 | *.tlh 85 | *.tmp 86 | *.tmp_proj 87 | *_wpftmp.csproj 88 | *.log 89 | *.vspscc 90 | *.vssscc 91 | .builds 92 | *.pidb 93 | *.svclog 94 | *.scc 95 | 96 | # Chutzpah Test files 97 | _Chutzpah* 98 | 99 | # Visual C++ cache files 100 | ipch/ 101 | *.aps 102 | *.ncb 103 | *.opendb 104 | *.opensdf 105 | *.sdf 106 | *.cachefile 107 | *.VC.db 108 | *.VC.VC.opendb 109 | 110 | # Visual Studio profiler 111 | *.psess 112 | *.vsp 113 | *.vspx 114 | *.sap 115 | 116 | # Visual Studio Trace Files 117 | *.e2e 118 | 119 | # TFS 2012 Local Workspace 120 | $tf/ 121 | 122 | # Guidance Automation Toolkit 123 | *.gpState 124 | 125 | # ReSharper is a .NET coding add-in 126 | _ReSharper*/ 127 | *.[Rr]e[Ss]harper 128 | *.DotSettings.user 129 | 130 | # JustCode is a .NET coding add-in 131 | .JustCode 132 | 133 | # TeamCity is a build add-in 134 | _TeamCity* 135 | 136 | # DotCover is a Code Coverage Tool 137 | *.dotCover 138 | 139 | # AxoCover is a Code Coverage Tool 140 | .axoCover/* 141 | !.axoCover/settings.json 142 | 143 | # Visual Studio code coverage results 144 | *.coverage 145 | *.coveragexml 146 | 147 | # NCrunch 148 | _NCrunch_* 149 | .*crunch*.local.xml 150 | nCrunchTemp_* 151 | 152 | # MightyMoose 153 | *.mm.* 154 | AutoTest.Net/ 155 | 156 | # Web workbench (sass) 157 | .sass-cache/ 158 | 159 | # Installshield output folder 160 | [Ee]xpress/ 161 | 162 | # DocProject is a documentation generator add-in 163 | DocProject/buildhelp/ 164 | DocProject/Help/*.HxT 165 | DocProject/Help/*.HxC 166 | DocProject/Help/*.hhc 167 | DocProject/Help/*.hhk 168 | DocProject/Help/*.hhp 169 | DocProject/Help/Html2 170 | DocProject/Help/html 171 | 172 | # Click-Once directory 173 | publish/ 174 | 175 | # Publish Web Output 176 | *.[Pp]ublish.xml 177 | *.azurePubxml 178 | # Note: Comment the next line if you want to checkin your web deploy settings, 179 | # but database connection strings (with potential passwords) will be unencrypted 180 | *.pubxml 181 | *.publishproj 182 | 183 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 184 | # checkin your Azure Web App publish settings, but sensitive information contained 185 | # in these scripts will be unencrypted 186 | PublishScripts/ 187 | 188 | # NuGet Packages 189 | *.nupkg 190 | # NuGet Symbol Packages 191 | *.snupkg 192 | # The packages folder can be ignored because of Package Restore 193 | **/[Pp]ackages/* 194 | # except build/, which is used as an MSBuild target. 195 | !**/[Pp]ackages/build/ 196 | # Uncomment if necessary however generally it will be regenerated when needed 197 | #!**/[Pp]ackages/repositories.config 198 | # NuGet v3's project.json files produces more ignorable files 199 | *.nuget.props 200 | *.nuget.targets 201 | 202 | # Microsoft Azure Build Output 203 | csx/ 204 | *.build.csdef 205 | 206 | # Microsoft Azure Emulator 207 | ecf/ 208 | rcf/ 209 | 210 | # Windows Store app package directories and files 211 | AppPackages/ 212 | BundleArtifacts/ 213 | Package.StoreAssociation.xml 214 | _pkginfo.txt 215 | *.appx 216 | *.appxbundle 217 | *.appxupload 218 | 219 | # Visual Studio cache files 220 | # files ending in .cache can be ignored 221 | *.[Cc]ache 222 | # but keep track of directories ending in .cache 223 | !?*.[Cc]ache/ 224 | 225 | # Others 226 | ClientBin/ 227 | ~$* 228 | *~ 229 | *.dbmdl 230 | *.dbproj.schemaview 231 | *.jfm 232 | *.pfx 233 | *.publishsettings 234 | orleans.codegen.cs 235 | 236 | # Including strong name files can present a security risk 237 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 238 | #*.snk 239 | 240 | # Since there are multiple workflows, uncomment next line to ignore bower_components 241 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 242 | #bower_components/ 243 | 244 | # RIA/Silverlight projects 245 | Generated_Code/ 246 | 247 | # Backup & report files from converting an old project file 248 | # to a newer Visual Studio version. Backup files are not needed, 249 | # because we have git ;-) 250 | _UpgradeReport_Files/ 251 | Backup*/ 252 | UpgradeLog*.XML 253 | UpgradeLog*.htm 254 | ServiceFabricBackup/ 255 | *.rptproj.bak 256 | 257 | # SQL Server files 258 | *.mdf 259 | *.ldf 260 | *.ndf 261 | 262 | # Business Intelligence projects 263 | *.rdl.data 264 | *.bim.layout 265 | *.bim_*.settings 266 | *.rptproj.rsuser 267 | *- [Bb]ackup.rdl 268 | *- [Bb]ackup ([0-9]).rdl 269 | *- [Bb]ackup ([0-9][0-9]).rdl 270 | 271 | # Microsoft Fakes 272 | FakesAssemblies/ 273 | 274 | # GhostDoc plugin setting file 275 | *.GhostDoc.xml 276 | 277 | # Node.js Tools for Visual Studio 278 | .ntvs_analysis.dat 279 | node_modules/ 280 | 281 | # Visual Studio 6 build log 282 | *.plg 283 | 284 | # Visual Studio 6 workspace options file 285 | *.opt 286 | 287 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 288 | *.vbw 289 | 290 | # Visual Studio LightSwitch build output 291 | **/*.HTMLClient/GeneratedArtifacts 292 | **/*.DesktopClient/GeneratedArtifacts 293 | **/*.DesktopClient/ModelManifest.xml 294 | **/*.Server/GeneratedArtifacts 295 | **/*.Server/ModelManifest.xml 296 | _Pvt_Extensions 297 | 298 | # Paket dependency manager 299 | .paket/paket.exe 300 | paket-files/ 301 | 302 | # FAKE - F# Make 303 | .fake/ 304 | 305 | # CodeRush personal settings 306 | .cr/personal 307 | 308 | # Python Tools for Visual Studio (PTVS) 309 | __pycache__/ 310 | *.pyc 311 | 312 | # Cake - Uncomment if you are using it 313 | # tools/** 314 | # !tools/packages.config 315 | 316 | # Tabs Studio 317 | *.tss 318 | 319 | # Telerik's JustMock configuration file 320 | *.jmconfig 321 | 322 | # BizTalk build output 323 | *.btp.cs 324 | *.btm.cs 325 | *.odx.cs 326 | *.xsd.cs 327 | 328 | # OpenCover UI analysis results 329 | OpenCover/ 330 | 331 | # Azure Stream Analytics local run output 332 | ASALocalRun/ 333 | 334 | # MSBuild Binary and Structured Log 335 | *.binlog 336 | 337 | # NVidia Nsight GPU debugger configuration file 338 | *.nvuser 339 | 340 | # MFractors (Xamarin productivity tool) working folder 341 | .mfractor/ 342 | 343 | # Local History for Visual Studio 344 | .localhistory/ 345 | 346 | # BeatPulse healthcheck temp database 347 | healthchecksdb 348 | 349 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 350 | MigrationBackup/ 351 | 352 | # Ionide (cross platform F# VS Code tools) working folder 353 | .ionide/ 354 | squashTo.bat 355 | -------------------------------------------------------------------------------- /App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /DecompFillerForm.Designer.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace mapdas 3 | { 4 | partial class DecompFillerForm 5 | { 6 | /// 7 | /// Required designer variable. 8 | /// 9 | private System.ComponentModel.IContainer components = null; 10 | 11 | /// 12 | /// Clean up any resources being used. 13 | /// 14 | /// true if managed resources should be disposed; otherwise, false. 15 | protected override void Dispose(bool disposing) 16 | { 17 | if (disposing && (components != null)) 18 | { 19 | components.Dispose(); 20 | } 21 | base.Dispose(disposing); 22 | } 23 | 24 | #region Windows Form Designer generated code 25 | 26 | /// 27 | /// Required method for Designer support - do not modify 28 | /// the contents of this method with the code editor. 29 | /// 30 | private void InitializeComponent() 31 | { 32 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DecompFillerForm)); 33 | this.richTextBox1 = new System.Windows.Forms.RichTextBox(); 34 | this.button1 = new System.Windows.Forms.Button(); 35 | this.richTextBox2 = new System.Windows.Forms.RichTextBox(); 36 | this.label1 = new System.Windows.Forms.Label(); 37 | this.button2 = new System.Windows.Forms.Button(); 38 | this.SuspendLayout(); 39 | // 40 | // richTextBox1 41 | // 42 | this.richTextBox1.Location = new System.Drawing.Point(13, 13); 43 | this.richTextBox1.Name = "richTextBox1"; 44 | this.richTextBox1.ReadOnly = true; 45 | this.richTextBox1.Size = new System.Drawing.Size(328, 22); 46 | this.richTextBox1.TabIndex = 0; 47 | this.richTextBox1.Text = ""; 48 | this.richTextBox1.TextChanged += new System.EventHandler(this.richTextBox1_TextChanged); 49 | // 50 | // button1 51 | // 52 | this.button1.Location = new System.Drawing.Point(347, 12); 53 | this.button1.Name = "button1"; 54 | this.button1.Size = new System.Drawing.Size(75, 24); 55 | this.button1.TabIndex = 1; 56 | this.button1.Text = "Open Folder"; 57 | this.button1.UseVisualStyleBackColor = true; 58 | this.button1.Click += new System.EventHandler(this.button1_Click); 59 | // 60 | // richTextBox2 61 | // 62 | this.richTextBox2.Location = new System.Drawing.Point(13, 68); 63 | this.richTextBox2.Name = "richTextBox2"; 64 | this.richTextBox2.Size = new System.Drawing.Size(409, 300); 65 | this.richTextBox2.TabIndex = 2; 66 | this.richTextBox2.Text = ""; 67 | // 68 | // label1 69 | // 70 | this.label1.AutoSize = true; 71 | this.label1.ForeColor = System.Drawing.Color.White; 72 | this.label1.Location = new System.Drawing.Point(20, 52); 73 | this.label1.Name = "label1"; 74 | this.label1.Size = new System.Drawing.Size(402, 13); 75 | this.label1.TabIndex = 3; 76 | this.label1.Text = "Enter all known namespaces in the game\'s symbols (use new line for each new one)\r" + 77 | "\n"; 78 | // 79 | // button2 80 | // 81 | this.button2.Location = new System.Drawing.Point(13, 376); 82 | this.button2.Name = "button2"; 83 | this.button2.Size = new System.Drawing.Size(409, 23); 84 | this.button2.TabIndex = 4; 85 | this.button2.Text = "Done"; 86 | this.button2.UseVisualStyleBackColor = true; 87 | this.button2.Click += new System.EventHandler(this.button2_Click); 88 | // 89 | // DecompFillerForm 90 | // 91 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 92 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 93 | this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); 94 | this.ClientSize = new System.Drawing.Size(434, 411); 95 | this.Controls.Add(this.button2); 96 | this.Controls.Add(this.label1); 97 | this.Controls.Add(this.richTextBox2); 98 | this.Controls.Add(this.button1); 99 | this.Controls.Add(this.richTextBox1); 100 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); 101 | this.Name = "DecompFillerForm"; 102 | this.Text = "Decompilation Filler"; 103 | this.ResumeLayout(false); 104 | this.PerformLayout(); 105 | 106 | } 107 | 108 | #endregion 109 | 110 | private System.Windows.Forms.RichTextBox richTextBox1; 111 | private System.Windows.Forms.Button button1; 112 | private System.Windows.Forms.RichTextBox richTextBox2; 113 | private System.Windows.Forms.Label label1; 114 | private System.Windows.Forms.Button button2; 115 | } 116 | } -------------------------------------------------------------------------------- /DecompFillerForm.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.WindowsAPICodePack.Dialogs; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.ComponentModel; 5 | using System.Data; 6 | using System.Drawing; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | using System.Windows.Forms; 11 | 12 | namespace mapdas 13 | { 14 | public partial class DecompFillerForm : Form 15 | { 16 | public DecompFillerForm() 17 | { 18 | InitializeComponent(); 19 | } 20 | 21 | private void button1_Click(object sender, EventArgs e) 22 | { 23 | CommonOpenFileDialog dialog = new CommonOpenFileDialog 24 | { 25 | IsFolderPicker = true, 26 | Title = "Select mapdas output folder to clean..." 27 | }; 28 | 29 | if (dialog.ShowDialog() != CommonFileDialogResult.Ok) 30 | { 31 | return; 32 | } 33 | 34 | richTextBox1.Text = dialog.FileName; 35 | } 36 | 37 | private void richTextBox1_TextChanged(object sender, EventArgs e) 38 | { 39 | 40 | } 41 | 42 | private void button2_Click(object sender, EventArgs e) 43 | { 44 | if (richTextBox1.Text == string.Empty) 45 | { 46 | MessageBox.Show("Enter the mapdas output folder!"); 47 | return; 48 | } 49 | 50 | List namespaces = new List(); 51 | namespaces = richTextBox2.Text.Split(new char[] { ',', '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries).ToList(); 52 | MessageBox.Show("Starting, wait until the \"Done\" message pops up to do anything else!"); 53 | CommonDecompFiller.Filler.Run(richTextBox1.Text, namespaces); 54 | MessageBox.Show("Done"); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Form1.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace mapdas 2 | { 3 | partial class Form1 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); 32 | this.DebugLog = new System.Windows.Forms.RichTextBox(); 33 | this.MapTree = new System.Windows.Forms.TreeView(); 34 | this.menuStrip1 = new System.Windows.Forms.MenuStrip(); 35 | this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 36 | this.toolsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 37 | this.commonFSCleanerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 38 | this.menuStrip1.SuspendLayout(); 39 | this.SuspendLayout(); 40 | // 41 | // DebugLog 42 | // 43 | this.DebugLog.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); 44 | this.DebugLog.Dock = System.Windows.Forms.DockStyle.Bottom; 45 | this.DebugLog.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F); 46 | this.DebugLog.ForeColor = System.Drawing.Color.White; 47 | this.DebugLog.Location = new System.Drawing.Point(0, 627); 48 | this.DebugLog.Name = "DebugLog"; 49 | this.DebugLog.ReadOnly = true; 50 | this.DebugLog.Size = new System.Drawing.Size(680, 130); 51 | this.DebugLog.TabIndex = 0; 52 | this.DebugLog.Text = ""; 53 | // 54 | // MapTree 55 | // 56 | this.MapTree.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); 57 | this.MapTree.Dock = System.Windows.Forms.DockStyle.Top; 58 | this.MapTree.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F); 59 | this.MapTree.ForeColor = System.Drawing.Color.White; 60 | this.MapTree.Location = new System.Drawing.Point(0, 24); 61 | this.MapTree.Name = "MapTree"; 62 | this.MapTree.Size = new System.Drawing.Size(680, 601); 63 | this.MapTree.TabIndex = 1; 64 | this.MapTree.Click += new System.EventHandler(this.MapTree_Click); 65 | // 66 | // menuStrip1 67 | // 68 | this.menuStrip1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); 69 | this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 70 | this.fileToolStripMenuItem, 71 | this.toolsToolStripMenuItem}); 72 | this.menuStrip1.Location = new System.Drawing.Point(0, 0); 73 | this.menuStrip1.Name = "menuStrip1"; 74 | this.menuStrip1.Size = new System.Drawing.Size(680, 24); 75 | this.menuStrip1.TabIndex = 2; 76 | this.menuStrip1.Text = "menuStrip1"; 77 | // 78 | // fileToolStripMenuItem 79 | // 80 | this.fileToolStripMenuItem.ForeColor = System.Drawing.SystemColors.Control; 81 | this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; 82 | this.fileToolStripMenuItem.Size = new System.Drawing.Size(75, 20); 83 | this.fileToolStripMenuItem.Text = "Open Map"; 84 | this.fileToolStripMenuItem.Click += new System.EventHandler(this.FileToolStripMenuItem_Click); 85 | // 86 | // toolsToolStripMenuItem 87 | // 88 | this.toolsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { 89 | this.commonFSCleanerToolStripMenuItem}); 90 | this.toolsToolStripMenuItem.ForeColor = System.Drawing.SystemColors.Control; 91 | this.toolsToolStripMenuItem.Name = "toolsToolStripMenuItem"; 92 | this.toolsToolStripMenuItem.Size = new System.Drawing.Size(46, 20); 93 | this.toolsToolStripMenuItem.Text = "Tools"; 94 | // 95 | // commonFSCleanerToolStripMenuItem 96 | // 97 | this.commonFSCleanerToolStripMenuItem.Name = "commonFSCleanerToolStripMenuItem"; 98 | this.commonFSCleanerToolStripMenuItem.Size = new System.Drawing.Size(183, 22); 99 | this.commonFSCleanerToolStripMenuItem.Text = "Common FS Cleaner"; 100 | this.commonFSCleanerToolStripMenuItem.Click += new System.EventHandler(this.commonFSCleanerToolStripMenuItem_Click); 101 | // 102 | // Form1 103 | // 104 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 105 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 106 | this.ClientSize = new System.Drawing.Size(680, 757); 107 | this.Controls.Add(this.MapTree); 108 | this.Controls.Add(this.DebugLog); 109 | this.Controls.Add(this.menuStrip1); 110 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D; 111 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); 112 | this.MainMenuStrip = this.menuStrip1; 113 | this.MaximizeBox = false; 114 | this.MinimizeBox = false; 115 | this.Name = "Form1"; 116 | this.Text = "mapdas"; 117 | this.Load += new System.EventHandler(this.Form1_Load); 118 | this.menuStrip1.ResumeLayout(false); 119 | this.menuStrip1.PerformLayout(); 120 | this.ResumeLayout(false); 121 | this.PerformLayout(); 122 | 123 | } 124 | 125 | #endregion 126 | 127 | private System.Windows.Forms.RichTextBox DebugLog; 128 | private System.Windows.Forms.TreeView MapTree; 129 | private System.Windows.Forms.MenuStrip menuStrip1; 130 | private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem; 131 | private System.Windows.Forms.ToolStripMenuItem toolsToolStripMenuItem; 132 | private System.Windows.Forms.ToolStripMenuItem commonFSCleanerToolStripMenuItem; 133 | } 134 | } 135 | 136 | -------------------------------------------------------------------------------- /Form1.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.WindowsAPICodePack.Dialogs; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Diagnostics; 5 | using System.Drawing; 6 | using System.Globalization; 7 | using System.IO; 8 | using System.Linq; 9 | using System.Text.RegularExpressions; 10 | using System.Threading; 11 | using System.Threading.Tasks; 12 | using System.Windows.Forms; 13 | using static arookas.Demangler; 14 | 15 | namespace mapdas 16 | { 17 | public partial class Form1 : Form 18 | { 19 | private readonly List _FilesOpen = new List(); 20 | private int _SelectedFile = 0; 21 | 22 | public Form1() 23 | { 24 | InitializeComponent(); 25 | } 26 | 27 | private void Form1_Load(object sender, EventArgs e) 28 | { 29 | /* IMPORTANT 30 | * the MapTree ViewTree will give "tags" to the different levels of information 31 | * displayed on the screen at any one time with a symbol map loaded, it will go 32 | * as follows: 33 | * 34 | * Files (e.g. "G:/Hacking/mapdas/pikmin-1.map") will be tagged "File" (image list index 0) 35 | * Paths (e.g. "jaudio/bankdrv.c") will be tagged "Path" (image list index 1) 36 | * Functions (e.g. "Bank_RandToOfs(Rand_ *)") will be tagged "Function" (image list index 2) 37 | */ 38 | _FileContextMenu.MenuItems[0].Click += OpenDol_Click; // OpenDol 39 | _FileContextMenu.MenuItems[1].Click += ExportFilesystem_Click; // ExportFilesystem 40 | _FileContextMenu.MenuItems[2].Click += ExportToLinkerMap_Click; // ExportToLinkerMap 41 | _FileContextMenu.MenuItems[3].Click += ConvertToIdc_Click; // ConvertToIdc 42 | _FileContextMenu.MenuItems[4].Click += ExportTypesMap_Click; // ExportTypes 43 | _FileContextMenu.MenuItems[5].Click += CloseMap_Click; // CloseMap 44 | 45 | _PathContextMenu.MenuItems[0].Click += ExportFile_Click; // ExportFile 46 | _PathContextMenu.MenuItems[1].Click += ExportTypesFile_Click; // ExportTypes 47 | 48 | _FunctionContextMenu.MenuItems[0].Click += ExportTypesFunction_Click; // ExportTypes 49 | _FunctionContextMenu.MenuItems[1].Click += DecompileToView_Click; // DecompileToView 50 | } 51 | 52 | // Functionality on right click 53 | private readonly ContextMenu _FileContextMenu = new ContextMenu(new MenuItem[] { 54 | new MenuItem("Open DOL"), 55 | new MenuItem("Export Filesystem"), 56 | new MenuItem("Export To Linker Map"), 57 | new MenuItem("Convert To IDC"), 58 | new MenuItem("Export Types"), 59 | new MenuItem("Close") 60 | }); 61 | private readonly ContextMenu _PathContextMenu = new ContextMenu(new MenuItem[] { 62 | new MenuItem("Export File"), 63 | new MenuItem("Export Types") 64 | }); 65 | private readonly ContextMenu _FunctionContextMenu = new ContextMenu(new MenuItem[] { 66 | new MenuItem("Export Types"), 67 | new MenuItem("Decompile") 68 | }); 69 | private void MapTree_Click(object sender, EventArgs ea) 70 | { 71 | MouseEventArgs e = (MouseEventArgs)ea; 72 | 73 | TreeNode node = MapTree.GetNodeAt(e.X, e.Y); 74 | MapTree.SelectedNode = node; 75 | string nodeTag = (string)node.Tag; 76 | 77 | switch (nodeTag) 78 | { 79 | case "File": 80 | _SelectedFile = node.Index; 81 | break; 82 | case "Path": 83 | _SelectedFile = node.Parent.Index; 84 | break; 85 | case "Function": 86 | _SelectedFile = node.Parent.Parent.Index; 87 | break; 88 | default: 89 | break; 90 | } 91 | 92 | if (e.Button != MouseButtons.Right) 93 | { 94 | return; 95 | } 96 | 97 | switch (nodeTag) 98 | { 99 | case "File": 100 | _FileContextMenu.Show(MapTree, new Point(e.X, e.Y)); 101 | break; 102 | case "Path": 103 | _PathContextMenu.Show(MapTree, new Point(e.X, e.Y)); 104 | break; 105 | case "Function": 106 | _FunctionContextMenu.Show(MapTree, new Point(e.X, e.Y)); 107 | break; 108 | default: 109 | break; 110 | } 111 | } 112 | 113 | // TargetPath is the path in the symbol map 114 | // OutputPath is the path where we dump everything 115 | private void ExportFile(MAP file, string targetPath, string outputPath) 116 | { 117 | foreach (MAPParsing.TextEntry node in file._TextSymbols.FindAll(x => x._Path == targetPath)) 118 | { 119 | if (node._Address.Contains("...")) 120 | { 121 | continue; 122 | } 123 | 124 | string function = node._SymbolDemangled; 125 | 126 | if (!function.Contains("(")) 127 | { 128 | function += "(void)"; 129 | } 130 | 131 | string set = $"\n\n/*\n * --INFO--\n * Address:\t{node._Address.ToUpper()}\n * Size:\t{node._Size.ToUpper()}\n */\nvoid {function}\n{{\n"; 132 | 133 | if (file._AssociatedDol != null) 134 | { 135 | // we have a DOL file we can read PPC from 136 | try 137 | { 138 | set += "/*\n" + ReadAddressFromDol(file._AssociatedDol, node._Address, node._Size) + "\n*/\n"; 139 | } 140 | catch (Exception) 141 | { 142 | // Failed to read from address 143 | set += "\t// TODO\n"; 144 | } 145 | } 146 | else 147 | { 148 | // no PPC :( 149 | set += "\t// TODO\n"; 150 | } 151 | 152 | set += "}"; 153 | 154 | // Normalize line endings 155 | set = Regex.Replace(set, @"\r\n|\n\r|\n|\r", "\r\n"); 156 | File.AppendAllText(outputPath, set); 157 | Update(); 158 | } 159 | } 160 | 161 | private void ExportFile_Click(object o, EventArgs e) 162 | { 163 | SaveFileDialog dialog = new SaveFileDialog 164 | { 165 | Filter = "Any Files (*.*)|*.*|C++ Files (*.cpp)|*.cpp|C Files (*.c)|*.c", 166 | FileName = Path.GetFileName(MapTree.SelectedNode.Text) 167 | }; 168 | 169 | if (dialog.ShowDialog() != DialogResult.OK) 170 | { 171 | return; 172 | } 173 | 174 | ExportFile(_FilesOpen[_SelectedFile], MapTree.SelectedNode.Text, dialog.FileName); 175 | } 176 | 177 | private void ExportFilesystem_Click(object o, EventArgs e) 178 | { 179 | CommonOpenFileDialog dialog = new CommonOpenFileDialog 180 | { 181 | IsFolderPicker = true, 182 | }; 183 | 184 | if (dialog.ShowDialog() != CommonFileDialogResult.Ok) 185 | { 186 | return; 187 | } 188 | 189 | foreach (TreeNode node in MapTree.SelectedNode.Nodes) 190 | { 191 | if (!Directory.Exists(dialog.FileName + "/" + Path.GetDirectoryName(node.Text))) 192 | { 193 | Directory.CreateDirectory(dialog.FileName + "/" + Path.GetDirectoryName(node.Text.Replace(":", ""))); 194 | } 195 | 196 | ExportFile(_FilesOpen[_SelectedFile], node.Text, dialog.FileName + "/" + node.Text.Replace(":", "")); 197 | DebugLog.SelectionStart = DebugLog.Text.Length; 198 | DebugLog.ScrollToCaret(); 199 | 200 | Update(); 201 | Application.DoEvents(); 202 | } 203 | 204 | DebugLog.Text += "Done!\n"; 205 | } 206 | 207 | private void ExportToLinkerMap_Click(object o, EventArgs e) 208 | { 209 | SaveFileDialog diag = new SaveFileDialog() 210 | { 211 | Filter = "Linker Map (*.txt)|*.txt", 212 | FileName = "linker-map.txt", 213 | }; 214 | 215 | if (diag.ShowDialog() != DialogResult.OK) 216 | { 217 | return; 218 | } 219 | 220 | using (StreamWriter writer = new StreamWriter(diag.FileName)) 221 | { 222 | MAP openMap = _FilesOpen[_SelectedFile]; 223 | foreach (MAPParsing.TextEntry entry in openMap._TextSymbols) 224 | { 225 | if (entry._Address.Contains(".")) 226 | { 227 | continue; 228 | } 229 | 230 | writer.WriteLine($"{entry._Symbol}=0x{entry._Address.ToUpper()}"); 231 | } 232 | } 233 | } 234 | 235 | 236 | private void CloseMap_Click(object o, EventArgs e) 237 | { 238 | DebugLog.Text += "Closing Symbol Map... "; 239 | Update(); 240 | MapTree.BeginUpdate(); 241 | 242 | MapTree.Nodes.Remove(MapTree.SelectedNode); 243 | _FilesOpen.RemoveAt(_SelectedFile); 244 | _SelectedFile = 0; 245 | 246 | MapTree.EndUpdate(); 247 | DebugLog.Text += "Done!\n"; 248 | GC.Collect(); 249 | } 250 | 251 | private void ConvertToIdc_Click(object o, EventArgs e) 252 | { 253 | SaveFileDialog dialog = new SaveFileDialog 254 | { 255 | Filter = "IDC File (*.idc)|*.idc", 256 | RestoreDirectory = true 257 | }; 258 | 259 | if (dialog.ShowDialog() != DialogResult.OK) 260 | { 261 | return; 262 | } 263 | 264 | DebugLog.Text += $"Saving IDC to {dialog.FileName}... "; 265 | 266 | using (StreamWriter sw = new StreamWriter(File.OpenWrite(dialog.FileName))) 267 | { 268 | sw.WriteLine("#include \n"); 269 | 270 | sw.WriteLine("static main()"); 271 | sw.WriteLine("{"); 272 | sw.WriteLine("\tset_inf_attr(INF_GENFLAGS, INFFL_LOADIDC|get_inf_attr(INF_GENFLAGS));\n"); 273 | sw.WriteLine("\thandleSegments();"); 274 | sw.WriteLine("\thandleFunctions();"); 275 | sw.WriteLine("}\n"); 276 | 277 | // SEGMENTS 278 | sw.WriteLine("static handleSegments()"); 279 | sw.WriteLine("{"); 280 | 281 | List segments = new List(); 282 | foreach (MAPParsing.MemoryMapEntry symbol in MAPParsing.ParseMemoryMapSection(_FilesOpen[_SelectedFile])) 283 | { 284 | sw.WriteLine($"\tSegRename(0x{symbol._Start}, \"{symbol._Name}\");"); 285 | segments.Add(symbol._Name); 286 | } 287 | 288 | foreach (MAPParsing.LinkerSymbolEntry symbol in MAPParsing.ParseLinkerSymbolSection(_FilesOpen[_SelectedFile])) 289 | { 290 | sw.WriteLine($"\tset_name(0x{symbol._Start}, \"{symbol._Name}\");"); 291 | } 292 | sw.WriteLine("}\n"); 293 | 294 | // WRITING FUNCTIONS 295 | sw.WriteLine("static handleFunctions()"); 296 | sw.WriteLine("{"); 297 | foreach (string[] lines in from string segment in segments 298 | let lines = _FilesOpen[_SelectedFile].TryGetSection($"{segment} section layout") 299 | select lines) 300 | { 301 | if (lines == null) 302 | { 303 | continue; 304 | } 305 | 306 | foreach (string line in lines) 307 | { 308 | Match match = Regex.Match(line, @"\s+(?[a-f0-9]+)\s+(?[a-f0-9]+)\s+(?
[a-f0-9]+)\s+(?\d+)\s+(?[^ ]+)\s*(?.+)?", RegexOptions.Compiled); 309 | if (!match.Success) 310 | { 311 | continue; 312 | } 313 | 314 | string name = match.Groups["name"].Value.Trim(); 315 | 316 | if (name == ".text") 317 | { 318 | continue; 319 | } 320 | 321 | // rename items that are strings or un-named globals (const strings for instance) 322 | if (name.StartsWith("@") && match.Groups["module"].Success) 323 | { 324 | string moduleCppFile = match.Groups["module"].Value; 325 | 326 | for (int i = 1; i < moduleCppFile.Length; i++) 327 | { 328 | // See if the string has a `.a` in it 329 | if (moduleCppFile[i] != 'a' || moduleCppFile[i - 1] != '.') 330 | { 331 | continue; 332 | } 333 | 334 | // Remove the bottom half of the string including space/tab 335 | moduleCppFile = moduleCppFile.Remove(0, i + 2) + "_"; 336 | break; 337 | } 338 | 339 | // Insert the cppFile before the number 340 | name = moduleCppFile + name.Replace("@", ""); 341 | } 342 | 343 | if (match.Groups["type"].Value == "4" || match.Groups["type"].Value == "32") 344 | { 345 | // rename items that are the same name as essential PPC registers (r0 - r31, f0 - f31) 346 | if (name.Length <= 3 && int.TryParse(name.Substring(1, name.Length - 1), out int r) 347 | && (name.StartsWith("r") || name.StartsWith("f"))) 348 | { 349 | for (int i = 0; i < 31; i++) 350 | { 351 | string v = "r" + i.ToString(); 352 | string f = "f" + i.ToString(); 353 | if (name == v || name == f) 354 | { 355 | name.Insert(0, "_"); 356 | } 357 | } 358 | } 359 | 360 | // Make comments stating which .o file and the file 361 | if (match.Groups["module"].Success) 362 | { 363 | sw.WriteLine("\tMakeComm(0x{0}, \"{1}\");", match.Groups["address"].Value, match.Groups["module"].Value.Trim()); 364 | } 365 | 366 | if (match.Groups["size"].Success) 367 | { 368 | // Auto-set vtables 369 | if (name.StartsWith("__vt__")) 370 | { 371 | // Get the amount of elements in the vtbl 372 | int size = int.Parse(match.Groups["size"].Value, NumberStyles.HexNumber) >> 2; 373 | int address = int.Parse(match.Groups["address"].Value, NumberStyles.HexNumber); 374 | for (int i = 0; i < size; i++) 375 | { 376 | sw.WriteLine("\tcreate_dword({0});", string.Format("0x{0:X}", address + (i * 4))); 377 | } 378 | } 379 | } 380 | } 381 | // Handle floats/doubles 382 | else if (match.Groups["type"].Value == "8") 383 | { 384 | sw.WriteLine("\tcreate_double(0x{0});", match.Groups["address"].Value); 385 | } 386 | // Handle C functions 387 | else if (match.Groups["type"].Value == "16") 388 | { 389 | sw.WriteLine("\tSetType(0x{0}, \"void __cdecl {1}\");", match.Groups["address"].Value, name); 390 | } 391 | 392 | sw.WriteLine("\tset_name(0x{0}, \"{1}\");", match.Groups["address"].Value, name); 393 | } 394 | } 395 | 396 | sw.WriteLine("}\n"); 397 | } 398 | 399 | DebugLog.Text += "Done!\n"; 400 | } 401 | 402 | // Function Version (e.g. "test_function(yeah, yeah2)") 403 | private void ExportTypesFunction_Click(object o, EventArgs e) 404 | { 405 | string typeText = string.Empty; 406 | 407 | List types = SYMParsing.GetTypes(MapTree.SelectedNode.Text); 408 | if (types != null && types.Count > 0) 409 | { 410 | foreach (string trimmed in from string parameter in types.Distinct() 411 | let trimmed = parameter.Trim() 412 | where !string.IsNullOrWhiteSpace(trimmed) 413 | select trimmed) 414 | { 415 | typeText += $"{trimmed}\n"; 416 | } 417 | } 418 | else 419 | { 420 | MessageBox.Show("No types found"); 421 | return; 422 | } 423 | 424 | List sorted = typeText.TrimEnd().Split('\n').Distinct().ToList(); 425 | sorted.Sort(); 426 | 427 | Form3 disasmView = new Form3(string.Join("\r\n", sorted)); 428 | disasmView.Show(); 429 | } 430 | 431 | // File Version (e.g. "test_file.cpp") 432 | private void ExportTypesFile_Click(object o, EventArgs e) 433 | { 434 | string typeText = string.Empty; 435 | 436 | foreach (TreeNode function in MapTree.SelectedNode.Nodes) 437 | { 438 | List types = SYMParsing.GetTypes(function.Text); 439 | if (types != null && types.Count > 0) 440 | { 441 | foreach (string trimmed in from string parameter in types.Distinct() 442 | let trimmed = parameter.Trim() 443 | where !string.IsNullOrWhiteSpace(trimmed) 444 | select trimmed) 445 | { 446 | typeText += $"{trimmed}\n"; 447 | } 448 | } 449 | } 450 | 451 | if (string.IsNullOrWhiteSpace(typeText)) 452 | { 453 | MessageBox.Show("File had no function parameters"); 454 | return; 455 | } 456 | 457 | List sorted = typeText.TrimEnd().Split('\n').Distinct().ToList(); 458 | sorted.Sort(); 459 | 460 | Form3 disasmView = new Form3(string.Join("\r\n", sorted)); 461 | disasmView.Show(); 462 | } 463 | 464 | // Whole symbol map version (e.g. "pikmin-1.map") 465 | private void ExportTypesMap_Click(object o, EventArgs e) 466 | { 467 | string typeText = string.Empty; 468 | List typeList = new List(); 469 | foreach (List types in from TreeNode file in MapTree.SelectedNode.Nodes 470 | from TreeNode function in file.Nodes 471 | let types = SYMParsing.GetTypes(function.Text) 472 | select types) 473 | { 474 | if (types == null || types.Count == 0) 475 | { 476 | continue; 477 | } 478 | 479 | foreach (string trimmed in types) 480 | { 481 | /* 482 | * EXPERIMENTAL 483 | */ 484 | string[] ignoredTypes = new string[] 485 | { 486 | "char", 487 | "bool", 488 | "wchar_t", 489 | "unsigned", 490 | "signed", 491 | "short", 492 | "int", 493 | "long", 494 | "float", 495 | "double", 496 | "void", 497 | "...", 498 | }; 499 | 500 | string typeOnly = trimmed.Replace("const", "").Replace("&", "").Replace("*", "").Trim(); 501 | 502 | bool skipType = false; 503 | foreach (string ignored in ignoredTypes) 504 | { 505 | if (typeOnly.StartsWith(ignored) || typeOnly == ignored) 506 | { 507 | skipType = true; 508 | break; 509 | } 510 | } 511 | 512 | if (skipType || typeOnly.Contains("(") || typeOnly.Contains(")")) 513 | { 514 | continue; 515 | } 516 | 517 | typeList.Add(typeOnly); 518 | } 519 | } 520 | 521 | List finalList = new List(); 522 | foreach (string type in typeList) 523 | { 524 | string item = string.Empty; 525 | if (type.Contains("<")) 526 | { 527 | item += "template <"; 528 | StringStream input = new StringStream(type); 529 | 530 | // Storing the positions of the open and close "<>" brackets 531 | int openT = 0; 532 | int closeT = 0; 533 | 534 | int level = 0; 535 | int templateTypeCount = 0; 536 | while (input.Position < input.Length) 537 | { 538 | char r = input.Read(); 539 | 540 | switch (r) 541 | { 542 | case '(': 543 | level++; 544 | break; 545 | case '<': 546 | if (level == 0) 547 | { 548 | level++; 549 | openT = input.Position; 550 | templateTypeCount++; 551 | } 552 | break; 553 | case ')': 554 | level--; 555 | break; 556 | case '>': 557 | if (level != 0) 558 | { 559 | level--; 560 | } 561 | break; 562 | case ',': 563 | if (level == 1) 564 | { 565 | templateTypeCount++; 566 | } 567 | break; 568 | } 569 | } 570 | 571 | for (int i = 0; i < templateTypeCount; i++) 572 | { 573 | item += $"typename T{i}{(i == templateTypeCount - 1 ? "" : ", ")}"; 574 | } 575 | 576 | item += ">\r\n"; 577 | closeT = type.LastIndexOf('>') + 1; 578 | item += $"struct {type.Remove(openT - 1, closeT - openT + 1)};"; 579 | } 580 | else 581 | { 582 | item += $"struct {type};"; 583 | } 584 | 585 | item = item.Replace('@', '_'); 586 | item = item.Replace(':', '_'); 587 | item = item.Replace('$', '_'); 588 | finalList.Add(item); 589 | } 590 | 591 | finalList.Sort(); 592 | Form3 disasmView = new Form3(string.Join("\r\n", finalList.Distinct())); 593 | disasmView.Show(); 594 | 595 | GC.Collect(); 596 | } 597 | 598 | private byte[] ExtractHexFromDol(DOL file, long addr, long size) 599 | { 600 | file.Seek(addr, SeekOrigin.Begin); 601 | byte[] function = file.Read(size); 602 | return function; 603 | } 604 | 605 | private void DecompileToView_Click(object o, EventArgs e) 606 | { 607 | if (_FilesOpen[_SelectedFile]._AssociatedDol == null) 608 | { 609 | MessageBox.Show("Open the DOL file first!"); 610 | return; 611 | } 612 | 613 | MAPParsing.TextEntry entry = _FilesOpen[_SelectedFile]._TextSymbols.Find(x => x._SymbolDemangled == MapTree.SelectedNode.Text); 614 | 615 | if (entry._Address.Contains("...")) 616 | { 617 | MessageBox.Show("The selected function is unused, there is no PPC that can be decompiled"); 618 | return; 619 | } 620 | 621 | long address = long.Parse(entry._Address, NumberStyles.HexNumber); 622 | long size = long.Parse(entry._Size, NumberStyles.HexNumber); 623 | byte[] extractedHex = ExtractHexFromDol(_FilesOpen[_SelectedFile]._AssociatedDol, address, size); 624 | string[] ppcList = ReadAddressFromDol(_FilesOpen[_SelectedFile]._AssociatedDol, entry._Address, entry._Size).Split('\n'); 625 | string[] hexList = new string[extractedHex.Length >> 2]; 626 | 627 | string rawHex = string.Empty; 628 | int hIndex = 0; 629 | foreach (byte b in extractedHex) 630 | { 631 | rawHex += $"{b:X2}"; 632 | hIndex += 1; 633 | if (hIndex % 4 == 0) 634 | { 635 | hexList[(hIndex - 1) >> 2] = rawHex; 636 | rawHex = string.Empty; 637 | } 638 | } 639 | 640 | string hexViewText = string.Empty; 641 | long ofs = 0; 642 | for (int i = 0; i < ppcList.Length; ++i) 643 | { 644 | if (ppcList[i].Trim() == "" || ppcList[i].Trim().StartsWith(".")) 645 | { 646 | hexViewText += Environment.NewLine; 647 | } 648 | else 649 | { 650 | hexViewText += hexList[ofs] + Environment.NewLine; 651 | ofs += 1; 652 | } 653 | } 654 | 655 | string ppcViewText = ReadAddressFromDol(_FilesOpen[_SelectedFile]._AssociatedDol, entry._Address, entry._Size); 656 | 657 | DisasmView disasmView = new DisasmView(entry._SymbolDemangled, hexViewText, ppcViewText); 658 | disasmView.Show(); 659 | } 660 | 661 | private string ReadAddressFromDol(DOL file, string address, string size) 662 | { 663 | long addr = long.Parse(address, NumberStyles.HexNumber); 664 | long sz = long.Parse(size, NumberStyles.HexNumber); 665 | return ReadAddressFromDol(file, addr, sz); 666 | } 667 | 668 | private string ReadAddressFromDol(DOL file, long address, long size) 669 | { 670 | string functionHex = string.Empty; 671 | byte[] function = ExtractHexFromDol(file, address, size); 672 | foreach (byte b in function) 673 | { 674 | functionHex += $"{b:x2}"; 675 | } 676 | 677 | File.WriteAllText("raw.txt", functionHex); 678 | 679 | using (Process p = new Process()) 680 | { 681 | p.StartInfo.FileName = "pyiiasmh.exe"; 682 | p.StartInfo.Arguments = $"\"raw.txt\" d --codetype RAW --dest code.txt"; 683 | p.StartInfo.UseShellExecute = false; 684 | p.StartInfo.CreateNoWindow = true; 685 | p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; 686 | try 687 | { 688 | p.Start(); 689 | p.WaitForExit(); 690 | } 691 | catch (Exception ex) 692 | { 693 | if (ex.Message.ToLower().Contains("not found")) 694 | { 695 | MessageBox.Show("Install pyiiasmh before using this function!"); 696 | return "Unable to read\n"; 697 | } 698 | 699 | MessageBox.Show(ex.Message); 700 | return "Unable to read\n"; 701 | } 702 | } 703 | 704 | string ppc = string.Empty; 705 | if (File.Exists("code.txt")) 706 | { 707 | ppc = File.ReadAllText("code.txt"); 708 | } 709 | 710 | return ppc.Replace("-----------------", "").Trim(); 711 | } 712 | 713 | private void OpenDol_Click(object sender, EventArgs e) 714 | { 715 | if (_FilesOpen[_SelectedFile]._AssociatedDol != null) 716 | { 717 | DialogResult result = MessageBox.Show("Symbol map already has an associated DOL file!\nOpen new DOL file anyways?", "Open new DOL file", MessageBoxButtons.YesNo); 718 | if (result != DialogResult.Yes) 719 | { 720 | return; 721 | } 722 | } 723 | 724 | OpenFileDialog dialog = new OpenFileDialog() 725 | { 726 | CheckFileExists = true, 727 | CheckPathExists = true, 728 | ValidateNames = true, 729 | 730 | Filter = "GC/Wii Executable (*.dol)|*.dol" 731 | }; 732 | 733 | if (dialog.ShowDialog() != DialogResult.OK) 734 | { 735 | return; 736 | } 737 | 738 | DebugLog.Text += "Reading DOL file... "; 739 | BigEndianReader reader = new BigEndianReader(File.OpenRead(dialog.FileName)); 740 | try 741 | { 742 | _FilesOpen[_SelectedFile]._AssociatedDol = new DOL(reader); 743 | } 744 | catch (Exception any) 745 | { 746 | string errorMessage = $"Error: {any.Message}"; 747 | 748 | MessageBox.Show(errorMessage); 749 | DebugLog.Text += errorMessage + "\n"; 750 | } 751 | DebugLog.Text += "Done!\n"; 752 | } 753 | 754 | private void FileToolStripMenuItem_Click(object sender, EventArgs e) 755 | { 756 | OpenFileDialog dialog = new OpenFileDialog() 757 | { 758 | CheckFileExists = true, 759 | CheckPathExists = true, 760 | ValidateNames = true, 761 | 762 | Filter = "Symbol Map (*.map)|*.map" 763 | }; 764 | 765 | if (dialog.ShowDialog() != DialogResult.OK) 766 | { 767 | return; 768 | } 769 | 770 | // Checking if the symbol map is already open 771 | foreach (TreeNode files in MapTree.Nodes) 772 | { 773 | if (dialog.FileName == files.Text) 774 | { 775 | DialogResult result = MessageBox.Show("This symbol map has already been loaded,\nare you sure you want to add the same one?", "Symbol map already open", MessageBoxButtons.YesNo); 776 | if (result != DialogResult.Yes) 777 | { 778 | return; 779 | } 780 | } 781 | } 782 | 783 | DebugLog.Text += "Opening Map File... "; 784 | MAP newFile = new MAP(File.ReadAllLines(dialog.FileName)); 785 | 786 | _FilesOpen.Add(newFile); 787 | 788 | if (newFile._TextSymbols == null) 789 | { 790 | MessageBox.Show("There are no TEXT symbols in this map file!"); 791 | return; 792 | } 793 | 794 | DialogResult invertInputResult = MessageBox.Show("Reverse the order of all functions?", "Urgent", MessageBoxButtons.YesNo, MessageBoxIcon.Question); 795 | 796 | /* Populate tree with text data 797 | * 798 | * (FILENAME) 799 | * - (FILE) 800 | * - (SYMBOL) 801 | * - (ADDRESS) 802 | * - (SIZE) 803 | * - (PARAMETERS) 804 | */ 805 | 806 | Update(); 807 | MapTree.BeginUpdate(); 808 | 809 | // (FILENAME) 810 | TreeNode parent = new TreeNode(dialog.FileName) 811 | { 812 | Tag = "File", 813 | ImageIndex = 0, 814 | }; 815 | 816 | List pathsDone = new List(); 817 | int currentPath = -1; 818 | 819 | foreach (MAPParsing.TextEntry node in newFile._TextSymbols) 820 | { 821 | if (!pathsDone.Contains(node._Path)) 822 | { 823 | // (FILE) 824 | TreeNode fileParent = new TreeNode(node._Path) 825 | { 826 | Tag = "Path", 827 | ImageIndex = 1, 828 | }; 829 | parent.Nodes.Add(fileParent); 830 | 831 | pathsDone.Add(node._Path); 832 | currentPath++; 833 | } 834 | 835 | // (SYMBOL) 836 | TreeNode symbol = new TreeNode(node._SymbolDemangled) 837 | { 838 | Tag = "Function", 839 | ImageIndex = 2, 840 | }; 841 | 842 | // (ADDRESS) / (SIZE) 843 | symbol.Nodes.Add(new TreeNode($"Address - {node._Address}")); 844 | symbol.Nodes.Add(new TreeNode($"Size - {node._Size}")); 845 | 846 | List types = SYMParsing.GetTypes(node._SymbolDemangled); 847 | if (types != null) 848 | { 849 | foreach (string parameter in types) 850 | { 851 | // (PARAMETERS) 852 | symbol.Nodes.Add(new TreeNode($"Parameter Type - {parameter}")); 853 | } 854 | } 855 | 856 | if (invertInputResult == DialogResult.Yes) 857 | { 858 | parent.Nodes[currentPath].Nodes.Insert(0, symbol); 859 | } 860 | else 861 | { 862 | parent.Nodes[currentPath].Nodes.Add(symbol); 863 | } 864 | } 865 | 866 | MapTree.Nodes.Add(parent); 867 | MapTree.EndUpdate(); 868 | DebugLog.Text += "Done!\n"; 869 | 870 | _SelectedFile = _FilesOpen.Count; 871 | } 872 | 873 | private void commonFSCleanerToolStripMenuItem_Click(object sender, EventArgs e) 874 | { 875 | new DecompFillerForm().Show(); 876 | } 877 | } 878 | } 879 | -------------------------------------------------------------------------------- /Form2.Designer.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Forms; 2 | 3 | namespace mapdas 4 | { 5 | partial class DisasmView 6 | { 7 | /// 8 | /// Required designer variable. 9 | /// 10 | private System.ComponentModel.IContainer components = null; 11 | 12 | /// 13 | /// Clean up any resources being used. 14 | /// 15 | /// true if managed resources should be disposed; otherwise, false. 16 | protected override void Dispose(bool disposing) 17 | { 18 | if (disposing && (components != null)) 19 | { 20 | components.Dispose(); 21 | } 22 | base.Dispose(disposing); 23 | } 24 | 25 | #region Windows Form Designer generated code 26 | 27 | /// 28 | /// Required method for Designer support - do not modify 29 | /// the contents of this method with the code editor. 30 | /// 31 | private void InitializeComponent() 32 | { 33 | this.ppcView = new SyncTextBox(ScrollBars.Vertical); 34 | this.hexView = new SyncTextBox(ScrollBars.None); 35 | 36 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DisasmView)); 37 | this.funcIdentityView = new System.Windows.Forms.TextBox(); 38 | this.SuspendLayout(); 39 | 40 | // 41 | // ppcView 42 | // 43 | this.ppcView.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(32)))), ((int)(((byte)(32)))), ((int)(((byte)(32))))); 44 | this.ppcView.Buddy = this.hexView; 45 | this.ppcView.Font = new System.Drawing.Font("Lucida Console", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 46 | this.ppcView.ForeColor = System.Drawing.SystemColors.Control; 47 | this.ppcView.Location = new System.Drawing.Point(89, 49); 48 | this.ppcView.Multiline = true; 49 | this.ppcView.Name = "ppcView"; 50 | this.ppcView.ReadOnly = true; 51 | this.ppcView.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; 52 | this.ppcView.Size = new System.Drawing.Size(865, 600); 53 | this.ppcView.TabIndex = 0; 54 | this.ppcView.WordWrap = false; 55 | // 56 | // hexView 57 | // 58 | this.hexView.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(32)))), ((int)(((byte)(32)))), ((int)(((byte)(32))))); 59 | this.hexView.Buddy = this.ppcView; 60 | this.hexView.Font = new System.Drawing.Font("Lucida Console", 9F); 61 | this.hexView.ForeColor = System.Drawing.SystemColors.Control; 62 | this.hexView.Location = new System.Drawing.Point(12, 49); 63 | this.hexView.Multiline = true; 64 | this.hexView.Name = "hexView"; 65 | this.hexView.ReadOnly = true; 66 | this.hexView.Size = new System.Drawing.Size(78, 600); 67 | this.hexView.TabIndex = 1; 68 | this.hexView.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; 69 | this.hexView.WordWrap = false; 70 | // 71 | // funcIdentityView 72 | // 73 | this.funcIdentityView.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(32)))), ((int)(((byte)(32)))), ((int)(((byte)(32))))); 74 | this.funcIdentityView.Font = new System.Drawing.Font("Lucida Console", 15F); 75 | this.funcIdentityView.ForeColor = System.Drawing.SystemColors.Control; 76 | this.funcIdentityView.Location = new System.Drawing.Point(12, 12); 77 | this.funcIdentityView.Name = "funcIdentityView"; 78 | this.funcIdentityView.ReadOnly = true; 79 | this.funcIdentityView.Size = new System.Drawing.Size(942, 27); 80 | this.funcIdentityView.TabIndex = 2; 81 | this.funcIdentityView.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; 82 | this.funcIdentityView.WordWrap = false; 83 | // 84 | // DisasmView 85 | // 86 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 87 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 88 | this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); 89 | this.ClientSize = new System.Drawing.Size(966, 661); 90 | this.Controls.Add(this.funcIdentityView); 91 | this.Controls.Add(this.hexView); 92 | this.Controls.Add(this.ppcView); 93 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; 94 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); 95 | this.Name = "DisasmView"; 96 | this.Text = "Disassembly View"; 97 | this.ResumeLayout(false); 98 | this.PerformLayout(); 99 | 100 | } 101 | 102 | #endregion 103 | 104 | private SyncTextBox ppcView; 105 | private SyncTextBox hexView; 106 | private System.Windows.Forms.TextBox funcIdentityView; 107 | } 108 | } -------------------------------------------------------------------------------- /Form2.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Forms; 2 | 3 | namespace mapdas 4 | { 5 | public partial class DisasmView : Form 6 | { 7 | public DisasmView(string funcName = "", string hex = "", string ppc = "") 8 | { 9 | InitializeComponent(); 10 | 11 | funcIdentityView.Text = funcName; 12 | hexView.Text = hex; 13 | ppcView.Text = ppc; 14 | Icon = ActiveForm.Icon; 15 | MinimizeBox = false; 16 | MaximizeBox = false; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Form3.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace mapdas 2 | { 3 | partial class Form3 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form3)); 32 | this.typeBox = new System.Windows.Forms.TextBox(); 33 | this.SuspendLayout(); 34 | // 35 | // typeBox 36 | // 37 | this.typeBox.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(32)))), ((int)(((byte)(32)))), ((int)(((byte)(32))))); 38 | this.typeBox.Dock = System.Windows.Forms.DockStyle.Fill; 39 | this.typeBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 40 | this.typeBox.ForeColor = System.Drawing.Color.White; 41 | this.typeBox.Location = new System.Drawing.Point(0, 0); 42 | this.typeBox.Multiline = true; 43 | this.typeBox.Name = "typeBox"; 44 | this.typeBox.ScrollBars = System.Windows.Forms.ScrollBars.Both; 45 | this.typeBox.Size = new System.Drawing.Size(384, 361); 46 | this.typeBox.TabIndex = 0; 47 | // 48 | // Form3 49 | // 50 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 51 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 52 | this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); 53 | this.ClientSize = new System.Drawing.Size(384, 361); 54 | this.Controls.Add(this.typeBox); 55 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); 56 | this.Name = "Form3"; 57 | this.Text = "Type View"; 58 | this.Load += new System.EventHandler(this.Form3_Load); 59 | this.ResumeLayout(false); 60 | this.PerformLayout(); 61 | 62 | } 63 | 64 | #endregion 65 | 66 | private System.Windows.Forms.TextBox typeBox; 67 | } 68 | } -------------------------------------------------------------------------------- /Form3.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | 4 | namespace mapdas 5 | { 6 | public partial class Form3 : Form 7 | { 8 | public Form3(string typeString) 9 | { 10 | InitializeComponent(); 11 | 12 | typeBox.Text = typeString; 13 | } 14 | 15 | private void Form3_Load(object sender, EventArgs e) 16 | { 17 | 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Formats/DOL.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | 5 | namespace mapdas 6 | { 7 | internal class DOL 8 | { 9 | public enum SectionType 10 | { 11 | Text = 0, 12 | Data 13 | } 14 | 15 | public class Section 16 | { 17 | public long _Offset = 0; 18 | public long _Address = 0; 19 | public long _Size = 0; 20 | 21 | public MemoryStream _Data = null; 22 | 23 | public SectionType _Type = SectionType.Text; 24 | } 25 | 26 | public List
_TextSections = new List
(); 27 | public List
_DataSections = new List
(); 28 | private const int _MaxTextSections = 7; 29 | private const int _MaxDataSections = 11; 30 | private const long _AddressInfoLoc = 0x48; 31 | private const long _SizeInfoLoc = 0x90; 32 | private readonly long _OffsetInfoLoc = 0; 33 | private long _CurrLogicAddr = 0; 34 | 35 | public DOL(BigEndianReader reader) 36 | { 37 | for (int i = 0; i < _MaxTextSections + _MaxDataSections; i++) 38 | { 39 | reader.BaseStream.Seek(_OffsetInfoLoc + (i << 2), SeekOrigin.Begin); 40 | uint offset = reader.ReadUInt32(); 41 | 42 | reader.BaseStream.Seek(_AddressInfoLoc + (i << 2), SeekOrigin.Begin); 43 | uint address = reader.ReadUInt32(); 44 | 45 | reader.BaseStream.Seek(_SizeInfoLoc + (i << 2), SeekOrigin.Begin); 46 | uint size = reader.ReadUInt32(); 47 | 48 | if (offset < 0x100) 49 | { 50 | continue; 51 | } 52 | 53 | reader.BaseStream.Seek(offset, SeekOrigin.Begin); 54 | 55 | Section newSection = new Section() 56 | { 57 | _Offset = offset, 58 | _Address = address, 59 | _Size = size, 60 | _Data = new MemoryStream(reader.ReadBytes(size)), 61 | }; 62 | 63 | if (i < _MaxTextSections) 64 | { 65 | newSection._Type = SectionType.Text; 66 | _TextSections.Add(newSection); 67 | } 68 | else 69 | { 70 | newSection._Type = SectionType.Data; 71 | _DataSections.Add(newSection); 72 | } 73 | } 74 | 75 | _CurrLogicAddr = GetFirstSection()._Address; 76 | Seek(_CurrLogicAddr, SeekOrigin.Begin); 77 | reader.BaseStream.Seek(0, SeekOrigin.Begin); 78 | } 79 | 80 | public Section ResolveAddress(long gcAddr) 81 | { 82 | foreach (Section section in _TextSections) 83 | { 84 | if (section._Address <= gcAddr && gcAddr < section._Address + section._Size) 85 | { 86 | return section; 87 | } 88 | } 89 | 90 | foreach (Section section in _DataSections) 91 | { 92 | if (section._Address <= gcAddr && gcAddr < section._Address + section._Size) 93 | { 94 | return section; 95 | } 96 | } 97 | 98 | throw new Exception($"Unmapped Address {gcAddr:X}"); 99 | } 100 | 101 | public void Seek(long where, SeekOrigin origin) 102 | { 103 | if (origin == SeekOrigin.Begin) 104 | { 105 | Section resolvedAddr = ResolveAddress(where); 106 | resolvedAddr._Data.Seek(where - resolvedAddr._Address, SeekOrigin.Begin); 107 | _CurrLogicAddr = where; 108 | } 109 | else if (origin == SeekOrigin.Current) 110 | { 111 | Section resolvedAddr = ResolveAddress(_CurrLogicAddr); 112 | resolvedAddr._Data.Seek((where + _CurrLogicAddr) - resolvedAddr._Address, SeekOrigin.Begin); 113 | _CurrLogicAddr += where; 114 | } 115 | } 116 | 117 | public byte[] Read(long size) 118 | { 119 | Section addr = ResolveAddress(_CurrLogicAddr); 120 | if (_CurrLogicAddr + size > addr._Address + addr._Size) 121 | { 122 | throw new Exception("Read goes over current section"); 123 | } 124 | 125 | _CurrLogicAddr += size; 126 | BinaryReader beReader = new BinaryReader(addr._Data); 127 | return beReader.ReadBytes((int)size); 128 | } 129 | 130 | public Section GetFirstSection() 131 | { 132 | long smallestOffset = 0xffffffff; 133 | int idx = 0; 134 | SectionType type = SectionType.Text; 135 | 136 | for (int i = 0; i < _TextSections.Count; i++) 137 | { 138 | if (_TextSections[i]._Offset < smallestOffset) 139 | { 140 | smallestOffset = _TextSections[i]._Offset; 141 | idx = i; 142 | type = SectionType.Text; 143 | } 144 | } 145 | for (int i = 0; i < _DataSections.Count; i++) 146 | { 147 | if (_DataSections[i]._Offset < smallestOffset) 148 | { 149 | smallestOffset = _DataSections[i]._Offset; 150 | idx = i; 151 | type = SectionType.Data; 152 | } 153 | } 154 | 155 | return type == SectionType.Text ? _TextSections[idx] : _DataSections[idx]; 156 | } 157 | } 158 | } 159 | -------------------------------------------------------------------------------- /Formats/MAP.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | 4 | namespace mapdas 5 | { 6 | internal class MAP 7 | { 8 | public enum SectionType 9 | { 10 | Init = 0, 11 | Extab, 12 | ExtabIndex, 13 | Text, 14 | Ctors, 15 | Dtors, 16 | Rodata, 17 | Data, 18 | Bss, 19 | Sdata, 20 | Sbss, 21 | Sdata2, 22 | Sbss2, 23 | MemoryMap, 24 | LinkerSymbols, 25 | LinkerMap, 26 | } 27 | 28 | private readonly Dictionary _SectionConverter = new Dictionary(16) { { SectionType.Init, ".init section layout" }, { SectionType.Extab, "extab section layout" }, { SectionType.ExtabIndex, "extabindex section layout" }, { SectionType.Text, ".text section layout" }, { SectionType.Ctors, ".ctors section layout" }, { SectionType.Dtors, ".dtors section layout" }, { SectionType.Rodata, ".rodata section layout" }, { SectionType.Data, ".data section layout" }, { SectionType.Bss, ".bss section layout" }, { SectionType.Sbss, ".sbss section layout" }, { SectionType.Sbss2, ".sbss2 section layout" }, { SectionType.Sdata, ".sdata section layout" }, { SectionType.Sdata2, ".sdata2 section layout" }, { SectionType.MemoryMap, "Memory map:" }, { SectionType.LinkerMap, "Link map of __start" }, { SectionType.LinkerSymbols, "Linker generated symbols:" }, 29 | }; 30 | private readonly Dictionary _Sections = new Dictionary(); 31 | 32 | public List _TextSymbols = new List(); 33 | public DOL _AssociatedDol = null; 34 | 35 | public MAP(string[] lines) 36 | { 37 | List currentSegmentEntries = new List(); 38 | string currentSegment = ""; 39 | 40 | foreach (string line in lines) 41 | { 42 | if (string.IsNullOrEmpty(line)) 43 | { 44 | if (currentSegmentEntries.Any()) 45 | { 46 | _Sections[currentSegment] = currentSegmentEntries.ToArray(); 47 | currentSegmentEntries.Clear(); 48 | 49 | continue; 50 | } 51 | 52 | continue; 53 | } 54 | 55 | if (line[0] != ' ') 56 | { 57 | currentSegment = line.TrimStart(); 58 | continue; 59 | } 60 | 61 | currentSegmentEntries.Add(line); 62 | } 63 | if (currentSegmentEntries.Any()) 64 | { 65 | _Sections[currentSegment] = currentSegmentEntries.ToArray(); 66 | } 67 | 68 | _TextSymbols = MAPParsing.ParseTextSection(this); 69 | } 70 | 71 | public string[] TryGetSection(SectionType type) 72 | { 73 | return _Sections.TryGetValue(_SectionConverter[type], out string[] result) ? result : null; 74 | } 75 | 76 | public string[] TryGetSection(string type) 77 | { 78 | return _Sections.TryGetValue(type, out string[] result) ? result : null; 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /Helpers/DecompFiller.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Globalization; 4 | using System.IO; 5 | using System.Linq; 6 | 7 | namespace CommonDecompFiller 8 | { 9 | static class Filler 10 | { 11 | static private void EncapsulateNamespace(string name, ref List lines) 12 | { 13 | bool insideNamespace = false; 14 | for (int i = 0; i < lines.Count; i++) 15 | { 16 | string line = lines[i].Trim(); 17 | bool checkCtor = line.StartsWith(name + "::") && line.Contains("("); 18 | // Only support u32, s32 and void functions as we can 19 | // be sure these are atleast automatically generated 20 | if (checkCtor || 21 | ((line.StartsWith("void") || line.StartsWith("u32") || line.StartsWith("s32")) 22 | && line.Contains("("))) 23 | { 24 | // Fix double parenthesis 25 | if (line.Contains("((")) 26 | { 27 | // Replace the (( 28 | lines[i] = lines[i].Replace("((", "("); 29 | if (line.Contains("))")) 30 | { 31 | lines[i] = lines[i].Replace("))", ")"); 32 | } 33 | else 34 | { 35 | // Search the next 5 lines for the ending )) 36 | for (int j = 0; j < 10; j++) 37 | { 38 | if (lines[i + j].Contains("))")) 39 | { 40 | lines[i + j] = lines[i + j].Replace("))", ")"); 41 | break; 42 | } 43 | } 44 | } 45 | } 46 | 47 | string type = line.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries).Where(s => !string.IsNullOrWhiteSpace(line)).ToArray()[0]; 48 | if (!checkCtor) 49 | { 50 | // Check if we are actually in the namespace 51 | line = line.Remove(0, type.Length).Trim(); 52 | } 53 | 54 | if (checkCtor || line.StartsWith(name + "::")) 55 | { 56 | if (insideNamespace == false) 57 | { 58 | lines.Insert(i - 5, $"namespace {name} {{\n"); 59 | i++; 60 | insideNamespace = true; 61 | } 62 | 63 | // Remove the name and the :: afterwards 64 | lines[i] = line.Remove(0, name.Length + 2); 65 | if (!checkCtor) 66 | { 67 | lines[i] = lines[i].Insert(0, type + " "); 68 | } 69 | } 70 | else if (insideNamespace) 71 | { 72 | lines.Insert(i - 5, $"}} // {name}\n"); 73 | i++; 74 | insideNamespace = false; 75 | } 76 | } 77 | } 78 | 79 | if (insideNamespace) 80 | { 81 | lines.Add($"}} // {name}\n"); 82 | } 83 | } 84 | 85 | static private void HandleSimpleStorePattern(string version, int i, ref List lines) 86 | { 87 | if (i + 3 < lines.Count 88 | && lines[i + 1].Contains("li") 89 | && lines[i + 2].Contains(version) 90 | && lines[i + 3].Contains("blr")) 91 | { 92 | if (lines[i - 3].StartsWith("void")) 93 | { 94 | // Check if it's in a class or not 95 | string[] scopeList = lines[i - 3].Remove(0, 5).Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries); 96 | if (scopeList.Length >= 1) 97 | { 98 | string liLine = lines[i + 1]; 99 | string[] liTokens = liLine.Split(); 100 | for (int j = 0; j < liTokens.Length; j++) 101 | { 102 | liTokens[j] = liTokens[j].Trim(); 103 | } 104 | var liFinalTokens = liTokens.Where(s => !string.IsNullOrWhiteSpace(s)).ToArray(); 105 | 106 | if (liFinalTokens[0] == "li" && liFinalTokens[1] == "r0,") 107 | { 108 | bool liValueNegative = liFinalTokens[2].Contains("-"); 109 | string liValueHex = liFinalTokens[2].Replace("-", ""); 110 | int liValue = 0; 111 | if (liValueHex.StartsWith("0x")) 112 | { 113 | liValue = int.Parse(liValueHex.Replace("0x", ""), NumberStyles.HexNumber); 114 | if (liValueNegative) 115 | { 116 | liValue = -liValue; 117 | } 118 | } 119 | else 120 | { 121 | liValue = int.Parse(liValueHex); 122 | } 123 | 124 | string stwLine = lines[i + 2]; 125 | string[] stwTokens = stwLine.Split(); 126 | for (int j = 0; j < stwTokens.Length; j++) 127 | { 128 | stwTokens[j] = stwTokens[j].Trim(); 129 | } 130 | var stwFinalTokens = stwTokens.Where(s => !string.IsNullOrWhiteSpace(s)).ToArray(); 131 | 132 | if (stwFinalTokens[0] == version && stwFinalTokens[1] == "r0," 133 | && stwFinalTokens[2].EndsWith("(r3)")) 134 | { 135 | string stwValueHex = stwFinalTokens[2].Replace("0x", "").Replace("(r3)", ""); 136 | int stwValueSet = int.Parse(stwValueHex, NumberStyles.HexNumber); 137 | 138 | lines.RemoveAt(i - 1); 139 | lines.RemoveAt(i - 1); 140 | lines.RemoveAt(i - 1); 141 | lines.RemoveAt(i - 1); 142 | lines.RemoveAt(i - 1); 143 | lines.RemoveAt(i - 1); 144 | 145 | lines.Insert(i - 1, $"_{stwValueSet.ToString("X2").ToUpper()} = {liValue};"); 146 | lines.Insert(i - 1, $"// Generated from {version} r0, 0x{stwValueHex}(r3)"); 147 | } 148 | } 149 | } 150 | } 151 | } 152 | 153 | } 154 | 155 | static private void HandleSimpleArgStorePattern(string version, int i, ref List lines) 156 | { 157 | if (i + 2 < lines.Count 158 | && lines[i + 1].Contains(version) 159 | && lines[i + 2].Contains("blr")) 160 | { 161 | if (lines[i - 3].StartsWith("void")) 162 | { 163 | // Check if it's in a class or not 164 | string[] scopeList = lines[i - 3].Remove(0, 5).Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries); 165 | if (scopeList.Length >= 1) 166 | { 167 | string stwLine = lines[i + 1]; 168 | string[] stwTokens = stwLine.Split(); 169 | for (int j = 0; j < stwTokens.Length; j++) 170 | { 171 | stwTokens[j] = stwTokens[j].Trim(); 172 | } 173 | var stwFinalTokens = stwTokens.Where(s => !string.IsNullOrWhiteSpace(s)).ToArray(); 174 | 175 | if (stwFinalTokens[0] == version && stwFinalTokens[1] == "r4," 176 | && stwFinalTokens[2].EndsWith("(r3)")) 177 | { 178 | string stwValueHex = stwFinalTokens[2].Replace("0x", "").Replace("(r3)", ""); 179 | int stwValueSet = int.Parse(stwValueHex, NumberStyles.HexNumber); 180 | 181 | lines.RemoveAt(i - 1); 182 | lines.RemoveAt(i - 1); 183 | lines.RemoveAt(i - 1); 184 | lines.RemoveAt(i - 1); 185 | lines.RemoveAt(i - 1); 186 | 187 | // Set the variable name in the arguments 188 | int lastBracket = lines[i - 3].LastIndexOf(")"); 189 | if (lastBracket != -1) 190 | { 191 | lines[i - 3] = lines[i - 3].Insert(lastBracket, " a1"); 192 | 193 | lines.Insert(i - 1, $"_{stwValueSet.ToString("X2").ToUpper()} = a1;"); 194 | lines.Insert(i - 1, $"// Generated from {version} r4, 0x{stwValueHex}(r3)"); 195 | } 196 | } 197 | } 198 | } 199 | } 200 | } 201 | 202 | static public void Run(string src, List namespaces) 203 | { 204 | List files = new List(); 205 | files.AddRange(Directory.GetFiles(src, "*.cpp", SearchOption.AllDirectories)); 206 | files.AddRange(Directory.GetFiles(src, "*.c", SearchOption.AllDirectories)); 207 | 208 | foreach (string file in files) 209 | { 210 | List lines = File.ReadAllLines(file).ToList(); 211 | 212 | for (int i = 0; i < lines.Count; i++) 213 | { 214 | if (lines[i].StartsWith("void")) 215 | { 216 | string[] seperators = new string[] { "::", " " }; 217 | int end = lines[i].IndexOf("("); 218 | if (end != -1) 219 | { 220 | string[] scopeSplit = lines[i].Substring(0, end).Split(seperators, StringSplitOptions.RemoveEmptyEntries); 221 | if (scopeSplit.Length > 1 222 | && (scopeSplit[scopeSplit.Length - 1] == scopeSplit[scopeSplit.Length - 2] 223 | || scopeSplit[scopeSplit.Length - 1] == "~" + scopeSplit[scopeSplit.Length - 2])) 224 | { 225 | lines[i] = lines[i].Remove(0, 5); 226 | } 227 | } 228 | } 229 | 230 | if (lines[i].Contains("__ct")) 231 | { 232 | int ctIdx = lines[i].LastIndexOf("__ct"); 233 | string cutOff = lines[i].Substring(0, ctIdx).Trim(); 234 | string[] splitByScope = cutOff.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries); 235 | if (splitByScope.Length > 2) 236 | { 237 | string ctorName = splitByScope[splitByScope.Length - 2]; 238 | lines[i] = lines[i].Replace("__ct", ctorName); 239 | if (lines[i].StartsWith("void")) 240 | { 241 | lines[i] = lines[i].Remove(0, 4).Trim(); 242 | } 243 | } 244 | } 245 | else if (lines[i].Contains("__dt")) 246 | { 247 | int dtIdx = lines[i].LastIndexOf("__dt"); 248 | string cutOff = lines[i].Substring(0, dtIdx).Trim(); 249 | string[] splitByScope = cutOff.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries); 250 | if (splitByScope.Length > 2) 251 | { 252 | string dtorName = "~" + splitByScope[splitByScope.Length - 2]; 253 | lines[i] = lines[i].Replace("__dt", dtorName); 254 | 255 | if (lines[i].StartsWith("void")) 256 | { 257 | lines[i] = lines[i].Remove(0, 4).Trim(); 258 | } 259 | } 260 | } 261 | else if (lines[i].Contains("( const") && !lines[i].Contains("( const(")) 262 | { 263 | lines[i] = lines[i].Replace("( const", "() const"); 264 | } 265 | else if (lines[i].Contains("void _Print(char*, ...)")) 266 | { 267 | lines.RemoveAt(i); 268 | lines.RemoveAt(i); 269 | lines.RemoveAt(i); 270 | lines.RemoveAt(i); 271 | lines.RemoveAt(i - 1); 272 | lines.RemoveAt(i - 2); 273 | lines.RemoveAt(i - 3); 274 | lines.RemoveAt(i - 4); 275 | lines.RemoveAt(i - 5); 276 | } 277 | // Codegen pattern recognition 278 | else if (lines[i].Contains(".loc_0x0:")) 279 | { 280 | // Handle copying from the .s to the function 281 | 282 | if (i + 1 != lines.Count 283 | && lines[i + 1].Contains("blr")) 284 | { 285 | lines.RemoveAt(i - 1); 286 | lines.RemoveAt(i - 1); 287 | lines.RemoveAt(i - 1); 288 | lines.RemoveAt(i - 1); 289 | } 290 | else if (i + 2 < lines.Count 291 | && lines[i + 1].Contains("li") 292 | && lines[i + 2].Contains("blr")) 293 | { 294 | string liLine = lines[i + 1]; 295 | string[] tokens = liLine.Split(); 296 | for (int j = 0; j < tokens.Length; j++) 297 | { 298 | tokens[j] = tokens[j].Trim(); 299 | } 300 | 301 | var filteredTokens = tokens.Where(s => !string.IsNullOrWhiteSpace(s)).ToArray(); 302 | 303 | if (filteredTokens[0] == "li" && filteredTokens[1] == "r3,") 304 | { 305 | string numHex = filteredTokens[2].Replace("0x", ""); 306 | bool negative = numHex.StartsWith("-"); 307 | 308 | int num = int.Parse(negative ? numHex.Remove(0, 1) : numHex, System.Globalization.NumberStyles.HexNumber); 309 | lines.RemoveAt(i - 1); 310 | lines.RemoveAt(i - 1); 311 | lines.RemoveAt(i - 1); 312 | lines.RemoveAt(i - 1); 313 | lines.RemoveAt(i - 1); 314 | string retLine = "\treturn "; 315 | if (negative) 316 | { 317 | retLine += "-"; 318 | } 319 | retLine += "0x" + num.ToString("X") + ";"; 320 | lines.Insert(i - 1, retLine); 321 | 322 | if (lines[i - 3].StartsWith("void")) 323 | { 324 | string oldFunc = lines[i - 3]; 325 | oldFunc = oldFunc.Remove(0, 4); 326 | oldFunc = oldFunc.Insert(0, negative ? "s32 " : "u32 "); 327 | lines[i - 3] = oldFunc; 328 | } 329 | } 330 | } 331 | 332 | HandleSimpleStorePattern("stw", i, ref lines); 333 | HandleSimpleStorePattern("sth", i, ref lines); 334 | HandleSimpleStorePattern("stb", i, ref lines); 335 | 336 | HandleSimpleArgStorePattern("stw", i, ref lines); 337 | HandleSimpleArgStorePattern("sth", i, ref lines); 338 | HandleSimpleArgStorePattern("stb", i, ref lines); 339 | } 340 | } 341 | 342 | if (file.EndsWith(".cpp")) 343 | { 344 | // Handle namespacing the C++ code 345 | for (int i = 0; i < namespaces.Count; i++) 346 | { 347 | EncapsulateNamespace(namespaces[i], ref lines); 348 | } 349 | } 350 | 351 | File.WriteAllLines(file, lines.ToArray()); 352 | } 353 | } 354 | } 355 | } 356 | -------------------------------------------------------------------------------- /Helpers/Demangler.cs: -------------------------------------------------------------------------------- 1 | 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace arookas 7 | { 8 | 9 | static class Demangler 10 | { 11 | 12 | static void DemangleTemplate(StringStream input, StringBuilder output) 13 | { 14 | output.Append('<'); 15 | bool end = false; 16 | 17 | do 18 | { 19 | DemangleType(input, output); 20 | 21 | switch (input.Read()) 22 | { 23 | case '>': 24 | { 25 | end = true; 26 | break; 27 | } 28 | case ',': 29 | { 30 | output.Append(", "); 31 | break; 32 | } 33 | case '\0': 34 | { 35 | end = true; 36 | break; 37 | } 38 | } 39 | } while (!end); 40 | 41 | output.Append('>'); 42 | } 43 | 44 | static void DemangleComponents(IList components, int start, StringBuilder output) 45 | { 46 | if (components.Count == 0) 47 | { 48 | return; 49 | } 50 | 51 | ComponentType last = components[start].type; 52 | 53 | while (start < components.Count) 54 | { 55 | if (components[start].type != last) 56 | { 57 | output.Append(' '); 58 | last = components[start].type; 59 | } 60 | 61 | switch (components[start].type) 62 | { 63 | case ComponentType.Const: output.Append("const"); break; 64 | case ComponentType.Pointer: output.Append('*'); break; 65 | case ComponentType.Reference: output.Append('&'); break; 66 | case ComponentType.Unsigned: output.Append("unsigned"); break; 67 | case ComponentType.Ellipsis: output.Append("..."); break; 68 | case ComponentType.Void: output.Append("void"); break; 69 | case ComponentType.Bool: output.Append("bool"); break; 70 | case ComponentType.Char: output.Append("char"); break; 71 | case ComponentType.WChar: output.Append("wchar_t"); break; 72 | case ComponentType.Short: output.Append("short"); break; 73 | case ComponentType.Int: output.Append("int"); break; 74 | case ComponentType.Long: output.Append("long"); break; 75 | case ComponentType.LongLong: output.Append("long long"); break; 76 | case ComponentType.Float: output.Append("float"); break; 77 | case ComponentType.Double: output.Append("double"); break; 78 | case ComponentType.Type: output.Append(components[start].name); break; 79 | case ComponentType.Func: 80 | { 81 | output.Append(components[start].name); 82 | output.Append(' '); 83 | 84 | if ((start + 1) < components.Count) 85 | { 86 | output.Append('('); 87 | DemangleComponents(components, (start + 1), output); 88 | output.Append(") "); 89 | } 90 | 91 | output.Append('('); 92 | output.Append(components[start].prms); 93 | output.Append(')'); 94 | return; 95 | } 96 | case ComponentType.Array: 97 | { 98 | int count = 0; 99 | 100 | while ((start + count) < components.Count && components[start + count].type == ComponentType.Array) 101 | { 102 | ++count; 103 | } 104 | 105 | if (count > 0 && (start + count) < components.Count) 106 | { 107 | output.Append('('); 108 | DemangleComponents(components, (start + count), output); 109 | output.Append(") "); 110 | } 111 | 112 | // output in reverse, e.g. "A4_A3_" becomes "[3][4]" 113 | while (count-- > 0) 114 | { 115 | output.Append('['); 116 | output.Append(components[start + count].length); 117 | output.Append(']'); 118 | } 119 | return; 120 | } 121 | } 122 | 123 | ++start; 124 | } 125 | } 126 | 127 | static void DemangleType(StringStream input, StringBuilder output) 128 | { 129 | char c = input.Peek(); 130 | 131 | if (c == '-' || ('0' <= c && c <= '9')) 132 | { 133 | bool literal = false; 134 | bool negative = false; 135 | 136 | if (c == '-') 137 | { 138 | ++input.Position; 139 | c = input.Peek(); 140 | 141 | literal = true; 142 | negative = true; 143 | } 144 | 145 | int length = 0; 146 | 147 | while ('0' <= c && c <= '9') 148 | { 149 | length *= 10; 150 | length += (c - '0'); 151 | 152 | ++input.Position; 153 | c = input.Peek(); 154 | } 155 | 156 | if (c == ',' || c == '>') 157 | { 158 | literal = true; 159 | } 160 | 161 | if (literal) 162 | { 163 | if (negative) 164 | { 165 | length = -length; 166 | } 167 | 168 | output.Append(length.ToString()); 169 | } 170 | else 171 | { 172 | int start = input.Position; 173 | 174 | while ((input.Position - start) < length 175 | && input.Position != input.Length) 176 | { 177 | c = input.Read(); 178 | 179 | if (c == '<') 180 | { 181 | DemangleTemplate(input, output); 182 | } 183 | else 184 | { 185 | output.Append(c); 186 | } 187 | } 188 | } 189 | } 190 | else 191 | { 192 | bool end = false; 193 | List components = new List(50); 194 | 195 | do 196 | { 197 | c = input.Read(); 198 | 199 | if (c == '\0') 200 | { 201 | end = true; 202 | } 203 | 204 | switch (c) 205 | { 206 | case 'C': 207 | { 208 | components.Insert(0, new ComponentInfo(ComponentType.Const)); 209 | break; 210 | } 211 | case 'P': 212 | { 213 | components.Insert(0, new ComponentInfo(ComponentType.Pointer)); 214 | break; 215 | } 216 | case 'R': 217 | { 218 | components.Insert(0, new ComponentInfo(ComponentType.Reference)); 219 | break; 220 | } 221 | case 'U': 222 | { 223 | components.Insert(0, new ComponentInfo(ComponentType.Unsigned)); 224 | break; 225 | } 226 | case 'A': 227 | { 228 | int length = 0; 229 | 230 | while ((c = input.Read()) != '_') 231 | { 232 | length *= 10; 233 | length += (c - '0'); 234 | } 235 | 236 | components.Insert(0, new ComponentInfo(length)); 237 | break; 238 | } 239 | case 'e': 240 | { 241 | components.Insert(0, new ComponentInfo(ComponentType.Ellipsis)); 242 | end = true; 243 | break; 244 | } 245 | case 'v': 246 | { 247 | components.Insert(0, new ComponentInfo(ComponentType.Void)); 248 | end = true; 249 | break; 250 | } 251 | case 'b': 252 | { 253 | components.Insert(0, new ComponentInfo(ComponentType.Bool)); 254 | end = true; 255 | break; 256 | } 257 | case 'c': 258 | { 259 | components.Insert(0, new ComponentInfo(ComponentType.Char)); 260 | end = true; 261 | break; 262 | } 263 | case 'w': 264 | { 265 | components.Insert(0, new ComponentInfo(ComponentType.WChar)); 266 | end = true; 267 | break; 268 | } 269 | case 's': 270 | { 271 | components.Insert(0, new ComponentInfo(ComponentType.Short)); 272 | end = true; 273 | break; 274 | } 275 | case 'i': 276 | { 277 | components.Insert(0, new ComponentInfo(ComponentType.Int)); 278 | end = true; 279 | break; 280 | } 281 | case 'l': 282 | { 283 | components.Insert(0, new ComponentInfo(ComponentType.Long)); 284 | end = true; 285 | break; 286 | } 287 | case 'x': 288 | { 289 | components.Insert(0, new ComponentInfo(ComponentType.LongLong)); 290 | end = true; 291 | break; 292 | } 293 | case 'f': 294 | { 295 | components.Insert(0, new ComponentInfo(ComponentType.Float)); 296 | end = true; 297 | break; 298 | } 299 | case 'd': 300 | { 301 | components.Insert(0, new ComponentInfo(ComponentType.Double)); 302 | end = true; 303 | break; 304 | } 305 | case 'Q': 306 | { 307 | int count = (input.Read() - '0'); 308 | StringBuilder name = new StringBuilder(500); 309 | 310 | while (count-- > 0) 311 | { 312 | DemangleType(input, name); 313 | 314 | if (count > 0) 315 | { 316 | name.Append("::"); 317 | } 318 | } 319 | 320 | components.Insert(0, new ComponentInfo(name.ToString())); 321 | end = true; 322 | break; 323 | } 324 | case 'F': 325 | { 326 | StringBuilder prms = new StringBuilder(500); 327 | StringBuilder ret = new StringBuilder(500); 328 | 329 | for (char nc = input.Peek(); nc != '_' && nc != '\0'; nc = input.Peek()) 330 | { 331 | if (prms.Length > 0) 332 | { 333 | prms.Append(", "); 334 | } 335 | 336 | DemangleType(input, prms); 337 | } 338 | 339 | // i.e. prefer "()" over "(void)" 340 | string prms_str = prms.ToString(); 341 | 342 | if (prms_str == "void") 343 | { 344 | prms_str = ""; 345 | } 346 | 347 | ++input.Position; 348 | DemangleType(input, ret); 349 | components.Insert(0, new ComponentInfo(prms_str, ret.ToString())); 350 | end = true; 351 | break; 352 | } 353 | default: 354 | { 355 | if ('0' <= c && c <= '9') 356 | { 357 | --input.Position; 358 | StringBuilder name = new StringBuilder(500); 359 | DemangleType(input, name); 360 | components.Insert(0, new ComponentInfo(name.ToString())); 361 | end = true; 362 | } 363 | break; 364 | } 365 | } 366 | } while (!end); 367 | 368 | // e.g. prefer "unsigned int" over "int unsigned" 369 | int const_index = 1; 370 | if (components.Count >= 2 && components[1].type == ComponentType.Unsigned) 371 | { 372 | components.RemoveAt(1); 373 | components.Insert(0, new ComponentInfo(ComponentType.Unsigned)); 374 | ++const_index; 375 | } 376 | 377 | // e.g. prefer "const float *" over "float const *" 378 | if (components.Count >= (const_index + 1) && components[const_index].type == ComponentType.Const) 379 | { 380 | components.RemoveAt(const_index); 381 | components.Insert(0, new ComponentInfo(ComponentType.Const)); 382 | } 383 | 384 | DemangleComponents(components, 0, output); 385 | } 386 | } 387 | 388 | static int ScanNameEnd(StringStream input) 389 | { 390 | int end = input.Length; 391 | 392 | for (int i = input.Position; i < input.Length; ++i) 393 | { 394 | if (input[i] != '_' || input[i + 1] != '_') 395 | { 396 | continue; 397 | } 398 | 399 | int digit_index = (i + 2); 400 | if (input[i + 2] == 'Q') 401 | { 402 | ++digit_index; 403 | } 404 | else if (input[i + 2] != 'F') 405 | { 406 | char c = input[digit_index]; 407 | 408 | if (c < '0' || c > '9') 409 | { 410 | continue; 411 | } 412 | } 413 | 414 | end = i; 415 | } 416 | 417 | return end; 418 | } 419 | 420 | static string DemangleName(StringStream input) 421 | { 422 | StringBuilder output = new StringBuilder(500); 423 | int end = ScanNameEnd(input); 424 | 425 | while (input.Position < end) 426 | { 427 | char c = input.Read(); 428 | 429 | if (c == '<') 430 | { 431 | DemangleTemplate(input, output); 432 | } 433 | else 434 | { 435 | output.Append(c); 436 | } 437 | } 438 | 439 | if (end < input.Length) 440 | { 441 | input.Position += 2; 442 | } 443 | 444 | return output.ToString(); 445 | } 446 | 447 | public static string Demangle(string symbol) 448 | { 449 | StringStream input = new StringStream(symbol); 450 | StringBuilder output = new StringBuilder(1000); 451 | 452 | string name = DemangleName(input); 453 | string type = null; 454 | string prms = null; 455 | bool constant = false; 456 | 457 | if (input.Position < input.Length && input.Peek() != 'F') 458 | { 459 | DemangleType(input, output); 460 | type = output.ToString(); 461 | output.Clear(); 462 | } 463 | 464 | if (input.Peek() == 'C') 465 | { 466 | ++input.Position; 467 | constant = true; 468 | } 469 | 470 | if (input.Peek() == 'F') 471 | { 472 | ++input.Position; 473 | 474 | while (input.Position < input.Length) 475 | { 476 | if (output.Length > 0) 477 | { 478 | output.Append(", "); 479 | } 480 | 481 | DemangleType(input, output); 482 | } 483 | 484 | prms = output.ToString(); 485 | output.Clear(); 486 | } 487 | 488 | if (type != null) 489 | { 490 | output.Append(type); 491 | output.Append("::"); 492 | } 493 | 494 | if (name != null) 495 | { 496 | bool op = true; 497 | bool space = true; 498 | 499 | switch (name) 500 | { 501 | case "__ct": 502 | case "__dt": 503 | { 504 | if (type == null) 505 | { 506 | break; 507 | } 508 | 509 | if (name == "__dt") 510 | { 511 | output.Append('~'); 512 | } 513 | 514 | name = type; 515 | int index = type.IndexOf('<'); 516 | 517 | if (index >= 0) 518 | { 519 | name = name.Substring(0, index); 520 | } 521 | 522 | index = name.LastIndexOf("::"); 523 | 524 | if (index >= 0) 525 | { 526 | name = name.Substring(index + 2); 527 | } 528 | 529 | op = false; 530 | space = false; 531 | break; 532 | } 533 | case "__nw": name = " new"; break; 534 | case "__nwa": name = " new[]"; break; 535 | case "__dl": name = " delete"; break; 536 | case "__dla": name = " delete[]"; break; 537 | case "__pl": name = "+"; break; 538 | case "__mi": name = "-"; break; 539 | case "__ml": name = "*"; break; 540 | case "__dv": name = "/"; break; 541 | case "__md": name = "%"; break; 542 | case "__er": name = "^"; break; 543 | case "__ad": name = "&"; break; 544 | case "__or": name = "|"; break; 545 | case "__co": name = "~"; break; 546 | case "__nt": name = "!"; break; 547 | case "__as": name = "="; break; 548 | case "__lt": name = "<"; break; 549 | case "__gt": name = ">"; break; 550 | case "__apl": name = "+="; break; 551 | case "__ami": name = "-="; break; 552 | case "__amu": name = "*="; break; 553 | case "__adv": name = "/="; break; 554 | case "__amd": name = "%="; break; 555 | case "__aer": name = "^="; break; 556 | case "__aad": name = "&="; break; 557 | case "__aor": name = "|="; break; 558 | case "__ls": name = "<<"; break; 559 | case "__rs": name = ">>"; break; 560 | case "__ars": name = ">>="; break; 561 | case "__als": name = "<<="; break; 562 | case "__eq": name = "=="; break; 563 | case "__ne": name = "!="; break; 564 | case "__le": name = "<="; break; 565 | case "__ge": name = ">="; break; 566 | case "__aa": name = "&&"; break; 567 | case "__oo": name = "||"; break; 568 | case "__pp": name = "++"; break; 569 | case "__mm": name = "--"; break; 570 | case "__cm": name = ","; break; 571 | case "__rm": name = "->*"; break; 572 | case "__rf": name = "->"; break; 573 | case "__cl": name = "()"; break; 574 | case "__vc": name = "[]"; break; 575 | default: 576 | { 577 | op = false; 578 | space = false; 579 | break; 580 | } 581 | } 582 | 583 | if (op) 584 | { 585 | output.Append("operator"); 586 | } 587 | 588 | output.Append(name); 589 | 590 | if (space) 591 | { 592 | output.Append(' '); 593 | } 594 | } 595 | 596 | if (prms != null) 597 | { 598 | output.Append('('); 599 | 600 | if (prms != "void") 601 | { 602 | output.Append(prms); 603 | } 604 | 605 | output.Append(')'); 606 | } 607 | 608 | if (constant) 609 | { 610 | output.Append(" const"); 611 | } 612 | 613 | return output.ToString(); 614 | } 615 | 616 | enum ComponentType 617 | { 618 | 619 | Const, 620 | Pointer, 621 | Reference, 622 | Unsigned, 623 | Ellipsis, 624 | Void, 625 | Bool, 626 | Char, 627 | WChar, 628 | Short, 629 | Int, 630 | Long, 631 | LongLong, 632 | Float, 633 | Double, 634 | Type, 635 | Func, 636 | Array, 637 | 638 | } 639 | 640 | struct ComponentInfo 641 | { 642 | 643 | public ComponentType type; 644 | public int length; // array dimension length 645 | public string name; // user type or return type 646 | public string prms; // parameter types 647 | 648 | public ComponentInfo(ComponentType type) : this(type, 0, "", "") { } 649 | public ComponentInfo(int length) : this(ComponentType.Array, length, "", "") { } 650 | public ComponentInfo(string name) : this(ComponentType.Type, 0, name, "") { } 651 | public ComponentInfo(string prms, string ret) : this(ComponentType.Func, 0, ret, prms) { } 652 | public ComponentInfo(ComponentType type, int length, string name, string prms) 653 | { 654 | this.type = type; 655 | this.length = length; 656 | this.name = name; 657 | this.prms = prms; 658 | } 659 | 660 | } 661 | 662 | public class StringStream 663 | { 664 | 665 | public string Data { get; private set; } 666 | public int Position { get; set; } 667 | public int Length { get { return Data.Length; } } 668 | 669 | public char this[int index] 670 | { 671 | get 672 | { 673 | if (index >= Length) 674 | { 675 | return '\0'; 676 | } 677 | 678 | return Data[index]; 679 | } 680 | } 681 | 682 | public StringStream(string data) 683 | { 684 | Data = data; 685 | Position = 0; 686 | } 687 | 688 | public char Read() 689 | { 690 | if (Position >= Length) 691 | { 692 | return '\0'; 693 | } 694 | 695 | return Data[Position++]; 696 | } 697 | 698 | public char Peek() 699 | { 700 | if (Position >= Length) 701 | { 702 | return '\0'; 703 | } 704 | 705 | return Data[Position]; 706 | } 707 | 708 | public string Read(int count) 709 | { 710 | int read = Math.Min(count, (Length - Position)); 711 | 712 | if (read <= 0) 713 | { 714 | return new String('\0', count); 715 | } 716 | 717 | int fill = (count - read); 718 | string data = Data.Substring(Position, read); 719 | Position += read; 720 | 721 | if (fill > 0) 722 | { 723 | data += new String('\0', fill); 724 | } 725 | 726 | return data; 727 | } 728 | 729 | public string Peek(int count) 730 | { 731 | int read = Math.Min(count, (Length - Position)); 732 | 733 | if (read <= 0) 734 | { 735 | return new String('\0', count); 736 | } 737 | 738 | int fill = (count - read); 739 | string data = Data.Substring(Position, read); 740 | 741 | if (fill > 0) 742 | { 743 | data += new String('\0', fill); 744 | } 745 | 746 | return data; 747 | } 748 | 749 | } 750 | 751 | } 752 | 753 | } -------------------------------------------------------------------------------- /Helpers/MAPParsing.cs: -------------------------------------------------------------------------------- 1 | using arookas; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Globalization; 5 | using System.Text.RegularExpressions; 6 | using System.Windows.Forms; 7 | 8 | namespace mapdas 9 | { 10 | internal static class MAPParsing 11 | { 12 | public class TextEntry 13 | { 14 | public string _Path = string.Empty; 15 | 16 | public string _Address = string.Empty; 17 | public string _Start = string.Empty; 18 | public string _Size = string.Empty; 19 | 20 | public string _Type = string.Empty; 21 | 22 | public string _Symbol = string.Empty; 23 | public string _SymbolDemangled = string.Empty; 24 | } 25 | 26 | public class MemoryMapEntry 27 | { 28 | public string _Name = string.Empty; 29 | public string _Start = string.Empty; 30 | public string _Size = string.Empty; 31 | public string _Offset = string.Empty; 32 | } 33 | 34 | public class LinkerSymbolEntry 35 | { 36 | public string _Name = string.Empty; 37 | public string _Start = string.Empty; 38 | } 39 | 40 | public static List ParseTextSection(MAP file) 41 | { 42 | string[] segmentLines = file.TryGetSection(MAP.SectionType.Text); 43 | if (segmentLines == null) 44 | { 45 | return null; 46 | } 47 | 48 | bool updatedMap = segmentLines[0].Contains("File"); 49 | DialogResult cppOrNo = MessageBox.Show("Use .cpp or .c?\n(Yes for cpp, No for c)", "Urgent", MessageBoxButtons.YesNo, MessageBoxIcon.Question); 50 | 51 | List symbols = new List(); 52 | foreach (string line in segmentLines) 53 | { 54 | // Skip ".text" symbols and empty lines 55 | if (line.Contains(".text") || string.IsNullOrWhiteSpace(line)) 56 | { 57 | continue; 58 | } 59 | 60 | // st = start 61 | // si = size 62 | // addr = address 63 | // offs = offset 64 | // t = type 65 | // fun_n = function name 66 | // fol_n = folder name 67 | // fil_n = file name 68 | 69 | Match symbol = null; 70 | if (!updatedMap) 71 | { 72 | // folder & used 73 | Match fu_sym = Regex.Match(line, @"\s(?[a-f0-9]+)\s+(?[a-f0-9]+)\s+(?[a-f0-9]+)\s+(?\d+)\s+(?[^ ]+)\s+(?[^ ]+)?\s(?[^ ]+)", RegexOptions.Compiled); 74 | // unused & folder 75 | Match uf_sym = Regex.Match(line, @"\s(?[A-Z]+)\s+(?[a-f0-9]+)\s+(?[.]+)\s+(?[^ ]+)\s+(?[^ ]+)?\s(?[^ ]+)", RegexOptions.Compiled); 76 | // unused & no folder 77 | Match unf_sym = Regex.Match(line, @"\s(?[A-Z]+)\s+(?[a-f0-9]+)\s+(?[.]+)\s+(?[^ ]+)?\s(?[^ ]+)", RegexOptions.Compiled); 78 | if (!fu_sym.Success && !uf_sym.Success && !unf_sym.Success) 79 | { 80 | continue; 81 | } 82 | 83 | if (fu_sym.Success) 84 | { 85 | symbol = fu_sym; 86 | } 87 | else if (uf_sym.Success) 88 | { 89 | symbol = uf_sym; 90 | } 91 | else if (unf_sym.Success) 92 | { 93 | symbol = unf_sym; 94 | } 95 | } 96 | else // Updated map, thanks wowjinxy for showing me these 97 | { 98 | // used & folder 99 | Match fu_sym = Regex.Match(line, @"\s(?[a-f0-9]+)\s+(?[a-f0-9]+)\s+(?[a-f0-9]+)\s+(?[a-f0-9]+)\s+(?\d+)\s+(?[^ ]+)\s+(?[^ ]+)?\s(?[^ ]+)", RegexOptions.Compiled); 100 | // unused & folder 101 | Match uf_sym = Regex.Match(line, @"\s(?[A-Z]+)\s+(?[a-f0-9]+)\s+(?[.]+)\s+(?[a-f0-9]+)\s+(?[^ ]+)\s+(?[^ ]+)?\s(?[^ ]+)", RegexOptions.Compiled); 102 | // unused & no folder 103 | Match unf_sym = Regex.Match(line, @"\s(?[A-Z]+)\s+(?[a-f0-9]+)\s+(?[.]+)\s+(?[a-f0-9]+)\s+(?[^ ]+)?\s(?[^ ]+)", RegexOptions.Compiled); 104 | if (!fu_sym.Success && !uf_sym.Success && !unf_sym.Success) 105 | { 106 | continue; 107 | } 108 | 109 | if (fu_sym.Success) 110 | { 111 | symbol = fu_sym; 112 | } 113 | else if (uf_sym.Success) 114 | { 115 | symbol = uf_sym; 116 | } 117 | else if (unf_sym.Success) 118 | { 119 | symbol = unf_sym; 120 | } 121 | } 122 | 123 | TextEntry newTextSymbol = new TextEntry 124 | { 125 | _Address = symbol.Groups["addr"].Value, 126 | _Start = symbol.Groups["st"].Value, 127 | _Size = symbol.Groups["si"].Value, 128 | _Type = symbol.Groups["t"].Value, 129 | _Symbol = symbol.Groups["fun_n"].Value, 130 | _SymbolDemangled = Demangler.Demangle(symbol.Groups["fun_n"].Value), 131 | }; 132 | 133 | // If the .o file uses an absolute path we just recreate the entire directory 134 | // because fuck it. 135 | if (!symbol.Groups["fil_n"].Value.Contains(":\\")) 136 | { 137 | string folder = symbol.Groups["fol_n"].Value.Replace(".o", "").Replace(".a", "").Replace('.', '/'); 138 | if (folder.Length != 0 && !folder.EndsWith("/")) 139 | { 140 | folder += "/"; 141 | } 142 | newTextSymbol._Path = folder + symbol.Groups["fil_n"].Value.Replace(".o", cppOrNo == DialogResult.Yes ? ".cpp" : ".c"); 143 | } 144 | else 145 | { 146 | newTextSymbol._Path = symbol.Groups["fil_n"].Value.Replace(".o", cppOrNo == DialogResult.Yes ? ".cpp" : ".c"); 147 | } 148 | 149 | symbols.Add(newTextSymbol); 150 | } 151 | return symbols; 152 | } 153 | 154 | public static List ParseMemoryMapSection(MAP file) 155 | { 156 | string[] segmentLines = file.TryGetSection(MAP.SectionType.MemoryMap); 157 | if (segmentLines == null) 158 | { 159 | return null; 160 | } 161 | 162 | List symbols = new List(); 163 | foreach (string line in segmentLines) 164 | { 165 | Match match = Regex.Match(line, @"\s+(?[^ ]+)\s+(?[a-f0-9]+)\s+(?[a-f0-9]+)\s+(?[a-f0-9]+)", RegexOptions.Compiled); 166 | if (match.Success) 167 | { 168 | symbols.Add(new MemoryMapEntry 169 | { 170 | _Name = match.Groups["name"].Value, 171 | _Start = match.Groups["start"].Value.Trim(), 172 | _Size = match.Groups["size"].Value, 173 | _Offset = match.Groups["offset"].Value, 174 | }); 175 | } 176 | } 177 | 178 | return symbols; 179 | } 180 | 181 | public static List ParseLinkerSymbolSection(MAP file) 182 | { 183 | string[] segmentLines = file.TryGetSection(MAP.SectionType.LinkerSymbols); 184 | if (segmentLines == null) 185 | { 186 | return null; 187 | } 188 | 189 | List symbols = new List(); 190 | foreach (string line in segmentLines) 191 | { 192 | Match match = Regex.Match(line, @"\s+(?[^ ]+)\s+(?[a-f0-9]+)", RegexOptions.Compiled); 193 | if (!match.Success) 194 | { 195 | continue; 196 | } 197 | 198 | symbols.Add(new LinkerSymbolEntry 199 | { 200 | _Name = match.Groups["name"].Value, 201 | _Start = match.Groups["start"].Value 202 | }); 203 | } 204 | 205 | return symbols; 206 | } 207 | } 208 | } 209 | -------------------------------------------------------------------------------- /Helpers/SYMParsing.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using static arookas.Demangler; 3 | 4 | namespace mapdas 5 | { 6 | public static class SYMParsing 7 | { 8 | // sy must be a demangled symbol (includes parameter arguments like "function(char*, int)") 9 | public static List GetTypes(string sy) 10 | { 11 | int openBracketIdx = sy.IndexOf("("); 12 | if (openBracketIdx == -1) 13 | { 14 | return null; 15 | } 16 | 17 | if (sy.Contains("operator()")) 18 | { 19 | sy = sy.Replace("operator()", ""); 20 | } 21 | 22 | List parameters = new List(); 23 | string functionName = string.Empty; 24 | SeperateTypes(sy, ref parameters, ref functionName); 25 | return parameters; 26 | } 27 | 28 | // seperates a comma-seperated list of types, with special handling for function pointers 29 | public static void SeperateTypes(string s, ref List parameters, ref string functionName) 30 | { 31 | StringStream input = new StringStream(s); 32 | int level = 0; 33 | int pIdx = 0; 34 | int prevPIdx = -1; 35 | while (input.Position < input.Length) 36 | { 37 | char r = input.Read(); 38 | 39 | switch (r) 40 | { 41 | case '(': 42 | level++; 43 | break; 44 | case '<': 45 | if (level != 0) 46 | { 47 | level++; 48 | } 49 | break; 50 | } 51 | 52 | if (level == 0) 53 | { 54 | functionName += r; 55 | } 56 | else 57 | { 58 | if (prevPIdx != pIdx) 59 | { 60 | parameters.Add(r.ToString()); 61 | prevPIdx = pIdx; 62 | } 63 | else 64 | { 65 | parameters[pIdx] += r; 66 | } 67 | } 68 | 69 | switch (r) 70 | { 71 | case ')': 72 | level--; 73 | break; 74 | case '>': 75 | if (level != 0) 76 | { 77 | level--; 78 | } 79 | break; 80 | case ',': 81 | if (level == 1) 82 | { 83 | pIdx++; 84 | } 85 | break; 86 | } 87 | } 88 | 89 | if (parameters.Count > 0) 90 | { 91 | parameters[0] = parameters[0].Remove(0, 1); 92 | parameters[parameters.Count - 1] = parameters[parameters.Count - 1].Remove(parameters[parameters.Count - 1].Length - 1, 1); 93 | 94 | for (int i = 0; i < parameters.Count; i++) 95 | { 96 | parameters[i] = parameters[i].Trim().TrimEnd(','); 97 | 98 | if (string.IsNullOrEmpty(parameters[i])) 99 | { 100 | parameters.RemoveAt(i); 101 | i--; 102 | } 103 | } 104 | } 105 | } 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /Helpers/SyncTextBox.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using System.Windows.Forms; 4 | 5 | internal class SyncTextBox : TextBox 6 | { 7 | public SyncTextBox(ScrollBars scrollBar = ScrollBars.Both) 8 | { 9 | Multiline = true; 10 | ScrollBars = scrollBar; 11 | } 12 | public Control Buddy { get; set; } 13 | 14 | private static bool scrolling; // In case buddy tries to scroll us 15 | protected override void WndProc(ref Message m) 16 | { 17 | base.WndProc(ref m); 18 | // Trap WM_VSCROLL message and pass to buddy 19 | if ((m.Msg == 0x115 || m.Msg == 0x20a) && !scrolling && Buddy != null && Buddy.IsHandleCreated) 20 | { 21 | scrolling = true; 22 | SendMessage(Buddy.Handle, m.Msg, m.WParam, m.LParam); 23 | scrolling = false; 24 | } 25 | } 26 | 27 | [DllImport("user32.dll", CharSet = CharSet.Auto)] 28 | private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp, IntPtr lp); 29 | } 30 | -------------------------------------------------------------------------------- /IO/BigEndianReader.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | 3 | namespace System.IO 4 | { 5 | public class BigEndianReader : BinaryReader //By Wexos 6 | { 7 | public BigEndianReader(Stream stream) : base(stream) { } 8 | 9 | public override byte ReadByte() 10 | { 11 | return base.ReadByte(); 12 | } 13 | public override byte[] ReadBytes(int Count) 14 | { 15 | byte[] value = new byte[Count]; 16 | for (int i = 0; i < Count; i++) 17 | { 18 | value[i] = base.ReadByte(); 19 | } 20 | return value; 21 | } 22 | public byte[] ReadBytes(uint Count) 23 | { 24 | byte[] value = new byte[Count]; 25 | for (int i = 0; i < Count; i++) 26 | { 27 | value[i] = base.ReadByte(); 28 | } 29 | return value; 30 | } 31 | public override sbyte ReadSByte() 32 | { 33 | return base.ReadSByte(); 34 | } 35 | public sbyte[] ReadSBytes(int Count) 36 | { 37 | sbyte[] value = new sbyte[Count]; 38 | for (int i = 0; i < Count; i++) 39 | { 40 | value[i] = base.ReadSByte(); 41 | } 42 | return value; 43 | } 44 | public sbyte[] ReadSBytes(uint Count) 45 | { 46 | sbyte[] value = new sbyte[Count]; 47 | for (int i = 0; i < Count; i++) 48 | { 49 | value[i] = base.ReadSByte(); 50 | } 51 | return value; 52 | } 53 | public override ushort ReadUInt16() 54 | { 55 | byte[] value = base.ReadBytes(0x02); 56 | Array.Reverse(value); 57 | return BitConverter.ToUInt16(value, 0); 58 | } 59 | public ushort[] ReadUInt16s(int Count) 60 | { 61 | ushort[] value = new ushort[Count]; 62 | for (int i = 0; i < Count; i++) 63 | { 64 | byte[] value2 = base.ReadBytes(0x02); 65 | Array.Reverse(value2); 66 | value[i] = BitConverter.ToUInt16(value2, 0); 67 | } 68 | return value; 69 | } 70 | public ushort[] ReadUInt16s(uint Count) 71 | { 72 | ushort[] value = new ushort[Count]; 73 | for (int i = 0; i < Count; i++) 74 | { 75 | byte[] value2 = base.ReadBytes(0x02); 76 | Array.Reverse(value2); 77 | value[i] = BitConverter.ToUInt16(value2, 0); 78 | } 79 | return value; 80 | } 81 | public override short ReadInt16() 82 | { 83 | byte[] value = base.ReadBytes(0x02); 84 | Array.Reverse(value); 85 | return BitConverter.ToInt16(value, 0); 86 | } 87 | public short[] ReadInt16s(int Count) 88 | { 89 | short[] value = new short[Count]; 90 | for (int i = 0; i < Count; i++) 91 | { 92 | byte[] value2 = base.ReadBytes(0x02); 93 | Array.Reverse(value2); 94 | value[i] = BitConverter.ToInt16(value2, 0); 95 | } 96 | return value; 97 | } 98 | public short[] ReadInt16s(uint Count) 99 | { 100 | short[] value = new short[Count]; 101 | for (int i = 0; i < Count; i++) 102 | { 103 | byte[] value2 = base.ReadBytes(0x02); 104 | Array.Reverse(value2); 105 | value[i] = BitConverter.ToInt16(value2, 0); 106 | } 107 | return value; 108 | } 109 | public override uint ReadUInt32() 110 | { 111 | byte[] value = base.ReadBytes(0x04); 112 | Array.Reverse(value); 113 | return BitConverter.ToUInt32(value, 0); 114 | } 115 | public uint[] ReadUInt32s(int Count) 116 | { 117 | uint[] value = new uint[Count]; 118 | for (int i = 0; i < Count; i++) 119 | { 120 | byte[] value2 = base.ReadBytes(0x04); 121 | Array.Reverse(value2); 122 | value[i] = BitConverter.ToUInt32(value2, 0); 123 | } 124 | return value; 125 | } 126 | public uint[] ReadUInt32s(uint Count) 127 | { 128 | uint[] value = new uint[Count]; 129 | for (int i = 0; i < Count; i++) 130 | { 131 | byte[] value2 = base.ReadBytes(0x04); 132 | Array.Reverse(value2); 133 | value[i] = BitConverter.ToUInt32(value2, 0); 134 | } 135 | return value; 136 | } 137 | public override int ReadInt32() 138 | { 139 | byte[] value = base.ReadBytes(0x04); 140 | Array.Reverse(value); 141 | return BitConverter.ToInt32(value, 0); 142 | } 143 | public int[] ReadInt32s(int Count) 144 | { 145 | int[] value = new int[Count]; 146 | for (int i = 0; i < Count; i++) 147 | { 148 | byte[] value2 = base.ReadBytes(0x04); 149 | Array.Reverse(value2); 150 | value[i] = BitConverter.ToInt32(value2, 0); 151 | } 152 | return value; 153 | } 154 | public int[] ReadInt32s(uint Count) 155 | { 156 | int[] value = new int[Count]; 157 | for (int i = 0; i < Count; i++) 158 | { 159 | byte[] value2 = base.ReadBytes(0x04); 160 | Array.Reverse(value2); 161 | value[i] = BitConverter.ToInt32(value2, 0); 162 | } 163 | return value; 164 | } 165 | public override ulong ReadUInt64() 166 | { 167 | byte[] value = base.ReadBytes(0x08); 168 | Array.Reverse(value); 169 | return BitConverter.ToUInt64(value, 0); 170 | } 171 | public ulong[] ReadUInt64s(int Count) 172 | { 173 | ulong[] value = new ulong[Count]; 174 | for (int i = 0; i < Count; i++) 175 | { 176 | byte[] value2 = base.ReadBytes(0x08); 177 | Array.Reverse(value2); 178 | value[i] = BitConverter.ToUInt64(value2, 0); 179 | } 180 | return value; 181 | } 182 | public ulong[] ReadUInt64s(uint Count) 183 | { 184 | ulong[] value = new ulong[Count]; 185 | for (int i = 0; i < Count; i++) 186 | { 187 | byte[] value2 = base.ReadBytes(0x08); 188 | Array.Reverse(value2); 189 | value[i] = BitConverter.ToUInt64(value2, 0); 190 | } 191 | return value; 192 | } 193 | public override long ReadInt64() 194 | { 195 | byte[] value = base.ReadBytes(0x08); 196 | Array.Reverse(value); 197 | return BitConverter.ToInt64(value, 0); 198 | } 199 | public long[] ReadInt64s(int Count) 200 | { 201 | long[] value = new long[Count]; 202 | for (int i = 0; i < Count; i++) 203 | { 204 | byte[] value2 = base.ReadBytes(0x08); 205 | Array.Reverse(value2); 206 | value[i] = BitConverter.ToInt64(value2, 0); 207 | } 208 | return value; 209 | } 210 | public long[] ReadInt64s(uint Count) 211 | { 212 | long[] value = new long[Count]; 213 | for (int i = 0; i < Count; i++) 214 | { 215 | byte[] value2 = base.ReadBytes(0x08); 216 | Array.Reverse(value2); 217 | value[i] = BitConverter.ToInt64(value2, 0); 218 | } 219 | return value; 220 | } 221 | public override float ReadSingle() 222 | { 223 | byte[] value = base.ReadBytes(0x04); 224 | Array.Reverse(value); 225 | return BitConverter.ToSingle(value, 0); 226 | } 227 | public float[] ReadSingles(int Count) 228 | { 229 | float[] value = new float[Count]; 230 | for (int i = 0; i < Count; i++) 231 | { 232 | byte[] value2 = base.ReadBytes(0x04); 233 | Array.Reverse(value2); 234 | value[i] = BitConverter.ToSingle(value2, 0); 235 | } 236 | return value; 237 | } 238 | public float[] ReadSingles(uint Count) 239 | { 240 | float[] value = new float[Count]; 241 | for (int i = 0; i < Count; i++) 242 | { 243 | byte[] value2 = base.ReadBytes(0x04); 244 | Array.Reverse(value2); 245 | value[i] = BitConverter.ToSingle(value2, 0); 246 | } 247 | return value; 248 | } 249 | public override string ReadString() 250 | { 251 | return base.ReadString(); 252 | } 253 | public string ReadASCII(int count) 254 | { 255 | return Encoding.ASCII.GetString(base.ReadBytes(count)); 256 | } 257 | public string ReadASCII(uint count) 258 | { 259 | return Encoding.ASCII.GetString(base.ReadBytes(Convert.ToInt32(count))); 260 | } 261 | public string[] ReadStrings(int Count) 262 | { 263 | string[] value = new string[Count]; 264 | for (int i = 0; i < Count; i++) 265 | { 266 | value[i] = base.ReadString(); 267 | } 268 | return value; 269 | } 270 | } 271 | } 272 | -------------------------------------------------------------------------------- /IO/BigEndianWriter.cs: -------------------------------------------------------------------------------- 1 | namespace System.IO 2 | { 3 | public class BigEndianWriter : BinaryWriter //By Wexos 4 | { 5 | public BigEndianWriter(Stream stream) : base(stream) { } 6 | public void WriteBoolean(bool Value) 7 | { 8 | base.Write(Value); 9 | } 10 | public void WriteByte(byte Value) 11 | { 12 | base.Write(Value); 13 | } 14 | public void WriteBytes(byte[] Value) 15 | { 16 | foreach (byte by in Value) 17 | { 18 | base.Write(by); 19 | } 20 | } 21 | public void WriteSByte(sbyte Value) 22 | { 23 | base.Write(Value); 24 | } 25 | public void WriteSBytes(sbyte[] Value) 26 | { 27 | foreach (sbyte by in Value) 28 | { 29 | base.Write(by); 30 | } 31 | } 32 | public void WriteUInt16(ushort Value) 33 | { 34 | byte[] Value2 = BitConverter.GetBytes(Value); 35 | Array.Reverse(Value2); 36 | base.Write(Value2); 37 | } 38 | public void WriteUInt16s(ushort[] Value) 39 | { 40 | foreach (ushort UInt in Value) 41 | { 42 | byte[] Value2 = BitConverter.GetBytes(UInt); 43 | Array.Reverse(Value2); 44 | base.Write(Value2); 45 | } 46 | } 47 | public void WriteInt16(short Value) 48 | { 49 | byte[] Value2 = BitConverter.GetBytes(Value); 50 | Array.Reverse(Value2); 51 | base.Write(Value2); 52 | } 53 | public void WriteInt16s(short[] Value) 54 | { 55 | foreach (short Int in Value) 56 | { 57 | byte[] Value2 = BitConverter.GetBytes(Int); 58 | Array.Reverse(Value2); 59 | base.Write(Value2); 60 | } 61 | } 62 | public void WriteUInt32(uint Value) 63 | { 64 | byte[] Value2 = BitConverter.GetBytes(Value); 65 | Array.Reverse(Value2); 66 | base.Write(Value2); 67 | } 68 | public void WriteUInt32s(uint[] Value) 69 | { 70 | foreach (uint UInt in Value) 71 | { 72 | byte[] Value2 = BitConverter.GetBytes(UInt); 73 | Array.Reverse(Value2); 74 | base.Write(Value2); 75 | } 76 | } 77 | public void WriteInt32(int Value) 78 | { 79 | byte[] Value2 = BitConverter.GetBytes(Value); 80 | Array.Reverse(Value2); 81 | base.Write(Value2); 82 | } 83 | public void WriteInt32s(int[] Value) 84 | { 85 | foreach (int Int in Value) 86 | { 87 | byte[] Value2 = BitConverter.GetBytes(Int); 88 | Array.Reverse(Value2); 89 | base.Write(Value2); 90 | } 91 | } 92 | public void WriteUInt64(ulong Value) 93 | { 94 | byte[] Value2 = BitConverter.GetBytes(Value); 95 | Array.Reverse(Value2); 96 | base.Write(Value2); 97 | } 98 | public void WriteUInt64s(ulong[] Value) 99 | { 100 | foreach (ulong UInt in Value) 101 | { 102 | byte[] Value2 = BitConverter.GetBytes(UInt); 103 | Array.Reverse(Value2); 104 | base.Write(Value2); 105 | } 106 | } 107 | public void WriteInt64(long Value) 108 | { 109 | byte[] Value2 = BitConverter.GetBytes(Value); 110 | Array.Reverse(Value2); 111 | base.Write(Value2); 112 | } 113 | public void WriteUInt64s(long[] Value) 114 | { 115 | foreach (long Int in Value) 116 | { 117 | byte[] Value2 = BitConverter.GetBytes(Int); 118 | Array.Reverse(Value2); 119 | base.Write(Value2); 120 | } 121 | } 122 | public void WriteSingle(float Value) 123 | { 124 | byte[] Value2 = BitConverter.GetBytes(Value); 125 | Array.Reverse(Value2); 126 | base.Write(Value2); 127 | } 128 | public void WriteSingles(float[] Value) 129 | { 130 | foreach (float fl in Value) 131 | { 132 | byte[] Value2 = BitConverter.GetBytes(fl); 133 | Array.Reverse(Value2); 134 | base.Write(Value2); 135 | } 136 | } 137 | public void WriteDecimal(decimal Value) 138 | { 139 | byte[] Value2 = BitConverter.GetBytes(Convert.ToDouble(Value)); 140 | Array.Reverse(Value2); 141 | base.Write(Value2); 142 | } 143 | public void WriteDecimals(decimal[] Value) 144 | { 145 | foreach (decimal de in Value) 146 | { 147 | byte[] Value2 = BitConverter.GetBytes(Convert.ToInt64(de)); 148 | Array.Reverse(Value2); 149 | base.Write(Value2); 150 | } 151 | } 152 | public void WriteString(string Value) 153 | { 154 | base.Write(Value); 155 | } 156 | public void WriteChar(char Value) 157 | { 158 | byte[] Value2 = BitConverter.GetBytes(Value); 159 | Array.Reverse(Value2); 160 | base.Write(Value2); 161 | } 162 | public void WriteChars(char[] Value) 163 | { 164 | foreach (char ch in Value) 165 | { 166 | byte[] Value2 = BitConverter.GetBytes(ch); 167 | Array.Reverse(Value2); 168 | base.Write(Value2); 169 | } 170 | } 171 | public void WriteChars(char[] Value, int index, int count) 172 | { 173 | base.Write(Value, index, count); 174 | } 175 | } 176 | } 177 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | 4 | namespace mapdas 5 | { 6 | internal static class Program 7 | { 8 | /// 9 | /// The main entry point for the application. 10 | /// 11 | [STAThread] 12 | private static void Main() 13 | { 14 | Application.EnableVisualStyles(); 15 | Application.SetCompatibleTextRenderingDefault(false); 16 | Application.Run(new Form1()); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("mapdas")] 9 | [assembly: AssemblyDescription("Tools for Symbol Maps provided in some Nintendo Games for the Wii and GameCube")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Ambrosia GmbH")] 12 | [assembly: AssemblyProduct("mapdas")] 13 | [assembly: AssemblyCopyright("")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("4b728f41-c961-4c8e-ab0b-11deabf02fab")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | [assembly: NeutralResourcesLanguage("en")] 38 | -------------------------------------------------------------------------------- /Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace mapdas.Properties 12 | { 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources 26 | { 27 | 28 | private static global::System.Resources.ResourceManager resourceMan; 29 | 30 | private static global::System.Globalization.CultureInfo resourceCulture; 31 | 32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 33 | internal Resources() 34 | { 35 | } 36 | 37 | /// 38 | /// Returns the cached ResourceManager instance used by this class. 39 | /// 40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 41 | internal static global::System.Resources.ResourceManager ResourceManager 42 | { 43 | get 44 | { 45 | if ((resourceMan == null)) 46 | { 47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("mapdas.Properties.Resources", typeof(Resources).Assembly); 48 | resourceMan = temp; 49 | } 50 | return resourceMan; 51 | } 52 | } 53 | 54 | /// 55 | /// Overrides the current thread's CurrentUICulture property for all 56 | /// resource lookups using this strongly typed resource class. 57 | /// 58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 59 | internal static global::System.Globalization.CultureInfo Culture 60 | { 61 | get 62 | { 63 | return resourceCulture; 64 | } 65 | set 66 | { 67 | resourceCulture = value; 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace mapdas.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # mapdas 2 | Tools for Gamecube and Wii symbol maps 3 | 4 | # Special thanks 5 | - Arookas for the Demangler 6 | - JoshuaMK for vital work on the tool that allowed for the decompilation 7 | 8 | # Features 9 | - Loads multiple symbol map files 10 | - Displays map files in a sorted tree 11 | - Parses and demangles symbols (thanks to arookas for this feature) 12 | - Can export symbol maps to .idc files (IDA's scripted language) 13 | - Can export every referenced file inside the symbol map to get a 1:1 recreation of the original developer's directory and file layout 14 | - Can extract every type found in function arguments into an easily-compiled C++ header (see Extract Types when right clicking on the symbol map when it's loaded) 15 | - Extracting symbols and converting it to a linker map easily for use in a decompilation project / modding project 16 | - Loading DOL files to extract the PowerPC assembly for functions to get a better base for decompiling 17 | - Viewing the hex and the PowerPC assembly of a function side by side 18 | - Cleaning up the exported filesystem quickly suing the Common FS Cleaner tool, that searches for easily done functions and decompiles them, furthermore it also has the capability to encase blocks of code in namespaces, given a list 19 | 20 | # How To Use 21 | Load the symbol map by clicking "Open Map", note that you can open multiple MAP files. 22 | 23 | Upon right clicking on the opened symbol map file, you can also load a DOL file. 24 | 25 | When traversing the symbol map tree, you can access the various menus by right clicking on the entries. 26 | 27 | # Menu Entries that can be seen with a right click 28 | ## On a Symbol Map 29 | - Open DOL 30 | - Export Filesystem 31 | - Export To Linker Map 32 | - Convert To IDC 33 | - Export Types 34 | - Close 35 | 36 | ## On a file within a Symbol Map 37 | - Export File 38 | - Export Types 39 | 40 | ## On a function within a file 41 | - Export Types 42 | - Decompile 43 | -------------------------------------------------------------------------------- /TODO.md: -------------------------------------------------------------------------------- 1 | # TODO List 2 | - Export classes/functions/etc as empty definitions in file 3 | - Combine PPC and RAW data windows into one window with two textboxes that scroll in tandum 4 | - Export individual functions as PPC files 5 | - Parse ELF files for map data -------------------------------------------------------------------------------- /logo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intns/mapdas/928d87c70d55d8401a2f57a69e3b38ed32e72b13/logo.ico -------------------------------------------------------------------------------- /mapdas.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {4B728F41-C961-4C8E-AB0B-11DEABF02FAB} 8 | WinExe 9 | mapdas 10 | mapdas 11 | v4.8 12 | 512 13 | true 14 | true 15 | publish\ 16 | true 17 | Disk 18 | false 19 | Foreground 20 | 7 21 | Days 22 | false 23 | false 24 | true 25 | 0 26 | 1.0.0.%2a 27 | false 28 | false 29 | true 30 | 31 | 32 | AnyCPU 33 | true 34 | full 35 | false 36 | bin\Debug\ 37 | DEBUG;TRACE 38 | prompt 39 | 4 40 | 41 | 42 | AnyCPU 43 | none 44 | true 45 | bin\Release\ 46 | TRACE 47 | prompt 48 | 4 49 | 50 | 51 | 52 | packages\WindowsAPICodePack-Core.1.1.1\lib\Microsoft.WindowsAPICodePack.dll 53 | 54 | 55 | packages\WindowsAPICodePack-Shell.1.1.1\lib\Microsoft.WindowsAPICodePack.Shell.dll 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | Form 72 | 73 | 74 | DecompFillerForm.cs 75 | 76 | 77 | Form 78 | 79 | 80 | Form1.cs 81 | 82 | 83 | Form 84 | 85 | 86 | Form2.cs 87 | 88 | 89 | Form 90 | 91 | 92 | Form3.cs 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | Component 102 | 103 | 104 | 105 | 106 | 107 | 108 | DecompFillerForm.cs 109 | 110 | 111 | Form1.cs 112 | 113 | 114 | Form2.cs 115 | 116 | 117 | Form3.cs 118 | 119 | 120 | ResXFileCodeGenerator 121 | Resources.Designer.cs 122 | Designer 123 | 124 | 125 | True 126 | Resources.resx 127 | 128 | 129 | 130 | SettingsSingleFileGenerator 131 | Settings.Designer.cs 132 | 133 | 134 | True 135 | Settings.settings 136 | True 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | False 145 | Microsoft .NET Framework 4.8 %28x86 and x64%29 146 | true 147 | 148 | 149 | False 150 | .NET Framework 3.5 SP1 151 | false 152 | 153 | 154 | 155 | -------------------------------------------------------------------------------- /mapdas.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30204.135 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mapdas", "mapdas.csproj", "{4B728F41-C961-4C8E-AB0B-11DEABF02FAB}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {4B728F41-C961-4C8E-AB0B-11DEABF02FAB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {4B728F41-C961-4C8E-AB0B-11DEABF02FAB}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {4B728F41-C961-4C8E-AB0B-11DEABF02FAB}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {4B728F41-C961-4C8E-AB0B-11DEABF02FAB}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {7147EDB7-698B-40F5-9A25-E215880B3B66} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | --------------------------------------------------------------------------------