diff --git a/BurnOutSharp.Builder/NewExecutable.cs b/BurnOutSharp.Builder/NewExecutable.cs
index c78f2979..158a12bd 100644
--- a/BurnOutSharp.Builder/NewExecutable.cs
+++ b/BurnOutSharp.Builder/NewExecutable.cs
@@ -132,6 +132,25 @@ namespace BurnOutSharp.Builder
#endregion
+ #region Imported-Name Table
+
+ // If the offset for the imported-name table doesn't exist
+ tableAddress = initialOffset
+ + (int)stub.Header.NewExeHeaderAddr
+ + executableHeader.ImportedNamesTableOffset;
+ if (tableAddress >= data.Length)
+ return executable;
+
+ // Try to parse the imported-name table
+ var importedNameTable = ParseImportedNameTable(data, tableAddress, executableHeader.EntryTableOffset);
+ if (moduleReferenceTable == null)
+ return null;
+
+ // Set the imported-name table
+ executable.ImportedNameTable = importedNameTable;
+
+ #endregion
+
// TODO: Complete NE parsing
return executable;
}
@@ -322,6 +341,30 @@ namespace BurnOutSharp.Builder
return moduleReferenceTable;
}
+ ///
+ /// Parse a byte array into an imported-name table
+ ///
+ /// Byte array to parse
+ /// Offset into the byte array
+ /// First address not part of the imported-name table
+ /// Filled imported-name table on success, null on error
+ private static Dictionary ParseImportedNameTable(byte[] data, int offset, ushort endOffset)
+ {
+ // TODO: Use marshalling here instead of building
+ var importedNameTable = new Dictionary();
+
+ while (offset < endOffset)
+ {
+ ushort currentOffset = (ushort)offset;
+ var entry = new ImportedNameTableEntry();
+ entry.Length = data.ReadByte(ref offset);
+ entry.NameString = data.ReadBytes(ref offset, entry.Length);
+ importedNameTable[currentOffset] = entry;
+ }
+
+ return importedNameTable;
+ }
+
#endregion
#region Stream Data
@@ -451,6 +494,26 @@ namespace BurnOutSharp.Builder
#endregion
+ #region Imported-Name Table
+
+ // If the offset for the imported-name table doesn't exist
+ tableAddress = initialOffset
+ + (int)stub.Header.NewExeHeaderAddr
+ + executableHeader.ResidentNameTableOffset;
+ if (tableAddress >= data.Length)
+ return executable;
+
+ // Try to parse the imported-name table
+ data.Seek(tableAddress, SeekOrigin.Begin);
+ var importedNameTable = ParseImportedNameTable(data, executableHeader.EntryTableOffset);
+ if (importedNameTable == null)
+ return null;
+
+ // Set the imported-name table
+ executable.ImportedNameTable = importedNameTable;
+
+ #endregion
+
// TODO: Complete NE parsing
return executable;
}
@@ -637,6 +700,29 @@ namespace BurnOutSharp.Builder
return moduleReferenceTable;
}
+ ///
+ /// Parse a byte array into an imported-name table
+ ///
+ /// Stream to parse
+ /// First address not part of the imported-name table
+ /// Filled imported-name table on success, null on error
+ private static Dictionary ParseImportedNameTable(Stream data, ushort endOffset)
+ {
+ // TODO: Use marshalling here instead of building
+ var importedNameTable = new Dictionary();
+
+ while (data.Position < endOffset)
+ {
+ ushort currentOffset = (ushort)data.Position;
+ var entry = new ImportedNameTableEntry();
+ entry.Length = data.ReadByteValue();
+ entry.NameString = data.ReadBytes(entry.Length);
+ importedNameTable[currentOffset] = entry;
+ }
+
+ return importedNameTable;
+ }
+
#endregion
}
}
\ No newline at end of file