├── .gitignore ├── README.md ├── Resources └── AppIcon.ico ├── Properties ├── Settings.settings ├── Settings.Designer.cs ├── AssemblyInfo.cs ├── Resources.Designer.cs └── Resources.resx ├── app.config ├── Forms ├── Entities │ ├── GsDlls.cs │ ├── GsDumpFile.cs │ ├── GsDumps.cs │ ├── GsFile.cs │ └── GsFiles.cs ├── Helper │ ├── ILogger.cs │ ├── IFolderWithFallBackFinder.cs │ ├── IGsDumpFinder.cs │ ├── IGsdxDllFinder.cs │ ├── FolderWithFallBackFinder.cs │ ├── GsdxDllFinder.cs │ ├── RichTextBoxLogger.cs │ ├── ExtensionMethods.cs │ └── GsDumpFinder.cs └── SettingsProvider │ └── PortableXmlSettingsProvider.cs ├── Library ├── GSDump │ ├── GSData │ │ ├── GIFPacket │ │ │ ├── GIFReg │ │ │ │ ├── IGifData.cs │ │ │ │ ├── GifImage.cs │ │ │ │ ├── GIFRegAD.cs │ │ │ │ ├── GIFRegUnimpl.cs │ │ │ │ ├── GIFRegNOP.cs │ │ │ │ ├── GIFRegFOG.cs │ │ │ │ ├── GIFRegUV.cs │ │ │ │ ├── GIFRegST.cs │ │ │ │ ├── GIFRegRGBAQ.cs │ │ │ │ ├── GIFRegPrim.cs │ │ │ │ ├── GIFReg.cs │ │ │ │ ├── GIFRegXYZF.cs │ │ │ │ └── GIFRegTEX0.cs │ │ │ ├── GIFPrim.cs │ │ │ └── GIFTag.cs │ │ ├── GIFUtil.cs │ │ ├── GSData.cs │ │ └── GSTransfer.cs │ └── GSDump.cs ├── TCPLibrary │ ├── Base │ │ ├── Data.cs │ │ ├── CancelArgs.cs │ │ ├── ClientS.cs │ │ ├── Client.cs │ │ └── Server.cs │ └── Message │ │ ├── BaseMessageClientS.cs │ │ ├── TCPMessage.cs │ │ ├── BaseMessageClient.cs │ │ └── BaseMessageServer.cs ├── NativeMethods.cs └── GSDXWrapper.cs ├── GSDumpGUI.sln └── GSDumpGUI.csproj /.gitignore: -------------------------------------------------------------------------------- 1 | /bin 2 | /obj 3 | .vs 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GSDumpGUI 2 | A tool used for GSdx debugging. 3 | -------------------------------------------------------------------------------- /Resources/AppIcon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PCSX2/GSDumpGUI/HEAD/Resources/AppIcon.ico -------------------------------------------------------------------------------- /Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /Forms/Entities/GsDlls.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2019 PCSX2 Dev Team 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | 23 | namespace GSDumpGUI.Forms.Entities 24 | { 25 | public sealed class GsDlls : GsFiles { } 26 | } -------------------------------------------------------------------------------- /Forms/Entities/GsDumpFile.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2019 PCSX2 Dev Team 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | 23 | using System.IO; 24 | 25 | namespace GSDumpGUI.Forms.Entities 26 | { 27 | public sealed class GsDumpFile : GsFile 28 | { 29 | public FileInfo PreviewFile { get; set; } 30 | } 31 | } -------------------------------------------------------------------------------- /Forms/Entities/GsDumps.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2019 PCSX2 Dev Team 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | 23 | using System.IO; 24 | 25 | namespace GSDumpGUI.Forms.Entities 26 | { 27 | public sealed class GsDumps : GsFiles 28 | { 29 | private FileInfo GsDumpPreviewFile { get; set; } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Forms/Entities/GsFile.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2019 PCSX2 Dev Team 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | 23 | using System.IO; 24 | 25 | namespace GSDumpGUI.Forms.Entities 26 | { 27 | public class GsFile 28 | { 29 | public FileInfo File { get; set; } 30 | public string DisplayText { get; set; } 31 | } 32 | } -------------------------------------------------------------------------------- /Forms/Helper/ILogger.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2019 PCSX2 Dev Team 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | 23 | namespace GSDumpGUI.Forms.Helper 24 | { 25 | public interface ILogger 26 | { 27 | void Information(string line = null); 28 | void Warning(string line = null); 29 | void Error(string line = null); 30 | } 31 | } -------------------------------------------------------------------------------- /Forms/Helper/IFolderWithFallBackFinder.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2019 PCSX2 Dev Team 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | 23 | using System.IO; 24 | 25 | namespace GSDumpGUI.Forms.Helper 26 | { 27 | public interface IFolderWithFallBackFinder 28 | { 29 | DirectoryInfo GetViaPatternWithFallback(string defaultDir, string filePattern, params string[] fallBackFolder); 30 | } 31 | } -------------------------------------------------------------------------------- /Library/GSDump/GSData/GIFPacket/GIFReg/IGifData.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2011 Ferreri Alessio 3 | * Copyright (C) 2009-2018 PCSX2 Dev Team 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | using System; 25 | using System.Collections.Generic; 26 | using System.Text; 27 | 28 | namespace GSDumpGUI 29 | { 30 | public interface IGifData 31 | { 32 | String ToString(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Forms/Helper/IGsDumpFinder.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2019 PCSX2 Dev Team 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | 23 | using System.Collections.Generic; 24 | using System.IO; 25 | using GSDumpGUI.Forms.Entities; 26 | 27 | namespace GSDumpGUI.Forms.Helper 28 | { 29 | public interface IGsDumpFinder 30 | { 31 | IEnumerable GetValidGsdxDumps(DirectoryInfo directory); 32 | } 33 | } -------------------------------------------------------------------------------- /GSDumpGUI.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.28803.352 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GSDumpGUI", "GSDumpGUI.csproj", "{825E4311-652D-4A1E-8AA1-F6D81B186E33}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {825E4311-652D-4A1E-8AA1-F6D81B186E33}.Debug|x64.ActiveCfg = Debug|x64 17 | {825E4311-652D-4A1E-8AA1-F6D81B186E33}.Debug|x64.Build.0 = Debug|x64 18 | {825E4311-652D-4A1E-8AA1-F6D81B186E33}.Debug|x86.ActiveCfg = Debug|x86 19 | {825E4311-652D-4A1E-8AA1-F6D81B186E33}.Debug|x86.Build.0 = Debug|x86 20 | {825E4311-652D-4A1E-8AA1-F6D81B186E33}.Release|x64.ActiveCfg = Release|x64 21 | {825E4311-652D-4A1E-8AA1-F6D81B186E33}.Release|x64.Build.0 = Release|x64 22 | {825E4311-652D-4A1E-8AA1-F6D81B186E33}.Release|x86.ActiveCfg = Release|x86 23 | {825E4311-652D-4A1E-8AA1-F6D81B186E33}.Release|x86.Build.0 = Release|x86 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {19DB287E-B866-4E97-B0AE-95CF54B00134} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /Forms/Helper/IGsdxDllFinder.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2019 PCSX2 Dev Team 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | 23 | using System.Collections.Generic; 24 | using System.IO; 25 | using GSDumpGUI.Forms.Entities; 26 | 27 | namespace GSDumpGUI.Forms.Helper 28 | { 29 | public interface IGsdxDllFinder 30 | { 31 | IEnumerable GetEnrichedPathToValidGsdxDlls(DirectoryInfo directory); 32 | } 33 | } -------------------------------------------------------------------------------- /Library/GSDump/GSData/GIFUtil.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2011 Ferreri Alessio 3 | * Copyright (C) 2009-2018 PCSX2 Dev Team 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | using System; 25 | 26 | namespace GSDumpGUI 27 | { 28 | [Serializable] 29 | public class GIFUtil 30 | { 31 | public static UInt64 GetBit(UInt64 value, int lower, int count) 32 | { 33 | return (value >> lower) & (ulong)((1ul << count) - 1); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /Library/GSDump/GSData/GSData.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2011 Ferreri Alessio 3 | * Copyright (C) 2009-2018 PCSX2 Dev Team 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | using System; 25 | using System.Collections.Generic; 26 | using System.Text; 27 | 28 | namespace GSDumpGUI 29 | { 30 | public class GSData 31 | { 32 | public GSType id; 33 | public byte[] data; 34 | } 35 | 36 | public enum GSType 37 | { 38 | Transfer = 0, 39 | VSync = 1, 40 | ReadFIFO2 = 2, 41 | Registers = 3 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Library/GSDump/GSData/GSTransfer.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2011 Ferreri Alessio 3 | * Copyright (C) 2009-2018 PCSX2 Dev Team 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | using System; 25 | using System.Collections.Generic; 26 | using System.Text; 27 | 28 | namespace GSDumpGUI 29 | { 30 | public class GSTransfer : GSData 31 | { 32 | public GSTransferPath Path; 33 | } 34 | 35 | public enum GSTransferPath 36 | { 37 | Path1Old = 0, 38 | Path2 = 1, 39 | Path3 = 2, 40 | Path1New = 3 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Library/GSDump/GSData/GIFPacket/GIFReg/GifImage.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2011 Ferreri Alessio 3 | * Copyright (C) 2009-2018 PCSX2 Dev Team 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | using System; 25 | using System.Collections.Generic; 26 | using System.Text; 27 | 28 | namespace GSDumpGUI 29 | { 30 | [Serializable] 31 | public class GifImage : IGifData 32 | { 33 | public byte[] Data; 34 | 35 | public override string ToString() 36 | { 37 | return "IMAGE@" + Data.Length.ToString() + " bytes"; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Library/GSDump/GSData/GIFPacket/GIFReg/GIFRegAD.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2011 Ferreri Alessio 3 | * Copyright (C) 2009-2018 PCSX2 Dev Team 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | using System; 25 | using System.Collections.Generic; 26 | using System.Text; 27 | 28 | namespace GSDumpGUI 29 | { 30 | [Serializable] 31 | public static class GIFRegAD 32 | { 33 | static public GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) 34 | { 35 | byte reg = (byte)GIFReg.GetBit(HighData, 0, 8); 36 | if (reg == (byte)GIFRegDescriptor.AD) 37 | return GIFRegNOP.Unpack(tag, reg, LowData, HighData, PackedFormat); 38 | return GIFTag.GetUnpack(reg)(tag, reg, LowData, HighData, false); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Library/GSDump/GSData/GIFPacket/GIFReg/GIFRegUnimpl.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2011 Ferreri Alessio 3 | * Copyright (C) 2009-2018 PCSX2 Dev Team 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | using System; 25 | using System.Collections.Generic; 26 | using System.Text; 27 | 28 | namespace GSDumpGUI 29 | { 30 | [Serializable] 31 | public class GIFRegUnimpl : GIFReg 32 | { 33 | public GIFRegUnimpl(byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) : base(addr, LowData, HighData, PackedFormat) { } 34 | 35 | static public GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) 36 | { 37 | GIFRegUnimpl u = new GIFRegUnimpl(addr, LowData, HighData, PackedFormat); 38 | u.Descriptor = (GIFRegDescriptor)addr; 39 | return u; 40 | } 41 | 42 | public override string ToString() 43 | { 44 | return Descriptor.ToString(); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /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 GSDumpGUI.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | 26 | [global::System.Configuration.UserScopedSettingAttribute()] 27 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 28 | [global::System.Configuration.DefaultSettingValueAttribute("")] 29 | public string GSDXDir { 30 | get { 31 | return ((string)(this["GSDXDir"])); 32 | } 33 | set { 34 | this["GSDXDir"] = value; 35 | } 36 | } 37 | 38 | [global::System.Configuration.UserScopedSettingAttribute()] 39 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 40 | [global::System.Configuration.DefaultSettingValueAttribute("")] 41 | public string DumpDir { 42 | get { 43 | return ((string)(this["DumpDir"])); 44 | } 45 | set { 46 | this["DumpDir"] = value; 47 | } 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Library/GSDump/GSData/GIFPacket/GIFReg/GIFRegNOP.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2011 Ferreri Alessio 3 | * Copyright (C) 2009-2018 PCSX2 Dev Team 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | using System; 25 | using System.Collections.Generic; 26 | using System.Text; 27 | 28 | namespace GSDumpGUI 29 | { 30 | [Serializable] 31 | public class GIFRegNOP : GIFReg 32 | { 33 | public byte addr; 34 | 35 | public GIFRegNOP(byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) : base(addr, LowData, HighData, PackedFormat) { } 36 | 37 | static public GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) 38 | { 39 | GIFRegNOP nop = new GIFRegNOP(addr, LowData, HighData, PackedFormat); 40 | nop.Descriptor = GIFRegDescriptor.NOP; 41 | 42 | return nop; 43 | } 44 | 45 | public override string ToString() 46 | { 47 | return Descriptor.ToString() + " (0x" + addr.ToString("X2") + ")"; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Library/TCPLibrary/Base/Data.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2011 Ferreri Alessio 3 | * Copyright (C) 2009-2018 PCSX2 Dev Team 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | using System; 25 | using System.Collections.Generic; 26 | using System.Text; 27 | 28 | namespace TCPLibrary.Core 29 | { 30 | /// 31 | /// Structure for containing the data to be sent over a base client/server 32 | /// 33 | public class Data 34 | { 35 | /// 36 | /// Data to be sent. 37 | /// 38 | private byte[] _message; 39 | 40 | /// 41 | /// Get/set the data to be sent. 42 | /// 43 | public byte[] Message 44 | { 45 | get { return _message; } 46 | set { _message = value; } 47 | } 48 | 49 | /// 50 | /// Base constructor of the class. 51 | /// 52 | /// Data to be sent. 53 | public Data(byte[] msg) 54 | { 55 | this._message = msg; 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Library/GSDump/GSData/GIFPacket/GIFReg/GIFRegFOG.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2011 Ferreri Alessio 3 | * Copyright (C) 2009-2018 PCSX2 Dev Team 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | using System; 25 | using System.Collections.Generic; 26 | using System.Text; 27 | 28 | namespace GSDumpGUI 29 | { 30 | [Serializable] 31 | public class GIFRegFOG : GIFReg 32 | { 33 | public double F; 34 | 35 | public GIFRegFOG(byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) : base(addr, LowData, HighData, PackedFormat) { } 36 | 37 | static public GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) 38 | { 39 | GIFRegFOG u = new GIFRegFOG(addr, LowData, HighData, PackedFormat); 40 | u.Descriptor = (GIFRegDescriptor)addr; 41 | if (PackedFormat) 42 | u.F = (UInt16)(GetBit(HighData, 36, 8)); 43 | else 44 | u.F = GetBit(LowData, 56, 8); 45 | return u; 46 | } 47 | 48 | public override string ToString() 49 | { 50 | return Descriptor.ToString() + "@F : " + F.ToString(); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Library/TCPLibrary/Base/CancelArgs.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2011 Ferreri Alessio 3 | * Copyright (C) 2009-2018 PCSX2 Dev Team 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | using System; 25 | using System.Collections.Generic; 26 | using System.Text; 27 | 28 | namespace TCPLibrary.Core 29 | { 30 | /// 31 | /// Class for containing information regarding the acceptance of a determinate situation. 32 | /// 33 | public class CancelArgs 34 | { 35 | /// 36 | /// Whether the operation should be cancelled. 37 | /// 38 | private Boolean _cancel; 39 | /// 40 | /// Get/set the flag that determines if the operation should be cancelled. 41 | /// 42 | public Boolean Cancel 43 | { 44 | get { return _cancel; } 45 | set { _cancel = value; } 46 | } 47 | 48 | /// 49 | /// Base constructor of the class. 50 | /// 51 | /// Whether the operation should be cancelled. 52 | public CancelArgs(Boolean cancel) 53 | { 54 | this._cancel = cancel; 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Library/TCPLibrary/Message/BaseMessageClientS.cs: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2008 Ferreri Alessio 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | */ 24 | 25 | using System.Net.Sockets; 26 | using TCPLibrary.Core; 27 | using TCPLibrary.MessageBased.Core; 28 | 29 | namespace TCPLibrary.MessageBased.Core 30 | { 31 | /// 32 | /// Class that manages the single connection between a client and the server based 33 | /// on Message structures. 34 | /// 35 | public class BaseMessageClientS : ClientS 36 | { 37 | /// 38 | /// Base constructor of the class. 39 | /// 40 | /// Server to which this client is linked to. 41 | /// Socket of the client. 42 | protected internal BaseMessageClientS(Server server, TcpClient client) 43 | : base(server, client) 44 | { 45 | 46 | } 47 | 48 | /// 49 | /// Send a Message structure to the client. 50 | /// 51 | /// Message to be sent. 52 | /// 53 | public void Send(TCPMessage msg) 54 | { 55 | ((BaseMessageServer)_server).RaiseBeforeMessageSentEvent(this, msg); 56 | base.Send(new Data(msg.ToByteArray())); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Library/GSDump/GSData/GIFPacket/GIFReg/GIFRegUV.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2011 Ferreri Alessio 3 | * Copyright (C) 2009-2018 PCSX2 Dev Team 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | using System; 25 | using System.Collections.Generic; 26 | using System.Text; 27 | 28 | namespace GSDumpGUI 29 | { 30 | [Serializable] 31 | public class GIFRegUV : GIFReg 32 | { 33 | public double U; 34 | public double V; 35 | 36 | public GIFRegUV(byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) : base(addr, LowData, HighData, PackedFormat) { } 37 | 38 | static public GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) 39 | { 40 | GIFRegUV uv = new GIFRegUV(addr, LowData, HighData, PackedFormat); 41 | uv.Descriptor = (GIFRegDescriptor)addr; 42 | if (PackedFormat) 43 | { 44 | uv.U = GetBit(LowData, 0, 14) / 16d; 45 | uv.V = GetBit(LowData, 32, 14) / 16d; 46 | } 47 | else 48 | { 49 | uv.U = GetBit(LowData, 0, 14) / 16d; 50 | uv.V = GetBit(LowData, 16, 14) / 16d; 51 | } 52 | return uv; 53 | } 54 | 55 | public override string ToString() 56 | { 57 | return Descriptor.ToString() + "@U : " + U.ToString("F4") + "@V : " + V.ToString("F4"); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Library/GSDump/GSData/GIFPacket/GIFReg/GIFRegST.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2011 Ferreri Alessio 3 | * Copyright (C) 2009-2018 PCSX2 Dev Team 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | using System; 25 | using System.Collections.Generic; 26 | using System.Text; 27 | 28 | namespace GSDumpGUI 29 | { 30 | [Serializable] 31 | public class GIFRegST : GIFReg 32 | { 33 | public float S; 34 | public float T; 35 | public float Q; 36 | 37 | public bool isSTQ; 38 | 39 | public GIFRegST(byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) : base(addr, LowData, HighData, PackedFormat) { } 40 | 41 | static public GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) 42 | { 43 | GIFRegST st = new GIFRegST(addr, LowData, HighData, PackedFormat); 44 | st.Descriptor = (GIFRegDescriptor)addr; 45 | 46 | st.S = BitConverter.ToSingle(BitConverter.GetBytes(LowData), 0); 47 | st.T = BitConverter.ToSingle(BitConverter.GetBytes(LowData), 4); 48 | if (PackedFormat) 49 | { 50 | st.Q = BitConverter.ToSingle(BitConverter.GetBytes(HighData), 0); 51 | tag.Q = st.Q; 52 | st.isSTQ = true; 53 | } 54 | else 55 | st.isSTQ = false; 56 | 57 | return st; 58 | } 59 | 60 | public override string ToString() 61 | { 62 | return Descriptor.ToString() + "@S : " + S.ToString("F8") + "@T : " + T.ToString("F8") + (isSTQ ? "@Q : " + Q.ToString("F8") : ""); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Forms/Helper/FolderWithFallBackFinder.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2019 PCSX2 Dev Team 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | 23 | using System; 24 | using System.IO; 25 | using System.Linq; 26 | 27 | namespace GSDumpGUI.Forms.Helper 28 | { 29 | public class FolderWithFallBackFinder : IFolderWithFallBackFinder 30 | { 31 | public DirectoryInfo GetViaPatternWithFallback(string defaultDir, string filePattern, params string[] fallBackFolder) 32 | { 33 | if (!string.IsNullOrWhiteSpace(defaultDir)) 34 | return new DirectoryInfo(defaultDir); 35 | 36 | DirectoryInfo gsdxDllDirectory; 37 | if (TryGetExistingDirectory(fallBackFolder, filePattern, out gsdxDllDirectory)) 38 | return gsdxDllDirectory; 39 | return new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory); 40 | } 41 | 42 | private static bool TryGetExistingDirectory(string[] relativePaths, string pattern, out DirectoryInfo validDirectory) 43 | { 44 | if (relativePaths == null) 45 | throw new ArgumentNullException(nameof(relativePaths)); 46 | foreach (var relativePath in relativePaths) 47 | { 48 | 49 | var candidate = new DirectoryInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, relativePath)); 50 | if (candidate.Exists && candidate.GetFiles(pattern).Any()) 51 | { 52 | validDirectory = candidate; 53 | return true; 54 | } 55 | } 56 | 57 | validDirectory = null; 58 | return false; 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2011 Ferreri Alessio 3 | * Copyright (C) 2009-2018 PCSX2 Dev Team 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | using System.Reflection; 25 | using System.Runtime.CompilerServices; 26 | using System.Runtime.InteropServices; 27 | 28 | // General Information about an assembly is controlled through the following 29 | // set of attributes. Change these attribute values to modify the information 30 | // associated with an assembly. 31 | [assembly: AssemblyTitle("GSDumpGUI")] 32 | [assembly: AssemblyDescription("")] 33 | [assembly: AssemblyConfiguration("")] 34 | [assembly: AssemblyCompany("PCSX2 Team")] 35 | [assembly: AssemblyProduct("GSDumpGUI")] 36 | [assembly: AssemblyCopyright("")] 37 | [assembly: AssemblyTrademark("")] 38 | [assembly: AssemblyCulture("")] 39 | 40 | // Setting ComVisible to false makes the types in this assembly not visible 41 | // to COM components. If you need to access a type in this assembly from 42 | // COM, set the ComVisible attribute to true on that type. 43 | [assembly: ComVisible(false)] 44 | 45 | // The following GUID is for the ID of the typelib if this project is exposed to COM 46 | [assembly: Guid("ff0f400c-a2cc-4d81-be4a-43c53eed5025")] 47 | 48 | // Version information for an assembly consists of the following four values: 49 | // 50 | // Major Version 51 | // Minor Version 52 | // Build Number 53 | // Revision 54 | // 55 | // You can specify all the values or you can default the Build and Revision Numbers 56 | // by using the '*' as shown below: 57 | // [assembly: AssemblyVersion("1.0.*")] 58 | [assembly: AssemblyVersion("1.0.0.0")] 59 | [assembly: AssemblyFileVersion("1.0.0.0")] 60 | -------------------------------------------------------------------------------- /Forms/Helper/GsdxDllFinder.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2011 Ferreri Alessio 3 | * Copyright (C) 2009-2019 PCSX2 Dev Team 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | using System.Collections.Generic; 25 | using System.IO; 26 | using GSDumpGUI.Forms.Entities; 27 | 28 | namespace GSDumpGUI.Forms.Helper 29 | { 30 | public class GsdxDllFinder : IGsdxDllFinder 31 | { 32 | private readonly ILogger _logger; 33 | 34 | public GsdxDllFinder(ILogger logger) 35 | { 36 | _logger = logger; 37 | } 38 | 39 | public IEnumerable GetEnrichedPathToValidGsdxDlls(DirectoryInfo directory) 40 | { 41 | var availableDlls = directory.GetFiles("*.dll", SearchOption.TopDirectoryOnly); 42 | 43 | var wrap = new GSDXWrapper(); 44 | foreach (var availableDll in availableDlls) 45 | { 46 | GsFile dll; 47 | try 48 | { 49 | wrap.Load(availableDll.FullName); 50 | 51 | dll = new GsFile 52 | { 53 | DisplayText = availableDll.Name + " | " + wrap.PS2EGetLibName(), 54 | File = availableDll 55 | }; 56 | _logger.Information($"'{availableDll}' correctly identified as '{wrap.PS2EGetLibName()}'"); 57 | 58 | wrap.Unload(); 59 | } 60 | catch (InvalidGSPlugin) 61 | { 62 | _logger.Warning($"Failed to load '{availableDll}'. Is it really a GSdx DLL?"); 63 | continue; 64 | } 65 | 66 | yield return dll; 67 | } 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Forms/Helper/RichTextBoxLogger.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2019 PCSX2 Dev Team 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | 23 | using System; 24 | using System.Drawing; 25 | using System.Windows.Forms; 26 | 27 | namespace GSDumpGUI.Forms.Helper 28 | { 29 | public class RichTextBoxLogger : ILogger 30 | { 31 | private readonly RichTextBox _richTextBox; 32 | public RichTextBoxLogger(RichTextBox richTextBox) 33 | { 34 | _richTextBox = richTextBox; 35 | _richTextBox.BackColor = Color.White; 36 | _richTextBox.Focus(); 37 | _richTextBox.HideSelection = false; 38 | } 39 | 40 | private void WriteLine(Color color, string line = null) 41 | { 42 | _richTextBox.Invoke(new MethodInvoker(delegate 43 | { 44 | ThreadLocalWrite(color, line); 45 | })); 46 | } 47 | 48 | private void ThreadLocalWrite(Color color, string line) 49 | { 50 | if (line == null) 51 | { 52 | _richTextBox.AppendText(Environment.NewLine); 53 | return; 54 | } 55 | 56 | _richTextBox.SelectionStart = _richTextBox.TextLength; 57 | _richTextBox.SelectionLength = 0; 58 | 59 | _richTextBox.SelectionColor = color; 60 | _richTextBox.AppendText(line); 61 | _richTextBox.SelectionColor = _richTextBox.ForeColor; 62 | 63 | _richTextBox.AppendText(Environment.NewLine); 64 | } 65 | 66 | public void Information(string line = null) => WriteLine(Color.Black, line); 67 | public void Warning(string line = null) => WriteLine(Color.DarkGoldenrod, line); 68 | public void Error(string line = null) => WriteLine(Color.DarkRed, line); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Library/GSDump/GSData/GIFPacket/GIFReg/GIFRegRGBAQ.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2011 Ferreri Alessio 3 | * Copyright (C) 2009-2018 PCSX2 Dev Team 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | using System; 25 | using System.Collections.Generic; 26 | using System.Text; 27 | 28 | namespace GSDumpGUI 29 | { 30 | [Serializable] 31 | public class GIFRegRGBAQ : GIFReg 32 | { 33 | public byte R; 34 | public byte G; 35 | public byte B; 36 | public byte A; 37 | public float Q; 38 | 39 | public GIFRegRGBAQ(byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) : base(addr, LowData, HighData, PackedFormat) { } 40 | 41 | static public GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) 42 | { 43 | GIFRegRGBAQ r = new GIFRegRGBAQ(addr, LowData, HighData, PackedFormat); 44 | r.Descriptor = (GIFRegDescriptor)addr; 45 | if (PackedFormat) 46 | { 47 | r.R = (byte)GetBit(LowData, 0, 8); 48 | r.G = (byte)GetBit(LowData, 32, 8); 49 | r.B = (byte)GetBit(HighData, 0, 8); 50 | r.A = (byte)GetBit(HighData, 32, 8); 51 | r.Q = tag.Q; 52 | } 53 | else 54 | { 55 | r.R = (byte)GetBit(LowData, 0, 8); 56 | r.G = (byte)GetBit(LowData, 8, 8); 57 | r.B = (byte)GetBit(LowData, 16, 8); 58 | r.A = (byte)GetBit(LowData, 24, 8); 59 | r.Q = BitConverter.ToSingle(BitConverter.GetBytes(LowData), 4); 60 | } 61 | return r; 62 | } 63 | 64 | public override string ToString() 65 | { 66 | return Descriptor.ToString() + "@Red : " + R.ToString() + "@Green : " + G.ToString() + "@Blue : " + B.ToString() + "@Alpha : " + A.ToString(); 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Forms/Entities/GsFiles.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2019 PCSX2 Dev Team 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | 23 | using System; 24 | using System.ComponentModel; 25 | 26 | namespace GSDumpGUI.Forms.Entities 27 | { 28 | public abstract class GsFiles 29 | where TUnderlying : GsFile 30 | { 31 | private int _selectedFileIndex = -1; 32 | 33 | public class SelectedIndexUpdatedEventArgs 34 | { 35 | public SelectedIndexUpdatedEventArgs(int formerIndex, int updatedIndex) 36 | { 37 | FormerIndex = formerIndex; 38 | UpdatedIndex = updatedIndex; 39 | } 40 | 41 | public int FormerIndex { get; } 42 | public int UpdatedIndex { get; } 43 | } 44 | 45 | public delegate void SelectedIndexUpdateEventHandler(object sender, SelectedIndexUpdatedEventArgs args); 46 | 47 | public event SelectedIndexUpdateEventHandler OnIndexUpdatedEvent; 48 | public BindingList Files { get; } = new BindingList(); 49 | 50 | public int SelectedFileIndex 51 | { 52 | get 53 | { 54 | return _selectedFileIndex; 55 | } 56 | set 57 | { 58 | var oldValue = _selectedFileIndex; 59 | _selectedFileIndex = value; 60 | OnIndexUpdatedEvent?.Invoke(this, new SelectedIndexUpdatedEventArgs(oldValue, value)); 61 | } 62 | } 63 | 64 | public bool IsSelected => SelectedFileIndex != -1 && Files.Count > SelectedFileIndex; 65 | 66 | public TUnderlying Selected 67 | { 68 | get 69 | { 70 | return SelectedFileIndex >= 0 ? Files[SelectedFileIndex] : null; 71 | } 72 | set 73 | { 74 | SelectedFileIndex = Files.IndexOf(value); 75 | } 76 | } 77 | } 78 | } -------------------------------------------------------------------------------- /Forms/Helper/ExtensionMethods.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2020 PCSX2 Dev Team 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | 23 | using System.Windows.Forms; 24 | 25 | // Important ! Create the ExtensionMethods class as a "public static" class 26 | public static class ExtensionMethods 27 | { 28 | public static void EnableContextMenu(this RichTextBox rtb) 29 | { 30 | if (rtb.ContextMenuStrip == null) 31 | { 32 | // Create a ContextMenuStrip without icons 33 | ContextMenuStrip cms = new ContextMenuStrip(); 34 | cms.ShowImageMargin = false; 35 | 36 | // Add the Copy option (copies the selected text inside the richtextbox) 37 | ToolStripMenuItem tsmiCopy = new ToolStripMenuItem("Copy"); 38 | tsmiCopy.Click += (sender, e) => rtb.Copy(); 39 | cms.Items.Add(tsmiCopy); 40 | 41 | // Add the Clear option (clears the text inside the richtextbox) 42 | ToolStripMenuItem tsmiClear = new ToolStripMenuItem("Clear Log"); 43 | tsmiClear.Click += (sender, e) => rtb.Clear(); 44 | cms.Items.Add(tsmiClear); 45 | 46 | // Add a Separator 47 | cms.Items.Add(new ToolStripSeparator()); 48 | 49 | // Add the Select All Option (selects all the text inside the richtextbox) 50 | ToolStripMenuItem tsmiSelectAll = new ToolStripMenuItem("Select All"); 51 | tsmiSelectAll.Click += (sender, e) => rtb.SelectAll(); 52 | cms.Items.Add(tsmiSelectAll); 53 | 54 | // When opening the menu, check if the condition is fulfilled 55 | // in order to enable the action 56 | cms.Opening += (sender, e) => 57 | { 58 | tsmiCopy.Enabled = rtb.SelectionLength > 0; 59 | tsmiClear.Enabled = rtb.TextLength > 0; 60 | tsmiSelectAll.Enabled = rtb.TextLength > 0 && rtb.SelectionLength < rtb.TextLength; 61 | }; 62 | 63 | rtb.ContextMenuStrip = cms; 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Library/GSDump/GSData/GIFPacket/GIFPrim.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2011 Ferreri Alessio 3 | * Copyright (C) 2009-2018 PCSX2 Dev Team 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | using System; 25 | using System.Collections.Generic; 26 | using System.Text; 27 | 28 | namespace GSDumpGUI 29 | { 30 | [Serializable] 31 | public class GIFPrim : GIFUtil 32 | { 33 | public GS_PRIM PrimitiveType; 34 | public GSIIP IIP; 35 | public bool TME; 36 | public bool FGE; 37 | public bool ABE; 38 | public bool AA1; 39 | public GSFST FST; 40 | public GSCTXT CTXT; 41 | public GSFIX FIX; 42 | 43 | static internal GIFPrim ExtractGIFPrim(UInt32 LowData) 44 | { 45 | GIFPrim pr = new GIFPrim(); 46 | pr.PrimitiveType = (GS_PRIM)GetBit(LowData, 0, 3); 47 | pr.IIP = (GSIIP)GetBit(LowData, 3, 1); 48 | pr.TME = Convert.ToBoolean(GetBit(LowData, 4, 1)); 49 | pr.FGE = Convert.ToBoolean(GetBit(LowData, 5, 1)); 50 | pr.ABE = Convert.ToBoolean(GetBit(LowData, 6, 1)); 51 | pr.AA1 = Convert.ToBoolean(GetBit(LowData, 7, 1)); 52 | pr.FST = (GSFST)(GetBit(LowData, 8, 1)); 53 | pr.CTXT = (GSCTXT)(GetBit(LowData, 9, 1)); 54 | pr.FIX = (GSFIX)(GetBit(LowData, 10, 1)); 55 | return pr; 56 | } 57 | 58 | public override string ToString() 59 | { 60 | return "Primitive Type : " + PrimitiveType.ToString() + "@IIP : " + IIP.ToString() + "@TME : " + TME.ToString() + "@FGE : " + FGE.ToString() 61 | + "@ABE : " + ABE.ToString() + "@AA1 : " + AA1.ToString() + "@FST : " + FST.ToString() + "@CTXT : " + CTXT.ToString() + "@FIX : " + FIX.ToString(); 62 | } 63 | } 64 | 65 | public enum GS_PRIM 66 | { 67 | GS_POINTLIST = 0, 68 | GS_LINELIST = 1, 69 | GS_LINESTRIP = 2, 70 | GS_TRIANGLELIST = 3, 71 | GS_TRIANGLESTRIP = 4, 72 | GS_TRIANGLEFAN = 5, 73 | GS_SPRITE = 6, 74 | GS_INVALID = 7, 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /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 GSDumpGUI.Properties { 12 | using System; 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", "15.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("GSDumpGUI.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). 65 | /// 66 | internal static System.Drawing.Icon AppIcon { 67 | get { 68 | object obj = ResourceManager.GetObject("AppIcon", resourceCulture); 69 | return ((System.Drawing.Icon)(obj)); 70 | } 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /Forms/Helper/GsDumpFinder.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2011 Ferreri Alessio 3 | * Copyright (C) 2009-2019 PCSX2 Dev Team 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | using System.Collections.Generic; 25 | using System.IO; 26 | using GSDumpGUI.Forms.Entities; 27 | 28 | namespace GSDumpGUI.Forms.Helper 29 | { 30 | public class GsDumpFinder : IGsDumpFinder 31 | { 32 | private readonly ILogger _logger; 33 | 34 | public GsDumpFinder(ILogger logger) 35 | { 36 | _logger = logger; 37 | } 38 | 39 | public IEnumerable GetValidGsdxDumps(DirectoryInfo directory) 40 | { 41 | var dumps = new FileInfo[0]; 42 | 43 | try 44 | { 45 | dumps = directory.GetFiles("*.gs", SearchOption.TopDirectoryOnly); 46 | } 47 | catch (DirectoryNotFoundException) 48 | { 49 | _logger.Warning($"Failed to open folder '{directory}'."); 50 | yield break; 51 | } 52 | 53 | foreach (var dump in dumps) 54 | { 55 | int crc; 56 | using (var fileStream = File.OpenRead(dump.FullName)) 57 | { 58 | using (var br = new BinaryReader(fileStream)) 59 | { 60 | crc = br.ReadInt32(); 61 | br.Close(); 62 | } 63 | } 64 | 65 | var extensions = new[] {".png", ".bmp"}; 66 | var dumpPreview = default(FileInfo); 67 | foreach (var extension in extensions) 68 | { 69 | var imageFile = new FileInfo(Path.ChangeExtension(dump.FullName, extension)); 70 | if (!imageFile.Exists) 71 | continue; 72 | dumpPreview = imageFile; 73 | break; 74 | } 75 | 76 | _logger.Information($"Identified Dump for game ({crc:X}) with filename '{dump}'"); 77 | yield return new GsDumpFile 78 | { 79 | DisplayText = dump.Name + " | CRC : " + crc.ToString("X"), 80 | File = dump, 81 | PreviewFile = dumpPreview 82 | }; 83 | } 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /Library/GSDump/GSData/GIFPacket/GIFReg/GIFRegPrim.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2011 Ferreri Alessio 3 | * Copyright (C) 2009-2018 PCSX2 Dev Team 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | using System; 25 | using System.Collections.Generic; 26 | using System.Text; 27 | 28 | namespace GSDumpGUI 29 | { 30 | [Serializable] 31 | public class GIFRegPRIM : GIFReg 32 | { 33 | public GS_PRIM PrimitiveType; 34 | public GSIIP IIP; 35 | public bool TME; 36 | public bool FGE; 37 | public bool ABE; 38 | public bool AA1; 39 | public GSFST FST; 40 | public GSCTXT CTXT; 41 | public GSFIX FIX; 42 | 43 | public GIFRegPRIM(byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) : base(addr, LowData, HighData, PackedFormat) { } 44 | 45 | static public GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) 46 | { 47 | GIFRegPRIM pr = new GIFRegPRIM(addr, LowData, HighData, PackedFormat); 48 | pr.Descriptor = (GIFRegDescriptor)addr; 49 | pr.PrimitiveType = (GS_PRIM)GetBit(LowData, 0, 3); 50 | pr.IIP = (GSIIP)GetBit(LowData, 3, 1); 51 | pr.TME = Convert.ToBoolean(GetBit(LowData, 4, 1)); 52 | pr.FGE = Convert.ToBoolean(GetBit(LowData, 5, 1)); 53 | pr.ABE = Convert.ToBoolean(GetBit(LowData, 6, 1)); 54 | pr.AA1 = Convert.ToBoolean(GetBit(LowData, 7, 1)); 55 | pr.FST = (GSFST)(GetBit(LowData, 8, 1)); 56 | pr.CTXT = (GSCTXT)(GetBit(LowData, 9, 1)); 57 | pr.FIX = (GSFIX)(GetBit(LowData, 10, 1)); 58 | return pr; 59 | } 60 | 61 | public override string ToString() 62 | { 63 | return Descriptor.ToString() + "@Primitive Type : " + PrimitiveType.ToString() + "@IIP : " + IIP.ToString() + "@TME : " + TME.ToString() + "@FGE : " + FGE.ToString() 64 | + "@ABE : " + ABE.ToString() + "@AA1 : " + AA1.ToString() + "@FST : " + FST.ToString() + "@CTXT : " + CTXT.ToString() + "@FIX : " + FIX.ToString(); 65 | } 66 | } 67 | 68 | public enum GSIIP 69 | { 70 | FlatShading=0, 71 | Gouraud=1 72 | } 73 | 74 | public enum GSFST 75 | { 76 | STQValue=0, 77 | UVValue=1 78 | } 79 | 80 | public enum GSCTXT 81 | { 82 | Context1 =0, 83 | Context2 =1 84 | } 85 | 86 | public enum GSFIX 87 | { 88 | Unfixed =0, 89 | Fixed = 1 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /Library/GSDump/GSData/GIFPacket/GIFReg/GIFReg.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2011 Ferreri Alessio 3 | * Copyright (C) 2009-2018 PCSX2 Dev Team 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | using System; 25 | using System.Collections.Generic; 26 | using System.Text; 27 | 28 | namespace GSDumpGUI 29 | { 30 | [Serializable] 31 | abstract public class GIFReg : GIFUtil, IGifData 32 | { 33 | public GIFRegDescriptor Descriptor; 34 | public UInt64 LowData, HighData; 35 | public bool PackedFormat; 36 | 37 | private GIFReg() { } 38 | 39 | public GIFReg(byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) 40 | { 41 | this.LowData = LowData; 42 | this.HighData = HighData; 43 | this.PackedFormat = PackedFormat; 44 | } 45 | 46 | abstract public new String ToString(); 47 | } 48 | 49 | public enum GIFRegDescriptor 50 | { 51 | PRIM = 0x00, 52 | RGBAQ = 0x01, 53 | ST = 0x02, 54 | UV = 0x03, 55 | XYZF2 = 0x04, 56 | XYZ2 = 0x05, 57 | TEX0_1 = 0x06, 58 | TEX0_2 = 0x07, 59 | CLAMP_1 = 0x08, 60 | CLAMP_2 = 0x09, 61 | FOG = 0x0a, 62 | XYZF3 = 0x0c, 63 | XYZ3 = 0x0d, 64 | AD = 0x0e, 65 | NOP = 0x0f, // actually, 0xf is the standard GIF NOP and 0x7f is the standard GS NOP, but all unregistered addresses act as NOPs... probably 66 | TEX1_1 = 0x14, 67 | TEX1_2 = 0x15, 68 | TEX2_1 = 0x16, 69 | TEX2_2 = 0x17, 70 | XYOFFSET_1 = 0x18, 71 | XYOFFSET_2 = 0x19, 72 | PRMODECONT = 0x1a, 73 | PRMODE = 0x1b, 74 | TEXCLUT = 0x1c, 75 | SCANMSK = 0x22, 76 | MIPTBP1_1 = 0x34, 77 | MIPTBP1_2 = 0x35, 78 | MIPTBP2_1 = 0x36, 79 | MIPTBP2_2 = 0x37, 80 | TEXA = 0x3b, 81 | FOGCOL = 0x3d, 82 | TEXFLUSH = 0x3f, 83 | SCISSOR_1 = 0x40, 84 | SCISSOR_2 = 0x41, 85 | ALPHA_1 = 0x42, 86 | ALPHA_2 = 0x43, 87 | DIMX = 0x44, 88 | DTHE = 0x45, 89 | COLCLAMP = 0x46, 90 | TEST_1 = 0x47, 91 | TEST_2 = 0x48, 92 | PABE = 0x49, 93 | FBA_1 = 0x4a, 94 | FBA_2 = 0x4b, 95 | FRAME_1 = 0x4c, 96 | FRAME_2 = 0x4d, 97 | ZBUF_1 = 0x4e, 98 | ZBUF_2 = 0x4f, 99 | BITBLTBUF = 0x50, 100 | TRXPOS = 0x51, 101 | TRXREG = 0x52, 102 | TRXDIR = 0x53, 103 | HWREG = 0x54, 104 | SIGNAL = 0x60, 105 | FINISH = 0x61, 106 | LABEL = 0x62, 107 | } 108 | 109 | } 110 | -------------------------------------------------------------------------------- /Library/GSDump/GSData/GIFPacket/GIFReg/GIFRegXYZF.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2011 Ferreri Alessio 3 | * Copyright (C) 2009-2018 PCSX2 Dev Team 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | using System; 25 | using System.Collections.Generic; 26 | using System.Text; 27 | 28 | namespace GSDumpGUI 29 | { 30 | [Serializable] 31 | public class GIFRegXYZF : GIFReg 32 | { 33 | public double X; 34 | public double Y; 35 | public UInt32 Z; 36 | public UInt16 F; 37 | 38 | public bool IsXYZF; 39 | 40 | public GIFRegXYZF(byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) : base(addr, LowData, HighData, PackedFormat) { } 41 | 42 | static public GIFReg UnpackXYZ(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) 43 | { 44 | GIFRegXYZF xyzf = new GIFRegXYZF(addr, LowData, HighData, PackedFormat); 45 | 46 | xyzf.IsXYZF = false; 47 | if (PackedFormat && addr == (int)GIFRegDescriptor.XYZ2 && GetBit(HighData, 47, 1) == 1) 48 | xyzf.Descriptor = GIFRegDescriptor.XYZ3; 49 | else 50 | xyzf.Descriptor = (GIFRegDescriptor)addr; 51 | 52 | if (PackedFormat) 53 | { 54 | xyzf.X = GetBit(LowData, 0, 16) / 16d; 55 | xyzf.Y = GetBit(LowData, 32, 16) / 16d; 56 | xyzf.Z = (UInt32)(GetBit(HighData, 0, 32)); 57 | } 58 | else 59 | { 60 | xyzf.X = GetBit(LowData, 0, 16) / 16d; 61 | xyzf.Y = GetBit(LowData, 16, 16) / 16d; 62 | xyzf.Z = (UInt32)(GetBit(LowData, 32, 32)); 63 | } 64 | return xyzf; 65 | } 66 | 67 | static public GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) 68 | { 69 | GIFRegXYZF xyzf = new GIFRegXYZF(addr, LowData, HighData, PackedFormat); 70 | 71 | xyzf.IsXYZF = true; 72 | if (PackedFormat && addr == (int)GIFRegDescriptor.XYZF2 && GetBit(HighData, 47, 1) == 1) 73 | xyzf.Descriptor = GIFRegDescriptor.XYZF3; 74 | else 75 | xyzf.Descriptor = (GIFRegDescriptor)addr; 76 | 77 | if (PackedFormat) 78 | { 79 | xyzf.X = GetBit(LowData, 0, 16) / 16d; 80 | xyzf.Y = GetBit(LowData, 32, 16) / 16d; 81 | xyzf.Z = (UInt32)(GetBit(HighData, 4, 24)); 82 | xyzf.F = (UInt16)(GetBit(HighData, 36, 8)); 83 | } 84 | else 85 | { 86 | xyzf.X = GetBit(LowData, 0, 16) / 16d; 87 | xyzf.Y = GetBit(LowData, 16, 16) / 16d; 88 | xyzf.Z = (UInt32)(GetBit(LowData, 32, 24)); 89 | xyzf.F = (UInt16)(GetBit(LowData, 56, 8)); 90 | } 91 | return xyzf; 92 | } 93 | 94 | public override string ToString() 95 | { 96 | return Descriptor.ToString() + "@X : " + X.ToString("F4") + "@Y : " + Y.ToString("F4") + "@Z : " + Z.ToString() + (IsXYZF ? "@F : " + F.ToString() : ""); 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /Library/TCPLibrary/Message/TCPMessage.cs: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2008 Ferreri Alessio 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | */ 24 | 25 | using System; 26 | using System.Collections.Generic; 27 | using System.Xml.Serialization; 28 | using System.IO; 29 | using System.Runtime.Serialization.Formatters.Binary; 30 | 31 | namespace TCPLibrary.MessageBased.Core 32 | { 33 | /// 34 | /// Message structure that contains all the information of the message exchanged between 35 | /// Message driven server/client. 36 | /// 37 | [Serializable] 38 | public class TCPMessage 39 | { 40 | /// 41 | /// Message Type. 42 | /// 43 | private MessageType _messageType; 44 | /// 45 | /// Messages parameters. 46 | /// 47 | private List _parameters; 48 | 49 | /// 50 | /// Get/set the message type. 51 | /// 52 | public MessageType MessageType 53 | { 54 | get { return _messageType; } 55 | set { _messageType = value; } 56 | } 57 | 58 | /// 59 | /// Get/set the message parameters. 60 | /// 61 | public List Parameters 62 | { 63 | get { return _parameters; } 64 | } 65 | 66 | /// 67 | /// Base constructor of the class. 68 | /// 69 | public TCPMessage() 70 | { 71 | _messageType = MessageType.Connect; 72 | _parameters = new List(); 73 | } 74 | 75 | /// 76 | /// Parse a string and create a Message structure. 77 | /// 78 | /// Raw data. 79 | /// Parsed message structure. 80 | static public TCPMessage FromByteArray(byte[] data) 81 | { 82 | MemoryStream ms = new MemoryStream(); 83 | BinaryWriter sw = new BinaryWriter(ms); 84 | sw.Write(data, 0, data.Length); 85 | sw.Flush(); 86 | ms.Position = 0; 87 | 88 | BinaryFormatter formatter = new BinaryFormatter(); 89 | TCPMessage msg = formatter.Deserialize(ms) as TCPMessage; 90 | 91 | return msg; 92 | } 93 | 94 | /// 95 | /// Trasform the structure into a String. 96 | /// 97 | /// The structure in a String format. 98 | public byte[] ToByteArray() 99 | { 100 | MemoryStream ms = new MemoryStream(); 101 | BinaryFormatter formatter = new BinaryFormatter(); 102 | formatter.Serialize(ms, this); 103 | ms.Position = 0; 104 | return ms.ToArray(); 105 | } 106 | } 107 | 108 | public enum MessageType 109 | { 110 | Connect, 111 | MaxUsers, 112 | SizeDump, 113 | Statistics, 114 | StateOld, 115 | 116 | GetDebugMode, 117 | SetDebugMode, 118 | DebugState, 119 | PacketInfo, 120 | 121 | Step, 122 | RunToCursor, 123 | RunToNextVSync 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /Library/GSDump/GSData/GIFPacket/GIFReg/GIFRegTEX0.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2011 Ferreri Alessio 3 | * Copyright (C) 2009-2018 PCSX2 Dev Team 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | using System; 25 | using System.Collections.Generic; 26 | using System.Text; 27 | 28 | namespace GSDumpGUI 29 | { 30 | [Serializable] 31 | public class GIFRegTEX0 : GIFReg 32 | { 33 | public ushort TBP0; 34 | public byte TBW; 35 | public TEXPSM PSM; 36 | public byte TW; 37 | public byte TH; 38 | public TEXTCC TCC; 39 | public TEXTFX TFX; 40 | public ushort CBP; 41 | public TEXCPSM CPSM; 42 | public TEXCSM CSM; 43 | public byte CSA; 44 | public byte CLD; 45 | 46 | public GIFRegTEX0(byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) : base(addr, LowData, HighData, PackedFormat) { } 47 | 48 | static public GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) 49 | { 50 | GIFRegTEX0 tex0 = new GIFRegTEX0(addr, LowData, HighData, PackedFormat); 51 | tex0.Descriptor = (GIFRegDescriptor)addr; 52 | tex0.TBP0 = (ushort)GetBit(LowData, 0, 14); 53 | tex0.TBW = (byte)GetBit(LowData, 14, 6); 54 | tex0.PSM = (TEXPSM)GetBit(LowData, 20, 6); 55 | tex0.TW = (byte)GetBit(LowData, 26, 4); 56 | tex0.TH = (byte)GetBit(LowData, 30, 4); 57 | tex0.TCC = (TEXTCC)GetBit(LowData, 34, 1); 58 | tex0.TFX = (TEXTFX)GetBit(LowData, 35, 2); 59 | tex0.CBP = (ushort)GetBit(LowData, 37, 14); 60 | tex0.CPSM = (TEXCPSM)GetBit(LowData, 51, 4); 61 | tex0.CSM = (TEXCSM)GetBit(LowData, 55, 1); 62 | tex0.CSA = (byte)GetBit(LowData, 56, 5); 63 | tex0.CLD = (byte)GetBit(LowData, 61, 3); 64 | return tex0; 65 | } 66 | 67 | public override string ToString() 68 | { 69 | return Descriptor.ToString() + "@TBP0 : " + TBP0.ToString() + "@TBW : " + TBW.ToString() + "@PSM : " + PSM.ToString() + "@TW : " + TW.ToString() + "@TH : " + TH.ToString() 70 | + "@TCC : " + TCC.ToString() + "@TFX : " + TFX.ToString() + "@CBP : " + CBP.ToString() + "@CPSM : " + CPSM.ToString() + "@CSM : " + CSM.ToString() 71 | + "@CSA : " + CSA.ToString() + "@CLD : " + CLD.ToString(); 72 | } 73 | } 74 | 75 | public enum TEXPSM 76 | { 77 | PSMCT32 = 0, 78 | PSMCT24 = 1, 79 | PSMCT16 = 2, 80 | PSMCT16S = 10, 81 | PSMT8 = 19, 82 | PSMT4 = 20, 83 | PSMT8H = 27, 84 | PSMT4HL = 36, 85 | PSMT4HH = 44, 86 | PSMZ32 = 48, 87 | PSMZ24 = 49, 88 | PSMZ16 = 50, 89 | PSMZ16S = 58 90 | } 91 | 92 | public enum TEXTCC 93 | { 94 | RGB = 0, 95 | RGBA = 1 96 | } 97 | 98 | public enum TEXTFX 99 | { 100 | MODULATE = 0, 101 | DECAL = 1, 102 | HIGHLIGHT = 2, 103 | HIGHLIGHT2 = 3 104 | } 105 | 106 | public enum TEXCPSM 107 | { 108 | PSMCT32 = 0, 109 | PSMCT16 = 2, 110 | PSMCT16S = 10 111 | } 112 | 113 | public enum TEXCSM 114 | { 115 | CSM1 = 0, 116 | CSM2 = 1 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /Library/NativeMethods.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2011 Ferreri Alessio 3 | * Copyright (C) 2009-2018 PCSX2 Dev Team 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | using System; 25 | using System.Collections.Generic; 26 | using System.Text; 27 | using System.Security; 28 | using System.Runtime.InteropServices; 29 | using System.Drawing; 30 | 31 | namespace GSDumpGUI 32 | { 33 | static public class NativeMethods 34 | { 35 | [SuppressUnmanagedCodeSecurityAttribute] 36 | [DllImport("kernel32", CharSet = CharSet.Auto, SetLastError = true)] 37 | public extern static IntPtr LoadLibrary(string lpLibFileName); 38 | 39 | [SuppressUnmanagedCodeSecurityAttribute] 40 | [DllImport("kernel32", SetLastError = true)] 41 | [return: MarshalAs(UnmanagedType.Bool)] 42 | public extern static bool FreeLibrary(IntPtr hLibModule); 43 | 44 | [SuppressUnmanagedCodeSecurityAttribute] 45 | [DllImport("kernel32", CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)] 46 | public extern static IntPtr GetProcAddress(IntPtr hModule, string lpProcName); 47 | 48 | [SuppressUnmanagedCodeSecurityAttribute] 49 | [DllImport("kernel32")] 50 | public extern static UInt32 SetErrorMode(UInt32 uMode); 51 | 52 | [SuppressUnmanagedCodeSecurityAttribute] 53 | [DllImport("kernel32")] 54 | public extern static UInt32 GetLastError(); 55 | 56 | [SuppressUnmanagedCodeSecurityAttribute] 57 | [DllImport("kernel32", CharSet = CharSet.Auto, SetLastError = true)] 58 | [return: MarshalAs(UnmanagedType.Bool)] 59 | public extern static bool WritePrivateProfileString(string lpAppName, string lpKeyName, string lpString, string lpFileName); 60 | 61 | [SuppressUnmanagedCodeSecurityAttribute] 62 | [DllImport("user32")] 63 | public extern static UInt16 GetAsyncKeyState(Int32 vKey); 64 | 65 | [SuppressUnmanagedCodeSecurityAttribute] 66 | [DllImport("user32", CharSet = CharSet.Auto, EntryPoint = "SetClassLong")] 67 | public extern static UInt32 SetClassLong32(IntPtr hWnd, Int32 index, Int32 dwNewLong); 68 | 69 | [SuppressUnmanagedCodeSecurityAttribute] 70 | [DllImport("user32", CharSet = CharSet.Auto, EntryPoint = "SetClassLongPtr")] 71 | public extern static UIntPtr SetClassLong64(IntPtr hWnd, Int32 index, IntPtr dwNewLong); 72 | 73 | [SuppressUnmanagedCodeSecurityAttribute] 74 | [DllImport("user32")] 75 | public extern static bool IsWindowVisible(IntPtr hWnd); 76 | 77 | [SuppressUnmanagedCodeSecurityAttribute] 78 | [DllImport("user32.dll", CharSet = CharSet.Auto)] 79 | [return: MarshalAs(UnmanagedType.Bool)] 80 | public static extern bool PeekMessage(out NativeMessage lpMsg, IntPtr hWnd, UInt32 wMsgFilterMin, UInt32 wMsgFilterMax, UInt32 wRemoveMsg); 81 | 82 | [SuppressUnmanagedCodeSecurityAttribute] 83 | [DllImport("user32.dll")] 84 | [return: MarshalAs(UnmanagedType.Bool)] 85 | public static extern bool TranslateMessage(ref NativeMessage lpMsg); 86 | 87 | [SuppressUnmanagedCodeSecurityAttribute] 88 | [DllImport("user32.dll", CharSet = CharSet.Auto)] 89 | public static extern UInt32 DispatchMessage(ref NativeMessage lpMsg); 90 | 91 | public static UIntPtr SetClassLong(IntPtr hWnd, Int32 index, IntPtr dwNewLong) 92 | { 93 | if (Environment.Is64BitProcess) return SetClassLong64(hWnd, index, dwNewLong); 94 | else return new UIntPtr(SetClassLong32(hWnd, index, dwNewLong.ToInt32())); 95 | } 96 | } 97 | 98 | [StructLayout(LayoutKind.Sequential)] 99 | public struct NativeMessage 100 | { 101 | public IntPtr hWnd; 102 | public uint msg; 103 | public IntPtr wParam; 104 | public IntPtr lParam; 105 | public uint time; 106 | public Point p; 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /Library/GSDump/GSDump.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2011 Ferreri Alessio 3 | * Copyright (C) 2009-2018 PCSX2 Dev Team 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | using System; 25 | using System.Collections.Generic; 26 | using System.Text; 27 | using System.IO; 28 | 29 | namespace GSDumpGUI 30 | { 31 | public class GSDump 32 | { 33 | public Int32 CRC; 34 | public byte[] GSFreeze; 35 | public byte[] StateData; 36 | public byte[] Registers; // 8192 bytes 37 | 38 | public int Size 39 | { 40 | get 41 | { 42 | int size = 0; 43 | size = 4; 44 | size += StateData.Length; 45 | size += Registers.Length; 46 | foreach (var itm in Data) 47 | { 48 | size += itm.data.Length; 49 | } 50 | return size; 51 | } 52 | } 53 | 54 | public List Data; 55 | 56 | public GSDump() 57 | { 58 | Data = new List(); 59 | } 60 | 61 | public GSDump Clone() 62 | { 63 | GSDump newDump = new GSDump(); 64 | newDump.CRC = this.CRC; 65 | 66 | byte[] state = new byte[StateData.Length]; 67 | Array.Copy(StateData,state, StateData.Length); 68 | newDump.StateData = state; 69 | 70 | newDump.Registers = new byte[8192]; 71 | Array.Copy(this.Registers, newDump.Registers, 8192); 72 | 73 | foreach (var itm in this.Data) 74 | { 75 | if (itm.GetType().IsInstanceOfType(typeof(GSTransfer))) 76 | { 77 | GSTransfer gt = new GSTransfer(); 78 | gt.id = itm.id; 79 | gt.Path = ((GSTransfer)itm).Path; 80 | gt.data = new byte[itm.data.Length]; 81 | Array.Copy(itm.data, gt.data, itm.data.Length); 82 | newDump.Data.Add(gt); 83 | } 84 | else 85 | { 86 | GSData gt = new GSData(); 87 | gt.id = itm.id; 88 | gt.data = new byte[itm.data.Length]; 89 | Array.Copy(itm.data, gt.data, itm.data.Length); 90 | newDump.Data.Add(gt); 91 | } 92 | } 93 | return newDump; 94 | } 95 | 96 | static public GSDump LoadDump(String FileName) 97 | { 98 | GSDump dmp = new GSDump(); 99 | 100 | BinaryReader br = new BinaryReader(System.IO.File.Open(FileName, FileMode.Open)); 101 | dmp.CRC = br.ReadInt32(); 102 | 103 | Int32 ss = br.ReadInt32(); 104 | dmp.StateData = br.ReadBytes(ss); 105 | 106 | dmp.Registers = br.ReadBytes(8192); 107 | 108 | while (br.PeekChar() != -1) 109 | { 110 | GSType id = (GSType)br.ReadByte(); 111 | switch (id) 112 | { 113 | case GSType.Transfer: 114 | GSTransfer data = new GSTransfer(); 115 | 116 | byte index = br.ReadByte(); 117 | 118 | data.id = id; 119 | data.Path = (GSTransferPath)index; 120 | 121 | Int32 size = br.ReadInt32(); 122 | 123 | List Data = new List(); 124 | Data.AddRange(br.ReadBytes(size)); 125 | data.data = Data.ToArray(); 126 | dmp.Data.Add(data); 127 | break; 128 | case GSType.VSync: 129 | GSData dataV = new GSData(); 130 | dataV.id = id; 131 | dataV.data = br.ReadBytes(1); 132 | dmp.Data.Add(dataV); 133 | break; 134 | case GSType.ReadFIFO2: 135 | GSData dataR = new GSData(); 136 | dataR.id = id; 137 | Int32 sF = br.ReadInt32(); 138 | dataR.data = BitConverter.GetBytes(sF); 139 | dmp.Data.Add(dataR); 140 | break; 141 | case GSType.Registers: 142 | GSData dataRR = new GSData(); 143 | dataRR.id = id; 144 | dataRR.data = br.ReadBytes(8192); 145 | dmp.Data.Add(dataRR); 146 | break; 147 | default: 148 | break; 149 | } 150 | } 151 | br.Close(); 152 | 153 | return dmp; 154 | } 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /Library/TCPLibrary/Message/BaseMessageClient.cs: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2008 Ferreri Alessio 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | */ 24 | 25 | using TCPLibrary.MessageBased.Core; 26 | using TCPLibrary.Core; 27 | using System; 28 | 29 | namespace TCPLibrary.MessageBased.Core 30 | { 31 | /// 32 | /// TCP Client Class that work with Message structures. 33 | /// 34 | public class BaseMessageClient : Client 35 | { 36 | /// 37 | /// Delegate for the event of receiving a message structure from the server. 38 | /// 39 | /// Sender of the event. 40 | /// Message received. 41 | public delegate void MessageReceivedHandler(Client sender, TCPMessage Mess); 42 | /// 43 | /// Occurs when the client receive a message structure from the server. 44 | /// 45 | public event MessageReceivedHandler OnMessageReceived; 46 | /// 47 | /// Delegate for the event of sending a message structure to the server. 48 | /// 49 | /// Sender of the event. 50 | /// Message sent. 51 | public delegate void MessageSentHandler(Client sender, TCPMessage Mess); 52 | /// 53 | /// Occurs before the client send a message structure to the server. 54 | /// 55 | public event MessageSentHandler OnBeforeMessageSent; 56 | /// 57 | /// Occurs after the client send a message structure to the server. 58 | /// 59 | public event MessageSentHandler OnAfterMessageSent; 60 | /// 61 | /// Delegate for the event of connection fail for max users number reached. 62 | /// 63 | /// Sender of the event. 64 | public delegate void MaxUsersReached(Client sender); 65 | /// 66 | /// Occurs when the connection fail as the server reached the maximum number of clients allowed. 67 | /// 68 | public event MaxUsersReached OnMaxUsersConnectionFail; 69 | 70 | /// 71 | /// Base constructor of the class. 72 | /// 73 | public BaseMessageClient() 74 | { 75 | OnDataReceived += new DataCommunicationHandler(BaseMessageClient_OnDataReceived); 76 | OnAfterDataSent += new DataCommunicationHandler(BaseMessageClient_OnDataSent); 77 | OnConnectFailed += new ConnectionFailedHandler(BaseMessageClient_OnConnectFailed); 78 | } 79 | 80 | /// 81 | /// When the connection is rejected by the server raise the correct event. 82 | /// 83 | /// Sender of the event. 84 | /// Message of the server. 85 | void BaseMessageClient_OnConnectFailed(Client sender, byte[] Message) 86 | { 87 | if (TCPLibrary.MessageBased.Core.TCPMessage.FromByteArray(Message).MessageType == MessageType.MaxUsers) 88 | if (OnMaxUsersConnectionFail != null) 89 | OnMaxUsersConnectionFail(sender); 90 | } 91 | 92 | /// 93 | /// Parse the raw data sent to the server and create Message structures. 94 | /// 95 | /// Sender of the event. 96 | /// Line of data sent. 97 | void BaseMessageClient_OnDataSent(Client sender, Data Data) 98 | { 99 | TCPMessage msg = TCPMessage.FromByteArray(Data.Message); 100 | if (OnAfterMessageSent != null) 101 | OnAfterMessageSent(sender, msg); 102 | } 103 | 104 | /// 105 | /// Parse the raw data received from the server and create Message structures. 106 | /// 107 | /// Sender of the event. 108 | /// Line of data received. 109 | void BaseMessageClient_OnDataReceived(Client sender, Data Data) 110 | { 111 | TCPMessage msg = null; 112 | try 113 | { 114 | msg = TCPMessage.FromByteArray(Data.Message); 115 | } 116 | catch (Exception) 117 | { 118 | 119 | } 120 | if (msg != null) 121 | if (OnMessageReceived != null) 122 | OnMessageReceived(sender, msg); 123 | } 124 | 125 | /// 126 | /// Send a message structure to the server. 127 | /// 128 | /// Message structure to be send. 129 | /// 130 | public void Send(TCPMessage msg) 131 | { 132 | if (OnBeforeMessageSent != null) 133 | OnBeforeMessageSent(this, msg); 134 | base.Send(new Data(msg.ToByteArray())); 135 | } 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /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 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 122 | ..\Resources\AppIcon.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 123 | 124 | -------------------------------------------------------------------------------- /Library/TCPLibrary/Message/BaseMessageServer.cs: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2008 Ferreri Alessio 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | */ 24 | 25 | using System; 26 | using System.Collections.Generic; 27 | using System.Text; 28 | using TCPLibrary.MessageBased.Core; 29 | using System.Net.Sockets; 30 | using System.Threading; 31 | using TCPLibrary.Core; 32 | 33 | namespace TCPLibrary.MessageBased.Core 34 | { 35 | /// 36 | /// TCP Server Class that work with Message structures. 37 | /// 38 | public class BaseMessageServer : Server 39 | { 40 | /// 41 | /// Limit of user allowed inside the server. 42 | /// 43 | protected Int32 _userlimit; 44 | 45 | /// 46 | /// Delegate for the event of receiving a Message from a client. 47 | /// 48 | /// Server raising the event. 49 | /// Client sending the message. 50 | /// Message received. 51 | public delegate void MessageReceivedHandler(BaseMessageServer server, BaseMessageClientS sender, TCPMessage Mess); 52 | /// 53 | /// Occurs when a Message is received by the server. 54 | /// 55 | public event MessageReceivedHandler OnClientMessageReceived; 56 | /// 57 | /// Delegate for the event of sending a Message to a client. 58 | /// 59 | /// Server raising the event. 60 | /// Client that will receive the message. 61 | /// Message to be sent. 62 | public delegate void MessageSentHandler(BaseMessageServer server, BaseMessageClientS receiver, TCPMessage Mess); 63 | /// 64 | /// Occurs when the server send a Message to a client. 65 | /// 66 | public event MessageSentHandler OnClientBeforeMessageSent; 67 | /// 68 | /// Occurs when the server send a Message to a client. 69 | /// 70 | public event MessageSentHandler OnClientAfterMessageSent; 71 | 72 | /// 73 | /// Get/set the limit of users allowed inside the server. 74 | /// 75 | public Int32 UserLimit 76 | { 77 | get { return _userlimit; } 78 | set { _userlimit = value; } 79 | } 80 | 81 | /// 82 | /// Base constructor of the class. 83 | /// 84 | public BaseMessageServer() : base() 85 | { 86 | OnClientBeforeConnect += new BeforeConnectedHandler(BaseMessageServer_OnClientBeforeConnect); 87 | OnClientDataReceived += new DataCommunicationHandler(BaseMessageServer_OnDataReceived); 88 | OnClientAfterDataSent += new DataCommunicationHandler(BaseMessageServer_OnDataSent); 89 | _userlimit = 0; 90 | } 91 | 92 | /// 93 | /// Kick the client if the server reached the maximum allowed number of clients. 94 | /// 95 | /// Server raising the event. 96 | /// Client connecting to the server. 97 | /// Specify if the client should be accepted into the server. 98 | void BaseMessageServer_OnClientBeforeConnect(Server server, ClientS client, CancelArgs args) 99 | { 100 | if ((Clients.Count >= UserLimit) && (UserLimit != 0)) 101 | { 102 | TCPMessage msg = new TCPMessage(); 103 | msg.MessageType = MessageType.MaxUsers; 104 | ((BaseMessageClientS)client).Send(msg); 105 | 106 | args.Cancel = true; 107 | } 108 | } 109 | 110 | /// 111 | /// Trasform the line of data sent into a Message structure and raise 112 | /// the event linked. 113 | /// 114 | /// Server raising the event. 115 | /// Client that will receive the Message. 116 | /// Line of data sent. 117 | void BaseMessageServer_OnDataSent(Server server, ClientS receiver, Data Data) 118 | { 119 | TCPMessage msg = null; 120 | try 121 | { 122 | msg = TCPMessage.FromByteArray(Data.Message); 123 | } 124 | catch (Exception) 125 | { 126 | 127 | } 128 | if (msg != null) 129 | if (OnClientAfterMessageSent != null) 130 | OnClientAfterMessageSent(this, (BaseMessageClientS)receiver, msg); 131 | } 132 | 133 | /// 134 | /// Raise the OnClientBeforeMessageSent event. 135 | /// 136 | /// Client that raised the event. 137 | /// Message to be sent. 138 | internal void RaiseBeforeMessageSentEvent(ClientS cl, TCPMessage msg) 139 | { 140 | if (OnClientBeforeMessageSent != null) 141 | OnClientBeforeMessageSent(this, (BaseMessageClientS)cl, msg); 142 | } 143 | 144 | /// 145 | /// Trasform the line of data received into a Message structure and raise 146 | /// the event linked. 147 | /// 148 | /// Server raising the event. 149 | /// Client sending the data. 150 | /// Line of data received. 151 | void BaseMessageServer_OnDataReceived(Server server, ClientS sender, Data Data) 152 | { 153 | TCPMessage msg = null; 154 | try 155 | { 156 | msg = TCPMessage.FromByteArray(Data.Message); 157 | } 158 | catch (Exception) 159 | { 160 | 161 | } 162 | if (msg != null) 163 | if (OnClientMessageReceived != null) 164 | OnClientMessageReceived(this, (BaseMessageClientS)sender, msg); 165 | } 166 | 167 | /// 168 | /// Function that create the structure to memorize the client data. 169 | /// 170 | /// Socket of the client. 171 | /// The structure in which memorize all the information of the client. 172 | protected override ClientS CreateClient(TcpClient socket) 173 | { 174 | return new BaseMessageClientS(this, socket); 175 | } 176 | 177 | /// 178 | /// Send a message to all clients in broadcast. 179 | /// 180 | /// Message to be sent. 181 | public void Broadcast(TCPMessage Data) 182 | { 183 | base.Broadcast(new Data(Data.ToByteArray())); 184 | } 185 | } 186 | } 187 | -------------------------------------------------------------------------------- /Library/TCPLibrary/Base/ClientS.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2011 Ferreri Alessio 3 | * Copyright (C) 2009-2018 PCSX2 Dev Team 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | using System; 25 | using System.Net.Sockets; 26 | using System.Threading; 27 | using System.IO; 28 | using System.Diagnostics; 29 | 30 | namespace TCPLibrary.Core 31 | { 32 | /// 33 | /// Base class that manages the single connection between a client and the server. 34 | /// 35 | public class ClientS 36 | { 37 | /// 38 | /// Lock object to assure that certain operation over the socket class are executed 39 | /// in an exclusive way. 40 | /// 41 | private Object _lock; 42 | 43 | /// 44 | /// Wrapper around the Network Stream of the socket. (Read-Only) 45 | /// 46 | private BinaryReader tr; 47 | /// 48 | /// Wrapper around the Network Stream of the socket. (Write-Only) 49 | /// 50 | private BinaryWriter tw; 51 | /// 52 | /// Current IP address of the client. 53 | /// 54 | private String _ipaddress; 55 | 56 | /// 57 | /// Flag to permit thread exit from the external. 58 | /// 59 | protected Boolean _active; 60 | /// 61 | /// Link to the server to which this client is connected. 62 | /// 63 | protected Server _server; 64 | /// 65 | /// Actual socket of the client. 66 | /// 67 | protected TcpClient _client; 68 | 69 | /// 70 | /// Get the state of the connection. 71 | /// 72 | public Boolean Connected 73 | { 74 | get { return _client != null; } 75 | } 76 | 77 | /// 78 | /// IP Address of the client. 79 | /// 80 | public String IPAddress 81 | { 82 | get { return _ipaddress; } 83 | } 84 | 85 | /// 86 | /// Base class constructor. 87 | /// 88 | /// Server to which this client is linked to. 89 | /// Socket of the client. 90 | protected internal ClientS(Server server, TcpClient client) 91 | { 92 | _lock = new object(); 93 | 94 | _active = true; 95 | _server = server; 96 | _client = client; 97 | _ipaddress = _client.Client.RemoteEndPoint.ToString(); 98 | 99 | NetworkStream ns = _client.GetStream(); 100 | tr = new BinaryReader(ns); 101 | tw = new BinaryWriter(ns); 102 | } 103 | 104 | /// 105 | /// Start up the thread managing this Client-Server connection. 106 | /// 107 | protected internal virtual void Start() 108 | { 109 | Thread _thread = new Thread(new ThreadStart(MainThread)); 110 | _thread.IsBackground = true; 111 | _thread.Name = "Thread Client " + _ipaddress; 112 | _thread.Start(); 113 | } 114 | 115 | /// 116 | /// Thread function that actually run the socket work. 117 | /// 118 | private void MainThread() 119 | { 120 | while (_active) 121 | { 122 | byte[] arr = null; 123 | 124 | try 125 | { 126 | int length = Convert.ToInt32(tr.ReadInt32()); 127 | arr = new byte[length]; 128 | int index = 0; 129 | 130 | while (length > 0) 131 | { 132 | 133 | int receivedBytes = tr.Read(arr, index, length); 134 | length -= receivedBytes; 135 | index += receivedBytes; 136 | } 137 | } 138 | catch (Exception ex) 139 | { 140 | Debug.WriteLine(ex.ToString()); 141 | } 142 | 143 | lock (_lock) 144 | { 145 | if (_active) 146 | { 147 | Boolean Stato = _client.Client.Poll(100, SelectMode.SelectRead); 148 | if ((arr == null) && (Stato == true)) 149 | break; 150 | else 151 | _server.RaiseDataReceivedEvent(this, new Data(arr)); 152 | } 153 | else 154 | break; 155 | } 156 | } 157 | Stop(); 158 | } 159 | 160 | /// 161 | /// Send a line of data to the client. 162 | /// 163 | /// Data to send to the client. 164 | /// 165 | public void Send(Data Data) 166 | { 167 | if (_active) 168 | { 169 | _server.RaiseBeforeDataSentEvent(this, Data); 170 | 171 | try 172 | { 173 | tw.Write(Data.Message.Length); 174 | tw.Write(Data.Message); 175 | tw.Flush(); 176 | 177 | _server.RaiseAfterDataSentEvent(this, Data); 178 | } 179 | catch (Exception ex) 180 | { 181 | Debug.Write(ex.ToString()); 182 | // Pensare a cosa fare quà. Questo è il caso in cui il client ha chiuso forzatamente 183 | // la connessione mentre il server mandava roba. 184 | } 185 | } 186 | else 187 | throw new ArgumentException("The link is closed. Unable to send data."); 188 | } 189 | 190 | /// 191 | /// Close the link between Client e Server. 192 | /// 193 | public void Disconnect() 194 | { 195 | lock (_lock) 196 | { 197 | _active = false; 198 | tr.Close(); 199 | tw.Close(); 200 | } 201 | } 202 | 203 | /// 204 | /// Close the link between Client e Server. 205 | /// 206 | protected internal void Stop() 207 | { 208 | if (_client != null) 209 | { 210 | _server.RaiseClientBeforeDisconnectedEvent(this); 211 | 212 | tr.Close(); 213 | tw.Close(); 214 | 215 | _client.Close(); 216 | _client = null; 217 | 218 | lock (_server.Clients) 219 | { 220 | _server.Clients.Remove(this); 221 | } 222 | 223 | _server.RaiseClientAfterDisconnectedEvent(this); 224 | } 225 | } 226 | } 227 | } 228 | -------------------------------------------------------------------------------- /GSDumpGUI.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.30729 7 | 2.0 8 | {825E4311-652D-4A1E-8AA1-F6D81B186E33} 9 | WinExe 10 | Properties 11 | GSDumpGUI 12 | GSDumpGUI 13 | v4.0 14 | 512 15 | Resources\AppIcon.ico 16 | 17 | 18 | 19 | 20 | 3.5 21 | 22 | 23 | 24 | true 25 | bin\Debug\ 26 | DEBUG;TRACE 27 | true 28 | full 29 | x64 30 | 6 31 | prompt 32 | MinimumRecommendedRules.ruleset 33 | 34 | 35 | bin\Release\ 36 | TRACE 37 | true 38 | true 39 | pdbonly 40 | x64 41 | prompt 42 | MinimumRecommendedRules.ruleset 43 | 44 | 45 | true 46 | bin\Debug\ 47 | DEBUG;TRACE 48 | true 49 | full 50 | x86 51 | 6 52 | prompt 53 | MinimumRecommendedRules.ruleset 54 | 55 | 56 | bin\Release\ 57 | TRACE 58 | true 59 | true 60 | pdbonly 61 | x86 62 | prompt 63 | MinimumRecommendedRules.ruleset 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | Form 83 | 84 | 85 | frmMain.cs 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | frmMain.cs 131 | 132 | 133 | ResXFileCodeGenerator 134 | Resources.Designer.cs 135 | Designer 136 | 137 | 138 | True 139 | Resources.resx 140 | True 141 | 142 | 143 | 144 | SettingsSingleFileGenerator 145 | Settings.Designer.cs 146 | 147 | 148 | True 149 | Settings.settings 150 | True 151 | 152 | 153 | 154 | 155 | 156 | 157 | 164 | -------------------------------------------------------------------------------- /Forms/SettingsProvider/PortableXmlSettingsProvider.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2019 PCSX2 Dev Team 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | 23 | using System; 24 | using System.Collections.Specialized; 25 | using System.Configuration; 26 | using System.IO; 27 | using System.Xml; 28 | using System.Xml.Linq; 29 | 30 | namespace GSDumpGUI.Forms.SettingsProvider 31 | { 32 | public sealed class PortableXmlSettingsProvider : System.Configuration.SettingsProvider, IApplicationSettingsProvider 33 | { 34 | private const string RootNode = "configuration"; 35 | private static string SettingsDirectory => AppDomain.CurrentDomain.BaseDirectory; 36 | public override string Name => nameof(PortableXmlSettingsProvider); 37 | private static string ApplicationSettingsFile => Path.Combine(SettingsDirectory, "portable.config"); 38 | 39 | public static void ApplyProvider(params ApplicationSettingsBase[] settingsList) 40 | => ApplyProvider(new PortableXmlSettingsProvider(), settingsList); 41 | 42 | public override string ApplicationName 43 | { 44 | get 45 | { 46 | return nameof(GSDumpGUI); 47 | } 48 | set { } 49 | } 50 | 51 | private static XDocument GetOrCreateXmlDocument() 52 | { 53 | if (!File.Exists(ApplicationSettingsFile)) 54 | return CreateNewDocument(); 55 | try 56 | { 57 | return XDocument.Load(ApplicationSettingsFile); 58 | } 59 | catch 60 | { 61 | return CreateNewDocument(); 62 | } 63 | } 64 | 65 | private static void ApplyProvider(PortableXmlSettingsProvider provider, params ApplicationSettingsBase[] settingsList) 66 | { 67 | foreach (ApplicationSettingsBase settings in settingsList) 68 | { 69 | settings.Providers.Clear(); 70 | settings.Providers.Add(provider); 71 | foreach (SettingsProperty property in settings.Properties) 72 | property.Provider = provider; 73 | settings.Reload(); 74 | } 75 | } 76 | 77 | public override void Initialize(string name, NameValueCollection config) 78 | { 79 | if (String.IsNullOrEmpty(name)) 80 | name = Name; 81 | base.Initialize(name, config); 82 | } 83 | 84 | public SettingsPropertyValue GetPreviousVersion(SettingsContext context, SettingsProperty property) 85 | { 86 | throw new NotImplementedException(); 87 | } 88 | 89 | public void Reset(SettingsContext context) 90 | { 91 | if (!File.Exists(ApplicationSettingsFile)) 92 | return; 93 | File.Delete(ApplicationSettingsFile); 94 | } 95 | 96 | public void Upgrade(SettingsContext context, SettingsPropertyCollection properties) { } 97 | 98 | private static XDocument CreateNewDocument() 99 | { 100 | return new XDocument(new XElement(RootNode)); 101 | } 102 | 103 | public override SettingsPropertyValueCollection GetPropertyValues(SettingsContext context, SettingsPropertyCollection collection) 104 | { 105 | var xmlDoc = GetOrCreateXmlDocument(); 106 | var propertyValueCollection = new SettingsPropertyValueCollection(); 107 | foreach (SettingsProperty settingsProperty in collection) 108 | { 109 | propertyValueCollection.Add(new SettingsPropertyValue(settingsProperty) 110 | { 111 | IsDirty = false, 112 | SerializedValue = GetValue(xmlDoc, settingsProperty) 113 | }); 114 | } 115 | 116 | return propertyValueCollection; 117 | } 118 | 119 | public override void SetPropertyValues(SettingsContext context, SettingsPropertyValueCollection collection) 120 | { 121 | var xmlDoc = GetOrCreateXmlDocument(); 122 | foreach (SettingsPropertyValue settingsPropertyValue in collection) 123 | SetValue(xmlDoc, settingsPropertyValue); 124 | try 125 | { 126 | using (var writer = CreateWellFormattedXmlWriter(ApplicationSettingsFile)) 127 | { 128 | xmlDoc.Save(writer); 129 | } 130 | } 131 | catch { } 132 | } 133 | 134 | private static XmlWriter CreateWellFormattedXmlWriter(string outputFileName) 135 | { 136 | var settings = new XmlWriterSettings 137 | { 138 | NewLineHandling = NewLineHandling.Entitize, 139 | Indent = true 140 | }; 141 | return XmlWriter.Create(outputFileName, settings); 142 | } 143 | 144 | private static object GetValue(XContainer xmlDoc, SettingsProperty prop) 145 | { 146 | if (xmlDoc == null) 147 | return prop.DefaultValue; 148 | 149 | var rootNode = xmlDoc.Element(RootNode); 150 | if (rootNode == null) 151 | return prop.DefaultValue; 152 | 153 | var settingNode = rootNode.Element(prop.Name); 154 | if (settingNode == null) 155 | return prop.DefaultValue; 156 | 157 | return DeserializeSettingValueFromXmlNode(settingNode, prop); 158 | } 159 | 160 | private static void SetValue(XContainer xmlDoc, SettingsPropertyValue value) 161 | { 162 | if (xmlDoc == null) 163 | throw new ArgumentNullException(nameof(xmlDoc)); 164 | 165 | var rootNode = xmlDoc.Element(RootNode); 166 | if (rootNode == null) 167 | throw new ArgumentNullException(nameof(rootNode)); 168 | 169 | var settingNode = rootNode.Element(value.Name); 170 | 171 | var settingValueNode = SerializeSettingValueToXmlNode(value); 172 | if (settingNode == null) 173 | rootNode.Add(new XElement(value.Name, settingValueNode)); 174 | else 175 | settingNode.ReplaceAll(settingValueNode); 176 | 177 | } 178 | 179 | private static XNode SerializeSettingValueToXmlNode(SettingsPropertyValue value) 180 | { 181 | if (value.SerializedValue == null) 182 | return new XText(""); 183 | switch (value.Property.SerializeAs) 184 | { 185 | case SettingsSerializeAs.String: 186 | return new XText((string) value.SerializedValue); 187 | case SettingsSerializeAs.Xml: 188 | case SettingsSerializeAs.Binary: 189 | case SettingsSerializeAs.ProviderSpecific: 190 | throw new NotImplementedException($"I don't know how to handle serialization of settings that should be serialized as {value.Property.SerializeAs}"); 191 | default: 192 | throw new ArgumentOutOfRangeException(); 193 | } 194 | } 195 | 196 | private static object DeserializeSettingValueFromXmlNode(XNode node, SettingsProperty prop) 197 | { 198 | using (var reader = node.CreateReader()) 199 | { 200 | reader.MoveToContent(); 201 | switch (prop.SerializeAs) 202 | { 203 | case SettingsSerializeAs.Xml: 204 | case SettingsSerializeAs.Binary: 205 | case SettingsSerializeAs.ProviderSpecific: 206 | throw new NotImplementedException($"I don't know how to handle deserialization of settings that should be deserialized as {prop.SerializeAs}"); 207 | 208 | case SettingsSerializeAs.String: 209 | return reader.ReadElementContentAsString(); 210 | default: 211 | throw new ArgumentOutOfRangeException(); 212 | } 213 | } 214 | } 215 | } 216 | } 217 | -------------------------------------------------------------------------------- /Library/GSDump/GSData/GIFPacket/GIFTag.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2011 Ferreri Alessio 3 | * Copyright (C) 2009-2018 PCSX2 Dev Team 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | using System; 25 | using System.Collections.Generic; 26 | using System.Text; 27 | 28 | namespace GSDumpGUI 29 | { 30 | [Serializable] 31 | public class GIFTag : GIFUtil 32 | { 33 | public delegate GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat); 34 | static public Dictionary UnpackReg; 35 | 36 | private UInt64 TAG, REGS; 37 | internal float Q; // GIF has an internal Q register which is reset to 1.0 at the tag and updated on packed ST(Q) for output at next RGBAQ 38 | 39 | public GSTransferPath path; 40 | public UInt32 nloop; 41 | public UInt32 eop; 42 | public UInt32 pre; 43 | public GIFPrim prim; 44 | public GIFFLG flg; 45 | public UInt32 nreg; 46 | public List regs; 47 | public int size; 48 | 49 | static GIFTag() 50 | { 51 | UnpackReg = new Dictionary(); 52 | UnpackReg.Add((int)GIFRegDescriptor.PRIM, GIFRegPRIM.Unpack); 53 | UnpackReg.Add((int)GIFRegDescriptor.RGBAQ, GIFRegRGBAQ.Unpack); 54 | UnpackReg.Add((int)GIFRegDescriptor.ST, GIFRegST.Unpack); 55 | UnpackReg.Add((int)GIFRegDescriptor.UV, GIFRegUV.Unpack); 56 | UnpackReg.Add((int)GIFRegDescriptor.XYZF2, GIFRegXYZF.Unpack); 57 | UnpackReg.Add((int)GIFRegDescriptor.XYZ2, GIFRegXYZF.UnpackXYZ); 58 | UnpackReg.Add((int)GIFRegDescriptor.TEX0_1, GIFRegTEX0.Unpack); 59 | UnpackReg.Add((int)GIFRegDescriptor.TEX0_2, GIFRegTEX0.Unpack); 60 | UnpackReg.Add((int)GIFRegDescriptor.CLAMP_1, GIFRegUnimpl.Unpack); 61 | UnpackReg.Add((int)GIFRegDescriptor.CLAMP_2, GIFRegUnimpl.Unpack); 62 | UnpackReg.Add((int)GIFRegDescriptor.FOG, GIFRegFOG.Unpack); 63 | UnpackReg.Add((int)GIFRegDescriptor.XYZF3, GIFRegXYZF.Unpack); 64 | UnpackReg.Add((int)GIFRegDescriptor.XYZ3, GIFRegXYZF.UnpackXYZ); 65 | UnpackReg.Add((int)GIFRegDescriptor.AD, GIFRegAD.Unpack); 66 | UnpackReg.Add((int)GIFRegDescriptor.TEX1_1, GIFRegUnimpl.Unpack); 67 | UnpackReg.Add((int)GIFRegDescriptor.TEX1_2, GIFRegUnimpl.Unpack); 68 | UnpackReg.Add((int)GIFRegDescriptor.TEX2_1, GIFRegUnimpl.Unpack); 69 | UnpackReg.Add((int)GIFRegDescriptor.TEX2_2, GIFRegUnimpl.Unpack); 70 | UnpackReg.Add((int)GIFRegDescriptor.XYOFFSET_1, GIFRegUnimpl.Unpack); 71 | UnpackReg.Add((int)GIFRegDescriptor.XYOFFSET_2, GIFRegUnimpl.Unpack); 72 | UnpackReg.Add((int)GIFRegDescriptor.PRMODECONT, GIFRegUnimpl.Unpack); 73 | UnpackReg.Add((int)GIFRegDescriptor.PRMODE, GIFRegUnimpl.Unpack); 74 | UnpackReg.Add((int)GIFRegDescriptor.TEXCLUT, GIFRegUnimpl.Unpack); 75 | UnpackReg.Add((int)GIFRegDescriptor.SCANMSK, GIFRegUnimpl.Unpack); 76 | UnpackReg.Add((int)GIFRegDescriptor.MIPTBP1_1, GIFRegUnimpl.Unpack); 77 | UnpackReg.Add((int)GIFRegDescriptor.MIPTBP1_2, GIFRegUnimpl.Unpack); 78 | UnpackReg.Add((int)GIFRegDescriptor.MIPTBP2_1, GIFRegUnimpl.Unpack); 79 | UnpackReg.Add((int)GIFRegDescriptor.MIPTBP2_2, GIFRegUnimpl.Unpack); 80 | UnpackReg.Add((int)GIFRegDescriptor.TEXA, GIFRegUnimpl.Unpack); 81 | UnpackReg.Add((int)GIFRegDescriptor.FOGCOL, GIFRegUnimpl.Unpack); 82 | UnpackReg.Add((int)GIFRegDescriptor.TEXFLUSH, GIFRegUnimpl.Unpack); 83 | UnpackReg.Add((int)GIFRegDescriptor.SCISSOR_1, GIFRegUnimpl.Unpack); 84 | UnpackReg.Add((int)GIFRegDescriptor.SCISSOR_2, GIFRegUnimpl.Unpack); 85 | UnpackReg.Add((int)GIFRegDescriptor.ALPHA_1, GIFRegUnimpl.Unpack); 86 | UnpackReg.Add((int)GIFRegDescriptor.ALPHA_2, GIFRegUnimpl.Unpack); 87 | UnpackReg.Add((int)GIFRegDescriptor.DIMX, GIFRegUnimpl.Unpack); 88 | UnpackReg.Add((int)GIFRegDescriptor.DTHE, GIFRegUnimpl.Unpack); 89 | UnpackReg.Add((int)GIFRegDescriptor.COLCLAMP, GIFRegUnimpl.Unpack); 90 | UnpackReg.Add((int)GIFRegDescriptor.TEST_1, GIFRegUnimpl.Unpack); 91 | UnpackReg.Add((int)GIFRegDescriptor.TEST_2, GIFRegUnimpl.Unpack); 92 | UnpackReg.Add((int)GIFRegDescriptor.PABE, GIFRegUnimpl.Unpack); 93 | UnpackReg.Add((int)GIFRegDescriptor.FBA_1, GIFRegUnimpl.Unpack); 94 | UnpackReg.Add((int)GIFRegDescriptor.FBA_2, GIFRegUnimpl.Unpack); 95 | UnpackReg.Add((int)GIFRegDescriptor.FRAME_1, GIFRegUnimpl.Unpack); 96 | UnpackReg.Add((int)GIFRegDescriptor.FRAME_2, GIFRegUnimpl.Unpack); 97 | UnpackReg.Add((int)GIFRegDescriptor.ZBUF_1, GIFRegUnimpl.Unpack); 98 | UnpackReg.Add((int)GIFRegDescriptor.ZBUF_2, GIFRegUnimpl.Unpack); 99 | UnpackReg.Add((int)GIFRegDescriptor.BITBLTBUF, GIFRegUnimpl.Unpack); 100 | UnpackReg.Add((int)GIFRegDescriptor.TRXPOS, GIFRegUnimpl.Unpack); 101 | UnpackReg.Add((int)GIFRegDescriptor.TRXREG, GIFRegUnimpl.Unpack); 102 | UnpackReg.Add((int)GIFRegDescriptor.TRXDIR, GIFRegUnimpl.Unpack); 103 | UnpackReg.Add((int)GIFRegDescriptor.HWREG, GIFRegUnimpl.Unpack); 104 | UnpackReg.Add((int)GIFRegDescriptor.SIGNAL, GIFRegUnimpl.Unpack); 105 | UnpackReg.Add((int)GIFRegDescriptor.FINISH, GIFRegUnimpl.Unpack); 106 | UnpackReg.Add((int)GIFRegDescriptor.LABEL, GIFRegUnimpl.Unpack); 107 | } 108 | 109 | public static Unpack GetUnpack(int reg) 110 | { 111 | Unpack ret; 112 | if (!UnpackReg.TryGetValue(reg, out ret)) 113 | return GIFRegNOP.Unpack; 114 | return ret; 115 | } 116 | 117 | static internal GIFTag ExtractGifTag(byte[] data, GSTransferPath path) 118 | { 119 | GIFTag t = new GIFTag(); 120 | t.size = data.Length; 121 | t.path = path; 122 | t.TAG = BitConverter.ToUInt64(data, 0); 123 | t.REGS = BitConverter.ToUInt64(data, 8); 124 | 125 | t.Q = 1f; 126 | t.nloop = (uint)GetBit(t.TAG, 0, 15); 127 | t.eop = (uint)GetBit(t.TAG, 15, 1); 128 | t.pre = (uint)GetBit(t.TAG, 46, 1); 129 | t.prim = GIFPrim.ExtractGIFPrim((uint)GetBit(t.TAG, 47, 11)); 130 | t.flg = (GIFFLG)GetBit(t.TAG, 58, 2); 131 | t.nreg = (uint)GetBit(t.TAG, 60, 4); 132 | if (t.nreg == 0) 133 | t.nreg = 16; 134 | 135 | byte[] registers = new byte[t.nreg]; 136 | Unpack[] regsunpack = new Unpack[t.nreg]; 137 | 138 | t.regs = new List(); 139 | for (byte i = 0; i < t.nreg; i++) 140 | { 141 | byte reg = (byte)GetBit(t.REGS, i * 4, 4); 142 | registers[i] = reg; 143 | regsunpack[i] = GetUnpack(reg); 144 | } 145 | 146 | int p = 16; 147 | switch (t.flg) 148 | { 149 | case GIFFLG.GIF_FLG_PACKED: 150 | for (int j = 0; j < t.nloop; j++) 151 | for (int i = 0; i < t.nreg; i++) 152 | { 153 | UInt64 LowData = BitConverter.ToUInt64(data, p); 154 | UInt64 HighData = BitConverter.ToUInt64(data, p + 8); 155 | t.regs.Add(regsunpack[i](t, registers[i], LowData, HighData, true)); 156 | p += 16; 157 | } 158 | break; 159 | case GIFFLG.GIF_FLG_REGLIST: 160 | for (int j = 0; j < t.nloop; j++) 161 | for (int i = 0; i < t.nreg; i++) 162 | { 163 | UInt64 Data = BitConverter.ToUInt64(data, p); 164 | t.regs.Add(regsunpack[i](t, registers[i], Data, 0, false)); 165 | p += 8; 166 | } 167 | break; 168 | case GIFFLG.GIF_FLG_IMAGE: 169 | case GIFFLG.GIF_FLG_IMAGE2: 170 | GifImage image = new GifImage(); 171 | image.Data = new byte[t.nloop * 16]; 172 | try 173 | { 174 | Array.Copy(data, 16, image.Data, 0, t.nloop * 16); 175 | } 176 | catch (ArgumentException) { } 177 | t.regs.Add(image); 178 | break; 179 | default: 180 | break; 181 | } 182 | return t; 183 | } 184 | } 185 | 186 | public enum GIFFLG 187 | { 188 | GIF_FLG_PACKED =0, 189 | GIF_FLG_REGLIST =1, 190 | GIF_FLG_IMAGE = 2, 191 | GIF_FLG_IMAGE2 = 3 192 | } 193 | } 194 | -------------------------------------------------------------------------------- /Library/TCPLibrary/Base/Client.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2011 Ferreri Alessio 3 | * Copyright (C) 2009-2018 PCSX2 Dev Team 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | using System; 25 | using System.Net.Sockets; 26 | using System.Net; 27 | using System.Threading; 28 | using System.IO; 29 | using System.ComponentModel; 30 | using System.Text; 31 | using System.Diagnostics; 32 | 33 | namespace TCPLibrary.Core 34 | { 35 | /// 36 | /// Base TCP client class wrapped around TcpClient. 37 | /// 38 | public class Client 39 | { 40 | /// 41 | /// Lock object to assure that certain operation over the socket class are executed 42 | /// in an exclusive way. 43 | /// 44 | private Object _lock; 45 | 46 | /// 47 | /// Wrapper around the Network Stream of the socket. (Read-Only) 48 | /// 49 | private BinaryReader tr; 50 | /// 51 | /// Wrapper around the Network Stream of the socket. (Write-Only) 52 | /// 53 | private BinaryWriter tw; 54 | /// 55 | /// Address to which the client is connected. 56 | /// 57 | private IPEndPoint _address; 58 | 59 | /// 60 | /// Flag to permit thread exit from the external. 61 | /// 62 | protected Boolean _active; 63 | /// 64 | /// Socket maintaining the connection. 65 | /// 66 | protected TcpClient _socket; 67 | 68 | /// 69 | /// Get/set the address to which the client is connected. 70 | /// 71 | public IPEndPoint Address 72 | { 73 | get { return _address; } 74 | } 75 | 76 | /// 77 | /// Get the state of the connection. 78 | /// 79 | public Boolean Connected 80 | { 81 | get { return _socket != null; } 82 | } 83 | 84 | /// 85 | /// Delegate for the event of receiving/sending a line of data from/to the server. 86 | /// 87 | /// Sender of the event. 88 | /// Line of data received. 89 | public delegate void DataCommunicationHandler(Client sender, Data Data); 90 | /// 91 | /// Occurs when a line of data is received from the server. 92 | /// 93 | public event DataCommunicationHandler OnDataReceived; 94 | /// 95 | /// Occurs before the client send a line of data to the server. 96 | /// 97 | public event DataCommunicationHandler OnBeforeDataSent; 98 | /// 99 | /// Occurs after the client send a line of data to the server. 100 | /// 101 | public event DataCommunicationHandler OnAfterDataSent; 102 | 103 | /// 104 | /// Delegate for the event of connection/disconnection to the server. 105 | /// 106 | /// Sender of the event. 107 | public delegate void ConnectionStateHandler(Client sender); 108 | /// 109 | /// Occurs when the client successfully connect the server. 110 | /// 111 | public event ConnectionStateHandler OnConnected; 112 | /// 113 | /// Occurs when the client is disconnected from the server. 114 | /// 115 | public event ConnectionStateHandler OnDisconnected; 116 | 117 | /// 118 | /// Delegate for the event of connection failed for rejection by the server. 119 | /// 120 | /// Sender of the event. 121 | /// Message of fail sent by the server. 122 | public delegate void ConnectionFailedHandler(Client sender, byte[] Message); 123 | /// 124 | /// Occurs when the client failed to connect to the server because the server rejected the connection. 125 | /// 126 | public event ConnectionFailedHandler OnConnectFailed; 127 | 128 | /// 129 | /// Base constructor of the class. 130 | /// 131 | public Client() 132 | { 133 | _lock = new object(); 134 | _address = null; 135 | } 136 | 137 | /// 138 | /// Try to connect to the server specified. 139 | /// 140 | /// Address of the server to connect. 141 | /// Port of the server to connect. 142 | /// True if the connection is successfull, false otherwise. 143 | /// 144 | /// 145 | public virtual Boolean Connect(String Indirizzo, Int32 Port) 146 | { 147 | if (!Connected) 148 | { 149 | IPHostEntry addr = Dns.GetHostEntry(Indirizzo); 150 | IPAddress ip = null; 151 | 152 | foreach (var itm in addr.AddressList) 153 | { 154 | if (itm.AddressFamily == AddressFamily.InterNetwork) 155 | { 156 | ip = itm; 157 | break; 158 | } 159 | } 160 | 161 | if (ip != null) 162 | { 163 | _address = new IPEndPoint(ip, Port); 164 | _socket = new TcpClient(); 165 | 166 | try 167 | { 168 | _socket.Connect(_address); 169 | } 170 | catch (SocketException) 171 | { 172 | _socket = null; 173 | _address = null; 174 | throw; 175 | } 176 | 177 | tr = new BinaryReader(_socket.GetStream()); 178 | tw = new BinaryWriter(_socket.GetStream()); 179 | 180 | // Receive the confirmation of the status of the connection to the server. 181 | // Is CONNECTEDTCPSERVER if the connection is successfull, all other cases are wrong. 182 | 183 | Int32 Length = Convert.ToInt32(tr.ReadInt32()); 184 | byte[] arr = new byte[Length]; 185 | tr.Read(arr, 0, Length); 186 | ASCIIEncoding ae = new ASCIIEncoding(); 187 | String Accept = ae.GetString(arr, 0, arr.Length); 188 | 189 | if (Accept == "CONNECTEDTCPSERVER") 190 | { 191 | _active = true; 192 | 193 | Thread thd = new Thread(new ThreadStart(MainThread)); 194 | thd.IsBackground = true; 195 | thd.Name = "Client connected to " + Indirizzo + ":" + Port.ToString(); 196 | thd.Start(); 197 | 198 | if (OnConnected != null) 199 | OnConnected(this); 200 | 201 | return true; 202 | } 203 | else 204 | { 205 | Stop(); 206 | if (OnConnectFailed != null) 207 | OnConnectFailed(this, arr); 208 | 209 | return false; 210 | } 211 | } 212 | else 213 | return false; 214 | } 215 | else 216 | throw new ArgumentException("The client is already connected!"); 217 | } 218 | 219 | /// 220 | /// Disconnect a Client if connected. 221 | /// 222 | public virtual void Disconnect() 223 | { 224 | lock (_lock) 225 | { 226 | _active = false; 227 | tr.Close(); 228 | tw.Close(); 229 | } 230 | } 231 | 232 | /// 233 | /// Disconnect a Client if connected. 234 | /// 235 | protected virtual void Stop() 236 | { 237 | if (_socket != null) 238 | { 239 | tr.Close(); 240 | tw.Close(); 241 | _socket.Close(); 242 | 243 | _socket = null; 244 | _address = null; 245 | 246 | if (OnDisconnected != null) 247 | OnDisconnected(this); 248 | } 249 | } 250 | 251 | /// 252 | /// Thread function that actually run the socket work. 253 | /// 254 | private void MainThread() 255 | { 256 | while (_active) 257 | { 258 | byte[] arr = null; 259 | 260 | try 261 | { 262 | int length = Convert.ToInt32(tr.ReadInt32()); 263 | arr = new byte[length]; 264 | int index = 0; 265 | 266 | while (length > 0) 267 | { 268 | 269 | int receivedBytes = tr.Read(arr, index, length); 270 | length -= receivedBytes; 271 | index += receivedBytes; 272 | } 273 | } 274 | catch (Exception) { } 275 | 276 | lock (_lock) 277 | { 278 | if (_active) 279 | { 280 | Boolean Stato = _socket.Client.Poll(100, SelectMode.SelectRead); 281 | if ((arr == null) && (Stato == true)) 282 | break; 283 | else 284 | if (OnDataReceived != null) 285 | OnDataReceived(this, new Data(arr)); 286 | } 287 | else 288 | break; 289 | } 290 | } 291 | Stop(); 292 | } 293 | 294 | /// 295 | /// Send a line of data to the server. 296 | /// 297 | /// Data to send to the server. 298 | /// 299 | public void Send(Data msg) 300 | { 301 | if (_active) 302 | { 303 | if (OnBeforeDataSent != null) 304 | OnBeforeDataSent(this, msg); 305 | try 306 | { 307 | tw.Write(msg.Message.Length); 308 | tw.Write(msg.Message); 309 | tw.Flush(); 310 | 311 | if (OnAfterDataSent != null) 312 | OnAfterDataSent(this, msg); 313 | } 314 | catch (IOException) 315 | { 316 | // Pensare a cosa fare quà. Questo è il caso in cui il server ha chiuso forzatamente 317 | // la connessione mentre il client mandava roba. 318 | } 319 | } 320 | else 321 | throw new ArgumentException("The link is closed. Unable to send data."); 322 | } 323 | } 324 | } 325 | -------------------------------------------------------------------------------- /Library/TCPLibrary/Base/Server.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2011 Ferreri Alessio 3 | * Copyright (C) 2009-2018 PCSX2 Dev Team 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | using System; 25 | using System.Collections.Generic; 26 | using System.Net; 27 | using System.Net.Sockets; 28 | using System.Threading; 29 | using System.IO; 30 | using System.ComponentModel; 31 | using System.Text; 32 | 33 | namespace TCPLibrary.Core 34 | { 35 | /// 36 | /// Base TCP server class wrapped around TcpListener. 37 | /// 38 | public class Server 39 | { 40 | /// 41 | /// Socket maintaining the connection. 42 | /// 43 | private TcpListener _socket; 44 | /// 45 | /// Whether the server is enabled or not. 46 | /// 47 | private Boolean _enabled; 48 | /// 49 | /// List of the clients connected to the server. 50 | /// 51 | private List _clients; 52 | /// 53 | /// Number of connection permitted in the backlog of the server. 54 | /// 55 | private Int32 _connectionbacklog; 56 | 57 | /// 58 | /// Delegate for the event of the Enabled property change. 59 | /// 60 | /// Sender of the event. 61 | public delegate void EnabledChangedHandler(Server sender); 62 | /// 63 | /// Occurs when the Enabled property is changed. 64 | /// 65 | public event EnabledChangedHandler OnEnabledChanged; 66 | 67 | /// 68 | /// Delegate for the event of receiving a line of data from a client. 69 | /// 70 | /// Server raising the event. 71 | /// Client involved in the communication. 72 | /// Line of data received. 73 | public delegate void DataCommunicationHandler(Server server, ClientS client, Data Data); 74 | /// 75 | /// Occurs when a client send a line of data to the server. 76 | /// 77 | public event DataCommunicationHandler OnClientDataReceived; 78 | /// 79 | /// Occurs before the server send a line of data to a client. 80 | /// 81 | public event DataCommunicationHandler OnClientBeforeDataSent; 82 | /// 83 | /// Occurs after the server send a line of data to a client. 84 | /// 85 | public event DataCommunicationHandler OnClientAfterDataSent; 86 | 87 | /// 88 | /// Delegate for the event of a connection of a client. 89 | /// 90 | /// Server raising the event. 91 | /// The new client connected. 92 | public delegate void ConnectedHandler(Server server, ClientS sender); 93 | /// 94 | /// Occurs after a client is connected to the server. 95 | /// 96 | public event ConnectedHandler OnClientAfterConnect; 97 | 98 | /// 99 | /// Delegate for the event of a connection of a client. 100 | /// 101 | /// Server raising the event. 102 | /// The new client to be connected. 103 | /// Specify if the client should be accepted into the server. 104 | public delegate void BeforeConnectedHandler(Server server, ClientS client, CancelArgs args); 105 | /// 106 | /// Occurs before a client is allowed to connect to the server. 107 | /// 108 | public event BeforeConnectedHandler OnClientBeforeConnect; 109 | 110 | /// 111 | /// Delegate for the event of disconnection of a client. 112 | /// 113 | /// Server raising the event. 114 | /// The client disconnected. 115 | public delegate void DisconnectedHandler(Server server, ClientS sender); 116 | /// 117 | /// Occurs right after a client disconnect from the server. 118 | /// 119 | public event DisconnectedHandler OnClientAfterDisconnected; 120 | /// 121 | /// Occurs before a client disconnect from the server. 122 | /// 123 | public event DisconnectedHandler OnClientBeforeDisconnected; 124 | 125 | /// 126 | /// Get/set the port number to which the server will listen. Cannot be set while the server is active. 127 | /// 128 | /// 129 | public Int32 Port 130 | { 131 | get 132 | { 133 | if (Enabled) 134 | return ((IPEndPoint) _socket.LocalEndpoint).Port; 135 | throw new NotSupportedException("Server is not running and hence has no port."); 136 | } 137 | } 138 | 139 | /// 140 | /// Get/set the enabled state of the server. Setting this to true will actually activate the server. 141 | /// 142 | /// 143 | public Boolean Enabled 144 | { 145 | get { return _enabled; } 146 | set 147 | { 148 | if (value == true) 149 | { 150 | if (_enabled == false) 151 | ActivateServer(); 152 | } 153 | else 154 | { 155 | if (_enabled == true) 156 | DeactivateServer(); 157 | } 158 | } 159 | } 160 | 161 | /// 162 | /// Get/set the number of connection permitted in the backlog of the server. 163 | /// 164 | /// 165 | public Int32 ConnectionBackLog 166 | { 167 | get { return _connectionbacklog; } 168 | set 169 | { 170 | if (Enabled == false) 171 | _connectionbacklog = value; 172 | else 173 | throw new ArgumentException("Impossibile eseguire l'operazione a server attivo"); 174 | } 175 | } 176 | 177 | /// 178 | /// Get the list of the clients connected to the server. 179 | /// 180 | public List Clients 181 | { 182 | get { return _clients; } 183 | } 184 | 185 | /// 186 | /// Deactivate the server. 187 | /// 188 | protected virtual void DeactivateServer() 189 | { 190 | _enabled = false; 191 | _socket.Stop(); 192 | _socket = null; 193 | 194 | lock (_clients) 195 | { 196 | for (int i = 0; i < _clients.Count; i++) 197 | _clients[i].Disconnect(); 198 | } 199 | 200 | if (OnEnabledChanged != null) 201 | OnEnabledChanged(this); 202 | } 203 | 204 | /// 205 | /// Activate the server. 206 | /// 207 | protected virtual void ActivateServer() 208 | { 209 | _socket = new TcpListener(IPAddress.Any, 0); 210 | _socket.Start(ConnectionBackLog); 211 | Thread thd = new Thread(new ThreadStart(MainThread)); 212 | thd.Name = "Server on port " + ((IPEndPoint) _socket.LocalEndpoint).Port; 213 | thd.IsBackground = true; 214 | thd.Start(); 215 | _enabled = true; 216 | if (OnEnabledChanged != null) 217 | OnEnabledChanged(this); 218 | } 219 | 220 | /// 221 | /// Broadcast a line of data to all the clients connected to the server. 222 | /// 223 | /// Line of data to be sent. 224 | /// 225 | public void Broadcast(Data Data) 226 | { 227 | if (Enabled) 228 | { 229 | lock (_clients) 230 | { 231 | foreach (var itm in _clients) 232 | if (itm.Connected) 233 | itm.Send(Data); 234 | } 235 | } 236 | else 237 | throw new ArgumentException("Unable to execute this operation when the server is inactive."); 238 | } 239 | 240 | /// 241 | /// Base constructor of the class. 242 | /// 243 | public Server() 244 | { 245 | _clients = new List(); 246 | _connectionbacklog = 0; 247 | _enabled = false; 248 | } 249 | 250 | /// 251 | /// Thread function that actually run the server socket work. 252 | /// 253 | private void MainThread() 254 | { 255 | try 256 | { 257 | while (Enabled == true) 258 | { 259 | TcpClient client = _socket.AcceptTcpClient(); 260 | 261 | CancelArgs args = new CancelArgs(false); 262 | ClientS cl = CreateClient(client); 263 | if (OnClientBeforeConnect != null) 264 | OnClientBeforeConnect(this, cl, args); 265 | 266 | if (args.Cancel != true) 267 | { 268 | lock (_clients) 269 | { 270 | _clients.Add(cl); 271 | } 272 | 273 | ASCIIEncoding ae = new ASCIIEncoding(); 274 | byte[] arr = ae.GetBytes("CONNECTEDTCPSERVER"); 275 | 276 | cl.Send(new Data(arr)); 277 | 278 | if (OnClientAfterConnect != null) 279 | OnClientAfterConnect(this, cl); 280 | cl.Start(); 281 | } 282 | else 283 | { 284 | client.GetStream().Close(); 285 | client.Close(); 286 | } 287 | } 288 | } 289 | catch (SocketException) 290 | { 291 | Enabled = false; 292 | } 293 | } 294 | 295 | /// 296 | /// Overridable function that create the structure to memorize the client data. 297 | /// 298 | /// Socket of the client. 299 | /// The structure in which memorize all the information of the client. 300 | protected virtual ClientS CreateClient(TcpClient socket) 301 | { 302 | ClientS cl = new ClientS(this, socket); 303 | return cl; 304 | } 305 | 306 | /// 307 | /// Raise the OnClientAfterDataSent event. 308 | /// 309 | /// Client that raised the event. 310 | /// Line of data sent. 311 | internal void RaiseAfterDataSentEvent(ClientS cl, Data data) 312 | { 313 | if (OnClientAfterDataSent != null) 314 | OnClientAfterDataSent(this, cl, data); 315 | } 316 | 317 | /// 318 | /// Raise the OnClientBeforeDataSent event. 319 | /// 320 | /// Client that raised the event. 321 | /// Line of data sent. 322 | internal void RaiseBeforeDataSentEvent(ClientS cl, Data data) 323 | { 324 | if (OnClientBeforeDataSent != null) 325 | OnClientBeforeDataSent(this, cl, data); 326 | } 327 | 328 | /// 329 | /// Raise the OnDataReceived event. 330 | /// 331 | /// Client that raised the event. 332 | /// Line of data received. 333 | internal void RaiseDataReceivedEvent(ClientS cl, Data data) 334 | { 335 | if (OnClientDataReceived != null) 336 | OnClientDataReceived(this, cl, data); 337 | } 338 | 339 | /// 340 | /// Raise the OnClientAfterDisconnected event. 341 | /// 342 | /// Client that raised the event. 343 | internal void RaiseClientAfterDisconnectedEvent(ClientS cl) 344 | { 345 | if (OnClientAfterDisconnected != null) 346 | OnClientAfterDisconnected(this, cl); 347 | } 348 | 349 | /// 350 | /// Raise the OnClientBeforeDisconnected event. 351 | /// 352 | /// Client that raised the event. 353 | internal void RaiseClientBeforeDisconnectedEvent(ClientS cl) 354 | { 355 | if (OnClientBeforeDisconnected != null) 356 | OnClientBeforeDisconnected(this, cl); 357 | } 358 | } 359 | } 360 | -------------------------------------------------------------------------------- /Library/GSDXWrapper.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2011 Ferreri Alessio 3 | * Copyright (C) 2009-2018 PCSX2 Dev Team 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | using System; 25 | using System.Collections.Generic; 26 | using System.Text; 27 | using System.Runtime.InteropServices; 28 | using System.IO; 29 | using TCPLibrary.MessageBased.Core; 30 | using System.Threading; 31 | 32 | namespace GSDumpGUI 33 | { 34 | public delegate void GSgifTransfer(IntPtr data, int size); 35 | public delegate void GSgifTransfer1(IntPtr data, int size); 36 | public delegate void GSgifTransfer2(IntPtr data, int size); 37 | public delegate void GSgifTransfer3(IntPtr data, int size); 38 | public delegate void GSVSync(byte field); 39 | public delegate void GSreset(); 40 | public delegate void GSreadFIFO2(IntPtr data, int size); 41 | public delegate void GSsetGameCRC(int crc, int options); 42 | public delegate int GSfreeze(int mode, IntPtr data); 43 | public delegate int GSopen(IntPtr hwnd, String Title, int renderer); 44 | public delegate void GSclose(); 45 | public delegate void GSshutdown(); 46 | public delegate void GSConfigure(); 47 | public delegate void GSsetBaseMem(IntPtr data); 48 | public delegate IntPtr PS2EgetLibName(); 49 | public delegate void GSinit(); 50 | public delegate UInt32 GSmakeSnapshot(string path); 51 | 52 | public class InvalidGSPlugin : Exception 53 | { 54 | public InvalidGSPlugin(string reason) : base(reason) {} 55 | } 56 | 57 | public class GSDXWrapper 58 | { 59 | static public bool DumpTooOld = false; 60 | 61 | private GSConfigure gsConfigure; 62 | private PS2EgetLibName Ps2egetLibName; 63 | private GSgifTransfer GSgifTransfer; 64 | private GSgifTransfer1 GSgifTransfer1; 65 | private GSgifTransfer2 GSgifTransfer2; 66 | private GSgifTransfer3 GSgifTransfer3; 67 | private GSVSync GSVSync; 68 | private GSreadFIFO2 GSreadFIFO2; 69 | private GSsetGameCRC GSsetGameCRC; 70 | private GSfreeze GSfreeze; 71 | private GSopen GSopen; 72 | private GSclose GSclose; 73 | private GSshutdown GSshutdown; 74 | private GSsetBaseMem GSsetBaseMem; 75 | private GSinit GSinit; 76 | private GSreset GSreset; 77 | private GSmakeSnapshot GSmakeSnapshot; 78 | private Boolean Loaded; 79 | 80 | private String DLL; 81 | private IntPtr DLLAddr; 82 | 83 | private Boolean Running; 84 | 85 | public Queue QueueMessage; 86 | public Boolean DebugMode; 87 | public GSData CurrentGIFPacket; 88 | public bool ThereIsWork; 89 | public AutoResetEvent ExternalEvent; 90 | public int RunTo; 91 | 92 | public void Load(String DLL) 93 | { 94 | var formerDirectory = Directory.GetCurrentDirectory(); 95 | try 96 | { 97 | this.DLL = DLL; 98 | NativeMethods.SetErrorMode(0x8007); 99 | 100 | if (Loaded) 101 | Unload(); 102 | 103 | string dir = DLL; 104 | dir = Path.GetDirectoryName(dir); 105 | if (dir == null) return; 106 | 107 | Directory.SetCurrentDirectory(dir); 108 | IntPtr hmod = NativeMethods.LoadLibrary(DLL); 109 | if (hmod != IntPtr.Zero) 110 | { 111 | DLLAddr = hmod; 112 | 113 | IntPtr funcaddrLibName = NativeMethods.GetProcAddress(hmod, "PS2EgetLibName"); 114 | IntPtr funcaddrConfig = NativeMethods.GetProcAddress(hmod, "GSconfigure"); 115 | 116 | IntPtr funcaddrGIF = NativeMethods.GetProcAddress(hmod, "GSgifTransfer"); 117 | IntPtr funcaddrGIF1 = NativeMethods.GetProcAddress(hmod, "GSgifTransfer1"); 118 | IntPtr funcaddrGIF2 = NativeMethods.GetProcAddress(hmod, "GSgifTransfer2"); 119 | IntPtr funcaddrGIF3 = NativeMethods.GetProcAddress(hmod, "GSgifTransfer3"); 120 | IntPtr funcaddrVSync = NativeMethods.GetProcAddress(hmod, "GSvsync"); 121 | IntPtr funcaddrSetBaseMem = NativeMethods.GetProcAddress(hmod, "GSsetBaseMem"); 122 | IntPtr funcaddrGSReset = NativeMethods.GetProcAddress(hmod, "GSreset"); 123 | IntPtr funcaddrOpen = NativeMethods.GetProcAddress(hmod, "GSopen"); 124 | IntPtr funcaddrSetCRC = NativeMethods.GetProcAddress(hmod, "GSsetGameCRC"); 125 | IntPtr funcaddrClose = NativeMethods.GetProcAddress(hmod, "GSclose"); 126 | IntPtr funcaddrShutdown = NativeMethods.GetProcAddress(hmod, "GSshutdown"); 127 | IntPtr funcaddrFreeze = NativeMethods.GetProcAddress(hmod, "GSfreeze"); 128 | IntPtr funcaddrGSreadFIFO2 = NativeMethods.GetProcAddress(hmod, "GSreadFIFO2"); 129 | IntPtr funcaddrinit = NativeMethods.GetProcAddress(hmod, "GSinit"); 130 | IntPtr funcmakeSnapshot = NativeMethods.GetProcAddress(hmod, "GSmakeSnapshot"); 131 | 132 | if (!((funcaddrConfig.ToInt64() > 0) && (funcaddrLibName.ToInt64() > 0) && (funcaddrGIF.ToInt64() > 0))) 133 | throw new InvalidGSPlugin(""); 134 | 135 | gsConfigure = (GSConfigure) Marshal.GetDelegateForFunctionPointer(funcaddrConfig, typeof(GSConfigure)); 136 | Ps2egetLibName = (PS2EgetLibName) Marshal.GetDelegateForFunctionPointer(funcaddrLibName, typeof(PS2EgetLibName)); 137 | 138 | this.GSgifTransfer = (GSgifTransfer) Marshal.GetDelegateForFunctionPointer(funcaddrGIF, typeof(GSgifTransfer)); 139 | this.GSgifTransfer1 = (GSgifTransfer1) Marshal.GetDelegateForFunctionPointer(funcaddrGIF1, typeof(GSgifTransfer1)); 140 | this.GSgifTransfer2 = (GSgifTransfer2) Marshal.GetDelegateForFunctionPointer(funcaddrGIF2, typeof(GSgifTransfer2)); 141 | this.GSgifTransfer3 = (GSgifTransfer3) Marshal.GetDelegateForFunctionPointer(funcaddrGIF3, typeof(GSgifTransfer3)); 142 | this.GSVSync = (GSVSync) Marshal.GetDelegateForFunctionPointer(funcaddrVSync, typeof(GSVSync)); 143 | this.GSsetBaseMem = (GSsetBaseMem) Marshal.GetDelegateForFunctionPointer(funcaddrSetBaseMem, typeof(GSsetBaseMem)); 144 | this.GSopen = (GSopen) Marshal.GetDelegateForFunctionPointer(funcaddrOpen, typeof(GSopen)); 145 | this.GSsetGameCRC = (GSsetGameCRC) Marshal.GetDelegateForFunctionPointer(funcaddrSetCRC, typeof(GSsetGameCRC)); 146 | this.GSclose = (GSclose) Marshal.GetDelegateForFunctionPointer(funcaddrClose, typeof(GSclose)); 147 | this.GSshutdown = (GSshutdown) Marshal.GetDelegateForFunctionPointer(funcaddrShutdown, typeof(GSshutdown)); 148 | this.GSfreeze = (GSfreeze) Marshal.GetDelegateForFunctionPointer(funcaddrFreeze, typeof(GSfreeze)); 149 | this.GSreset = (GSreset) Marshal.GetDelegateForFunctionPointer(funcaddrGSReset, typeof(GSreset)); 150 | this.GSreadFIFO2 = (GSreadFIFO2) Marshal.GetDelegateForFunctionPointer(funcaddrGSreadFIFO2, typeof(GSreadFIFO2)); 151 | this.GSinit = (GSinit) Marshal.GetDelegateForFunctionPointer(funcaddrinit, typeof(GSinit)); 152 | this.GSmakeSnapshot = (GSmakeSnapshot)Marshal.GetDelegateForFunctionPointer(funcmakeSnapshot, typeof(GSmakeSnapshot)); 153 | 154 | Loaded = true; 155 | } 156 | 157 | if (!Loaded) 158 | { 159 | Exception lasterror = Marshal.GetExceptionForHR(Marshal.GetHRForLastWin32Error()); 160 | System.IO.File.AppendAllText(AppDomain.CurrentDomain.BaseDirectory + "log.txt", DLL + " failed to load. Error " + lasterror.ToString() + Environment.NewLine); 161 | NativeMethods.SetErrorMode(0x0000); 162 | Unload(); 163 | throw new InvalidGSPlugin(lasterror.ToString()); 164 | } 165 | 166 | NativeMethods.SetErrorMode(0x0000); 167 | } 168 | finally 169 | { 170 | Directory.SetCurrentDirectory(formerDirectory); 171 | } 172 | } 173 | 174 | public void Unload() 175 | { 176 | NativeMethods.FreeLibrary(DLLAddr); 177 | Loaded = false; 178 | } 179 | 180 | public void GSConfig() 181 | { 182 | if (!Loaded) 183 | throw new Exception("GSdx is not loaded"); 184 | gsConfigure.Invoke(); 185 | } 186 | 187 | public String PS2EGetLibName() 188 | { 189 | if (!Loaded) 190 | throw new Exception("GSdx is not loaded"); 191 | return Marshal.PtrToStringAnsi(Ps2egetLibName.Invoke()); 192 | } 193 | 194 | public unsafe void Run(GSDump dump, int rendererOverride) 195 | { 196 | QueueMessage = new Queue(); 197 | Running = true; 198 | ExternalEvent = new AutoResetEvent(true); 199 | 200 | GSinit(); 201 | byte[] tempregisters = new byte[8192]; 202 | Array.Copy(dump.Registers, tempregisters, 8192); 203 | fixed (byte* pointer = tempregisters) 204 | { 205 | GSsetBaseMem(new IntPtr(pointer)); 206 | IntPtr hWnd = IntPtr.Zero; 207 | 208 | if (GSopen(new IntPtr(&hWnd), "", rendererOverride) != 0) 209 | return; 210 | 211 | GSsetGameCRC(dump.CRC, 0); 212 | 213 | NativeMethods.SetClassLong(hWnd,/*GCL_HICON*/ -14, Program.hMainIcon); 214 | 215 | fixed (byte* freeze = dump.StateData) 216 | { 217 | byte[] GSFreez; 218 | 219 | if (Environment.Is64BitProcess) 220 | { 221 | GSFreez = new byte[16]; 222 | Array.Copy(BitConverter.GetBytes((Int64)dump.StateData.Length), 0, GSFreez, 0, 8); 223 | Array.Copy(BitConverter.GetBytes(new IntPtr(freeze).ToInt64()), 0, GSFreez, 8, 8); 224 | } 225 | else 226 | { 227 | GSFreez = new byte[8]; 228 | Array.Copy(BitConverter.GetBytes((Int32)dump.StateData.Length), 0, GSFreez, 0, 4); 229 | Array.Copy(BitConverter.GetBytes(new IntPtr(freeze).ToInt32()), 0, GSFreez, 4, 4); 230 | } 231 | 232 | fixed (byte* fr = GSFreez) 233 | { 234 | int ris = GSfreeze(0, new IntPtr(fr)); 235 | if (ris == -1) 236 | { 237 | DumpTooOld = true; 238 | Running = false; 239 | } 240 | GSVSync(1); 241 | 242 | GSreset(); 243 | Marshal.Copy(dump.Registers, 0, new IntPtr(pointer), 8192); 244 | GSsetBaseMem(new IntPtr(pointer)); 245 | GSfreeze(0, new IntPtr(fr)); 246 | 247 | GSData gsd_vsync = new GSData(); 248 | gsd_vsync.id = GSType.VSync; 249 | 250 | int gs_idx = 0; 251 | int debug_idx = 0; 252 | NativeMessage msg; 253 | 254 | while (Running) 255 | { 256 | while (NativeMethods.PeekMessage(out msg, hWnd, 0, 0, 1)) // PM_REMOVE 257 | { 258 | NativeMethods.TranslateMessage(ref msg); 259 | NativeMethods.DispatchMessage(ref msg); 260 | 261 | if(msg.msg == 0x0100) // WM_KEYDOWN 262 | { 263 | switch(msg.wParam.ToInt32() & 0xFF) 264 | { 265 | case 0x1B: Running = false; break; // VK_ESCAPE; 266 | case 0x77: GSmakeSnapshot(""); break; // VK_F8; 267 | } 268 | } 269 | } 270 | 271 | if (!Running || !NativeMethods.IsWindowVisible(hWnd)) 272 | break; 273 | 274 | if (DebugMode) 275 | { 276 | if (QueueMessage.Count > 0) 277 | { 278 | TCPMessage Mess = QueueMessage.Dequeue(); 279 | switch (Mess.MessageType) 280 | { 281 | case MessageType.Step: 282 | if (debug_idx >= dump.Data.Count) 283 | debug_idx = 0; 284 | RunTo = debug_idx; 285 | break; 286 | case MessageType.RunToCursor: 287 | RunTo = (int)Mess.Parameters[0]; 288 | if(debug_idx > RunTo) 289 | debug_idx = 0; 290 | break; 291 | case MessageType.RunToNextVSync: 292 | if (debug_idx >= dump.Data.Count) 293 | debug_idx = 1; 294 | RunTo = dump.Data.FindIndex(debug_idx, a => a.id == GSType.VSync); 295 | break; 296 | default: 297 | break; 298 | } 299 | } 300 | 301 | if (debug_idx <= RunTo) 302 | { 303 | while (debug_idx <= RunTo) 304 | { 305 | GSData itm = dump.Data[debug_idx]; 306 | CurrentGIFPacket = itm; 307 | Step(itm, pointer); 308 | debug_idx++; 309 | } 310 | 311 | int idxnextReg = dump.Data.FindIndex(debug_idx, a => a.id == GSType.Registers); 312 | if (idxnextReg != -1) 313 | Step(dump.Data[idxnextReg], pointer); 314 | 315 | TCPMessage Msg = new TCPMessage(); 316 | Msg.MessageType = MessageType.RunToCursor; 317 | Msg.Parameters.Add(debug_idx - 1); 318 | Program.Client.Send(Msg); 319 | 320 | ExternalEvent.Set(); 321 | } 322 | 323 | Step(gsd_vsync, pointer); 324 | } 325 | else 326 | { 327 | while (gs_idx < dump.Data.Count) 328 | { 329 | GSData itm = dump.Data[gs_idx++]; 330 | CurrentGIFPacket = itm; 331 | Step(itm, pointer); 332 | 333 | if (gs_idx < dump.Data.Count && dump.Data[gs_idx].id == GSType.VSync) 334 | break; 335 | } 336 | 337 | if (gs_idx >= dump.Data.Count) gs_idx = 0; 338 | } 339 | } 340 | 341 | GSclose(); 342 | GSshutdown(); 343 | } 344 | } 345 | } 346 | } 347 | 348 | private unsafe void Step(GSData itm, byte* registers) 349 | { 350 | /*"C:\Users\Alessio\Desktop\Plugins\Dll\GSdx-SSE4.dll" "C:\Users\Alessio\Desktop\Plugins\Dumps\gsdx_20101222215004.gs" "GSReplay" 0*/ 351 | switch (itm.id) 352 | { 353 | case GSType.Transfer: 354 | switch (((GSTransfer)itm).Path) 355 | { 356 | case GSTransferPath.Path1Old: 357 | byte[] data = new byte[16384]; 358 | int addr = 16384 - itm.data.Length; 359 | Array.Copy(itm.data, 0, data, addr, itm.data.Length); 360 | fixed (byte* gifdata = data) 361 | { 362 | GSgifTransfer1(new IntPtr(gifdata), addr); 363 | } 364 | break; 365 | case GSTransferPath.Path2: 366 | fixed (byte* gifdata = itm.data) 367 | { 368 | GSgifTransfer2(new IntPtr(gifdata), (itm.data.Length) / 16); 369 | } 370 | break; 371 | case GSTransferPath.Path3: 372 | fixed (byte* gifdata = itm.data) 373 | { 374 | GSgifTransfer3(new IntPtr(gifdata), (itm.data.Length) / 16); 375 | } 376 | break; 377 | case GSTransferPath.Path1New: 378 | fixed (byte* gifdata = itm.data) 379 | { 380 | GSgifTransfer(new IntPtr(gifdata), (itm.data.Length) / 16); 381 | } 382 | break; 383 | } 384 | break; 385 | case GSType.VSync: 386 | GSVSync((*((int*)(registers + 4096)) & 0x2000) > 0 ? (byte)1 : (byte)0); 387 | break; 388 | case GSType.ReadFIFO2: 389 | fixed (byte* FIFO = itm.data) 390 | { 391 | byte[] arrnew = new byte[*((int*)FIFO)]; 392 | fixed (byte* arrn = arrnew) 393 | { 394 | GSreadFIFO2(new IntPtr(arrn), *((int*)FIFO)); 395 | } 396 | } 397 | break; 398 | case GSType.Registers: 399 | Marshal.Copy(itm.data, 0, new IntPtr(registers), 8192); 400 | break; 401 | default: 402 | break; 403 | } 404 | } 405 | 406 | public void Stop() 407 | { 408 | Running = false; 409 | } 410 | 411 | internal List GetGifPackets(GSDump dump) 412 | { 413 | List Data = new List(); 414 | for (int i = 0; i < dump.Data.Count; i++) 415 | { 416 | String act = i.ToString() + "|"; 417 | act += dump.Data[i].id.ToString() + "|"; 418 | if (dump.Data[i].GetType().IsSubclassOf(typeof(GSData))) 419 | { 420 | act += ((GSTransfer)dump.Data[i]).Path.ToString() + "|"; 421 | act += ((GSTransfer)dump.Data[i]).data.Length; 422 | } 423 | else 424 | { 425 | act += ((GSData)dump.Data[i]).data.Length; 426 | } 427 | Data.Add(act); 428 | } 429 | return Data; 430 | } 431 | 432 | internal object GetGifPacketInfo(GSDump dump, int i) 433 | { 434 | if (dump.Data[i].id == GSType.Transfer) 435 | { 436 | try 437 | { 438 | GIFTag val = GIFTag.ExtractGifTag(dump.Data[i].data, ((GSTransfer)dump.Data[i]).Path); 439 | return val; 440 | } 441 | catch (Exception) 442 | { 443 | return new GIFTag(); 444 | } 445 | } 446 | else 447 | { 448 | switch (dump.Data[i].id) 449 | { 450 | case GSType.VSync: 451 | return dump.Data[i].data.Length + "|Field = " + dump.Data[i].data[0].ToString(); 452 | case GSType.ReadFIFO2: 453 | return dump.Data[i].data.Length + "|ReadFIFO2 : Size = " + BitConverter.ToInt32(dump.Data[i].data, 0).ToString() + " byte"; 454 | case GSType.Registers: 455 | return dump.Data[i].data.Length + "|Registers"; 456 | default: 457 | return ""; 458 | } 459 | } 460 | } 461 | } 462 | } 463 | --------------------------------------------------------------------------------