MCPcopy Create free account
hub / github.com/clementgallet/libTAS / first_scan

Method first_scan

src/program/ramsearch/MemScanner.cpp:42–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40}
41
42int MemScanner::first_scan(int mem_flags, int type, int align, CompareType ct, CompareOperator co, MemValueType cv, MemValueType dv, uintptr_t begin_address, uintptr_t end_address)
43{
44 value_type = type;
45 alignment = align;
46 if (type == RamArray) {
47 value_type_size = cv.v_array[RAM_ARRAY_MAX_SIZE];
48 if (alignment == 0)
49 alignment = 1;
50 }
51 else if (type == RamCString) {
52 value_type_size = strlen(cv.v_cstr);
53 if (alignment == 0)
54 alignment = 1;
55 }
56 else {
57 value_type_size = MemValue::type_size(value_type);
58 if (alignment == 0)
59 alignment = value_type_size;
60 else if (alignment > value_type_size)
61 alignment = value_type_size;
62 }
63
64 /* Align begin/end addresses to the next page size */
65 uintptr_t page_mask = 4095;
66 begin_address &= (~page_mask);
67 end_address = (end_address + page_mask) & (~page_mask);
68
69 /* Read the whole memory layout */
70 std::unique_ptr<MemLayout> memlayout (new MemLayout());
71
72 memsections.clear();
73
74 MemSection section;
75 total_size = 0;
76 while (memlayout->nextSection(MemSection::MemAll, mem_flags, section)) {
77 /* Filter for begin/end address here */
78 if (section.addr >= end_address)
79 continue;
80 if (section.endaddr <= begin_address)
81 continue;
82
83 section.addr = std::max(section.addr, begin_address);
84 section.endaddr = std::min(section.endaddr, end_address);
85 section.size = section.endaddr - section.addr;
86
87 memsections.push_back(section);
88 total_size += section.size;
89 }
90
91 if (total_size == 0) return MemScannerThread::ENOERROR;
92
93 return scan(true, ct, co, cv, dv);
94}
95
96int MemScanner::scan(bool first, CompareType ct, CompareOperator co, MemValueType cv, MemValueType dv)
97{

Callers 1

newWatchesMethod · 0.80

Calls 2

nextSectionMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected