Skip to content

Instantly share code, notes, and snippets.

@toptensoftware
Created October 11, 2016 01:31
Show Gist options
  • Select an option

  • Save toptensoftware/9d848b6ae3fb9757ddd01f6230c15792 to your computer and use it in GitHub Desktop.

Select an option

Save toptensoftware/9d848b6ae3fb9757ddd01f6230c15792 to your computer and use it in GitHub Desktop.
Applying a chain of relocations
void ApplyRelocations(byte[] data, ushort offset, uint value, bool additive)
{
if (additive)
{
data.WriteDWord(offset, (uint)(data.ReadDWord(offset) + value));
}
else
{
while (offset != 0xFFFF)
{
ushort nextOffset = data.ReadWord(offset);
data.WriteDWord(offset, value);
offset = nextOffset;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment