private ulong FindCodeRegistration(int count, Elf64_Shdr search, Elf64_Shdr search2, Elf64_Shdr range) { var searchend = search.sh_offset + search.sh_size; var rangeend = range.sh_addr + range.sh_size; var search2end = search2 == null ? 0 : search2.sh_offset + search2.sh_size; Position = search.sh_offset; while ((ulong)Position < searchend) { var add = Position; if (ReadUInt64() == (ulong)count) { try { ulong pointers = MapVATR(ReadUInt64()); if (pointers >= search.sh_offset && pointers <= searchend) { var np = Position; var temp = ReadClassArray <ulong>(pointers, count); var r = Array.FindIndex(temp, x => x <range.sh_addr || x> rangeend); if (r == -1) { return((ulong)add - search.sh_offset + search.sh_addr); //VirtualAddress } Position = np; } else if (search2 != null && pointers >= search2.sh_offset && pointers <= search2end) { var np = Position; var temp = ReadClassArray <ulong>(pointers, count); var r = Array.FindIndex(temp, x => x <range.sh_addr || x> rangeend); if (r == -1) { return((ulong)add - search.sh_offset + search.sh_addr); //VirtualAddress } Position = np; } } catch { // ignored } } } return(0); }
private ulong FindMetadataRegistration(int typeDefinitionsCount, Elf64_Shdr search, Elf64_Shdr search2, Elf64_Shdr range) { var searchend = search.sh_offset + search.sh_size; var rangeend = range.sh_addr + range.sh_size; var search2end = search2 == null ? 0 : search2.sh_offset + search2.sh_size; Position = search.sh_offset; while ((ulong)Position < searchend) { var add = Position; if (ReadUInt64() == (ulong)typeDefinitionsCount) { try { var np = Position; Position += 16; ulong pointers = MapVATR(ReadUInt64()); if (pointers >= search.sh_offset && pointers <= searchend) { var temp = ReadClassArray <ulong>(pointers, maxmetadataUsages); var r = Array.FindIndex(temp, x => x <range.sh_addr || x> rangeend); if (r == -1) { return((ulong)add - 96ul - search.sh_offset + search.sh_addr);//MapRATV } } else if (search2 != null && pointers >= search2.sh_offset && pointers <= search2end) { var temp = ReadClassArray <ulong>(pointers, maxmetadataUsages); var r = Array.FindIndex(temp, x => x <range.sh_addr || x> rangeend); if (r == -1) { return((ulong)add - 96ul - search.sh_offset + search.sh_addr);//MapRATV } } Position = np; } catch { // ignored } } } return(0); }