Add NB10 debug data type

This commit is contained in:
Matt Nadareski
2022-12-14 20:56:13 -08:00
parent 5465abe1ac
commit ab88e2f553
3 changed files with 71 additions and 1 deletions

View File

@@ -453,6 +453,32 @@ namespace BurnOutSharp.Builder
#region Debug
/// <summary>
/// Read debug data as an NB10 Program Database
/// </summary>
/// <param name="data">Data to parse into a database</param>
/// <param name="offset">Offset into the byte array</param>
/// <returns>A filled NB10 Program Database on success, null on error</returns>
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;
}
/// <summary>
/// Read debug data as an RSDS Program Database
/// </summary>

View File

@@ -0,0 +1,42 @@
using System.Runtime.InteropServices;
namespace BurnOutSharp.Models.PortableExecutable
{
/// <summary>
/// PDB 2.0 files
/// </summary>
/// <see href="https://www.debuginfo.com/articles/debuginfomatch.html"/>
[StructLayout(LayoutKind.Sequential)]
public class NB10ProgramDatabase
{
/// <summary>
/// "CodeView signature, equal to “NB10”
/// </summary>
public uint Signature;
/// <summary>
/// CodeView offset. Set to 0, because debug information
/// is stored in a separate file.
/// </summary>
public uint Offset;
/// <summary>
/// The time when debug information was created (in seconds
/// since 01.01.1970)
/// </summary>
public uint Timestamp;
/// <summary>
/// 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.
/// </summary>
public uint Age;
/// <summary>
/// Null-terminated name of the PDB file. It can also contain full
/// or partial path to the file.
/// </summary>
public string PdbFileName;
}
}

View File

@@ -22,7 +22,9 @@ namespace BurnOutSharp.Models.PortableExecutable
public Guid GUID;
/// <summary>
/// "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.
/// </summary>
public uint Age;