diff --git a/BurnOutSharp.Builder/Extensions.cs b/BurnOutSharp.Builder/Extensions.cs index 21208263..8359ef43 100644 --- a/BurnOutSharp.Builder/Extensions.cs +++ b/BurnOutSharp.Builder/Extensions.cs @@ -453,6 +453,32 @@ namespace BurnOutSharp.Builder #region Debug + /// + /// Read debug data as an NB10 Program Database + /// + /// Data to parse into a database + /// Offset into the byte array + /// A filled NB10 Program Database on success, null on error + public static Models.PortableExecutable.NB10ProgramDatabase AsNB10ProgramDatabase(this byte[] data, ref int offset) + { + // If we have data that's invalid, we can't do anything + if (data == null) + return null; + + var nb10ProgramDatabase = new Models.PortableExecutable.NB10ProgramDatabase(); + + nb10ProgramDatabase.Signature = data.ReadUInt32(ref offset); + if (nb10ProgramDatabase.Signature != 0x3031424E) + return null; + + nb10ProgramDatabase.Offset = data.ReadUInt32(ref offset); + nb10ProgramDatabase.Timestamp = data.ReadUInt32(ref offset); + nb10ProgramDatabase.Age = data.ReadUInt32(ref offset); + nb10ProgramDatabase.PdbFileName = data.ReadString(ref offset, Encoding.ASCII); // TODO: Actually null-terminated UTF-8? + + return nb10ProgramDatabase; + } + /// /// Read debug data as an RSDS Program Database /// diff --git a/BurnOutSharp.Models/PortableExecutable/NB10ProgramDatabase.cs b/BurnOutSharp.Models/PortableExecutable/NB10ProgramDatabase.cs new file mode 100644 index 00000000..6ca5cfcc --- /dev/null +++ b/BurnOutSharp.Models/PortableExecutable/NB10ProgramDatabase.cs @@ -0,0 +1,42 @@ +using System.Runtime.InteropServices; + +namespace BurnOutSharp.Models.PortableExecutable +{ + /// + /// PDB 2.0 files + /// + /// + [StructLayout(LayoutKind.Sequential)] + public class NB10ProgramDatabase + { + /// + /// "CodeView signature, equal to “NB10” + /// + public uint Signature; + + /// + /// CodeView offset. Set to 0, because debug information + /// is stored in a separate file. + /// + public uint Offset; + + /// + /// The time when debug information was created (in seconds + /// since 01.01.1970) + /// + public uint Timestamp; + + /// + /// Ever-incrementing value, which is initially set to 1 and + /// incremented every time when a part of the PDB file is updated + /// without rewriting the whole file. + /// + public uint Age; + + /// + /// Null-terminated name of the PDB file. It can also contain full + /// or partial path to the file. + /// + public string PdbFileName; + } +} diff --git a/BurnOutSharp.Models/PortableExecutable/RSDSProgramDatabase.cs b/BurnOutSharp.Models/PortableExecutable/RSDSProgramDatabase.cs index cc44986a..cecc596a 100644 --- a/BurnOutSharp.Models/PortableExecutable/RSDSProgramDatabase.cs +++ b/BurnOutSharp.Models/PortableExecutable/RSDSProgramDatabase.cs @@ -22,7 +22,9 @@ namespace BurnOutSharp.Models.PortableExecutable public Guid GUID; /// - /// "age" + /// Ever-incrementing value, which is initially set to 1 and + /// incremented every time when a part of the PDB file is updated + /// without rewriting the whole file. /// public uint Age;