Last active
October 11, 2016 04:04
-
-
Save toptensoftware/f82c5535edbedfb1caef67a581cf634b to your computer and use it in GitHub Desktop.
Example relocations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // InternalReference links to another segment in this module | |
| if (reloc.type == RelocationType.InternalReference) | |
| { | |
| var targetSegment = segments[reloc.param1 - 1]; | |
| ApplyRelocations(data, reloc.offset, (uint)(targetSegment.globalHandle << 16 | reloc.param2), additive); | |
| } | |
| // ImportedOrdinal links to an entry point in another module | |
| if (reloc.type == RelocationType.ImportedOrdinal) | |
| { | |
| // Get the proc address | |
| var moduleName = _neFile.ModuleReferenceTable[reloc.param1 - 1]; | |
| var module = machine.ModuleManager.GetModule(moduleName); | |
| uint farProc = module.GetProcAddress(reloc.param2); | |
| if (farProc == 0) | |
| throw new VirtualException("Module link failed, function ordinal #{0:X4} not found in module '{1}'", reloc.param2, moduleName); | |
| ApplyRelocations(data, reloc.offset, farProc, additive); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment