void PatchResourceDirectoryEntry(ByteBuffer resources) { if (!resources.SizeAvailable (8)) return; resources.Advance (4); var child = resources.ReadUInt32 (); var position = resources.position; resources.position = (int) child & 0x7fffffff; if ((child & 0x80000000) != 0) PatchResourceDirectoryTable (resources); else PatchResourceDataEntry (resources); resources.position = position; }
void PatchResourceDirectoryTable(ByteBuffer resources) { if (!resources.SizeAvailable (16)) return; resources.Advance (12); var entries = resources.ReadUInt16 () + resources.ReadUInt16 (); for (int i = 0; i < entries; i++) PatchResourceDirectoryEntry (resources); }
void PatchResourceDataEntry(ByteBuffer resources) { if (!resources.SizeAvailable (4)) return; var old_rsrc = GetImageResourceSection (); var rva = resources.ReadUInt32 (); resources.position -= 4; resources.WriteUInt32 (rva - old_rsrc.VirtualAddress + rsrc.VirtualAddress); }