Skip to content

Instantly share code, notes, and snippets.

@toptensoftware
Last active October 2, 2016 07:29
Show Gist options
  • Save toptensoftware/9f00d141380c659e9a77204af8742436 to your computer and use it in GitHub Desktop.
Save toptensoftware/9f00d141380c659e9a77204af8742436 to your computer and use it in GitHub Desktop.
API to the NeFileReader class
// NeFileReader - opens a 16-bit "NE" file
public class NeFileReader : IDisposable
{
// Constructor, throws exception if error, keeps file open, call IDispose to close
public NeFileReader(string filename);
// Name of currently open file
public string FileName { get; }
// Name of the module extract from name table
public string ModuleName { get; }
// All code and data segments contained in the file
public IList<SegmentEntry> Segments { get; }
// The names of all referenced modules
public string[] ModuleReferenceTable { get; }
// Retrieves an entry point given an ordinal
public EntryPoint GetEntryPoint(ushort ordinal);
// Retrieves the index of the default (aka auto) data segment
public int DataSegmentIndex { get; }
// Retrieves the default (auto) data segment
public SegmentEntry DataSegment { get; }
// Retrieves the NeHeader
public NeHeader Header { get; }
// Read a code or data segment into a buffer (must be pre-allocated a big enough)
public void ReadSegment(SegmentEntry seg, byte[] buffer);
// Looks up the ordinal for an exported name
public ushort GetOrdinalFromName(string functionName);
// Retrieve the exported name for an ordinal
public string GetNameFromOrdinal(ushort ordinal);
// Get the proc address for a function with given ordinal
public uint GetProcAddress(ushort ordinal);
// Check the header flags if this is a DLL or EXE
public bool IsDll { get; }
// Dump everything to the log file, optionally including the relocations
public void Dump(bool includeRelocations);
// Find a resource type
public ResourceTypeTable FindResourceType(string name);
// Find a resource
public ResourceEntry FindResource(string type, string entry);
// Load a resource returning it in a buffer
public byte[] LoadResource(string type, string entry);
// Seek the file stream to position of a resource and return it
// Doesn't really open a new stream (don't close the returned stream)
public Stream GetResourceStream(string type, string entry);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment